Java Code Examples for io.micrometer.core.instrument.Tags

The following examples show how to use io.micrometer.core.instrument.Tags. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: micrometer   Source File: OkHttpMetricsEventListener.java    License: Apache License 2.0 6 votes vote down vote up
void time(CallState state) {
    Request request = state.request;
    boolean requestAvailable = request != null;

    Iterable<Tag> tags = Tags.of(
                    "method", requestAvailable ? request.method() : TAG_VALUE_UNKNOWN,
                    "uri", getUriTag(state, request),
                    "status", getStatusMessage(state.response, state.exception)
            )
            .and(extraTags)
            .and(stream(contextSpecificTags.spliterator(), false)
                    .map(contextTag -> contextTag.apply(request, state.response))
                    .collect(toList()))
            .and(getRequestTags(request))
            .and(generateTagsForRoute(request));

    if (includeHostTag) {
        tags = Tags.of(tags).and("host", requestAvailable ? request.url().host() : TAG_VALUE_UNKNOWN);
    }

    Timer.builder(this.requestsMetricName)
            .tags(tags)
            .description("Timer of OkHttp operation")
            .register(registry)
            .record(registry.config().clock().monotonicTime() - state.startTime, TimeUnit.NANOSECONDS);
}
 
Example 2
Source Project: micrometer   Source File: CaffeineCacheMetricsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void reportExpectedGeneralMetrics() {
    MeterRegistry registry = new SimpleMeterRegistry();
    metrics.bindTo(registry);

    verifyCommonCacheMetrics(registry, metrics);

    FunctionCounter evictionWeight = fetch(registry, "cache.eviction.weight").functionCounter();
    CacheStats stats = cache.stats();
    assertThat(evictionWeight.count()).isEqualTo(stats.evictionWeight());

    // specific to LoadingCache instance
    TimeGauge loadDuration = fetch(registry, "cache.load.duration").timeGauge();
    assertThat(loadDuration.value()).isEqualTo(stats.totalLoadTime());

    FunctionCounter successfulLoad = fetch(registry, "cache.load", Tags.of("result", "success")).functionCounter();
    assertThat(successfulLoad.count()).isEqualTo(stats.loadSuccessCount());

    FunctionCounter failedLoad = fetch(registry, "cache.load", Tags.of("result", "failure")).functionCounter();
    assertThat(failedLoad.count()).isEqualTo(stats.loadFailureCount());
}
 
Example 3
Source Project: micrometer   Source File: HttpMetricsTagConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
OncePerRequestFilter extractCountry() {
    return new OncePerRequestFilter() {
        private final ObjectMapper mapper = new ObjectMapper();

        @Override
        protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
                                        FilterChain filterChain) throws ServletException, IOException {
            ContentCachingResponseWrapper cached = new ContentCachingResponseWrapper(response);
            filterChain.doFilter(request, cached);

            Object path = request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
            if (path.equals("/api/person/{id}")) {
                // Prometheus requires the same tags on all `http.server.requests`. So we'll need to add
                // a `@Timed("person.requests") to the /api/person/{id} endpoint so it has a different name.
                Person person = mapper.readValue(cached.getContentAsByteArray(), Person.class);
                responseTags.put(response, Tags.of("country", person.getCountry()));
            }

            cached.copyBodyToResponse();
        }
    };
}
 
Example 4
Source Project: rqueue   Source File: RqueueMetricsTest.java    License: Apache License 2.0 6 votes vote down vote up
private void verifyCounterRegisterMethodIsCalled(Tags tags) throws IllegalAccessException {
  MeterRegistry meterRegistry = new SimpleMeterRegistry();
  metricsProperties.setMetricTags(tags);
  RqueueMetrics metrics = rqueueMetrics(meterRegistry, metricsProperties);
  metrics.onApplicationEvent(new RqueueBootstrapEvent("Test", true));
  verify(queueCounter, times(1))
      .registerQueue(
          metricsProperties,
          Tags.concat(tags, "queue", simpleQueue),
          meterRegistry,
          simpleQueueDetail);
  verify(queueCounter, times(1))
      .registerQueue(
          metricsProperties,
          Tags.concat(tags, "queue", delayedQueue),
          meterRegistry,
          delayedQueueDetail);
  verify(queueCounter, times(2)).registerQueue(any(), any(), any(), any(QueueDetail.class));
}
 
