@Test public void testRegistryWithLabels() { SimpleMeterRegistry meterRegistry = new SimpleMeterRegistry(); Timer timer = meterRegistry.timer("sample", "tag1", "value1", "tag2", "value2"); timer.record(1, TimeUnit.SECONDS); timer = meterRegistry.timer("sample", "tag1", "value2", "tag2", "value2"); timer.record(1, TimeUnit.SECONDS); HistogramSnapshot snapshot = meterRegistry.find("sample") .tags("tag2", "value2") .timer().takeSnapshot(); System.out.println(snapshot); meterRegistry.find("sample").tags("tag2", "value2").meters().forEach(m -> System.out .printf("%s = %s%n", name(m), value(m))); }
private Timer timer(String command, String sourceClientId, String targetClientId, String context) { return timerMap.computeIfAbsent(metricName(command, sourceClientId, targetClientId, context), n -> meterFactory.timer(BaseMetricName.AXON_COMMAND, Tags.of( MeterFactory.REQUEST, command.replaceAll("\\.", "/"), MeterFactory.CONTEXT, context, MeterFactory.SOURCE, sourceClientId, MeterFactory.TARGET, targetClientId))); }
CommandMetricsRegistry { private Timer timer(String command, String sourceClientId, String targetClientId, String context) { return timerMap.computeIfAbsent(metricName(command, sourceClientId, targetClientId, context), n -> meterFactory.timer(BaseMetricName.AXON_COMMAND, Tags.of( MeterFactory.REQUEST, command.replaceAll("\\.", "/"), MeterFactory.CONTEXT, context, MeterFactory.SOURCE, sourceClientId, MeterFactory.TARGET, targetClientId))); } }
CommandMetricsRegistry { private Timer timer(String command, String sourceClientId, String targetClientId, String context) { return timerMap.computeIfAbsent(metricName(command, sourceClientId, targetClientId, context), n -> meterFactory.timer(BaseMetricName.AXON_COMMAND, Tags.of( MeterFactory.REQUEST, command.replaceAll("\\.", "/"), MeterFactory.CONTEXT, context, MeterFactory.SOURCE, sourceClientId, MeterFactory.TARGET, targetClientId))); } CommandMetricsRegistry(MeterFactory meterFactory); }
CommandMetricsRegistry { private Timer timer(String command, String sourceClientId, String targetClientId, String context) { return timerMap.computeIfAbsent(metricName(command, sourceClientId, targetClientId, context), n -> meterFactory.timer(BaseMetricName.AXON_COMMAND, Tags.of( MeterFactory.REQUEST, command.replaceAll("\\.", "/"), MeterFactory.CONTEXT, context, MeterFactory.SOURCE, sourceClientId, MeterFactory.TARGET, targetClientId))); } CommandMetricsRegistry(MeterFactory meterFactory); void add(String command,
                    String sourceClientId,
                    String targetClientId,
                    String context,
                    long duration); CommandMetric commandMetric(String command,
                                       String targetClientId,
                                       String context,
                                       String componentName); Gauge gauge(BaseMetricName name, T objectToWatch, ToDoubleFunction<T> gaugeFunction); MeterFactory.RateMeter rateMeter(String context, BaseMetricName meterName); }
CommandMetricsRegistry { private Timer timer(String command, String sourceClientId, String targetClientId, String context) { return timerMap.computeIfAbsent(metricName(command, sourceClientId, targetClientId, context), n -> meterFactory.timer(BaseMetricName.AXON_COMMAND, Tags.of( MeterFactory.REQUEST, command.replaceAll("\\.", "/"), MeterFactory.CONTEXT, context, MeterFactory.SOURCE, sourceClientId, MeterFactory.TARGET, targetClientId))); } CommandMetricsRegistry(MeterFactory meterFactory); void add(String command,
                    String sourceClientId,
                    String targetClientId,
                    String context,
                    long duration); CommandMetric commandMetric(String command,
                                       String targetClientId,
                                       String context,
                                       String componentName); Gauge gauge(BaseMetricName name, T objectToWatch, ToDoubleFunction<T> gaugeFunction); MeterFactory.RateMeter rateMeter(String context, BaseMetricName meterName);  }