Class DatabaseTableMetrics

java.lang.Object
io.micrometer.core.instrument.binder.db.DatabaseTableMetrics
All Implemented Interfaces:
MeterBinder

@NonNullApi
@NonNullFields
public class DatabaseTableMetrics
extends java.lang.Object
implements MeterBinder
  • Constructor Summary

    Constructors
    Constructor Description
    DatabaseTableMetrics​(javax.sql.DataSource dataSource, java.lang.String dataSourceName, java.lang.String tableName, java.lang.Iterable<Tag> tags)
    Record the row count for an individual database table.
    DatabaseTableMetrics​(javax.sql.DataSource dataSource, java.lang.String query, java.lang.String dataSourceName, java.lang.String tableName, java.lang.Iterable<Tag> tags)
    Record the result based on a query.
  • Method Summary

    Modifier and Type Method Description
    void bindTo​(MeterRegistry registry)  
    static void monitor​(MeterRegistry registry, java.lang.String tableName, java.lang.String dataSourceName, javax.sql.DataSource dataSource, java.lang.String... tags)
    Record the row count for an individual database table.
    static void monitor​(MeterRegistry registry, javax.sql.DataSource dataSource, java.lang.String dataSourceName, java.lang.String tableName, java.lang.Iterable<Tag> tags)
    Record the row count for an individual database table.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DatabaseTableMetrics

      public DatabaseTableMetrics​(javax.sql.DataSource dataSource, java.lang.String dataSourceName, java.lang.String tableName, java.lang.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​(javax.sql.DataSource dataSource, java.lang.String query, java.lang.String dataSourceName, java.lang.String tableName, java.lang.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, java.lang.String tableName, java.lang.String dataSourceName, javax.sql.DataSource dataSource, java.lang.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, javax.sql.DataSource dataSource, java.lang.String dataSourceName, java.lang.String tableName, java.lang.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

      public void bindTo​(MeterRegistry registry)
      Specified by:
      bindTo in interface MeterBinder