Example 5
Source Project: reactor-core   Source File: MonoMetricsFuseableTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void requestFusionDelegates() {
	AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create();
	MetricsFuseableSubscriber<Integer> fuseableSubscriber =
			new MetricsFuseableSubscriber<>(testSubscriber,
					registry, Clock.SYSTEM, Tags.empty());

	Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>();
	fuseableSubscriber.onSubscribe(testQueue);

	assertThat(fuseableSubscriber.requestFusion(Fuseable.SYNC))
			.as("fusion mode SYNC").isEqualTo(Fuseable.SYNC);

	assertThat(fuseableSubscriber.requestFusion(Fuseable.ASYNC))
			.as("fusion mode ASYNC").isEqualTo(Fuseable.ASYNC);

	assertThat(fuseableSubscriber.requestFusion(Fuseable.NONE))
			.as("fusion mode NONE").isEqualTo(Fuseable.NONE);
}
 
Example 6
private Iterable<Tag> nameTag(ObjectName name) {
    Tags tags = Tags.empty();
    String clientId = name.getKeyProperty("client-id");
    if (clientId != null) {
        tags = Tags.concat(tags, "client.id", clientId);
    }

    String topic = name.getKeyProperty("topic");
    if (topic != null) {
        tags = Tags.concat(tags, "topic", topic);
    }

    String nodeId = name.getKeyProperty("node-id");
    if (nodeId != null) {
        tags = Tags.concat(tags, "node-id", nodeId);
    }
    return tags;
}
 
Example 7
Source Project: che   Source File: CountedThreadFactory.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Wraps a {@link ThreadFactory} with an explicit name and records the number of created, running
 * and terminated threads.
 *
 * @param delegate {@link ThreadFactory} to wrap.
 * @param registry {@link MeterRegistry} that will contain the metrics.
 * @param name name for this delegate.
 * @param tags tags that can provide additional context.
 */
public CountedThreadFactory(
    ThreadFactory delegate, MeterRegistry registry, String name, Iterable<Tag> tags) {
  this.delegate = delegate;
  this.created =
      Counter.builder("thread.factory.created")
          .tags(Tags.concat(tags, "name", name))
          .description(
              "The approximate number of threads which were created with a thread factory")
          .baseUnit(BaseUnits.THREADS)
          .register(registry);
  this.terminated =
      Counter.builder("thread.factory.terminated")
          .tags(Tags.concat(tags, "name", name))
          .description("The approximate number of threads which have finished execution")
          .baseUnit(BaseUnits.THREADS)
          .register(registry);
  Gauge.builder("thread.factory.running", running, AtomicInteger::get)
      .tags(Tags.concat(tags, "name", name))
      .description(
          "The approximate number of threads which have started to execute, but have not terminated")
      .baseUnit(BaseUnits.THREADS)
      .register(registry);
}
 
Example 8
Source Project: micrometer   Source File: CounterSample.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    MeterRegistry registry = SampleConfig.myMonitoringSystem();
    Counter counter = registry.counter("counter", "method", "actual");

    AtomicInteger n = new AtomicInteger(0);
    registry.more().counter("counter", Tags.of("method", "function"), n);

    RandomEngine r = new MersenneTwister64(0);
    Normal dist = new Normal(0, 1, r);

    Flux.interval(Duration.ofMillis(10))
            .doOnEach(d -> {
                if (dist.nextDouble() + 0.1 > 0) {
                    counter.increment();
                    n.incrementAndGet();
                }
            })
            .blockLast();
}
 
