ygaller / java-jdbi

OpenTracing instrumentation for the JDBI database framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Released Version

OpenTracing JDBI Instrumentation

OpenTracing instrumentation for JDBI.

Installation

pom.xml

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>jdbi-opentracing</artifactId>
    <version>VERSION</version>
</dependency>

Usage

// Instantiate tracer
Tracer tracer = ...;

// Instatiate DBI
DBI dbi = ...;

// One time only: bind OpenTracing to the DBI instance as a TimingCollector.  
// OpenTracingCollector is a JDBI TimingCollector that creates OpenTracing Spans for each JDBI SQLStatement.
dbi.setTimingCollector(new OpenTracingCollector(tracer));
 
// Elsewhere, anywhere a `Handle` is available:
Handle handle = ...;
Span parentSpan = ...;  // optional
 
// Create statements as usual with your `handle` instance.
Query<Map<String, Object>> statement = handle.createQuery("SELECT COUNT(*) FROM accounts");
 
// If a parent Span is available, establish the relationship via setParent.
OpenTracingCollector.setParent(statement, parent);
 
// Use JDBI as per usual, and Spans will be created for every SQLStatement automatically.
List<Map<String, Object>> results = statement.list();

About

OpenTracing instrumentation for the JDBI database framework

License:Apache License 2.0


Languages

Language:Java 52.6%Language:Shell 31.9%Language:Batchfile 14.7%Language:Makefile 0.9%