metrics-jdbi3
A Dropwizard module for instrumenting JDBI3
Description
This module provides a way to instrument JDBI3 applications and report metrics to a MetricRegistry from dropwizard-metrics.
The main abstraction is the InstrumentedTimingCollector class that extends JDBI's TimingCollector and accepts MetricRegistry. It registers a Timer with a name provided by the user specified StatementNameStrategy. The user can choose several strategies:
NaiveNameStrategyuses the name of the SQL query (select name from users).BasicSqlNameStrategyuses the name of the SQL object under which it was executed (com.acme.UserDao.getUsers)ContextNameStrategyuses the name name of the context group and statement name.SmartNameStrategyuses theContextNameStrategystrategy, if not applicable thenBasicSqlNameStrategy, if it's not, then uses the constantsql.raw.
Use
Jdbi jdbi = Jdbi.create(dataSource);
jdbi.setTimingCollector(new InstrumentedTimingCollector(new MetricRegistry(), new SmartNameStrategy()));
Maven
<dependency>
<groupId>com.github.arteam</groupId>
<artifactId>metrics-jdbi3</artifactId>
<version>1.0-rc2</version>
</dependency>