use of org.springframework.boot.actuate.metrics.GaugeService in project spring-boot by spring-projects.
the class MetricRepositoryAutoConfigurationTests method dropwizardInstalledIfPresent.
@Test
public void dropwizardInstalledIfPresent() {
this.context = new AnnotationConfigApplicationContext(MetricsDropwizardAutoConfiguration.class, MetricRepositoryAutoConfiguration.class, AopAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(GaugeService.class);
assertThat(gaugeService).isNotNull();
gaugeService.submit("foo", 2.7);
DropwizardMetricServices exporter = this.context.getBean(DropwizardMetricServices.class);
assertThat(exporter).isEqualTo(gaugeService);
MetricRegistry registry = this.context.getBean(MetricRegistry.class);
@SuppressWarnings("unchecked") Gauge<Double> gauge = (Gauge<Double>) registry.getMetrics().get("gauge.foo");
assertThat(gauge.getValue()).isEqualTo(new Double(2.7));
}
use of org.springframework.boot.actuate.metrics.GaugeService in project spring-boot by spring-projects.
the class MetricExportAutoConfigurationTests method provideAdditionalWriter.
@Test
public void provideAdditionalWriter() {
this.context = new AnnotationConfigApplicationContext(WriterConfig.class, MetricRepositoryAutoConfiguration.class, MetricExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(GaugeService.class);
assertThat(gaugeService).isNotNull();
gaugeService.submit("foo", 2.7);
MetricExporters exporters = this.context.getBean(MetricExporters.class);
MetricCopyExporter exporter = (MetricCopyExporter) exporters.getExporters().get("writer");
exporter.setIgnoreTimestamps(true);
exporter.export();
MetricWriter writer = this.context.getBean("writer", MetricWriter.class);
Mockito.verify(writer, Mockito.atLeastOnce()).set(any(Metric.class));
}
use of org.springframework.boot.actuate.metrics.GaugeService in project spring-boot by spring-projects.
the class MetricExportAutoConfigurationTests method metricsFlushAutomatically.
@Test
public void metricsFlushAutomatically() throws Exception {
this.context = new AnnotationConfigApplicationContext(WriterConfig.class, MetricRepositoryAutoConfiguration.class, MetricExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(GaugeService.class);
assertThat(gaugeService).isNotNull();
gaugeService.submit("foo", 2.7);
MetricExporters flusher = this.context.getBean(MetricExporters.class);
// this will be called by Spring on shutdown
flusher.close();
MetricWriter writer = this.context.getBean("writer", MetricWriter.class);
verify(writer, atLeastOnce()).set(any(Metric.class));
}
use of org.springframework.boot.actuate.metrics.GaugeService in project spring-boot by spring-projects.
the class MetricFilterAutoConfigurationTests method gaugeServiceThatThrows.
@Test
public void gaugeServiceThatThrows() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class, MetricFilterAutoConfiguration.class);
GaugeService gaugeService = context.getBean(GaugeService.class);
willThrow(new IllegalStateException()).given(gaugeService).submit(anyString(), anyDouble());
Filter filter = context.getBean(Filter.class);
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController()).addFilter(filter).build();
mvc.perform(get("/templateVarTest/foo")).andExpect(status().isOk());
verify(context.getBean(CounterService.class)).increment("status.200.templateVarTest.someVariable");
verify(context.getBean(GaugeService.class)).submit(eq("response.templateVarTest.someVariable"), anyDouble());
context.close();
}
use of org.springframework.boot.actuate.metrics.GaugeService in project spring-boot by spring-projects.
the class MetricRepositoryAutoConfigurationTests method createServices.
@Test
public void createServices() throws Exception {
this.context = new AnnotationConfigApplicationContext(MetricRepositoryAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(BufferGaugeService.class);
assertThat(gaugeService).isNotNull();
assertThat(this.context.getBean(BufferCounterService.class)).isNotNull();
assertThat(this.context.getBean(PrefixMetricReader.class)).isNotNull();
gaugeService.submit("foo", 2.7);
MetricReader bean = this.context.getBean(MetricReader.class);
assertThat(bean.findOne("gauge.foo").getValue()).isEqualTo(2.7);
}
Aggregations