Class BaseMetricCollector<T,I extends io.prometheus.client.SimpleCollector<?>>

java.lang.Object
org.jenkinsci.plugins.prometheus.collectors.BaseMetricCollector<T,I>
All Implemented Interfaces:
MetricCollector<T,I>
Direct Known Subclasses:
BuildsMetricCollector, DiskUsageBytesGauge, DiskUsageFileCountGauge, ExecutorsAvailableGauge, ExecutorsBusyGauge, ExecutorsConnectingGauge, ExecutorsDefinedGauge, ExecutorsIdleGauge, ExecutorsOnlineGauge, ExecutorsQueueLengthGauge, FileStoreAvailableGauge, FileStoreCapacityGauge, JenkinsQuietDownGauge, JenkinsUpGauge, JenkinsUptimeGauge, JenkinsVersionInfo, JobUsageBytesGauge, NodesOnlineGauge

public abstract class BaseMetricCollector<T,I extends io.prometheus.client.SimpleCollector<?>> extends Object implements MetricCollector<T,I>
  • Field Details

    • SEPARATOR

      protected static final String SEPARATOR
      See Also:
    • labelNames

      protected final String[] labelNames
    • namespace

      protected final String namespace
    • subsystem

      protected final String subsystem
    • namePrefix

      protected final String namePrefix
    • collector

      protected final I extends io.prometheus.client.SimpleCollector<?> collector
  • Constructor Details

    • BaseMetricCollector

      protected BaseMetricCollector(String[] labelNames, String namespace, String subsystem, String namePrefix)
    • BaseMetricCollector

      protected BaseMetricCollector(String[] labelNames, String namespace, String subsystem)
  • Method Details

    • getCollectorType

      protected abstract CollectorType getCollectorType()
      Returns:
      - the name of the collector without subsystem, namespace, prefix
    • getHelpText

      protected abstract String getHelpText()
      Returns:
      - the help text which should be displayed
    • getCollectorBuilder

      protected abstract io.prometheus.client.SimpleCollector.Builder<?,I> getCollectorBuilder()
      Returns:
      - builder object of the type of collector
    • initCollector

      protected I initCollector()
    • collect

      public List<io.prometheus.client.Collector.MetricFamilySamples> collect()
      Description copied from interface: MetricCollector
      Calling this method basically calls I.collect()
      Specified by:
      collect in interface MetricCollector<T,I extends io.prometheus.client.SimpleCollector<?>>
    • calculateName

      public String calculateName()
      Description copied from interface: MetricCollector
      Calling this method will return the resulting name of the metric with base name and prefix
      Specified by:
      calculateName in interface MetricCollector<T,I extends io.prometheus.client.SimpleCollector<?>>
      Returns:
      the full name of the collector
    • getBaseName

      protected String getBaseName()
    • calculateMetric

      public abstract void calculateMetric(T jenkinsObject, String[] labelValues)
      Description copied from interface: MetricCollector
      This method contains the logic to calculate a metric value based on the given Jenkins object (e.g. Job, Run,...)
      Specified by:
      calculateMetric in interface MetricCollector<T,I extends io.prometheus.client.SimpleCollector<?>>
      Parameters:
      jenkinsObject - - Examples: Job, Run
      labelValues - - The label values for the calculation