use of io.micrometer.core.instrument.TimeGauge in project micrometer by micrometer-metrics.
the class ElasticMeterRegistryTest method nullGauge.
@Issue("#497")
@Test
void nullGauge() {
Gauge g = Gauge.builder("gauge", null, o -> 1).register(registry);
assertThat(registry.writeGauge(g, 0)).isEmpty();
TimeGauge tg = TimeGauge.builder("time.gauge", null, TimeUnit.MILLISECONDS, o -> 1).register(registry);
assertThat(registry.writeGauge(tg, 0)).isEmpty();
}
use of io.micrometer.core.instrument.TimeGauge in project spring-boot by spring-projects.
the class StartupTimeMetricsListenerTests method metricRecordedWithoutMainAppClassTag.
@Test
void metricRecordedWithoutMainAppClassTag() {
SpringApplication application = mock(SpringApplication.class);
this.listener.onApplicationEvent(new ApplicationStartedEvent(application, null, null, Duration.ofSeconds(2)));
TimeGauge applicationStartedGague = this.registry.find("application.started.time").timeGauge();
assertThat(applicationStartedGague).isNotNull();
assertThat(applicationStartedGague.getId().getTags()).isEmpty();
}
use of io.micrometer.core.instrument.TimeGauge in project spring-boot by spring-projects.
the class StartupTimeMetricsListenerAutoConfigurationTests method startupTimeMetricsAreRecorded.
@Test
void startupTimeMetricsAreRecorded() {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(StartupTimeMetricsListener.class);
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
context.publishEvent(new ApplicationStartedEvent(new SpringApplication(), null, context.getSourceApplicationContext(), Duration.ofMillis(1500)));
TimeGauge startedTimeGage = registry.find("application.started.time").timeGauge();
assertThat(startedTimeGage).isNotNull();
assertThat(startedTimeGage.value(TimeUnit.MILLISECONDS)).isEqualTo(1500L);
context.publishEvent(new ApplicationReadyEvent(new SpringApplication(), null, context.getSourceApplicationContext(), Duration.ofMillis(2000)));
TimeGauge readyTimeGage = registry.find("application.ready.time").timeGauge();
assertThat(readyTimeGage).isNotNull();
assertThat(readyTimeGage.value(TimeUnit.MILLISECONDS)).isEqualTo(2000L);
});
}
use of io.micrometer.core.instrument.TimeGauge 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