Skip to content
A Dropwizard module for instrumenting JDBI3
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
NOTICE
README.md
pom.xml

README.md

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:

  • NaiveNameStrategy uses the name of the SQL query (select name from users).
  • BasicSqlNameStrategy uses the name of the SQL object under which it was executed (com.acme.UserDao.getUsers)
  • ContextNameStrategy uses the name name of the context group and statement name.
  • SmartNameStrategy uses the ContextNameStrategy strategy, if not applicable then BasicSqlNameStrategy, if it's not, then uses the constant sql.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>
You can’t perform that action at this time.