-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
821 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# OpenTracing JDBI Instrumentation | ||
OpenTracing instrumentation for JDBI v2. | ||
|
||
## Installation | ||
|
||
[![Released Version][maven-img]][maven] | ||
|
||
pom.xml | ||
```xml | ||
<dependency> | ||
<groupId>io.opentracing.contrib</groupId> | ||
<artifactId>opentracing-jdbi</artifactId> | ||
<version>VERSION</version> | ||
</dependency> | ||
``` | ||
|
||
## Usage | ||
|
||
```java | ||
// Instantiate tracer | ||
Tracer tracer = ...; | ||
|
||
// Instatiate DBI | ||
DBI dbi = ...; | ||
|
||
// One time only: bind OpenTracing to the DBI instance as a TimingCollector. | ||
// OpenTracingCollector is a Jdbi SqlLogger that creates OpenTracing Spans for each Jdbi SqlStatement. | ||
dbi.setTimingCollector(new OpenTracingCollector(tracer)); //io.opentracing.contrib.**jdbi**.OpenTracingCollector | ||
|
||
// 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(); | ||
``` | ||
|
||
## License | ||
|
||
[Apache 2.0 License](./LICENSE). | ||
|
||
[ci-img]: https://travis-ci.org/opentracing-contrib/java-jdbi.svg?branch=master | ||
[ci]: https://travis-ci.org/opentracing-contrib/java-jdbi | ||
[cov-img]: https://coveralls.io/repos/github/opentracing-contrib/java-jdbi/badge.svg?branch=master | ||
[cov]: https://coveralls.io/github/opentracing-contrib/java-jdbi?branch=master | ||
[maven-img]: https://img.shields.io/maven-central/v/io.opentracing.contrib/jdbi-opentracing.svg | ||
[maven]: http://search.maven.org/#search%7Cga%7C1%7Cjdbi-opentracing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2016-2018 The OpenTracing Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the License | ||
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
or implied. See the License for the specific language governing permissions and limitations under | ||
the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.opentracing.contrib</groupId> | ||
<artifactId>jdbi-opentracing</artifactId> | ||
<version>0.5.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>opentracing-jdbi</artifactId> | ||
<description>OpenTracing Instrumentation for JDBI</description> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
|
||
<jdbi.version>2.78</jdbi.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jdbi</groupId> | ||
<artifactId>jdbi</artifactId> | ||
<version>${jdbi.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# OpenTracing JDBI Instrumentation | ||
OpenTracing instrumentation for JDBI. | ||
|
||
## Installation | ||
|
||
[![Released Version][maven-img]][maven] | ||
|
||
pom.xml | ||
```xml | ||
<dependency> | ||
<groupId>io.opentracing.contrib</groupId> | ||
<artifactId>opentracing-jdbi3</artifactId> | ||
<version>VERSION</version> | ||
</dependency> | ||
``` | ||
|
||
## Usage | ||
|
||
```java | ||
// Instantiate tracer | ||
Tracer tracer = ...; | ||
|
||
// Instatiate Jdbi | ||
Jdbi dbi = Jdbi.create...; | ||
|
||
// One time only: bind OpenTracing to the Jdbi instance as a SqlLogger. | ||
// OpentracingSqlLogger creates OpenTracing Spans for each Jdbi SqlStatement. | ||
dbi.setSqlLogger(new OpentracingSqlLogger(tracer)); | ||
|
||
// Elsewhere, anywhere a `Handle` is available: | ||
Handle handle = ...; | ||
Span parentSpan = ...; // optional | ||
|
||
// Create statements as usual with your `handle` instance. | ||
Query statement = handle.createQuery("SELECT COUNT(*) FROM accounts"); | ||
|
||
// If a parent Span is available, establish the relationship via setParent. | ||
OpentracingSqlLogger.setParent(statement, parent); | ||
|
||
// Use Jdbi as per usual, and Spans will be created for every SqlStatement automatically. | ||
List<Map<String, Object>> results = statement.mapToMap().list(); | ||
``` | ||
|
||
### Older Jdbi3 versions | ||
|
||
The `OpentracingSqlLogger` obviously implements `SqlLogger`. | ||
This interface was introduced in JDBI version `3.2`. | ||
In case you have an older version of Jdbi3, you should use the now-deprecated | ||
`OpentracingTimingCollector` instead. | ||
Configuration and behaviour is the same as described above, | ||
except setting the SqlLogger changes from `dbi.setSqlLogger(..)` to: | ||
```java | ||
dbi.setTimingCollector(new OpentracingTimingCollector(tracer)); | ||
``` | ||
|
||
## License | ||
|
||
[Apache 2.0 License](./LICENSE). | ||
|
||
[ci-img]: https://travis-ci.org/opentracing-contrib/java-jdbi.svg?branch=master | ||
[ci]: https://travis-ci.org/opentracing-contrib/java-jdbi | ||
[cov-img]: https://coveralls.io/repos/github/opentracing-contrib/java-jdbi/badge.svg?branch=master | ||
[cov]: https://coveralls.io/github/opentracing-contrib/java-jdbi?branch=master | ||
[maven-img]: https://img.shields.io/maven-central/v/io.opentracing.contrib/jdbi-opentracing.svg | ||
[maven]: http://search.maven.org/#search%7Cga%7C1%7Cjdbi-opentracing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2016-2018 The OpenTracing Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the License | ||
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
or implied. See the License for the specific language governing permissions and limitations under | ||
the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.opentracing.contrib</groupId> | ||
<artifactId>jdbi-opentracing</artifactId> | ||
<version>0.5.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>opentracing-jdbi3</artifactId> | ||
<description>OpenTracing Instrumentation for JDBI 3</description> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
|
||
<jdbi3.version>3.5.1</jdbi3.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jdbi</groupId> | ||
<artifactId>jdbi3-core</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jdbi</groupId> | ||
<artifactId>jdbi3-bom</artifactId> | ||
<version>${jdbi3.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.