Revision 56208
Added by Alessia Bardi almost 5 years ago
PrometheusEndpointConfig.java | ||
---|---|---|
9 | 9 |
import java.time.Duration; |
10 | 10 |
|
11 | 11 |
import io.micrometer.core.instrument.Clock; |
12 |
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics; |
|
13 |
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics; |
|
14 |
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics; |
|
12 | 15 |
import io.micrometer.prometheus.PrometheusConfig; |
13 | 16 |
import io.micrometer.prometheus.PrometheusMeterRegistry; |
14 | 17 |
import io.micrometer.spring.autoconfigure.export.prometheus.PrometheusProperties; |
... | ... | |
22 | 25 |
@Bean |
23 | 26 |
public PrometheusMeterRegistry prometheusMeterRegistry(PrometheusConfig config, CollectorRegistry collectorRegistry, |
24 | 27 |
Clock clock) { |
25 |
return new PrometheusMeterRegistry(config, collectorRegistry, clock); |
|
28 |
PrometheusMeterRegistry pr = new PrometheusMeterRegistry(config, collectorRegistry, clock); |
|
29 |
threadMetrics().bindTo(pr); |
|
30 |
memoryMetrics().bindTo(pr); |
|
31 |
jvmgcMetrics().bindTo(pr); |
|
32 |
return pr; |
|
26 | 33 |
} |
27 | 34 |
|
28 | 35 |
@Bean |
... | ... | |
45 | 52 |
return new CollectorRegistry(true); |
46 | 53 |
} |
47 | 54 |
|
55 |
@Bean |
|
56 |
public JvmThreadMetrics threadMetrics(){ |
|
57 |
return new JvmThreadMetrics();} |
|
58 |
|
|
59 |
@Bean |
|
60 |
public JvmMemoryMetrics memoryMetrics(){ |
|
61 |
return new JvmMemoryMetrics(); |
|
62 |
} |
|
63 |
|
|
64 |
@Bean |
|
65 |
public JvmGcMetrics jvmgcMetrics(){ |
|
66 |
return new JvmGcMetrics(); |
|
67 |
} |
|
68 |
|
|
69 |
|
|
48 | 70 |
private class DefaultPrometheusConfig implements PrometheusConfig { |
49 | 71 |
private final PrometheusProperties props; |
50 | 72 |
private final PrometheusConfig defaults = k -> null; |
Also available in: Unified diff
working with metrics for prometheus