Class Metric<T>

java.lang.Object
com.persequor.extension.metrics.Metric<T>
All Implemented Interfaces:
IMetric

public class Metric<T> extends Object implements IMetric
A generic metric with a value of type T.
  • Field Details

    • LABEL_NAME_PATTERN

      protected static final Pattern LABEL_NAME_PATTERN
  • Constructor Details

  • Method Details

    • suffix

      public IMetric suffix(String suffix)
      Description copied from interface: IMetric
      Add a suffix to be appended at the end of the metric name like so example_metric -> example_metric_suffix An example suffix is _avg so example_metric -> example_metric_avg This does not affect the IMetricFamily name.
      Specified by:
      suffix in interface IMetric
      Parameters:
      suffix - - The suffix to be appended. Should follow the OpenMetrics specification.
      Returns:
      the IMetric with the added suffix
    • label

      public IMetric label(String name, String value)
      Description copied from interface: IMetric
      Add a label
      Specified by:
      label in interface IMetric
      Parameters:
      name - - name of the label
      value - - value of the label
      Returns:
      the IMetric instance containing the added label
    • getLabels

      public ILabelList getLabels()
      Specified by:
      getLabels in interface IMetric
      Returns:
      Additional parameters for the metric/measurement
    • getMetricFamily

      public IMetricFamily getMetricFamily()
      Specified by:
      getMetricFamily in interface IMetric
    • getValue

      public T getValue()
      Specified by:
      getValue in interface IMetric
      Returns:
      the value of the measurement/metric.
    • getId

      public String getId()
      Description copied from interface: IMetric
      The id of the metric, this must be unique.
      Specified by:
      getId in interface IMetric
      Returns:
      the unique id of the metric
    • getSuffix

      public String getSuffix()
      Specified by:
      getSuffix in interface IMetric
    • getTimestamp

      public Instant getTimestamp()
      Specified by:
      getTimestamp in interface IMetric
      Returns:
      When the measurement was made.
    • toString

      public String toString()
      Overrides:
      toString in class Object