Search in sources :

Example 1 with DefaultGauge

use of io.micrometer.core.instrument.internal.DefaultGauge in project micrometer by micrometer-metrics.

the class PrometheusMeterRegistry method newGauge.

@SuppressWarnings("unchecked")
@Override
protected <T> io.micrometer.core.instrument.Gauge newGauge(Meter.Id id, @Nullable T obj, ToDoubleFunction<T> valueFunction) {
    MicrometerCollector collector = collectorByName(id);
    Gauge gauge = new DefaultGauge(id, obj, valueFunction);
    List<String> tagValues = tagValues(id);
    collector.add((conventionName, tagKeys) -> Stream.of(new MicrometerCollector.Family(Collector.Type.GAUGE, conventionName, Stream.of(new Collector.MetricFamilySamples.Sample(conventionName, tagKeys, tagValues, gauge.value())))));
    return gauge;
}
Also used : DefaultGauge(io.micrometer.core.instrument.internal.DefaultGauge) Collector(io.prometheus.client.Collector) DefaultGauge(io.micrometer.core.instrument.internal.DefaultGauge)

Aggregations

DefaultGauge (io.micrometer.core.instrument.internal.DefaultGauge)1 Collector (io.prometheus.client.Collector)1