Package org.graylog.metrics.prometheus
Class ReplaceableCollectorRegistry
java.lang.Object
io.prometheus.client.CollectorRegistry
org.graylog.metrics.prometheus.ReplaceableCollectorRegistry
public class ReplaceableCollectorRegistry
extends io.prometheus.client.CollectorRegistry
Custom
CollectorRegistry that delegates all read operations to a registry reference.
This allows atomic collector registry replacements at runtime.
The standard CollectorRegistry only supports a register/unregister workflow which opens up a potential
race condition. And since the HTTPServer doesn't allow the replacement
of the collector registry without restarting the HTTP server, we need this custom implementation.
Write operations are not supported and will throw an UnsupportedOperationException.-
Field Summary
Fields inherited from class io.prometheus.client.CollectorRegistry
defaultRegistry -
Constructor Summary
ConstructorsConstructorDescriptionReplaceableCollectorRegistry(AtomicReference<io.prometheus.client.CollectorRegistry> registryRef) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Enumeration<io.prometheus.client.Collector.MetricFamilySamples>filteredMetricFamilySamples(Set<String> includedNames) getSampleValue(String name) getSampleValue(String name, String[] labelNames, String[] labelValues) Enumeration<io.prometheus.client.Collector.MetricFamilySamples>voidregister(io.prometheus.client.Collector m) voidunregister(io.prometheus.client.Collector m)
-
Constructor Details
-
ReplaceableCollectorRegistry
public ReplaceableCollectorRegistry(AtomicReference<io.prometheus.client.CollectorRegistry> registryRef)
-
-
Method Details
-
register
public void register(io.prometheus.client.Collector m) - Overrides:
registerin classio.prometheus.client.CollectorRegistry
-
unregister
public void unregister(io.prometheus.client.Collector m) - Overrides:
unregisterin classio.prometheus.client.CollectorRegistry
-
clear
public void clear()- Overrides:
clearin classio.prometheus.client.CollectorRegistry
-
metricFamilySamples
- Overrides:
metricFamilySamplesin classio.prometheus.client.CollectorRegistry
-
filteredMetricFamilySamples
public Enumeration<io.prometheus.client.Collector.MetricFamilySamples> filteredMetricFamilySamples(Set<String> includedNames) - Overrides:
filteredMetricFamilySamplesin classio.prometheus.client.CollectorRegistry
-
getSampleValue
- Overrides:
getSampleValuein classio.prometheus.client.CollectorRegistry
-
getSampleValue
- Overrides:
getSampleValuein classio.prometheus.client.CollectorRegistry
-