use of io.micrometer.core.instrument.Tags in project feign by OpenFeign.
the class MeteredClient method createTimer.
protected Timer createTimer(Request request, Response response, Options options, Exception e) {
final RequestTemplate template = request.requestTemplate();
final Tags allTags = metricTagResolver.tag(template.methodMetadata(), template.feignTarget(), e, Tag.of("uri", template.methodMetadata().template().path())).and(extraTags(request, response, options, e));
return meterRegistry.timer(metricName.name(e), allTags);
}
use of io.micrometer.core.instrument.Tags in project hono by eclipse.
the class MicrometerBasedMetrics method create.
@Override
public SendMessageSampler create(final String messageType) {
Objects.requireNonNull(messageType);
return new SendMessageSampler() {
@Override
public Sample start(final String tenantId) {
final Timer.Sample sample = Timer.start(registry);
return new Sample() {
@Override
public void completed(final String outcome) {
final Tags tags = Tags.of(Tag.of(MetricsTags.TAG_TYPE, messageType), MetricsTags.getTenantTag(tenantId), Tag.of("outcome", outcome));
sample.stop(registry.timer(METER_DOWNSTREAM_SENT, tags));
}
@Override
public void timeout() {
/*
* We report timeouts with a different meter, since the message might still be
* accepted by the remote peer, at a time after the timeout expired. And so we
* can still track those times.
*/
final Tags tags = Tags.of(Tag.of(MetricsTags.TAG_TYPE, messageType), MetricsTags.getTenantTag(tenantId));
registry.counter(METER_DOWNSTREAM_TIMEOUT, tags).increment();
}
};
}
@Override
public void queueFull(final String tenantId) {
final Tags tags = Tags.of(Tag.of(MetricsTags.TAG_TYPE, messageType), MetricsTags.getTenantTag(tenantId));
registry.counter(METER_DOWNSTREAM_FULL, tags).increment();
}
};
}
use of io.micrometer.core.instrument.Tags in project reactor-core by reactor.
the class MonoMetricsFuseableTest method splitMetricsOnNameFuseable.
@Test
public void splitMetricsOnNameFuseable() {
final Mono<Integer> unnamedSource = Mono.just(0).map(v -> 100 / v);
final Mono<Integer> namedSource = Mono.just(0).map(v -> 100 / v).name("foo");
final Mono<Integer> unnamed = new MonoMetricsFuseable<>(unnamedSource).onErrorResume(e -> Mono.empty());
final Mono<Integer> named = new MonoMetricsFuseable<>(namedSource).onErrorResume(e -> Mono.empty());
Mono.when(unnamed, named).block();
Timer unnamedMeter = registry.find(REACTOR_DEFAULT_NAME + METER_FLOW_DURATION).tags(Tags.of(TAG_ON_ERROR)).tag(TAG_KEY_EXCEPTION, ArithmeticException.class.getName()).timer();
Timer namedMeter = registry.find("foo" + METER_FLOW_DURATION).tags(Tags.of(TAG_ON_ERROR)).tag(TAG_KEY_EXCEPTION, ArithmeticException.class.getName()).timer();
assertThat(unnamedMeter).isNotNull();
assertThat(unnamedMeter.count()).isOne();
assertThat(namedMeter).isNotNull();
assertThat(namedMeter.count()).isOne();
}
use of io.micrometer.core.instrument.Tags in project open-kilda by telstra.
the class PushToStreamMeterRegistry method writeCustomMeter.
private List<Datapoint> writeCustomMeter(Meter meter) {
long wallTime = config().clock().wallTime();
List<Tag> tags = getConventionTags(meter.getId());
return StreamSupport.stream(meter.measure().spliterator(), false).map(ms -> {
String name = getConventionName(meter.getId());
switch(ms.getStatistic()) {
case TOTAL:
case TOTAL_TIME:
name += ".sum";
break;
case MAX:
name += ".max";
break;
case ACTIVE_TASKS:
name += ".active.count";
break;
case DURATION:
name += ".duration.sum";
break;
default:
throw new IllegalStateException("Unknown statistic " + ms.getStatistic());
}
Datapoint datapoint = new Datapoint();
datapoint.setMetric(name);
datapoint.setTime(wallTime);
// Double type is not supported by {@link org.apache.storm.opentsdb.OpenTsdbMetricDatapoint}
datapoint.setValue((long) ms.getValue());
Tags localTags = Tags.concat(tags, "statistics", ms.getStatistic().toString());
Map<String, String> resultTags = new HashMap<>(localTags.stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue)));
if (resultTags.isEmpty()) {
// FIXME: opentsdb rejects datapoints without tags.
resultTags.put("dummy", "dummy");
}
datapoint.setTags(resultTags);
return datapoint;
}).collect(Collectors.toList());
}
use of io.micrometer.core.instrument.Tags in project spring-boot by spring-projects.
the class StartupTimeMetricsListenerTests method metricRecordedWithoutMainAppClassTagAndAdditionalTags.
@Test
void metricRecordedWithoutMainAppClassTagAndAdditionalTags() {
SpringApplication application = mock(SpringApplication.class);
Tags tags = Tags.of("foo", "bar");
this.listener = new StartupTimeMetricsListener(this.registry, "started", "ready", tags);
this.listener.onApplicationEvent(new ApplicationReadyEvent(application, null, null, Duration.ofSeconds(2)));
TimeGauge applicationReadyGague = this.registry.find("ready").timeGauge();
assertThat(applicationReadyGague).isNotNull();
assertThat(applicationReadyGague.getId().getTags()).containsExactlyElementsOf(tags);
}
Aggregations