-
Notifications
You must be signed in to change notification settings - Fork 46
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
1 parent
b66b275
commit 4987d88
Showing
127 changed files
with
1,670 additions
and
77 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
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 |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
</parent> | ||
<artifactId>opentracing-flowid-bom</artifactId> | ||
<packaging>pom</packaging> | ||
<description>Tracing requests through a distributed system.</description> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>opentracing-flowid-httpclient</artifactId> | ||
<description>HTTP Client interceptor for Tracing requests through a distributed system.</description> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>opentracing-flowid-okhttp</artifactId> | ||
<description>HTTP Client interceptor for Tracing requests through a distributed system.</description> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>opentracing-flowid-servlet</artifactId> | ||
<description>Servlet 3 filter for tracing requests through a distributed system.</description> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>opentracing-flowid-spring-boot-autoconfigure</artifactId> | ||
<description>Tracing requests through a distributed system.</description> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
|
File renamed without changes.
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>opentracing-flowid-spring-boot-starter</artifactId> | ||
<description>Tracing requests through a distributed system.</description> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>opentracing-flowid</artifactId> | ||
<description>Tracing requests through a distributed system.</description> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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,118 @@ | ||
# OpenTracing: JDBC | ||
|
||
[![Stability: Active](https://masterminds.github.io/stability/active.svg)](https://masterminds.github.io/stability/active.html) | ||
![Build Status](https://github.com/zalando/opentracing-toolbox/workflows/Test/badge.svg) | ||
[![Coverage Status](https://img.shields.io/coveralls/zalando/opentracing-toolbox/master.svg)](https://coveralls.io/r/zalando/opentracing-toolbox) | ||
[![Code Quality](https://img.shields.io/codacy/grade/69e173024eec403797466e147a2051a3/master.svg)](https://www.codacy.com/app/whiskeysierra/opentracing-toolbox) | ||
[![Javadoc](http://javadoc.io/badge/org.zalando/opentracing-jdbc.svg)](http://www.javadoc.io/doc/org.zalando/opentracing-jdbc) | ||
[![Release](https://img.shields.io/github/release/zalando/opentracing-toolbox.svg)](https://github.com/zalando/opentracing-toolbox/releases) | ||
[![Maven Central](https://img.shields.io/maven-central/v/org.zalando/opentracing-jdbc.svg)](https://maven-badges.herokuapp.com/maven-central/org.zalando/opentracing-jdbc) | ||
[![OpenTracing](https://img.shields.io/badge/OpenTracing-enabled-blue.svg)](http://opentracing.io) | ||
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/zalando/opentracing-toolbox/master/LICENSE) | ||
|
||
- **Technology stack**: Java 8+, OpenTracing, JDBC | ||
- **Status**: Under development and used in production | ||
|
||
## Why not [opentracing-contrib/java-jdbc](https://github.com/opentracing-contrib/java-jdbc):question: | ||
|
||
- operation name not customizable | ||
- span tags not customizable | ||
- `java.sql.Driver` approach requires `GlobalTracer` | ||
- no support for `javax.sql.DataSource` | ||
|
||
## Example | ||
|
||
```java | ||
DataSource dataSource = new DataSourceTracer(tracer) | ||
.trace(originalDataSource); | ||
``` | ||
|
||
## Features | ||
|
||
- OpenTracing instrumentation for any `DataSource` | ||
- Customizable operation name | ||
- Customizable span tags/logs | ||
- Convention over configuration (i.e. meaningful default values) | ||
|
||
## Dependencies | ||
|
||
- Java 8 or higher | ||
- [OpenTracing](https://github.com/opentracing/opentracing-java) | ||
- [datasource-proxy](https://github.com/ttddyy/datasource-proxy) | ||
|
||
## Installation | ||
|
||
Add the following dependency to your project: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.zalando</groupId> | ||
<artifactId>opentracing-jdbc</artifactId> | ||
<version>${opentracing-jdbc.version}</version> | ||
</dependency> | ||
``` | ||
|
||
## Configuration | ||
|
||
```java | ||
new DataSourceTracer(tracer) | ||
.withOperationName(new CustomOperationName()) | ||
.withAdditionalSpanDecorator(new CustomSpanDecorator()); | ||
``` | ||
|
||
A new span will be started for each statement. | ||
|
||
The following tags/logs are supported out of the box: | ||
|
||
| Tag/Log Field | Decorator | Example | | ||
|----------------------|----------------------------------|-----------------------------------| | ||
| `component` | `ComponentSpanDecorator` | `JDBC` | | ||
| `db.instance` | `DatabaseInstanceSpanDecorator` | `db` | | ||
| `db.statement` | `DatabaseStatementSpanDecorator` | `SELECT * FROM user WHERE id = ?` | | ||
| `db.type` | `DatabaseTypeSpanDecorator` | `sql` | | ||
| `db.user` | `DatabaseUserSpanDecorator` | `root` | | ||
| `peer.address`¹ | `PeerAddressSpanDecorator` | `postgres://localhost` | | ||
| `peer.hostname` | `PeerSpanDecorator` | `localhost` | | ||
| `peer.ipv4` | `PeerSpanDecorator` | `127.0.0.1` | | ||
| `peer.ipv6` | `PeerSpanDecorator` | `::1` | | ||
| `peer.port` | `PeerSpanDecorator` | `5432` | | ||
| `span.kind` | `SpanKindSpanDecorator` | `client` | | ||
| `error` | `ErrorSpanDecorator` | `true` | | ||
| `error.kind` (log) | `ErrorSpanDecorator` | `SocketTimeoutException` | | ||
| `error.object` (log) | `ErrorSpanDecorator` | (exception instance) | | ||
| `message` (log) | `ErrorMessageSpanDecorator` | `Connection timed out` | | ||
| `stack` (log) | `ErrorStackSpanDecorator` | `SocketTimeoutException at [...]` | | ||
|
||
¹ Disabled by default due to security concerns (may expose passwords) | ||
|
||
Custom `SpanDecorator` implementations that are registered using [Java's Service Provider Interface](https://docs.oracle.com/javase/tutorial/ext/basics/spi.html) mechanism will be picked up automatically by default. | ||
|
||
### Operation Name | ||
|
||
The operation name, by default, is derived from the `Statement`'s method that was used to execute it. Usually one of `execute`, `update`, `executeQuery`, `executeUpdate`, `executeBatch`, etc. | ||
|
||
The `OperationName` interface can be implemented in order to customize the operation name: | ||
|
||
```java | ||
new DataSourceTracer(tracer) | ||
.withOperationName((method, queries) -> | ||
toSnakeCase(method.getName())); | ||
``` | ||
|
||
Another alternative that is built-in is the `StoredProcedureOperationName` that | ||
looks for queries with the format `SELECT * FROM my_function(..)` and will | ||
extract the name of the function as the operation name. | ||
|
||
```java | ||
new DataSourceTracer(tracer) | ||
.withOperationName(new StoredProcedureOperationName()); | ||
``` | ||
|
||
## Getting Help | ||
|
||
If you have questions, concerns, bug reports, etc., please file an issue in this repository's [Issue Tracker](../../issues). | ||
|
||
## Getting Involved/Contributing | ||
|
||
To contribute, simply make a pull request and add a brief description (1-2 sentences) of your addition or change. For | ||
more details, check the [contribution guidelines](.github/CONTRIBUTING.md). |
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,109 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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>org.zalando</groupId> | ||
<artifactId>opentracing-jdbc-parent</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>opentracing-jdbc</artifactId> | ||
<scm> | ||
<url>https://github.com/zalando/opentracing-toolbox</url> | ||
<connection>scm:git:[email protected]:zalando/opentracing-toolbox.git</connection> | ||
<developerConnection>scm:git:[email protected]:zalando/opentracing-toolbox.git</developerConnection> | ||
</scm> | ||
<properties> | ||
<slf4j.version>1.7.26</slf4j.version> | ||
<junit-jupiter.version>5.5.1</junit-jupiter.version> | ||
</properties> | ||
<dependencies> | ||
<!-- Common --> | ||
<dependency> | ||
<groupId>org.apiguardian</groupId> | ||
<artifactId>apiguardian-api</artifactId> | ||
<version>1.1.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.findbugs</groupId> | ||
<artifactId>jsr305</artifactId> | ||
<version>3.0.2</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.gag</groupId> | ||
<artifactId>gag</artifactId> | ||
<version>1.0.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.8</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
|
||
<!-- Functionally important --> | ||
<dependency> | ||
<groupId>io.opentracing</groupId> | ||
<artifactId>opentracing-api</artifactId> | ||
<version>0.33.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.ttddyy</groupId> | ||
<artifactId>datasource-proxy</artifactId> | ||
<version>1.5.1</version> | ||
</dependency> | ||
|
||
<!-- Testing --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-nop</artifactId> | ||
<version>${slf4j.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentracing</groupId> | ||
<artifactId>opentracing-mock</artifactId> | ||
<version>0.33.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<version>1.4.199</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest</artifactId> | ||
<version>2.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>3.0.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.