Example 9
Source Project: micrometer   Source File: OkHttpMetricsEventListenerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void uriTagWorksWithUriMapper(@WiremockResolver.Wiremock WireMockServer server) throws IOException {
    server.stubFor(any(anyUrl()));
    OkHttpClient client = new OkHttpClient.Builder()
            .eventListener(OkHttpMetricsEventListener.builder(registry, "okhttp.requests")
                    .uriMapper(req -> req.url().encodedPath())
                    .tags(Tags.of("foo", "bar"))
                    .build())
            .build();

    Request request = new Request.Builder()
            .url(server.baseUrl() + "/helloworld.txt")
            .build();

    client.newCall(request).execute().close();

    assertThat(registry.get("okhttp.requests")
            .tags("foo", "bar", "uri", "/helloworld.txt", "status", "200",
                    "target.host", "localhost",
                    "target.port", String.valueOf(server.port()),
                    "target.scheme", "http")
            .timer().count()).isEqualTo(1L);
}
 
Example 10
Source Project: micrometer   Source File: DatadogMeterRegistryTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void postMetricDescriptionMetadataWhenDescriptionIsEnabledButNull() {
    DatadogConfig config = new DatadogConfig() {

        @Override
        public String get(String key) {
            return null;
        }

        @Override
        public String apiKey() {
            return "fake";
        }
    };

    HttpSender httpSender = mock(HttpSender.class);
    DatadogMeterRegistry registry = DatadogMeterRegistry.builder(config).httpClient(httpSender).build();
    Meter.Id id = new Meter.Id("my.meter", Tags.empty(), null, null, Meter.Type.COUNTER);
    registry.postMetricDescriptionMetadata("my.meter", new DatadogMetricMetadata(id, true));
    verifyNoInteractions(httpSender);
}
 
