Skip to content
This repository was archived by the owner on Nov 11, 2021. It is now read-only.

Repository files navigation

Build StatusCoverage StatusReleased Version

opentracing-p6spy

OpenTracing instrumentation for p6spy

Installation

pom.xml

<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-p6spy</artifactId>
<version>0.3.1</version>
</dependency>

build.gradle

compile 'io.opentracing.contrib:opentracing-p6spy:0.3.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

modulelist=io.opentracing.contrib.p6spy.TracingP6SpyFactory
tracingPeerService=token_database
traceWithActiveSpanOnly=true
traceWithStatementValues=true
  • tracingPeerService is used to set the peer.service value as defined here.
  • traceWithActiveSpanOnly in case you only want to trace calls when there is an active span;
  • traceWithStatementValues in case you want to trace calls with values of prepared statement. ⚠️ this can cause data leaks / security issues;

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, traceWithActiveSpanOnly and traceWithStatementValues in the jdbc url :

jdbc:p6spy:mysql://localhost/tk_db?tracingPeerService=token_database;traceWithActiveSpanOnly=true;traceWithStatementValues=true

This will override spy.properties.

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 :

modulelist=io.opentracing.contrib.p6spy.TracingP6SpyFactory
tracingPeerService=token_database
traceWithActiveSpanOnly=true
traceWithStatementValues=true
jmxPrefix=authentication_service

You can find more info on p6spy here

Tracing tags

The following tags are added to traces :

Span tag nameNotes
span.kindclient
componentjava-p6spy
peer.serviceif exists, the peer service name set in spy.properties or within the jdbc url using tracingPeerService
errortrue is any error occurred. false otherwise
db.typeif exists, the authoritative part of the jdbc url (ex : mysql in jdbc:mysql://localhost)
db.statementthe SQL query. If traceWithStatementValues is true, values from prepared statements will be logged.
db.instanceif exists, the connection's catalog (can be a database name or a schema)
db.userif exists, the user name

Releases

Packages

Contributors

Languages