Skip to content

Commit

Permalink
Merge 429fb5c into b53de96
Browse files Browse the repository at this point in the history
  • Loading branch information
malafeev committed Nov 12, 2018
2 parents b53de96 + 429fb5c commit cbc6e7b
Show file tree
Hide file tree
Showing 10 changed files with 701 additions and 694 deletions.
49 changes: 24 additions & 25 deletions .settings.xml
@@ -1,4 +1,3 @@

<?xml version="1.0" encoding="UTF-8"?>
<!--
Expand All @@ -16,29 +15,29 @@
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>sonatype</id>
<username>${env.SONATYPE_USER}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
<server>
<id>bintray</id>
<username>${env.BINTRAY_USER}</username>
<password>${env.BINTRAY_KEY}</password>
</server>
<server>
<id>jfrog-snapshots</id>
<username>${env.BINTRAY_USER}</username>
<password>${env.BINTRAY_KEY}</password>
</server>
<server>
<id>github.com</id>
<username>${env.GH_USER}</username>
<password>${env.GH_TOKEN}</password>
</server>
</servers>
<servers>
<server>
<id>sonatype</id>
<username>${env.SONATYPE_USER}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
<server>
<id>bintray</id>
<username>${env.BINTRAY_USER}</username>
<password>${env.BINTRAY_KEY}</password>
</server>
<server>
<id>jfrog-snapshots</id>
<username>${env.BINTRAY_USER}</username>
<password>${env.BINTRAY_KEY}</password>
</server>
<server>
<id>github.com</id>
<username>${env.GH_USER}</username>
<password>${env.GH_TOKEN}</password>
</server>
</servers>
</settings>
20 changes: 10 additions & 10 deletions .travis.yml
Expand Up @@ -10,24 +10,24 @@ cache:
- $HOME/.m2/repository

before_install:
# allocate commits to CI, not the owner of the deploy key
- git config user.name "opentracingci"
- git config user.email "opentracingci+opentracing@googlegroups.com"
# allocate commits to CI, not the owner of the deploy key
- git config user.name "opentracingci"
- git config user.email "opentracingci+opentracing@googlegroups.com"

# setup https authentication credentials, used by ./mvnw release:prepare
- git config credential.helper "store --file=.git/credentials"
- echo "https://$GH_TOKEN:@github.com" > .git/credentials
# setup https authentication credentials, used by ./mvnw release:prepare
- git config credential.helper "store --file=.git/credentials"
- echo "https://$GH_TOKEN:@github.com" > .git/credentials

install:
# Override default travis to use the maven wrapper
- ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
# Override default travis to use the maven wrapper
- ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V

script:
- ./travis/publish.sh
- ./travis/publish.sh

branches:
except:
- /^[0-9]/
- /^[0-9]/

after_success:
- mvn jacoco:report coveralls:report
Expand Down
56 changes: 29 additions & 27 deletions opentracing-jdbi/pom.xml
Expand Up @@ -14,32 +14,34 @@
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.1-SNAPSHOT</version>
</parent>

<artifactId>opentracing-jdbi</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<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 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.1-SNAPSHOT</version>
</parent>

<artifactId>opentracing-jdbi</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<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>
94 changes: 48 additions & 46 deletions opentracing-jdbi3/pom.xml
Expand Up @@ -14,59 +14,61 @@
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">
<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.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.opentracing.contrib</groupId>
<artifactId>jdbi-opentracing</artifactId>
<version>0.5.1-SNAPSHOT</version>
</parent>

<artifactId>opentracing-jdbi3</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<description>OpenTracing Instrumentation for JDBI 3</description>
<artifactId>opentracing-jdbi3</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<description>OpenTracing Instrumentation for JDBI 3</description>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<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>
<jdbi3.version>3.5.1</jdbi3.version>
</properties>

<dependencies>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-core</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-core</artifactId>
</dependency>

