-
Notifications
You must be signed in to change notification settings - Fork 4
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
1bec3ac
commit 9fa2b5a
Showing
6 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
after_success: | | ||
if [ "$TRAVIS_SECURE_ENV_VARS" == true ]; then | ||
echo "$PGP_SECRET" | base64 --decode | gpg --import | ||
if [ -z "$TRAVIS_TAG" ]; then | ||
sbt publishSigned | ||
else | ||
sbt publishSigned sonatypeRelease | ||
fi | ||
fi | ||
cache: | ||
directories: | ||
- $HOME/.ivy2 | ||
- $HOME/.sbt | ||
deploy: | ||
api_key: $GITHUB_AUTH | ||
file: '*/target/**/*.jar' | ||
file_glob: true | ||
on: | ||
tags: true | ||
provider: releases | ||
skip_cleanup: true | ||
git: | ||
depth: 1 | ||
jdk: oraclejdk8 | ||
language: scala | ||
script: | ||
- '[ "$TRAVIS_PULL_REQUEST" != false ] || export SBT_OPTS=-Dbuild.version=${TRAVIS_TAG:-$TRAVIS_BRANCH-SNAPSHOT}' | ||
- sbt package |
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,26 @@ | ||
lazy val `thread-context` = project | ||
|
||
inScope(Global)(Seq( | ||
autoScalaLibrary := false, | ||
credentials += Credentials( | ||
"Sonatype Nexus Repository Manager", | ||
"oss.sonatype.org", | ||
sys.env.getOrElse("SONATYPE_USERNAME", ""), | ||
sys.env.getOrElse("SONATYPE_PASSWORD", "") | ||
), | ||
crossPaths := false, | ||
developers += Developer("pauldraper", "Paul Draper", "[email protected]", url("https://github.com/pauldraper")), | ||
homepage := Some(url("https://git.lucidchart.com/lucidsoftware/opentracing-thread-context")), | ||
licenses += "Apache 2.0 License" -> url("https://www.apache.org/licenses/LICENSE-2.0"), | ||
organization := "com.lucidchart", | ||
organizationHomepage := Some(url("https://github.com/lucidsoftware")), | ||
organizationName := "Lucid Software", | ||
PgpKeys.pgpPassphrase := Some(Array.emptyCharArray), | ||
resolvers += Resolver.typesafeRepo("releases"), | ||
scmInfo := Some(ScmInfo( | ||
url("https://github.com/lucidsoftware/opentracing-thread-context"), | ||
"scm:git:[email protected]:lucidsoftware/opentracing-thread-context" | ||
)), | ||
startYear := Some(2017), | ||
version := sys.props.getOrElse("build.version", "0-SNAPSHOT") | ||
)) |
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 @@ | ||
sbt.version=0.13.13 |
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,3 @@ | ||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") | ||
|
||
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") |
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,7 @@ | ||
libraryDependencies ++= Seq( | ||
"com.lucidchart" % "thread-context" % "0.4", | ||
"io.opentracing" % "opentracing-api" % "0.20.7", | ||
"io.opentracing" % "opentracing-noop" % "0.20.7" | ||
) | ||
|
||
name := s"opentracing-${name.value}" |
37 changes: 37 additions & 0 deletions
37
thread-context/src/main/java/io/opentracing/threadcontext/ThreadContextSpan.java
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,37 @@ | ||
package io.opentracing.threadcontext; | ||
|
||
import com.github.threadcontext.ThreadContext; | ||
import com.github.threadcontext.ThreadLocalSaver; | ||
import io.opentracing.NoopSpan; | ||
import io.opentracing.Span; | ||
import java.util.function.Supplier; | ||
|
||
public final class ThreadContextSpan { | ||
|
||
private static final ThreadLocal<Span> span = new ThreadLocal<Span>() { | ||
protected Span initialValue() { | ||
return defaultSpan.get(); | ||
} | ||
}; | ||
static { | ||
ThreadContext.savers.add(new ThreadLocalSaver<>(span)); | ||
} | ||
|
||
public static Supplier<Span> defaultSpan = () -> NoopSpan.INSTANCE; | ||
|
||
private ThreadContextSpan() { | ||
} | ||
|
||
public static Span get() { | ||
return span.get(); | ||
} | ||
|
||
public static void set(Span span) { | ||
ThreadContextSpan.span.set(span); | ||
} | ||
|
||
public static void clear() { | ||
span.remove(); | ||
} | ||
|
||
} |