本文整理汇总了Java中org.springframework.boot.actuate.endpoint.PublicMetrics类的典型用法代码示例。如果您正苦于以下问题:Java PublicMetrics类的具体用法?Java PublicMetrics怎么用?Java PublicMetrics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PublicMetrics类属于org.springframework.boot.actuate.endpoint包,在下文中一共展示了PublicMetrics类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getMetrics
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Override
public Flux<Metric> getMetrics(Mono<Empty> request) {
return request
.flatMapIterable(empty -> publicMetrics)
.flatMapIterable(PublicMetrics::metrics)
.map(metric -> {
Metric.Builder builder = Metric.newBuilder()
.setName(metric.getName());
if (metric.getTimestamp() != null) {
builder.setTimestamp(ProtobufMappers.dateToTimestamp(metric.getTimestamp()));
}
if (metric.getValue() instanceof Long || metric.getValue() instanceof Integer) {
builder.setLongValue(metric.getValue().longValue());
} else if (metric.getValue() instanceof Float || metric.getValue() instanceof Double) {
builder.setDoubleValue((metric.getValue()).doubleValue());
} else {
builder.setStringValue(metric.getValue().toString());
}
return builder.build();
});
}
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:22,代码来源:_MetricService.java
示例2: prometheusMetrics
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<String> prometheusMetrics() {
StringBuilder sb = new StringBuilder();
for (PublicMetrics publicMetrics : this.publicMetrics) {
for (Metric<?> metric : publicMetrics.metrics()) {
final String sanitizedName = sanitizeMetricName(metric.getName());
final String type = typeForName(sanitizedName);
final String metricName = metricName(sanitizedName, type);
double value = metric.getValue().doubleValue();
sb.append(String.format("#TYPE %s %s\n", metricName, type));
sb.append(String.format("#HELP %s %s\n", metricName, metricName));
sb.append(String.format("%s %s\n", metricName, prometheusDouble(value)));
}
}
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("text/plain; version=0.0.4; charset=utf-8"))
.body(sb.toString());
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:22,代码来源:PrometheusMetricsAutoConfiguration.java
示例3: multipleDataSources
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void multipleDataSources() {
load(MultipleDataSourcesConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.tomcat.active", "datasource.tomcat.usage",
"datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
// Hikari won't work unless a first connection has been retrieved
JdbcTemplate jdbcTemplate = new JdbcTemplate(
this.context.getBean("hikariDS", DataSource.class));
jdbcTemplate.execute(new ConnectionCallback<Void>() {
@Override
public Void doInConnection(Connection connection)
throws SQLException, DataAccessException {
return null;
}
});
Collection<Metric<?>> anotherMetrics = bean.metrics();
assertMetrics(anotherMetrics, "datasource.tomcat.active",
"datasource.tomcat.usage", "datasource.hikariDS.active",
"datasource.hikariDS.usage", "datasource.commonsDbcp.active",
"datasource.commonsDbcp.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:PublicMetricsAutoConfigurationTests.java
示例4: correctHttpResponse
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void correctHttpResponse() throws Exception {
PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("mem.free", 1024));
ResponseEntity<String> response = responseForMetrics(publicMetrics);
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
assertThat(response.getHeaders().getContentType().toString(),
equalTo("text/plain;version=0.0.4;charset=utf-8"));
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:10,代码来源:PrometheusMetricsAutoConfigurationTest.java
示例5: defaultsToGauge
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void defaultsToGauge() throws Exception {
PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("mem.free", 1024));
ResponseEntity<String> response = responseForMetrics(publicMetrics);
String body = response.getBody();
assertThat(body, equalTo(
"#TYPE mem_free gauge\n" +
"#HELP mem_free mem_free\n" +
"mem_free 1024.0\n"));
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:14,代码来源:PrometheusMetricsAutoConfigurationTest.java
示例6: detectsCounters
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void detectsCounters() throws Exception {
PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("counter_mem.free", 1024));
ResponseEntity<String> response = responseForMetrics(publicMetrics);
String body = response.getBody();
assertThat(body, equalTo(
"#TYPE mem_free counter\n" +
"#HELP mem_free mem_free\n" +
"mem_free 1024.0\n"));
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:14,代码来源:PrometheusMetricsAutoConfigurationTest.java
示例7: detectsGauges
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void detectsGauges() throws Exception {
PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("gauge_mem.free", 1024));
ResponseEntity<String> response = responseForMetrics(publicMetrics);
String body = response.getBody();
assertThat(body, equalTo(
"#TYPE mem_free gauge\n" +
"#HELP mem_free mem_free\n" +
"mem_free 1024.0\n"));
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:14,代码来源:PrometheusMetricsAutoConfigurationTest.java
示例8: collect
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Override
public List<MetricFamilySamples> collect() {
Map<String, MetricFamilySamples> samples = new HashMap<String, MetricFamilySamples>();
for (PublicMetrics publicMetrics : this.publicMetrics) {
for (Metric<?> metric : publicMetrics.metrics()) {
String name = Collector.sanitizeMetricName(metric.getName());
double value = metric.getValue().doubleValue();
MetricFamilySamples metricFamilySamples = new MetricFamilySamples(
name, Type.GAUGE, name, Collections.singletonList(new MetricFamilySamples.Sample(
name, Collections.<String>emptyList(), Collections.<String>emptyList(), value)));
samples.put(name, metricFamilySamples);
}
}
return new ArrayList<MetricFamilySamples>(samples.values());
}
开发者ID:maust,项目名称:spring-boot-prometheus,代码行数:16,代码来源:SpringBootMetricsCollector.java
示例9: EndpointAutoConfiguration
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
public EndpointAutoConfiguration(
ObjectProvider<HealthAggregator> healthAggregatorProvider,
ObjectProvider<Map<String, HealthIndicator>> healthIndicatorsProvider,
ObjectProvider<List<InfoContributor>> infoContributorsProvider,
ObjectProvider<Collection<PublicMetrics>> publicMetricsProvider,
ObjectProvider<TraceRepository> traceRepositoryProvider) {
this.healthAggregator = healthAggregatorProvider.getIfAvailable();
this.healthIndicators = healthIndicatorsProvider.getIfAvailable();
this.infoContributors = infoContributorsProvider.getIfAvailable();
this.publicMetrics = publicMetricsProvider.getIfAvailable();
this.traceRepository = traceRepositoryProvider.getIfAvailable();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:EndpointAutoConfiguration.java
示例10: metricsEndpoint
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public MetricsEndpoint metricsEndpoint() {
List<PublicMetrics> publicMetrics = new ArrayList<PublicMetrics>();
if (this.publicMetrics != null) {
publicMetrics.addAll(this.publicMetrics);
}
Collections.sort(publicMetrics, AnnotationAwareOrderComparator.INSTANCE);
return new MetricsEndpoint(publicMetrics);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EndpointAutoConfiguration.java
示例11: autoDataSource
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void autoDataSource() {
load(DataSourceAutoConfiguration.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:PublicMetricsAutoConfigurationTests.java
示例12: multipleDataSourcesWithPrimary
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void multipleDataSourcesWithPrimary() {
load(MultipleDataSourcesWithPrimaryConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
"datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:PublicMetricsAutoConfigurationTests.java
示例13: multipleDataSourcesWithCustomPrimary
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void multipleDataSourcesWithCustomPrimary() {
load(MultipleDataSourcesWithCustomPrimaryConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
"datasource.dataSource.active", "datasource.dataSource.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:PublicMetricsAutoConfigurationTests.java
示例14: customPrefix
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Test
public void customPrefix() {
load(MultipleDataSourcesWithPrimaryConfig.class,
CustomDataSourcePublicMetrics.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "ds.first.active", "ds.first.usage", "ds.second.active",
"ds.second.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:PublicMetricsAutoConfigurationTests.java
示例15: customPublicMetrics
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Bean
PublicMetrics customPublicMetrics() {
return new PublicMetrics() {
@Override
public Collection<Metric<?>> metrics() {
Metric<Integer> metric = new Metric<Integer>("foo", 1);
return Collections.<Metric<?>>singleton(metric);
}
};
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EndpointAutoConfigurationTests.java
示例16: PrometheusEndpoint
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
public PrometheusEndpoint(Collection<PublicMetrics> publicMetrics,
PrometeusMetricNameConverter prometeusMetricNameConverter, Map<String, HealthIndicator> healthIndicators,
HealthAggregator healthAggregator) {
super("prometheus", false, true);
this.publicMetrics = publicMetrics;
this.prometeusMetricNameConverter = prometeusMetricNameConverter;
this.healthIndicators = healthIndicators;
this.healthAggregator = healthAggregator;
}
开发者ID:akaGelo,项目名称:spring-boot-starter-prometheus,代码行数:11,代码来源:PrometheusEndpoint.java
示例17: prometheusEndpoint
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
@Autowired
public PrometheusEndpoint prometheusEndpoint(Collection<PublicMetrics> publicMetrics,
PrometeusMetricNameConverter prometeusMetricNameConverter, Map<String, HealthIndicator> healthIndicators,
HealthAggregator healthAggregator) {
return new PrometheusEndpoint(publicMetrics, prometeusMetricNameConverter, healthIndicators, healthAggregator);
}
开发者ID:akaGelo,项目名称:spring-boot-starter-prometheus,代码行数:10,代码来源:PrometheusEndpointConfiguration.java
示例18: createMetricsServlet
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
private MetricsServlet createMetricsServlet(PublicMetrics publicMetrics) {
CollectorRegistry collectorRegistry = CollectorRegistry.defaultRegistry;
MetricRegistry metricRegistry = new MetricRegistry();
for (Metric<?> metric : publicMetrics.metrics()) {
Counter counter = metricRegistry.counter(metric.getName());
counter.dec(counter.getCount());
counter.inc(Double.valueOf(metric.getValue().toString()).longValue());
}
DropwizardExports dropwizardExports = new DropwizardExports(metricRegistry);
// List<Collector.MetricFamilySamples> metricFamilySamples = dropwizardExports.collect();
collectorRegistry.register(dropwizardExports);
return new MetricsServlet(collectorRegistry);
}
开发者ID:AusDTO,项目名称:citizenship-appointment-server,代码行数:15,代码来源:MetricsConfig.java
示例19: threadPoolMetrics
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Bean
public PublicMetrics threadPoolMetrics() {
return new PublicMetricsAggregator(
new ThreadPoolMetrics(ctx),
new MetricReaderPublicMetrics(metricRepository())
);
}
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:8,代码来源:MonitoringConfig.java
示例20: collect
import org.springframework.boot.actuate.endpoint.PublicMetrics; //导入依赖的package包/类
@Override
public List<MetricFamilySamples> collect() {
ArrayList<MetricFamilySamples> samples = new ArrayList<MetricFamilySamples>();
for (PublicMetrics publicMetrics : this.publicMetrics) {
for (Metric<?> metric : publicMetrics.metrics()) {
String name = Collector.sanitizeMetricName(metric.getName());
double value = metric.getValue().doubleValue();
MetricFamilySamples metricFamilySamples = new MetricFamilySamples(
name, Type.GAUGE, name, Collections.singletonList(
new MetricFamilySamples.Sample(name, Collections.<String>emptyList(), Collections.<String>emptyList(), value)));
samples.add(metricFamilySamples);
}
}
return samples;
}
开发者ID:prometheus,项目名称:client_java,代码行数:16,代码来源:SpringBootMetricsCollector.java
注:本文中的org.springframework.boot.actuate.endpoint.PublicMetrics类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论