https://github.com/hypnoce/opentracing-p6spy
OpenTracing Instrumentation for P6Spy
https://github.com/hypnoce/opentracing-p6spy
jdbc opentracing p6spy
Last synced: 5 months ago
JSON representation
OpenTracing Instrumentation for P6Spy
- Host: GitHub
- URL: https://github.com/hypnoce/opentracing-p6spy
- Owner: hypnoce
- License: apache-2.0
- Created: 2017-09-16T11:30:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-28T20:46:58.000Z (over 8 years ago)
- Last Synced: 2025-03-14T19:18:11.705Z (about 1 year ago)
- Topics: jdbc, opentracing, p6spy
- Language: Java
- Homepage:
- Size: 73.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/hypnoce/opentracing-p6spy)
# opentracing-p6spy
OpenTracing instrumentation for p6spy
## Installation
pom.xml
```xml
io.opentracing.contrib
opentracing-p6spy
0.0.1
```
build.gradle
```groovy
compile 'io.opentracing.contrib:opentracing-p6spy:0.0.1'
```
## Usage
If you don't already have one, create a `spy.properties` file on your resource folder (ie `src/main/resources`)
Add the tracing module in your list
```properties
modulelist=io.opentracing.contrib.p6spy.TracingP6SpyFactory
tracingPeerService=token_database
```
`tracingPeerService` is used to set the `peer.service` value as defined [here](https://github.com/opentracing/specification/blob/master/semantic_conventions.md).
`spy.properties` is set globally to all instrumented connections. This can be limitating especially in environment accessing many databases.
To overcome this, you can optionally set the `tracingPeerService` in the jdbc url :
```
jdbc:p6spy:mysql://localhost/tk_db?tracingPeerService=token_database
```
This will override `spy.properties`.
In case you only want to trace calls when there is an active span, use `traceWithActiveSpanOnly`:
```
jdbc:p6spy:mysql://localhost/tk_db?traceWithActiveSpanOnly=true
```
Beware that some JDBC drivers do not support adding unknown properties.
Tips when using it in JavaEE application servers. If you happen to deploy many applications within the same application server, add the `jmxPrefix` to avoid jmx name conflict :
```properties
modulelist=io.opentracing.contrib.p6spy.TracingP6SpyFactory
tracingPeerService=token_database
jmxPrefix=authentication_service
```
You can find more info on p6spy [here](https://github.com/p6spy/p6spy)
## Tracing tags
The following tags are added to traces :
| Span tag name | Notes |
|:--------------|:-------------------|
| `span.kind` | `client` |
| `component` | `java-p6spy` |
| `peer.service` | if exists, the peer service name set in `spy.properties` or within the jdbc url using `tracingPeerService` |
| `error` | `true` is any error occurred. `false` otherwise |
| `db.type` | the authoritative part of the jdbc url (ex : `mysql` in `jdbc:mysql://localhost`) |
| `db.statement` | the SQL query |
| `db.instance` | the connection's catalog (can be a database name or a schema) |
| `db.user` | if exists, the user name |