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
,JenkinsUpGauge
,JenkinsUptimeGauge
,JenkinsVersionInfo
,JobUsageBytesGauge
,NodesOnlineGauge
public abstract class BaseMetricCollector<T,I extends io.prometheus.client.SimpleCollector<?>> extends Object implements MetricCollector<T,I>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseMetricCollector(String[] labelNames, String namespace, String subsystem)
protected
BaseMetricCollector(String[] labelNames, String namespace, String subsystem, String namePrefix)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
calculateMetric(T jenkinsObject, String[] labelValues)
This method contains the logic to calculate a metric value based on the given Jenkins object (e.g.String
calculateName()
Calling this method will return the resulting name of the metric with base name and prefixList<io.prometheus.client.Collector.MetricFamilySamples>
collect()
Calling this method basically calls I.collect()protected String
getBaseName()
protected abstract io.prometheus.client.SimpleCollector.Builder<?,I>
getCollectorBuilder()
protected abstract CollectorType
getCollectorType()
protected abstract String
getHelpText()
protected I
initCollector()
-
-
-
Field Detail
-
SEPARATOR
protected static final String SEPARATOR
- See Also:
- Constant Field Values
-
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
-
-
Method Detail
-
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 interfaceMetricCollector<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 interfaceMetricCollector<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 interfaceMetricCollector<T,I extends io.prometheus.client.SimpleCollector<?>>
- Parameters:
jenkinsObject
- - Examples:Job
,Run
labelValues
- - The label values for the calculation
-
-