Search in sources :

Example 11 with Tags

use of io.micrometer.core.instrument.Tags in project spring-boot by spring-projects.

the class StartupTimeMetricsListenerTests method metricsRecordedWithCustomTagsAndMetricNames.

@Test
void metricsRecordedWithCustomTagsAndMetricNames() {
    Tags tags = Tags.of("foo", "bar");
    this.listener = new StartupTimeMetricsListener(this.registry, "m1", "m2", tags);
    this.listener.onApplicationEvent(applicationStartedEvent(1000L));
    this.listener.onApplicationEvent(applicationReadyEvent(1050L));
    assertMetricExistsWithCustomTagsAndValue("m1", tags, 1000L);
    assertMetricExistsWithCustomTagsAndValue("m2", tags, 1050L);
}
Also used : Tags(io.micrometer.core.instrument.Tags) Test(org.junit.jupiter.api.Test)

Example 12 with Tags

use of io.micrometer.core.instrument.Tags in project spring-boot by spring-projects.

the class DiskSpaceMetricsBinderTests method diskSpaceMetricsWithMultiplePaths.

@Test
void diskSpaceMetricsWithMultiplePaths() {
    MeterRegistry meterRegistry = new SimpleMeterRegistry();
    File path1 = new File(".");
    File path2 = new File("..");
    DiskSpaceMetricsBinder metricsBinder = new DiskSpaceMetricsBinder(Arrays.asList(path1, path2), Tags.empty());
    metricsBinder.bindTo(meterRegistry);
    Tags tags = Tags.of("path", path1.getAbsolutePath());
    assertThat(meterRegistry.get("disk.free").tags(tags).gauge()).isNotNull();
    assertThat(meterRegistry.get("disk.total").tags(tags).gauge()).isNotNull();
    tags = Tags.of("path", path2.getAbsolutePath());
    assertThat(meterRegistry.get("disk.free").tags(tags).gauge()).isNotNull();
    assertThat(meterRegistry.get("disk.total").tags(tags).gauge()).isNotNull();
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) File(java.io.File) Tags(io.micrometer.core.instrument.Tags) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 13 with Tags

use of io.micrometer.core.instrument.Tags in project spring-boot by spring-projects.

the class DefaultWebFluxTagsProvider method httpRequestTags.

@Override
public Iterable<Tag> httpRequestTags(ServerWebExchange exchange, Throwable exception) {
    Tags tags = Tags.empty();
    tags = tags.and(WebFluxTags.method(exchange));
    tags = tags.and(WebFluxTags.uri(exchange, this.ignoreTrailingSlash));
    tags = tags.and(WebFluxTags.exception(exception));
    tags = tags.and(WebFluxTags.status(exchange));
    tags = tags.and(WebFluxTags.outcome(exchange, exception));
    for (WebFluxTagsContributor contributor : this.contributors) {
        tags = tags.and(contributor.httpRequestTags(exchange, exception));
    }
    return tags;
}
Also used : Tags(io.micrometer.core.instrument.Tags)

Example 14 with Tags

use of io.micrometer.core.instrument.Tags in project hono by eclipse.

the class MicrometerBasedMetrics method reportTelemetry.

@Override
public final void reportTelemetry(final MetricsTags.EndpointType type, final String tenantId, final TenantObject tenantObject, final MetricsTags.ProcessingOutcome outcome, final MetricsTags.QoS qos, final int payloadSize, final MetricsTags.TtdStatus ttdStatus, final Sample timer) {
    Objects.requireNonNull(type);
    Objects.requireNonNull(tenantId);
    Objects.requireNonNull(outcome);
    Objects.requireNonNull(qos);
    Objects.requireNonNull(ttdStatus);
    Objects.requireNonNull(timer);
    if (type != MetricsTags.EndpointType.TELEMETRY && type != MetricsTags.EndpointType.EVENT) {
        throw new IllegalArgumentException("invalid type, must be either telemetry or event");
    } else if (payloadSize < 0) {
        throw new IllegalArgumentException("payload size must not be negative");
    }
    final Tags tags = Tags.of(type.asTag()).and(MetricsTags.getTenantTag(tenantId)).and(outcome.asTag()).and(qos.asTag()).and(ttdStatus.asTag());
    timer.stop(this.registry.timer(METER_MESSAGES_RECEIVED, tags));
    // record payload size
    DistributionSummary.builder(METER_MESSAGES_PAYLOAD).baseUnit("bytes").minimumExpectedValue(0.0).tags(tags).register(this.registry).record(ServiceBaseUtils.calculatePayloadSize(payloadSize, tenantObject));
    updateLastSeenTimestamp(tenantId);
}
Also used : Tags(io.micrometer.core.instrument.Tags)

Example 15 with Tags

use of io.micrometer.core.instrument.Tags in project hono by eclipse.

the class MicrometerBasedMetrics method reportCommand.

@Override
public void reportCommand(final Direction direction, final String tenantId, final TenantObject tenantObject, final ProcessingOutcome outcome, final int payloadSize, final Sample timer) {
    Objects.requireNonNull(direction);
    Objects.requireNonNull(tenantId);
    Objects.requireNonNull(outcome);
    Objects.requireNonNull(timer);
    if (payloadSize < 0) {
        throw new IllegalArgumentException("payload size must not be negative");
    }
    final Tags tags = Tags.of(direction.asTag()).and(MetricsTags.getTenantTag(tenantId)).and(outcome.asTag());
    timer.stop(this.registry.timer(METER_COMMANDS_RECEIVED, tags));
    // record payload size
    DistributionSummary.builder(METER_COMMANDS_PAYLOAD).baseUnit("bytes").minimumExpectedValue(0.0).tags(tags).register(this.registry).record(ServiceBaseUtils.calculatePayloadSize(payloadSize, tenantObject));
    updateLastSeenTimestamp(tenantId);
}
Also used : Tags(io.micrometer.core.instrument.Tags)

Aggregations

Tags (io.micrometer.core.instrument.Tags)26 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)10 Test (org.junit.jupiter.api.Test)9 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)7 Timer (io.micrometer.core.instrument.Timer)6 Clock (io.micrometer.core.instrument.Clock)5 Counter (io.micrometer.core.instrument.Counter)5 DistributionSummary (io.micrometer.core.instrument.DistributionSummary)5 TimeUnit (java.util.concurrent.TimeUnit)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 MockClock (io.micrometer.core.instrument.MockClock)4 SimpleConfig (io.micrometer.core.instrument.simple.SimpleConfig)4 Duration (java.time.Duration)4 Scannable (reactor.core.Scannable)4 Metrics (reactor.util.Metrics)4 Sample (io.micrometer.core.instrument.Timer.Sample)3 Vertx (io.vertx.core.Vertx)3 File (java.io.File)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assertions.assertThatCode (org.assertj.core.api.Assertions.assertThatCode)3