前言
示例
-
注册 Metrics
实现
MeterBinder
接口的bindTo
方法,将要采集的指标注册到MeterRegistry
@Component public class JobMetrics implements MeterBinder { public Counter job1Counter; public Counter job2Counter; public Map<String, Double> map; JobMetrics() { map = new HashMap<>(); } @Override public void bindTo(MeterRegistry meterRegistry) { this.job1Counter = Counter.builder("my_job") .tags(new String[]{"name", "job1"}) .description("Job 1 execute count").register(meterRegistry); this.job2Counter = Counter.builder("my_job") .tags(new String[]{"name", "job2"})