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);
}
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();
}
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;
}
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);
}
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);
}
Aggregations