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
ConstructorDescriptionReplaceableCollectorRegistry
(AtomicReference<io.prometheus.client.CollectorRegistry> registryRef) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
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>
void
register
(io.prometheus.client.Collector m) void
unregister
(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:
register
in classio.prometheus.client.CollectorRegistry
-
unregister
public void unregister(io.prometheus.client.Collector m) - Overrides:
unregister
in classio.prometheus.client.CollectorRegistry
-
clear
public void clear()- Overrides:
clear
in classio.prometheus.client.CollectorRegistry
-
metricFamilySamples
- Overrides:
metricFamilySamples
in classio.prometheus.client.CollectorRegistry
-
filteredMetricFamilySamples
public Enumeration<io.prometheus.client.Collector.MetricFamilySamples> filteredMetricFamilySamples(Set<String> includedNames) - Overrides:
filteredMetricFamilySamples
in classio.prometheus.client.CollectorRegistry
-
getSampleValue
- Overrides:
getSampleValue
in classio.prometheus.client.CollectorRegistry
-
getSampleValue
- Overrides:
getSampleValue
in classio.prometheus.client.CollectorRegistry
-