@NonNullApi @NonNullFields public class DatabaseTableMetrics extends Object implements MeterBinder
Constructor and Description |
---|
DatabaseTableMetrics(DataSource dataSource,
String dataSourceName,
String tableName,
Iterable<Tag> tags)
Record the row count for an individual database table.
|
DatabaseTableMetrics(DataSource dataSource,
String query,
String dataSourceName,
String tableName,
Iterable<Tag> tags)
Record the result based on a query.
|
Modifier and Type | Method and Description |
---|---|
void |
bindTo(MeterRegistry registry) |
static void |
monitor(MeterRegistry registry,
DataSource dataSource,
String dataSourceName,
String tableName,
Iterable<Tag> tags)
Record the row count for an individual database table.
|
static void |
monitor(MeterRegistry registry,
String tableName,
String dataSourceName,
DataSource dataSource,
String... tags)
Record the row count for an individual database table.
|
public DatabaseTableMetrics(DataSource dataSource, String dataSourceName, String tableName, Iterable<Tag> tags)
dataSource
- The data source to use to run the row count query.dataSourceName
- Will be used to tag metrics with "db".tableName
- The name of the table to report table size for.tags
- Tags to apply to all recorded metrics.public DatabaseTableMetrics(DataSource dataSource, String query, String dataSourceName, String tableName, Iterable<Tag> tags)
dataSource
- The data source to use to run the row count query.query
- The query to be run against the table. The first column of the result will be the metric and
it should return a single row.dataSourceName
- The name prefix of the metrics.tableName
- The name of the table to report table size for.tags
- Tags to apply to all recorded metrics.public static void monitor(MeterRegistry registry, String tableName, String dataSourceName, DataSource dataSource, String... tags)
registry
- The registry to bind metrics to.tableName
- The name of the table to report table size for.dataSourceName
- Will be used to tag metrics with "db".dataSource
- The data source to use to run the row count query.tags
- Tags to apply to all recorded metrics. Must be an even number of arguments representing key/value pairs of tags.public static void monitor(MeterRegistry registry, DataSource dataSource, String dataSourceName, String tableName, Iterable<Tag> tags)
registry
- The registry to bind metrics to.dataSource
- The data source to use to run the row count query.dataSourceName
- The name prefix of the metrics.tableName
- The name of the table to report table size for.tags
- Tags to apply to all recorded metrics.public void bindTo(MeterRegistry registry)
bindTo
in interface MeterBinder
Copyright © 2018. All rights reserved.