use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method autoCacheManager.
@Test
public void autoCacheManager() {
load(CacheConfiguration.class);
CachePublicMetrics bean = this.context.getBean(CachePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "cache.books.size", "cache.speakers.size");
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method multipleCacheManagers.
@Test
public void multipleCacheManagers() {
load(MultipleCacheConfiguration.class);
CachePublicMetrics bean = this.context.getBean(CachePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "cache.books.size", "cache.second_speakers.size", "cache.first_speakers.size", "cache.users.size");
}
use of org.springframework.boot.actuate.metrics.Metric in project ontrack by nemerosa.
the class JobMetrics method metrics.
@Override
public Collection<Metric<?>> metrics() {
// Gets the statuses
Collection<JobStatus> statuses = scheduler.getJobStatuses();
// Collects all metrics
List<Metric<?>> metrics = new ArrayList<>();
// Statuses
JobMetric general = new JobMetric();
Map<String, JobMetric> categories = new HashMap<>();
for (JobStatus status : statuses) {
general.count++;
JobMetric.getCategory(categories, status).count++;
if (status.isRunning()) {
general.running++;
JobMetric.getCategory(categories, status).running++;
}
if (status.isDisabled()) {
general.disabled++;
JobMetric.getCategory(categories, status).disabled++;
}
if (!status.isValid()) {
general.invalid++;
JobMetric.getCategory(categories, status).invalid++;
}
if (status.isPaused()) {
general.paused++;
JobMetric.getCategory(categories, status).paused++;
}
if (status.isError()) {
general.error++;
JobMetric.getCategory(categories, status).error++;
}
}
// Collection of metrics
metrics.add(new Metric<>("gauge.jobs", general.count));
metrics.add(new Metric<>("gauge.jobs.running", general.running));
metrics.add(new Metric<>("gauge.jobs.disabled", general.disabled));
metrics.add(new Metric<>("gauge.jobs.error", general.error));
metrics.add(new Metric<>("gauge.jobs.invalid", general.invalid));
metrics.add(new Metric<>("gauge.jobs.paused", general.paused));
// Per categories
for (Map.Entry<String, JobMetric> entry : categories.entrySet()) {
String category = entry.getKey();
JobMetric metric = entry.getValue();
metrics.add(new Metric<>("gauge.jobs." + category, metric.count));
metrics.add(new Metric<>("gauge.jobs." + category + ".running", metric.running));
metrics.add(new Metric<>("gauge.jobs." + category + ".disabled", metric.disabled));
metrics.add(new Metric<>("gauge.jobs." + category + ".error", metric.error));
metrics.add(new Metric<>("gauge.jobs." + category + ".invalid", metric.invalid));
metrics.add(new Metric<>("gauge.jobs." + category + ".paused", metric.paused));
}
// OK
return metrics;
}
use of org.springframework.boot.actuate.metrics.Metric in project ontrack by nemerosa.
the class DataSourceMetrics method metrics.
@Override
public Collection<Metric<?>> metrics() {
List<Metric<?>> metrics = new ArrayList<>();
dataSources.entrySet().stream().forEach(entry -> {
String name = entry.getKey();
String prefix = String.format("gauge.datasource.%s", name);
DataSource dataSource = entry.getValue();
DataSourcePoolMetadata poolMetadata = provider.getDataSourcePoolMetadata(dataSource);
metrics.add(new Metric<>(prefix + ".active", poolMetadata.getActive()));
metrics.add(new Metric<>(prefix + ".max", poolMetadata.getMax()));
metrics.add(new Metric<>(prefix + ".min", poolMetadata.getMin()));
metrics.add(new Metric<>(prefix + ".usage", poolMetadata.getUsage()));
});
return metrics;
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method multipleDataSourcesWithCustomPrimary.
@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");
}
Aggregations