Skip to content

Commit

Permalink
tmp commit: manually tested all previous OpenTelemetry versions
Browse files Browse the repository at this point in the history
  • Loading branch information
fstab committed Apr 24, 2021
1 parent 88a95e0 commit 103eb59
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ class YourClass {

## Exemplars

TODO: Document that Exemplars are supported with OpenTelemetry 0.16.0 or higher. When `client_java` 0.11.0 was released the current OpenTelemetry version was 1.1.0.

Exemplars are a feature of the [OpenMetrics](http://openmetrics.io) format that allows applications to link metrics
to example traces. Starting with version 0.11.0, `client_java` automatically adds Exemplars for applications that
are instrumented with [OpenTelemetry](https://opentelemetry.io/) distributed tracing. No code change is required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,57 @@ public static void main(String[] args) throws IOException, InterruptedException
.help("help")
.register();

// The following code works with OpenTelemetry versions 0.13.0 and higher.
// Exemplars work with 0.16.0 and higher. With 0.15.0 or lower the example will run but not have exemplars.
System.out.println(Tracer.class.getProtectionDomain().getCodeSource().getLocation());
Tracer tracer = SdkTracerProvider.builder().build().get(null);
Span span = tracer.spanBuilder("my span").startSpan();
span.makeCurrent();
counter.inc(1);
span.end();
Thread.currentThread().join(); // sleep forever

// Examples with older OpenTelemetry versions used for manual testing:

/*
// OpenTelemetry versions 0.10.0 - 0.12.0
System.out.println(Tracer.class.getProtectionDomain().getCodeSource().getLocation());
Tracer tracer = OpenTelemetrySdk.get().getTracer("test");
Span span = tracer.spanBuilder("my span").startSpan();
span.makeCurrent();
counter.inc(1);
span.end();
Thread.currentThread().join(); // sleep forever
*/

/*
// OpenTelemetry versions 0.4.0 - 0.9.1
System.out.println(TracerSdkProvider.class.getProtectionDomain().getCodeSource().getLocation());
Tracer tracer = TracerSdkProvider.builder().build().get("test");
Span span = tracer.spanBuilder("my span").startSpan();
counter.inc(1);
span.end();
Thread.currentThread().join(); // sleep forever
*/

/*
// OpenTelemetry version 0.3.0
System.out.println(TracerSdkProvider.class.getProtectionDomain().getCodeSource().getLocation());
TracerSdk tracer = TracerSdkProvider.builder().build().get("test");
Span span = tracer.spanBuilder("my span").startSpan();
counter.inc(1);
span.end();
Thread.currentThread().join(); // sleep forever
*/

/*
// OpenTelemetry version 0.2.0
System.out.println(TracerSdkFactory.class.getProtectionDomain().getCodeSource().getLocation());
TracerSdk tracer = TracerSdkFactory.create().get("test");
Span span = tracer.spanBuilder("my span").startSpan();
counter.inc(1);
span.end();
Thread.currentThread().join(); // sleep forever
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ public static boolean isAvailable() {
test.getSpanId();
test.getSpanId();
return true;
} catch (NoClassDefFoundError e) {
} catch (LinkageError ignored) {
// NoClassDefFoundError:
// Either OpenTelemetry is not present, or it is version 0.9.1 or older when io.opentelemetry.api.trace.Span did not exist.
// IncompatibleClassChangeError:
// The application uses an OpenTelemetry version between 0.10.0 and 0.15.0 when SpanContext was a class, and not an interface.
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public static boolean isAvailable() {
test.getSpanId();
test.getSpanId();
return true;
} catch (NoClassDefFoundError e) {
} catch (LinkageError ignored) {
// NoClassDefFoundError:
// Either OpenTelemetry is not present, or it is version 0.9.1 or older when io.opentelemetry.api.trace.Span did not exist.
// IncompatibleClassChangeError:
// The application uses an OpenTelemetry version between 0.10.0 and 0.15.0 when SpanContext was a class, and not an interface.
return false;
}
}
Expand Down

0 comments on commit 103eb59

Please sign in to comment.