本文整理汇总了Java中org.springframework.boot.actuate.metrics.writer.MetricWriter类的典型用法代码示例。如果您正苦于以下问题:Java MetricWriter类的具体用法?Java MetricWriter怎么用?Java MetricWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetricWriter类属于org.springframework.boot.actuate.metrics.writer包,在下文中一共展示了MetricWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flush
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
private void flush(GaugeWriter writer) {
if (writer instanceof CompositeMetricWriter) {
for (MetricWriter child : (CompositeMetricWriter) writer) {
flush(child);
}
}
try {
if (ClassUtils.isPresent("java.io.Flushable", null)) {
if (writer instanceof Flushable) {
((Flushable) writer).flush();
return;
}
}
Method method = ReflectionUtils.findMethod(writer.getClass(), "flush");
if (method != null) {
ReflectionUtils.invokeMethod(method, writer);
}
}
catch (Exception ex) {
logger.warn("Could not flush MetricWriter: " + ex.getClass() + ": "
+ ex.getMessage());
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:24,代码来源:MetricCopyExporter.java
示例2: provideAdditionalWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@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(Matchers.any(Metric.class));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:MetricExportAutoConfigurationTests.java
示例3: flush
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
private void flush(MetricWriter writer) {
if (writer instanceof CompositeMetricWriter) {
for (MetricWriter child : (CompositeMetricWriter) writer) {
flush(child);
}
}
try {
if (ClassUtils.isPresent("java.io.Flushable", null)) {
if (writer instanceof Flushable) {
((Flushable) writer).flush();
return;
}
}
Method method = ReflectionUtils.findMethod(writer.getClass(), "flush");
if (method != null) {
ReflectionUtils.invokeMethod(method, writer);
}
}
catch (Exception ex) {
logger.warn("Could not flush MetricWriter: " + ex.getClass() + ": "
+ ex.getMessage());
}
}
示例4: provideAdditionalWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@Test
public void provideAdditionalWriter() {
this.context = new AnnotationConfigApplicationContext(WriterConfig.class,
MetricRepositoryAutoConfiguration.class,
MetricExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(GaugeService.class);
assertNotNull(gaugeService);
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(Matchers.any(Metric.class));
}
示例5: metricsFlushAutomatically
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@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);
flusher.close(); // this will be called by Spring on shutdown
MetricWriter writer = this.context.getBean("writer", MetricWriter.class);
Mockito.verify(writer, Mockito.atLeastOnce()).set(Matchers.any(Metric.class));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:MetricExportAutoConfigurationTests.java
示例6: getExporter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
private MetricCopyExporter getExporter(MetricWriter writer,
TriggerProperties trigger) {
MetricCopyExporter exporter = new MetricCopyExporter(this.reader, writer);
exporter.setIncludes(trigger.getIncludes());
exporter.setExcludes(trigger.getExcludes());
exporter.setSendLatest(trigger.isSendLatest());
return exporter;
}
示例7: openTsdbMetricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@Bean
@ConfigurationProperties("metrics.export")
@ExportMetricWriter
public MetricWriter openTsdbMetricWriter() {
OpenTsdbMetricWriter writer = new OpenTsdbMetricWriter();
writer.setNamingStrategy(namingStrategy());
return writer;
}
示例8: primaryMetricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@Bean
@Primary
@ConditionalOnMissingClass("org.springframework.messaging.MessageChannel")
@ConditionalOnMissingBean(name = "primaryMetricWriter")
public MetricWriter primaryMetricWriter(List<MetricWriter> writers) {
return new CompositeMetricWriter(writers);
}
示例9: primaryMetricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@Bean(name = "primaryMetricWriter")
@Primary
static public MetricWriter primaryMetricWriter(List<MetricWriter> writers) {
// Normally the Metrics are written asynchronously to Spring Boot's repository. In tests we need to do it synchronously to be able to verify
// the correct output.
MetricWriter compositeMetricWriter = new CompositeMetricWriter(writers);
return compositeMetricWriter;
}
示例10: metricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@Bean
@ExportMetricWriter
/*
* Prometheus is not capable to scrape json metrics so we need to expose the actuator metrics to jmx. Every
* counter and gauge metrics are exposed too.
*/
public MetricWriter metricWriter(MBeanExporter exporter) {
return new JmxMetricWriter(exporter);
}
示例11: metricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricWriter
MetricWriter metricWriter() {
return new SpectatorLogMetricWriter();
}
示例12: metricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
/**
* Exports actuator metrics to JMX.
*/
@Bean
@ExportMetricWriter
public MetricWriter metricWriter(MBeanExporter exporter) {
return new JmxMetricWriter(exporter);
}
示例13: metricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
/**
* Export a new {@link StatfulMetricWriter} metrics writer.
* @return {@link MetricWriter}
*/
@Bean
@ExportMetricWriter
MetricWriter metricWriter() {
return new StatfulMetricWriter();
}
示例14: metricWriter
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
@Bean
@ExportMetricWriter
public MetricWriter metricWriter(MetricExportProperties export) {
return new RedisMetricRepository(redisConnectionFactory,
export.getRedis().getPrefix(), export.getRedis().getKey());
}
示例15: LegacyMetricServicesConfiguration
import org.springframework.boot.actuate.metrics.writer.MetricWriter; //导入依赖的package包/类
LegacyMetricServicesConfiguration(@ActuatorMetricWriter MetricWriter writer) {
this.writer = writer;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:4,代码来源:MetricRepositoryAutoConfiguration.java