diff --git a/java/pom.xml b/java/pom.xml
index d19b952..757f3ba 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -9,7 +9,7 @@
http://maven.apache.org
UTF-8
- 0.26.0
+ 0.31.0
1.7.5
23.0
1.1.4
@@ -40,8 +40,8 @@
- com.uber.jaeger
- jaeger-core
+ io.jaegertracing
+ jaeger-client
${jaeger.version}
diff --git a/java/run.sh b/java/run.sh
index d9b33e0..fc0d9bc 100755
--- a/java/run.sh
+++ b/java/run.sh
@@ -1,8 +1,8 @@
#!/bin/bash
if [ "$1" == "" ]; then
- echo "Usage: run.sh qualified-class-name [args]"
- exit 1
+ echo "Usage: run.sh qualified-class-name [args]"
+ exit 1
fi
className=$1
@@ -17,4 +17,9 @@ for jar in $(ls target/dependency/*.jar target/java-opentracing-tutorial-*.jar);
CLASSPATH=$CLASSPATH:$jar
done
-java -cp $CLASSPATH $className $*
+ADD_MODULES=""
+if [ "$(java -version 2>&1 | head -1 | grep '\"1\.[78].\+\"')" = "" ]; then
+ ADD_MODULES="--add-modules=java.xml.bind"
+fi
+
+java $ADD_MODULES -cp $CLASSPATH $className $*
diff --git a/java/src/main/java/lesson01/README.md b/java/src/main/java/lesson01/README.md
index ed1d541..8220933 100644
--- a/java/src/main/java/lesson01/README.md
+++ b/java/src/main/java/lesson01/README.md
@@ -53,18 +53,19 @@ We can use a global instance returned by `io.opentracing.util.GlobalTracer.get()
```java
import io.opentracing.Span;
+import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
public class Hello {
- private final io.opentracing.Tracer tracer;
+ private final Tracer tracer;
- private Hello(io.opentracing.Tracer tracer) {
+ private Hello(Tracer tracer) {
this.tracer = tracer;
}
private void sayHello(String helloTo) {
- Span span = tracer.buildSpan("say-hello").startManual();
+ Span span = tracer.buildSpan("say-hello").start();
String helloStr = String.format("Hello, %s!", helloTo);
System.out.println(helloStr);
@@ -85,7 +86,7 @@ public class Hello {
We are using the following basic features of the OpenTracing API:
* a `tracer` instance is used to create a span builder via `buildSpan()`
* each `span` is given an _operation name_, `"say-hello"` in this case
- * builder is used to create a span via `startManual()`
+ * builder is used to create a span via `start()`
* each `span` must be finished by calling its `finish()` function
* the start and end timestamps of the span will be captured automatically by the tracer implementation
@@ -94,40 +95,38 @@ That's because the function `GlobalTracer.get()` returns a no-op tracer by defau
### Initialize a real tracer
-Let's create an instance of a real tracer, such as Jaeger (http://github.com/uber/jaeger-client-java).
+Let's create an instance of a real tracer, such as Jaeger (https://github.com/jaegertracing/jaeger-client-java).
Our `pom.xml` already imports Jaeger:
```xml
- com.uber.jaeger
- jaeger-core
- 0.26.0
+ io.jaegertracing
+ jaeger-client
+ 0.31.0
```
First let's define a helper function that will create a tracer.
```java
-import com.uber.jaeger.Configuration;
-import com.uber.jaeger.Configuration.ReporterConfiguration;
-import com.uber.jaeger.Configuration.SamplerConfiguration;
-
-public static com.uber.jaeger.Tracer initTracer(String service) {
- SamplerConfiguration samplerConfig = new SamplerConfiguration("const", 1);
- ReporterConfiguration reporterConfig = new ReporterConfiguration(true, null, null, null, null);
- Configuration config = new Configuration(service, samplerConfig, reporterConfig);
- return (com.uber.jaeger.Tracer) config.getTracer();
+import io.jaegertracing.Configuration;
+import io.jaegertracing.Configuration.ReporterConfiguration;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+import io.jaegertracing.internal.JaegerTracer;
+
+public static JaegerTracer initTracer(String service) {
+ SamplerConfiguration samplerConfig = new SamplerConfiguration().withType("const").withParam(1);
+ ReporterConfiguration reporterConfig = new ReporterConfiguration().withLogSpans(true);
+ Configuration config = new Configuration(service).withSampler(samplerConfig).withReporter(reporterConfig);
+ return config.getTracer();
}
```
To use this instance, let's change the main function:
```java
-import com.uber.jaeger.Tracer;
-
Tracer tracer = initTracer("hello-world");
new Hello(tracer).sayHello(helloTo);
-tracer.close();
```
Note that we are passing a string `hello-world` to the init method. It is used to mark all spans emitted by
@@ -137,9 +136,9 @@ If we run the program now, we should see a span logged:
```
$ ./run.sh lesson01.exercise.Hello Bryan
-[lesson01.exercise.Hello.main()] INFO com.uber.jaeger.Configuration - Initialized tracer=Tracer(...)
+[lesson01.exercise.Hello.main()] INFO io.jaegertracing.Configuration - Initialized tracer=Tracer(...)
Hello, Bryan!
-[lesson01.exercise.Hello.main()] INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 76509ca0cd333055:76509ca0cd333055:0:1 - say-hello
+[lesson01.exercise.Hello.main()] INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 76509ca0cd333055:76509ca0cd333055:0:1 - say-hello
```
If you have Jaeger backend running, you should be able to see the trace in the UI.
@@ -177,7 +176,7 @@ In the case of `Hello Bryan`, the string `"Bryan"` is a good candidate for a spa
to the whole span and not to a particular moment in time. We can record it like this:
```java
-Span span = tracer.buildSpan("say-hello").startManual();
+Span span = tracer.buildSpan("say-hello").start();
span.setTag("hello-to", helloTo);
```
diff --git a/java/src/main/java/lesson01/solution/Hello.java b/java/src/main/java/lesson01/solution/Hello.java
index 4d5a04d..ab3ba07 100644
--- a/java/src/main/java/lesson01/solution/Hello.java
+++ b/java/src/main/java/lesson01/solution/Hello.java
@@ -1,9 +1,10 @@
package lesson01.solution;
import com.google.common.collect.ImmutableMap;
-import com.uber.jaeger.Tracer;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Span;
+import io.opentracing.Tracer;
import lib.Tracing;
public class Hello {
@@ -15,9 +16,9 @@ private Hello(Tracer tracer) {
}
private void sayHello(String helloTo) {
- Span span = tracer.buildSpan("say-hello").startManual();
+ Span span = tracer.buildSpan("say-hello").start();
span.setTag("hello-to", helloTo);
-
+
String helloStr = String.format("Hello, %s!", helloTo);
span.log(ImmutableMap.of("event", "string-format", "value", helloStr));
@@ -31,9 +32,10 @@ public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalArgumentException("Expecting one argument");
}
+
String helloTo = args[0];
- Tracer tracer = Tracing.init("hello-world");
- new Hello(tracer).sayHello(helloTo);
- tracer.close();
+ try (JaegerTracer tracer = Tracing.init("hello-world")) {
+ new Hello(tracer).sayHello(helloTo);
+ }
}
}
diff --git a/java/src/main/java/lesson02/README.md b/java/src/main/java/lesson02/README.md
index c8f3990..5e79b90 100644
--- a/java/src/main/java/lesson02/README.md
+++ b/java/src/main/java/lesson02/README.md
@@ -42,7 +42,7 @@ Of course, this does not change the outcome. What we really want to do is to wra
```java
private String formatString(Span rootSpan, String helloTo) {
- Span span = tracer.buildSpan("formatString").startManual();
+ Span span = tracer.buildSpan("formatString").start();
try {
String helloStr = String.format("Hello, %s!", helloTo);
span.log(ImmutableMap.of("event", "string-format", "value", helloStr));
@@ -53,7 +53,7 @@ private String formatString(Span rootSpan, String helloTo) {
}
private void printHello(Span rootSpan, String helloStr) {
- Span span = tracer.buildSpan("printHello").startManual();
+ Span span = tracer.buildSpan("printHello").start();
try {
System.out.println(helloStr);
span.log(ImmutableMap.of("event", "println"));
@@ -67,10 +67,10 @@ Let's run it:
```
$ ./run.sh lesson02.exercise.Hello Bryan
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 12c92a6604499c25:12c92a6604499c25:0:1 - formatString
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 12c92a6604499c25:12c92a6604499c25:0:1 - formatString
Hello, Bryan!
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 14aaaf7a377e5147:14aaaf7a377e5147:0:1 - printHello
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: a25cf88369793b9b:a25cf88369793b9b:0:1 - say-hello
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 14aaaf7a377e5147:14aaaf7a377e5147:0:1 - printHello
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: a25cf88369793b9b:a25cf88369793b9b:0:1 - say-hello
```
We got three spans, but there is a problem here. The first hexadecimal segment of the output represents
@@ -81,7 +81,7 @@ What we really wanted was to establish causal relationship between the two new s
span started in `main()`. We can do that by passing an additional option `asChildOf` to the span builder:
```java
-Span span = tracer.buildSpan("formatString").asChildOf(rootSpan).startManual();
+Span span = tracer.buildSpan("formatString").asChildOf(rootSpan).start();
```
If we think of the trace as a directed acyclic graph where nodes are the spans and edges are
@@ -100,10 +100,10 @@ spans now belong to the same trace:
```
$ ./run.sh lesson02.exercise.Hello Bryan
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 4ca67017b68d14c:42d38965612a195a:4ca67017b68d14c:1 - formatString
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 4ca67017b68d14c:42d38965612a195a:4ca67017b68d14c:1 - formatString
Hello, Bryan!
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 4ca67017b68d14c:19af156b64c22d23:4ca67017b68d14c:1 - printHello
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 4ca67017b68d14c:4ca67017b68d14c:0:1 - say-hello
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 4ca67017b68d14c:19af156b64c22d23:4ca67017b68d14c:1 - printHello
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 4ca67017b68d14c:4ca67017b68d14c:0:1 - say-hello
```
We can also see that instead of `0` in the 3rd position the first two reported spans display
@@ -121,7 +121,7 @@ You may have noticed a few unpleasant side effects of our recent changes
* we also had to write somewhat verbose try/finally code to finish the spans
OpenTracing API for Java provides a better way. Using thread-locals and the notion of an "active span",
-we can avoid passing the span through our code and just access it via `tracer.
+we can avoid passing the span through our code and just access it via `tracer`.
```java
private void sayHello(String helloTo) {
@@ -150,7 +150,7 @@ private void printHello(String helloStr) {
```
In the above code we're making the following changes:
- * We use `startActive()` method of the span builder instead of `startManual()`,
+ * We use `startActive()` method of the span builder instead of `start()`,
which makes the span "active" by storing it in a thread-local storage.
* `startActive()` returns a `Scope` object instead of a `Span`. Scope is a container of the currently
active span. We access the active span via `scope.span()`. Once the scope is closed, the previous
diff --git a/java/src/main/java/lesson02/solution/HelloActive.java b/java/src/main/java/lesson02/solution/HelloActive.java
index c08ec14..5f428e8 100644
--- a/java/src/main/java/lesson02/solution/HelloActive.java
+++ b/java/src/main/java/lesson02/solution/HelloActive.java
@@ -1,13 +1,14 @@
package lesson02.solution;
import com.google.common.collect.ImmutableMap;
-import com.uber.jaeger.Tracer;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
+import io.opentracing.Tracer;
import lib.Tracing;
public class HelloActive {
-
+
private final Tracer tracer;
private HelloActive(Tracer tracer) {
@@ -17,7 +18,7 @@ private HelloActive(Tracer tracer) {
private void sayHello(String helloTo) {
try (Scope scope = tracer.buildSpan("say-hello").startActive(true)) {
scope.span().setTag("hello-to", helloTo);
-
+
String helloStr = formatString(helloTo);
printHello(helloStr);
}
@@ -42,9 +43,10 @@ public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalArgumentException("Expecting one argument");
}
+
String helloTo = args[0];
- Tracer tracer = Tracing.init("hello-world");
- new HelloActive(tracer).sayHello(helloTo);
- tracer.close();
+ try (JaegerTracer tracer = Tracing.init("hello-world")) {
+ new HelloActive(tracer).sayHello(helloTo);
+ }
}
}
diff --git a/java/src/main/java/lesson02/solution/HelloManual.java b/java/src/main/java/lesson02/solution/HelloManual.java
index 695ab7c..0e8a7b6 100644
--- a/java/src/main/java/lesson02/solution/HelloManual.java
+++ b/java/src/main/java/lesson02/solution/HelloManual.java
@@ -1,13 +1,14 @@
package lesson02.solution;
import com.google.common.collect.ImmutableMap;
-import com.uber.jaeger.Tracer;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Span;
+import io.opentracing.Tracer;
import lib.Tracing;
public class HelloManual {
-
+
private final Tracer tracer;
private HelloManual(Tracer tracer) {
@@ -15,9 +16,9 @@ private HelloManual(Tracer tracer) {
}
private void sayHello(String helloTo) {
- Span span = tracer.buildSpan("say-hello").startManual();
+ Span span = tracer.buildSpan("say-hello").start();
span.setTag("hello-to", helloTo);
-
+
String helloStr = formatString(span, helloTo);
printHello(span, helloStr);
@@ -25,7 +26,7 @@ private void sayHello(String helloTo) {
}
private String formatString(Span rootSpan, String helloTo) {
- Span span = tracer.buildSpan("formatString").asChildOf(rootSpan).startManual();
+ Span span = tracer.buildSpan("formatString").asChildOf(rootSpan).start();
try {
String helloStr = String.format("Hello, %s!", helloTo);
span.log(ImmutableMap.of("event", "string-format", "value", helloStr));
@@ -36,7 +37,7 @@ private String formatString(Span rootSpan, String helloTo) {
}
private void printHello(Span rootSpan, String helloStr) {
- Span span = tracer.buildSpan("printHello").asChildOf(rootSpan).startManual();
+ Span span = tracer.buildSpan("printHello").asChildOf(rootSpan).start();
try {
System.out.println(helloStr);
span.log(ImmutableMap.of("event", "println"));
@@ -49,9 +50,10 @@ public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalArgumentException("Expecting one argument");
}
+
String helloTo = args[0];
- Tracer tracer = Tracing.init("hello-world");
- new HelloManual(tracer).sayHello(helloTo);
- tracer.close();
+ try (JaegerTracer tracer = Tracing.init("hello-world")) {
+ new HelloManual(tracer).sayHello(helloTo);
+ }
}
}
diff --git a/java/src/main/java/lesson03/README.md b/java/src/main/java/lesson03/README.md
index a0bd820..bffce38 100644
--- a/java/src/main/java/lesson03/README.md
+++ b/java/src/main/java/lesson03/README.md
@@ -219,7 +219,7 @@ Then run `lesson03.exercise.Hello`. You should see the outputs like this:
$ ./run.sh lesson03.exercise.Formatter server
[skip noise]
INFO org.eclipse.jetty.server.Server: Started @3968ms
-INFO com.uber.jaeger.reporters.LoggingReporter: Span reported: 5fe2d9de96c3887a:b73ff97ea68a36f8:72910f6018b1bd09:1 - format
+INFO io.jaegertracing.reporters.LoggingReporter: Span reported: 5fe2d9de96c3887a:b73ff97ea68a36f8:72910f6018b1bd09:1 - format
127.0.0.1 - - "GET /format?helloTo=Bryan HTTP/1.1" 200 13 "-" "okhttp/3.9.0" 3
# publisher
@@ -227,15 +227,15 @@ $ ./run.sh lesson03.exercise.Publisher server
[skip noise]
INFO org.eclipse.jetty.server.Server: Started @3388ms
Hello, Bryan!
-INFO com.uber.jaeger.reporters.LoggingReporter: Span reported: 5fe2d9de96c3887a:4a2c39e462cb2a92:62d73167c129ecd7:1 - publish
+INFO io.jaegertracing.reporters.LoggingReporter: Span reported: 5fe2d9de96c3887a:4a2c39e462cb2a92:62d73167c129ecd7:1 - publish
127.0.0.1 - - "GET /publish?helloStr=Hello,%20Bryan! HTTP/1.1" 200 9 "-" "okhttp/3.9.0" 80
# client
$ ./run.sh lesson03.exercise.Hello Bryan
-INFO com.uber.jaeger.Configuration - Initialized tracer=Tracer(...)
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 5fe2d9de96c3887a:72910f6018b1bd09:5fe2d9de96c3887a:1 - formatString
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 5fe2d9de96c3887a:62d73167c129ecd7:5fe2d9de96c3887a:1 - printHello
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: 5fe2d9de96c3887a:5fe2d9de96c3887a:0:1 - say-hello
+INFO io.jaegertracing.Configuration - Initialized tracer=Tracer(...)
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 5fe2d9de96c3887a:72910f6018b1bd09:5fe2d9de96c3887a:1 - formatString
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 5fe2d9de96c3887a:62d73167c129ecd7:5fe2d9de96c3887a:1 - printHello
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: 5fe2d9de96c3887a:5fe2d9de96c3887a:0:1 - say-hello
```
Note how all recorded spans show the same trace ID `5fe2d9de96c3887a`. This is a sign
diff --git a/java/src/main/java/lesson03/exercise/Hello.java b/java/src/main/java/lesson03/exercise/Hello.java
index 1a32c45..32a130f 100644
--- a/java/src/main/java/lesson03/exercise/Hello.java
+++ b/java/src/main/java/lesson03/exercise/Hello.java
@@ -3,9 +3,10 @@
import java.io.IOException;
import com.google.common.collect.ImmutableMap;
-import com.uber.jaeger.Tracer;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
+import io.opentracing.Tracer;
import lib.Tracing;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
@@ -66,9 +67,10 @@ public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalArgumentException("Expecting one argument");
}
+
String helloTo = args[0];
- Tracer tracer = Tracing.init("hello-world");
- new Hello(tracer).sayHello(helloTo);
- tracer.close();
+ try (JaegerTracer tracer = Tracing.init("hello-world")) {
+ new Hello(tracer).sayHello(helloTo);
+ }
}
}
diff --git a/java/src/main/java/lesson03/solution/Formatter.java b/java/src/main/java/lesson03/solution/Formatter.java
index 679620e..c31d5f6 100644
--- a/java/src/main/java/lesson03/solution/Formatter.java
+++ b/java/src/main/java/lesson03/solution/Formatter.java
@@ -13,6 +13,7 @@
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.setup.Environment;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
import io.opentracing.Tracer;
import lib.Tracing;
@@ -48,7 +49,8 @@ public static void main(String[] args) throws Exception {
System.setProperty("dw.server.applicationConnectors[0].port", "8081");
System.setProperty("dw.server.adminConnectors[0].port", "9081");
- Tracer tracer = Tracing.init("formatter");
- new Formatter(tracer).run(args);
+ try (JaegerTracer tracer = Tracing.init("formatter")) {
+ new Formatter(tracer).run(args);
+ }
}
}
diff --git a/java/src/main/java/lesson03/solution/Hello.java b/java/src/main/java/lesson03/solution/Hello.java
index f293f17..22dc23c 100644
--- a/java/src/main/java/lesson03/solution/Hello.java
+++ b/java/src/main/java/lesson03/solution/Hello.java
@@ -3,9 +3,10 @@
import java.io.IOException;
import com.google.common.collect.ImmutableMap;
-import com.uber.jaeger.Tracer;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
+import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import lib.Tracing;
@@ -74,9 +75,10 @@ public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalArgumentException("Expecting one argument");
}
+
String helloTo = args[0];
- Tracer tracer = Tracing.init("hello-world");
- new Hello(tracer).sayHello(helloTo);
- tracer.close();
+ try (JaegerTracer tracer = Tracing.init("hello-world")) {
+ new Hello(tracer).sayHello(helloTo);
+ }
}
}
diff --git a/java/src/main/java/lesson03/solution/Publisher.java b/java/src/main/java/lesson03/solution/Publisher.java
index 99d92bc..623c064 100644
--- a/java/src/main/java/lesson03/solution/Publisher.java
+++ b/java/src/main/java/lesson03/solution/Publisher.java
@@ -13,6 +13,7 @@
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.setup.Environment;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
import io.opentracing.Tracer;
import lib.Tracing;
@@ -47,7 +48,8 @@ public void run(Configuration configuration, Environment environment) throws Exc
public static void main(String[] args) throws Exception {
System.setProperty("dw.server.applicationConnectors[0].port", "8082");
System.setProperty("dw.server.adminConnectors[0].port", "9082");
- Tracer tracer = Tracing.init("publisher");
- new Publisher(tracer).run(args);
+ try (JaegerTracer tracer = Tracing.init("publisher")) {
+ new Publisher(tracer).run(args);
+ }
}
}
diff --git a/java/src/main/java/lesson04/README.md b/java/src/main/java/lesson04/README.md
index 280d3cc..7660f84 100644
--- a/java/src/main/java/lesson04/README.md
+++ b/java/src/main/java/lesson04/README.md
@@ -38,7 +38,6 @@ public static void main(String[] args) {
String greeting = args[1];
Tracer tracer = Tracing.init("hello-world");
new Hello(tracer).sayHello(helloTo, greeting);
- tracer.close();
}
```
@@ -72,7 +71,7 @@ with two arguments, e.g. `Bryan Bonjour`. The `publisher` should print `Bonjour,
$ ./run.sh lesson04.exercise.Formatter server
[skip noise]
INFO org.eclipse.jetty.server.Server: Started @3508ms
-INFO com.uber.jaeger.reporters.LoggingReporter: Span reported: e6ee8a816c8386ce:cd2c1d243ddf319b:ef06ddba375ff053:1 - format
+INFO io.jaegertracing.reporters.LoggingReporter: Span reported: e6ee8a816c8386ce:cd2c1d243ddf319b:ef06ddba375ff053:1 - format
127.0.0.1 - - "GET /format?helloTo=Bryan HTTP/1.1" 200 15 "-" "okhttp/3.9.0" 69
# publisher
@@ -80,15 +79,15 @@ $ ./run.sh lesson04.exercise.Publisher server
[skip noise]
INFO org.eclipse.jetty.server.Server: Started @3388ms
Bonjour, Bryan!
-INFO com.uber.jaeger.reporters.LoggingReporter: Span reported: e6ee8a816c8386ce:f46156fcd7d3abd3:20cdfed1d23892c1:1 - publish
+INFO io.jaegertracing.reporters.LoggingReporter: Span reported: e6ee8a816c8386ce:f46156fcd7d3abd3:20cdfed1d23892c1:1 - publish
127.0.0.1 - - "GET /publish?helloStr=Bonjour,%20Bryan! HTTP/1.1" 200 9 "-" "okhttp/3.9.0" 92
# client
$ ./run.sh lesson04.exercise.Hello Bryan Bonjour
-INFO com.uber.jaeger.Configuration - Initialized tracer=Tracer(...)
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: e6ee8a816c8386ce:ef06ddba375ff053:e6ee8a816c8386ce:1 - formatString
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: e6ee8a816c8386ce:20cdfed1d23892c1:e6ee8a816c8386ce:1 - printHello
-INFO com.uber.jaeger.reporters.LoggingReporter - Span reported: e6ee8a816c8386ce:e6ee8a816c8386ce:0:1 - say-hello
+INFO io.jaegertracing.Configuration - Initialized tracer=Tracer(...)
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: e6ee8a816c8386ce:ef06ddba375ff053:e6ee8a816c8386ce:1 - formatString
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: e6ee8a816c8386ce:20cdfed1d23892c1:e6ee8a816c8386ce:1 - printHello
+INFO io.jaegertracing.reporters.LoggingReporter - Span reported: e6ee8a816c8386ce:e6ee8a816c8386ce:0:1 - say-hello
```
### What's the Big Deal?
diff --git a/java/src/main/java/lesson04/exercise/Publisher.java b/java/src/main/java/lesson04/exercise/Publisher.java
index 101e25c..56b8a98 100644
--- a/java/src/main/java/lesson04/exercise/Publisher.java
+++ b/java/src/main/java/lesson04/exercise/Publisher.java
@@ -13,6 +13,7 @@
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.setup.Environment;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
import io.opentracing.Tracer;
import lib.Tracing;
@@ -47,7 +48,8 @@ public void run(Configuration configuration, Environment environment) throws Exc
public static void main(String[] args) throws Exception {
System.setProperty("dw.server.applicationConnectors[0].port", "8082");
System.setProperty("dw.server.adminConnectors[0].port", "9082");
- Tracer tracer = Tracing.init("publisher");
- new Publisher(tracer).run(args);
+ try (JaegerTracer tracer = Tracing.init("publisher")) {
+ new Publisher(tracer).run(args);
+ }
}
}
diff --git a/java/src/main/java/lesson04/solution/Formatter.java b/java/src/main/java/lesson04/solution/Formatter.java
index 9ea0a53..29775da 100644
--- a/java/src/main/java/lesson04/solution/Formatter.java
+++ b/java/src/main/java/lesson04/solution/Formatter.java
@@ -13,6 +13,7 @@
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.setup.Environment;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
import io.opentracing.Tracer;
import lib.Tracing;
@@ -51,7 +52,8 @@ public void run(Configuration configuration, Environment environment) throws Exc
public static void main(String[] args) throws Exception {
System.setProperty("dw.server.applicationConnectors[0].port", "8081");
System.setProperty("dw.server.adminConnectors[0].port", "9081");
- Tracer tracer = Tracing.init("formatter");
- new Formatter(tracer).run(args);
+ try (JaegerTracer tracer = Tracing.init("formatter")) {
+ new Formatter(tracer).run(args);
+ }
}
}
diff --git a/java/src/main/java/lesson04/solution/Hello.java b/java/src/main/java/lesson04/solution/Hello.java
index d155c14..35b27f0 100644
--- a/java/src/main/java/lesson04/solution/Hello.java
+++ b/java/src/main/java/lesson04/solution/Hello.java
@@ -3,9 +3,10 @@
import java.io.IOException;
import com.google.common.collect.ImmutableMap;
-import com.uber.jaeger.Tracer;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
+import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import lib.Tracing;
@@ -77,8 +78,8 @@ public static void main(String[] args) {
}
String helloTo = args[0];
String greeting = args[1];
- Tracer tracer = Tracing.init("hello-world");
- new Hello(tracer).sayHello(helloTo, greeting);
- tracer.close();
+ try (JaegerTracer tracer = Tracing.init("hello-world")) {
+ new Hello(tracer).sayHello(helloTo, greeting);
+ }
}
}
diff --git a/java/src/main/java/lesson04/solution/Publisher.java b/java/src/main/java/lesson04/solution/Publisher.java
index 74ab33d..d01c15f 100644
--- a/java/src/main/java/lesson04/solution/Publisher.java
+++ b/java/src/main/java/lesson04/solution/Publisher.java
@@ -13,6 +13,7 @@
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.setup.Environment;
+import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Scope;
import io.opentracing.Tracer;
import lib.Tracing;
@@ -47,7 +48,8 @@ public void run(Configuration configuration, Environment environment) throws Exc
public static void main(String[] args) throws Exception {
System.setProperty("dw.server.applicationConnectors[0].port", "8082");
System.setProperty("dw.server.adminConnectors[0].port", "9082");
- Tracer tracer = Tracing.init("publisher");
- new Publisher(tracer).run(args);
+ try (JaegerTracer tracer = Tracing.init("publisher")) {
+ new Publisher(tracer).run(args);
+ }
}
}
diff --git a/java/src/main/java/lib/Tracing.java b/java/src/main/java/lib/Tracing.java
index bea4531..a0b5a0e 100644
--- a/java/src/main/java/lib/Tracing.java
+++ b/java/src/main/java/lib/Tracing.java
@@ -6,11 +6,11 @@
import javax.ws.rs.core.MultivaluedMap;
-import com.uber.jaeger.Configuration;
-import com.uber.jaeger.Configuration.ReporterConfiguration;
-import com.uber.jaeger.Configuration.SamplerConfiguration;
-import com.uber.jaeger.samplers.ConstSampler;
-
+import io.jaegertracing.Configuration;
+import io.jaegertracing.Configuration.ReporterConfiguration;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+import io.jaegertracing.internal.JaegerTracer;
+import io.jaegertracing.internal.samplers.ConstSampler;
import io.opentracing.Scope;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
@@ -24,7 +24,7 @@ public final class Tracing {
private Tracing() {
}
- public static com.uber.jaeger.Tracer init(String service) {
+ public static JaegerTracer init(String service) {
SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv()
.withType(ConstSampler.TYPE)
.withParam(1);
@@ -36,7 +36,7 @@ public static com.uber.jaeger.Tracer init(String service) {
.withSampler(samplerConfig)
.withReporter(reporterConfig);
- return (com.uber.jaeger.Tracer) config.getTracer();
+ return config.getTracer();
}
public static Scope startServerSpan(Tracer tracer, javax.ws.rs.core.HttpHeaders httpHeaders, String operationName) {