Search in sources :

Example 1 with Tags

use of io.micrometer.core.instrument.Tags in project webpieces by deanhiller.

the class PersistenceHelper method monitorExecutionTime.

private void monitorExecutionTime(String transactionName, long start, long end) {
    String requestPath = (String) Context.get(ContextKey.REQUEST_PATH.toString());
    if ((requestPath == null) || requestPath.isBlank()) {
        requestPath = "unknown";
    }
    Tags transactionTags = Tags.of(DatabaseTransactionTags.EXECUTION_ID, transactionName, DatabaseTransactionTags.REQUEST, requestPath);
    meterRegistry.timer(DatabaseMetric.EXECUTION_TIME.getDottedMetricName(), transactionTags).record(end - start, TimeUnit.MILLISECONDS);
}
Also used : Tags(io.micrometer.core.instrument.Tags) DatabaseTransactionTags(org.webpieces.plugin.hibernate.metrics.DatabaseTransactionTags)

Example 2 with Tags

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

the class DefaultRepositoryTagsProvider method repositoryTags.

@Override
public Iterable<Tag> repositoryTags(RepositoryMethodInvocation invocation) {
    Tags tags = Tags.empty();
    tags = and(tags, invocation.getRepositoryInterface(), "repository", this::getSimpleClassName);
    tags = and(tags, invocation.getMethod(), "method", Method::getName);
    tags = and(tags, invocation.getResult().getState(), "state", State::name);
    tags = and(tags, invocation.getResult().getError(), "exception", this::getExceptionName, EXCEPTION_NONE);
    return tags;
}
Also used : Tags(io.micrometer.core.instrument.Tags)

Example 3 with Tags

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

the class DiskSpaceMetricsBinderTests method diskSpaceMetricsWithSinglePath.

@Test
void diskSpaceMetricsWithSinglePath() {
    MeterRegistry meterRegistry = new SimpleMeterRegistry();
    File path = new File(".");
    DiskSpaceMetricsBinder metricsBinder = new DiskSpaceMetricsBinder(Collections.singletonList(path), Tags.empty());
    metricsBinder.bindTo(meterRegistry);
    Tags tags = Tags.of("path", path.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 4 with Tags

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

the class DiskSpaceMetricsBinderTests method diskSpaceMetricsWithCustomTags.

@Test
void diskSpaceMetricsWithCustomTags() {
    MeterRegistry meterRegistry = new SimpleMeterRegistry();
    File path = new File(".");
    Tags customTags = Tags.of("foo", "bar");
    DiskSpaceMetricsBinder metricsBinder = new DiskSpaceMetricsBinder(Collections.singletonList(path), customTags);
    metricsBinder.bindTo(meterRegistry);
    Tags tags = Tags.of("path", path.getAbsolutePath(), "foo", "bar");
    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 5 with Tags

use of io.micrometer.core.instrument.Tags in project feign by OpenFeign.

the class MeteredClient method countResponseCode.

protected void countResponseCode(Request request, Response response, Options options, int responseStatus, Exception e) {
    final Tag[] extraTags = extraTags(request, response, options, e);
    final RequestTemplate template = request.requestTemplate();
    final Tags allTags = metricTagResolver.tag(template.methodMetadata(), template.feignTarget(), e, Tag.of("http_status", String.valueOf(responseStatus)), Tag.of("status_group", responseStatus / 100 + "xx"), Tag.of("uri", template.methodMetadata().template().path())).and(extraTags);
    meterRegistry.counter(metricName.name("http_response_code"), allTags).increment();
}
Also used : Tag(io.micrometer.core.instrument.Tag) Tags(io.micrometer.core.instrument.Tags)

Aggregations

Tags (io.micrometer.core.instrument.Tags)21 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)5 Test (org.junit.jupiter.api.Test)5 Sample (io.micrometer.core.instrument.Timer.Sample)3 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)3 Vertx (io.vertx.core.Vertx)3 File (java.io.File)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 Tag (io.micrometer.core.instrument.Tag)2 TimeGauge (io.micrometer.core.instrument.TimeGauge)2 Timer (io.micrometer.core.instrument.Timer)2 Clock (io.micrometer.core.instrument.Clock)1 Counter (io.micrometer.core.instrument.Counter)1 DistributionSummary (io.micrometer.core.instrument.DistributionSummary)1 FunctionCounter (io.micrometer.core.instrument.FunctionCounter)1 FunctionTimer (io.micrometer.core.instrument.FunctionTimer)1 Gauge (io.micrometer.core.instrument.Gauge)1 LongTaskTimer (io.micrometer.core.instrument.LongTaskTimer)1 Measurement (io.micrometer.core.instrument.Measurement)1