Class DatabaseTableMetrics
java.lang.Object
io.micrometer.core.instrument.binder.db.DatabaseTableMetrics
- All Implemented Interfaces:
MeterBinder
-
Constructor Summary
ConstructorDescriptionDatabaseTableMetrics
(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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindTo
(MeterRegistry registry) static void
monitor
(MeterRegistry registry, String tableName, String dataSourceName, DataSource dataSource, String... tags) Record the row count for an individual database table.static void
monitor
(MeterRegistry registry, DataSource dataSource, String dataSourceName, String tableName, Iterable<Tag> tags) Record the row count for an individual database table.
-
Constructor Details
-
DatabaseTableMetrics
public DatabaseTableMetrics(DataSource dataSource, String dataSourceName, String tableName, Iterable<Tag> tags) Record the row count for an individual database table.- Parameters:
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.
-
DatabaseTableMetrics
public DatabaseTableMetrics(DataSource dataSource, String query, String dataSourceName, String tableName, Iterable<Tag> tags) Record the result based on a query.- Parameters:
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.
-
-
Method Details
-
monitor
public static void monitor(MeterRegistry registry, String tableName, String dataSourceName, DataSource dataSource, String... tags) Record the row count for an individual database table.- Parameters:
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.
-
monitor
public static void monitor(MeterRegistry registry, DataSource dataSource, String dataSourceName, String tableName, Iterable<Tag> tags) Record the row count for an individual database table.- Parameters:
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.
-
bindTo
- Specified by:
bindTo
in interfaceMeterBinder
-