From 4680c3a327094b2c6b9fe793064a7c4f8e5a1062 Mon Sep 17 00:00:00 2001 From: John Watson Date: Mon, 3 Aug 2020 10:31:16 -0700 Subject: [PATCH] Fix examples from the latest updates. (#1495) --- examples/grpc/build.gradle | 6 ++++++ .../opentelemetry/sdk/example/ConfigureTraceExample.java | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/grpc/build.gradle b/examples/grpc/build.gradle index 62902e4a6b0..43bef19ef32 100644 --- a/examples/grpc/build.gradle +++ b/examples/grpc/build.gradle @@ -12,6 +12,12 @@ dependencies { compile "io.grpc:grpc-protobuf:${grpcVersion}" compile "io.grpc:grpc-stub:${grpcVersion}" compile "io.grpc:grpc-netty-shaded:${grpcVersion}" + + if (JavaVersion.current().isJava9Compatible()) { + // Workaround for @javax.annotation.Generated + // see: https://github.com/grpc/grpc-java/issues/3633 + compileOnly "javax.annotation:javax.annotation-api:1.3.2" + } } protobuf { diff --git a/examples/sdk-usage/src/main/java/io/opentelemetry/sdk/example/ConfigureTraceExample.java b/examples/sdk-usage/src/main/java/io/opentelemetry/sdk/example/ConfigureTraceExample.java index bcca8f83a84..dc3d4dc79da 100644 --- a/examples/sdk-usage/src/main/java/io/opentelemetry/sdk/example/ConfigureTraceExample.java +++ b/examples/sdk-usage/src/main/java/io/opentelemetry/sdk/example/ConfigureTraceExample.java @@ -26,6 +26,7 @@ import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; import io.opentelemetry.trace.Link; import io.opentelemetry.trace.Span; +import io.opentelemetry.trace.Span.Kind; import io.opentelemetry.trace.SpanContext; import io.opentelemetry.trace.TraceId; import io.opentelemetry.trace.Tracer; @@ -109,15 +110,16 @@ public static void main(String[] args) { class MySampler implements Sampler { @Override - public Decision shouldSample( + public SamplingResult shouldSample( SpanContext parentContext, TraceId traceId, String name, - Span.Kind spanKind, + Kind spanKind, ReadableAttributes attributes, List parentLinks) { // We sample only if the Span name contains "SAMPLE" - return Samplers.emptyDecision(name.contains("SAMPLE")); + return Samplers.emptySamplingResult( + name.contains("SAMPLE") ? Decision.RECORD_AND_SAMPLED : Decision.NOT_RECORD); } @Override