Example 11
Source Project: hono   Source File: MicrometerBasedMetricsTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Verifies that when reporting a downstream message no tags for
 * {@link QoS#UNKNOWN} nor {@link TtdStatus#NONE} are included.
 *
 * @param registry The registry that the tests should be run against.
 */
@ParameterizedTest
@MethodSource("registries")
public void testReportTelemetryWithUnknownTagValues(final MeterRegistry registry) {

    final MicrometerBasedMetrics metrics = new MicrometerBasedMetrics(registry, mock(Vertx.class));

    metrics.reportTelemetry(
            MetricsTags.EndpointType.TELEMETRY,
            "tenant",
            TenantObject.from("tenant", true),
            MetricsTags.ProcessingOutcome.FORWARDED,
            MetricsTags.QoS.UNKNOWN,
            1024,
            MetricsTags.TtdStatus.NONE,
            metrics.startTimer());

    final Tags expectedTags = Tags.of(MetricsTags.EndpointType.TELEMETRY.asTag())
            .and(MetricsTags.getTenantTag("tenant"))
            .and(MetricsTags.ProcessingOutcome.FORWARDED.asTag())
            .and(MetricsTags.QoS.UNKNOWN.asTag())
            .and(MetricsTags.TtdStatus.NONE.asTag());

    assertNotNull(registry.find(MicrometerBasedMetrics.METER_MESSAGES_RECEIVED).tags(expectedTags).timer());
}
 
Example 12
Source Project: reactor-core   Source File: FluxMetricsFuseableTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void requestFusionDelegates() {
	AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create();
	FluxMetricsFuseable.MetricsFuseableSubscriber<Integer> fuseableSubscriber =
			new FluxMetricsFuseable.MetricsFuseableSubscriber<>(testSubscriber,
					registry, Clock.SYSTEM, "foo", Tags.empty());

	Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>();
	fuseableSubscriber.onSubscribe(testQueue);

	assertThat(fuseableSubscriber.requestFusion(Fuseable.SYNC))
			.as("fusion mode SYNC").isEqualTo(Fuseable.SYNC);

	assertThat(fuseableSubscriber.requestFusion(Fuseable.ASYNC))
			.as("fusion mode ASYNC").isEqualTo(Fuseable.ASYNC);

	assertThat(fuseableSubscriber.requestFusion(Fuseable.NONE))
			.as("fusion mode NONE").isEqualTo(Fuseable.NONE);
}
 
Example 13
Source Project: reactor-core   Source File: MonoMetricsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void usesTags() {
	Mono<Integer> source = Mono.just(1)
	                           .tag("tag1", "A")
	                           .name("usesTags")
	                           .tag("tag2", "foo")
	                           .hide();
	new MonoMetrics<>(source, registry)
			.block();

	Timer meter = registry
			.find(METER_FLOW_DURATION)
			.tags(Tags.of(TAG_ON_COMPLETE))
			.tag(TAG_SEQUENCE_NAME, "usesTags")
			.tag("tag1", "A")
			.tag("tag2", "foo")
			.timer();

	assertThat(meter).isNotNull();
	assertThat(meter.count()).isEqualTo(1L);
}
 
Example 14
Source Project: skywalking   Source File: SkywalkingMeterRegistryTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFunctionTimer() {
    final SkywalkingMeterRegistry registry = new SkywalkingMeterRegistry();
    final FunctionTimerBean task = new FunctionTimerBean(1, 200);
    registry.more().timer("test_function_timer", Tags.of("skywalking", "test"), task,
        FunctionTimerBean::getCount, FunctionTimerBean::getTotalTime, TimeUnit.MILLISECONDS);
    final List<MeterId.Tag> tags = Arrays.asList(new MeterId.Tag("skywalking", "test"));

    // Check is has appoint meter
    Assert.assertEquals(2, meterMap.size());
    Gauge countGauge = null;
    Gauge sumGauge = null;
    for (BaseMeter meter : meterMap.values()) {
        if (meter.getName().endsWith("count")) {
            countGauge = (Gauge) meter;
        } else if (meter.getName().endsWith("sum")) {
            sumGauge = (Gauge) meter;
        }
    }

    // Check data
    assertGauge(countGauge, "test_function_timer_count", tags, 1);
    assertGauge(sumGauge, "test_function_timer_sum", tags, 200);
}
 
Example 15
Source Project: micrometer   Source File: DiskSpaceMetrics.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void bindTo(MeterRegistry registry) {
    Iterable<Tag> tagsWithPath = Tags.concat(tags, "path", absolutePath);
    Gauge.builder("disk.free", path, File::getUsableSpace)
            .tags(tagsWithPath)
            .description("Usable space for path")
            .baseUnit(BaseUnits.BYTES)
            .strongReference(true)
            .register(registry);
    Gauge.builder("disk.total", path, File::getTotalSpace)
            .tags(tagsWithPath)
            .description("Total space for path")
            .baseUnit(BaseUnits.BYTES)
            .strongReference(true)
            .register(registry);
}
 
Example 16
Source Project: micrometer   Source File: FileDescriptorMetricsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
void windowsFileDescriptorMetrics() {
    assumeTrue(System.getProperty("os.name").toLowerCase().contains("win"));

    new FileDescriptorMetrics(Tags.of("some", "tag")).bindTo(registry);

    assertThat(registry.find("process.files.open").gauge()).isNull();
    assertThat(registry.find("process.files.max").gauge()).isNull();
}
 
Example 17
Source Project: micrometer   Source File: KafkaConsumerMetricsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
void verifyKafkaMajorVersion() {
    try (Consumer<Long, String> consumer = createConsumer()) {
        Tags tags = Tags.of("client.id", "consumer-" + consumerCount);
        assertThat(kafkaConsumerMetrics.kafkaMajorVersion(tags)).isGreaterThanOrEqualTo(2);
    }
}
 
Example 18
Source Project: rqueue   Source File: SpringApp.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public RqueueMetricsProperties rqueueMetricsProperties() {
  RqueueMetricsProperties metricsProperties = new RqueueMetricsProperties();
  metricsProperties.setMetricTags(Tags.of("rqueue", "test"));
  metricsProperties.getCount().setExecution(true);
  metricsProperties.getCount().setFailure(true);
  return metricsProperties;
}
 
Example 19
Source Project: hono   Source File: MetricsTags.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates the default tag set for a protocol adapter.
 *
 * @param name The name of the protocol adapter.
 * @return A ready to use tag set.
 */
public static Tags forProtocolAdapter(final String name) {
    return Tags.of(
            Tag.of(MetricsTags.TAG_HOST, Hostnames.getHostname()),
            MetricsTags.ComponentType.ADAPTER.asTag(),
            Tag.of(MetricsTags.TAG_COMPONENT_NAME, name));
}
 
Example 20
Source Project: che   Source File: FileStoresMeterBinder.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void bindTo(MeterRegistry registry) {
  for (FileStore fileStore : FileSystems.getDefault().getFileStores()) {
    LOG.debug(
        "Add gauge metric for {}, isReadOnly {}, type {}",
        fileStore.name(),
        fileStore.isReadOnly(),
        fileStore.type());
    Iterable<Tag> tagsWithPath = Tags.concat(Tags.empty(), "path", fileStore.toString());

    Gauge.builder("disk.free", fileStore, exceptionToNonWrapper(FileStore::getUnallocatedSpace))
        .tags(tagsWithPath)
        .description("Unallocated space for file storage")
        .baseUnit("bytes")
        .strongReference(true)
        .register(registry);
    Gauge.builder("disk.total", fileStore, exceptionToNonWrapper(FileStore::getTotalSpace))
        .tags(tagsWithPath)
        .description("Total space for file storage")
        .baseUnit("bytes")
        .strongReference(true)
        .register(registry);
    Gauge.builder("disk.usable", fileStore, exceptionToNonWrapper(FileStore::getUsableSpace))
        .tags(tagsWithPath)
        .description("Usable space for file storage")
        .baseUnit("bytes")
        .strongReference(true)
        .register(registry);
  }
}
 
Example 21
Source Project: rqueue   Source File: QueueCounterTest.java    License: Apache License 2.0 5 votes vote down vote up
private void registerQueue(
    MetricProperties metricsProperties,
    MeterRegistry meterRegistry,
    QueueDetail queueDetail,
    String type) {
  QueueCounter counter = new QueueCounter();
  counter.registerQueue(
      metricsProperties, Tags.of("queue", queueDetail.getName()), meterRegistry, queueDetail);
  updateCount(type, counter, queueDetail.getName());
}
 
Example 22
Source Project: micrometer   Source File: DefaultJerseyTagsProviderTest.java    License: Apache License 2.0 5 votes vote down vote up
private static Tag[] tagsFrom(String uri, int status, String exception, String outcome) {
    Iterable<Tag> expectedTags = Tags.of(
        "method", "GET",
        "uri", uri,
        "status", String.valueOf(status),
        "exception", exception == null ? "None" : exception,
        "outcome", outcome
    );

    return stream(expectedTags.spliterator(), false)
        .toArray(Tag[]::new);
}
 
Example 23
Source Project: java-dcp-client   Source File: DcpChannel.java    License: Apache License 2.0 5 votes vote down vote up
public DcpChannel(HostAndPort address, final Client.Environment env, final Conductor conductor) {
  super(LifecycleState.DISCONNECTED);
  this.address = address;
  this.env = env;
  this.conductor = conductor;
  this.controlHandler = new DcpChannelControlHandler(this);
  this.isShutdown = false;
  this.metrics = new DcpChannelMetrics(new MetricsContext("dcp", Tags.of("remote", address.format())));
}
 
Example 24
private void registerTimeGaugeForObject(MeterRegistry registry, ObjectName o, String jmxMetricName,
    String meterName, Tags allTags, String description) {
    TimeGauge
        .builder(METRIC_NAME_PREFIX + meterName, getMBeanServer(), TimeUnit.MILLISECONDS,
            s -> safeDouble(() -> s.getAttribute(o, jmxMetricName)))
        .description(description).tags(allTags).register(registry);
}
 
Example 25
MolgenisTimedAspect(MeterRegistry registry) {
  this(
      registry,
      pjp ->
          Tags.of(
              "class",
              pjp.getStaticPart().getSignature().getDeclaringTypeName(),
              "method",
              pjp.getStaticPart().getSignature().getName()));
}
 
Example 26
Source Project: reactor-core   Source File: FluxMetricsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void splitMetricsOnName() {
	final Flux<Integer> unnamedSource = Flux.<Integer>error(new ArithmeticException("boom"))
			.hide();
	final Flux<Integer> unnamed = new FluxMetrics<>(unnamedSource, registry)
			.onErrorResume(e -> Mono.empty());
	final Flux<Integer> namedSource = Flux.range(1, 40)
	                                      .name("foo")
	                                      .map(i -> 100 / (40 - i))
	                                      .hide();
	final Flux<Integer> named = new FluxMetrics<>(namedSource, registry)
			.onErrorResume(e -> Mono.empty());

	Mono.when(unnamed, named).block();

	Timer unnamedMeter = registry
			.find(METER_FLOW_DURATION)
			.tags(Tags.of(TAG_ON_ERROR))
			.tag(TAG_KEY_EXCEPTION, ArithmeticException.class.getName())
			.tag(TAG_SEQUENCE_NAME, REACTOR_DEFAULT_NAME)
			.timer();

	Timer namedMeter = registry
			.find(METER_FLOW_DURATION)
			.tags(Tags.of(TAG_ON_ERROR))
			.tag(TAG_KEY_EXCEPTION, ArithmeticException.class.getName())
			.tag(TAG_SEQUENCE_NAME, "foo")
			.timer();

	assertThat(unnamedMeter).isNotNull();
	assertThat(namedMeter).isNotNull();

	assertThat(unnamedMeter.count()).isOne();
	assertThat(namedMeter.count()).isOne();
}
 
Example 27
Source Project: reactor-core   Source File: FluxMetrics.java    License: Apache License 2.0 5 votes vote down vote up
static void recordOnSubscribe(Tags commonTags, MeterRegistry registry) {
	Counter.builder(METER_SUBSCRIBED)
	       .tags(commonTags)
	       .baseUnit("subscribers")
	       .description("Counts how many Reactor sequences have been subscribed to")
	       .register(registry)
	       .increment();
}
 
Example 28
Source Project: summerframework   Source File: KafkaConsumerMetrics.java    License: Apache License 2.0 5 votes vote down vote up
private void registerGaugeForObject(MeterRegistry registry, ObjectName o, String jmxMetricName, String meterName,
    Tags allTags, String description, @Nullable String baseUnit) {
    Gauge
        .builder(METRIC_NAME_PREFIX + meterName, mBeanServer,
            s -> safeDouble(() -> s.getAttribute(o, jmxMetricName)))
        .description(description).baseUnit(baseUnit).tags(allTags).register(registry);
}
 
Example 29
Source Project: strimzi-kafka-operator   Source File: TopicOperator.java    License: Apache License 2.0 5 votes vote down vote up
public void initMetrics() {
    if (metrics != null) {
        Tags metricTags = Tags.of(Tag.of("kind", "KafkaTopic"));

        periodicReconciliationsCounter = metrics.counter(METRICS_PREFIX + "reconciliations.periodical",
                "Number of periodical reconciliations done by the operator",
                metricTags);

        reconciliationsCounter = metrics.counter(METRICS_PREFIX + "reconciliations",
                "Number of reconciliations done by the operator for individual topics",
                metricTags);

        failedReconciliationsCounter = metrics.counter(METRICS_PREFIX + "reconciliations.failed",
                "Number of reconciliations done by the operator for individual topics which failed",
                metricTags);

        successfulReconciliationsCounter = metrics.counter(METRICS_PREFIX + "reconciliations.successful",
                "Number of reconciliations done by the operator for individual topics which were successful",
                metricTags);

        topicCounter = metrics.gauge(METRICS_PREFIX + "resources",
                "Number of topics the operator sees",
                metricTags);

        reconciliationsTimer = metrics.timer(METRICS_PREFIX + "reconciliations.duration",
                "The time the reconciliation takes to complete",
                metricTags);

        lockedReconciliationsCounter = metrics.counter(METRICS_PREFIX + "reconciliations.locked",
                "Number of reconciliations skipped because another reconciliation for the same topic was still running",
                metricTags);
    }
}
 
Example 30
Source Project: micrometer   Source File: DiskSpaceMetricsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
void diskSpaceMetricsWithTags() {
    new DiskSpaceMetrics(new File(System.getProperty("user.dir")), Tags.of("key1", "value1")).bindTo(registry);

    assertThat(registry.get("disk.free").tags("key1", "value1").gauge().value()).isNotNaN().isGreaterThan(0);
    assertThat(registry.get("disk.total").tags("key1", "value1").gauge().value()).isNotNaN().isGreaterThan(0);
}