<dependency> <!-- Only used for (optional) automatic Plugin config -->
<groupId>io.opentracing</groupId>
<artifactId>opentracing-util</artifactId>
<version>${opentracing.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency> <!-- Only used for (optional) automatic Plugin config -->
<groupId>io.opentracing</groupId>
<artifactId>opentracing-util</artifactId>
<version>${opentracing.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-util</artifactId>
<version>${opentracing.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-util</artifactId>
<version>${opentracing.version}</version>
<type>test-jar</type>
<scope>test</scope>
</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>
<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>
Expand Up @@ -14,12 +14,11 @@
package io.opentracing.contrib.jdbi3;

import io.opentracing.Tracer;
import java.util.logging.Logger;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.core.spi.JdbiPlugin;
import org.jdbi.v3.core.statement.SqlStatements;

import java.util.logging.Logger;

/**
* Jdbi 3 {@linkplain JdbiPlugin plugin} that configures either the {@linkplain OpentracingSqlLogger}
* or the {@linkplain OpentracingTimingCollector} (in case of Jdbi &lt; 3.2).
Expand All @@ -44,57 +43,58 @@
* @author Sjoerd Talsma
*/
public class OpentracingJdbi3Plugin implements JdbiPlugin {
private static final Logger LOGGER = Logger.getLogger(OpentracingJdbi3Plugin.class.getName());
private static final Logger LOGGER = Logger.getLogger(OpentracingJdbi3Plugin.class.getName());

private final Tracer tracer;
private final Tracer tracer;

/**
* Constructor for the plugin that will use the {@code GlobalTracer}
*/
public OpentracingJdbi3Plugin() {
this(null);
}
/**
* Constructor for the plugin that will use the {@code GlobalTracer}
*/
public OpentracingJdbi3Plugin() {
this(null);
}

/**
* Constructor for the plugin that will use a specified {@linkplain Tracer}.
*
* @param tracer The tracer to use (optional, provide {@code null} to fallback to the {@code GlobalTracer})
*/
public OpentracingJdbi3Plugin(Tracer tracer) {
if (tracer == null) {
try {
// Use fully-qualified name: take care not to import anything from optional io.opentracing.util package!
tracer = io.opentracing.util.GlobalTracer.get();
} catch (LinkageError globalTracerUnavailable) {
LOGGER.warning(() -> "No tracer specified and Globaltracer cannot be used. " +
"Please provide a tracer or add opentracing-util to the classpath.");
}
}
this.tracer = tracer;
/**
* Constructor for the plugin that will use a specified {@linkplain Tracer}.
*
* @param tracer The tracer to use (optional, provide {@code null} to fallback to the {@code GlobalTracer})
*/
public OpentracingJdbi3Plugin(Tracer tracer) {
if (tracer == null) {
try {
// Use fully-qualified name: take care not to import anything from optional io.opentracing.util package!
tracer = io.opentracing.util.GlobalTracer.get();
} catch (LinkageError globalTracerUnavailable) {
LOGGER.warning(() -> "No tracer specified and Globaltracer cannot be used. " +
"Please provide a tracer or add opentracing-util to the classpath.");
}
}
this.tracer = tracer;
}

@Override
@SuppressWarnings("deprecation") // Fallback behaviour is deprecated to discourage use
public void customizeJdbi(Jdbi jdbi) {
if (tracer != null) {
final SqlStatements config = jdbi.getConfig(SqlStatements.class);
try {
config.setSqlLogger(new OpentracingSqlLogger(tracer, config.getSqlLogger()));
} catch (LinkageError sqlLoggerApiUnavailable) {
LOGGER.warning(() -> "Could not configure Opentracing SqlLogger implementation. " +
"Falling back to TimingCollector. Please consider using JDBI version 3.2 or greater.");
config.setTimingCollector(new OpentracingTimingCollector(tracer, config.getTimingCollector()));
}
}
@Override
@SuppressWarnings("deprecation") // Fallback behaviour is deprecated to discourage use
public void customizeJdbi(Jdbi jdbi) {
if (tracer != null) {
final SqlStatements config = jdbi.getConfig(SqlStatements.class);
try {
config.setSqlLogger(new OpentracingSqlLogger(tracer, config.getSqlLogger()));
} catch (LinkageError sqlLoggerApiUnavailable) {
LOGGER.warning(() -> "Could not configure Opentracing SqlLogger implementation. " +
"Falling back to TimingCollector. Please consider using JDBI version 3.2 or greater.");
config.setTimingCollector(
new OpentracingTimingCollector(tracer, config.getTimingCollector()));
}
}
}

/**
* Provides a human-readable string of this plugin with the tracer used (e.g. when logged by Jdbi).
*
* @return The name of the plugin and the tracer used.
*/
@Override
public String toString() {
return getClass().getSimpleName() + "{tracer=" + tracer + '}';
}
/**
* Provides a human-readable string of this plugin with the tracer used (e.g. when logged by Jdbi).
*
* @return The name of the plugin and the tracer used.
*/
@Override
public String toString() {
return getClass().getSimpleName() + "{tracer=" + tracer + '}';
}
}

0 comments on commit cbc6e7b

Please sign in to comment.