Skip to content

Commit 4680c3a

Browse files
authored
Fix examples from the latest updates. (#1495)
1 parent 70e8433 commit 4680c3a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

examples/grpc/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ dependencies {
1212
compile "io.grpc:grpc-protobuf:${grpcVersion}"
1313
compile "io.grpc:grpc-stub:${grpcVersion}"
1414
compile "io.grpc:grpc-netty-shaded:${grpcVersion}"
15+
16+
if (JavaVersion.current().isJava9Compatible()) {
17+
// Workaround for @javax.annotation.Generated
18+
// see: https://github.com/grpc/grpc-java/issues/3633
19+
compileOnly "javax.annotation:javax.annotation-api:1.3.2"
20+
}
1521
}
1622

1723
protobuf {

examples/sdk-usage/src/main/java/io/opentelemetry/sdk/example/ConfigureTraceExample.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
2727
import io.opentelemetry.trace.Link;
2828
import io.opentelemetry.trace.Span;
29+
import io.opentelemetry.trace.Span.Kind;
2930
import io.opentelemetry.trace.SpanContext;
3031
import io.opentelemetry.trace.TraceId;
3132
import io.opentelemetry.trace.Tracer;
@@ -109,15 +110,16 @@ public static void main(String[] args) {
109110
class MySampler implements Sampler {
110111

111112
@Override
112-
public Decision shouldSample(
113+
public SamplingResult shouldSample(
113114
SpanContext parentContext,
114115
TraceId traceId,
115116
String name,
116-
Span.Kind spanKind,
117+
Kind spanKind,
117118
ReadableAttributes attributes,
118119
List<Link> parentLinks) {
119120
// We sample only if the Span name contains "SAMPLE"
120-
return Samplers.emptyDecision(name.contains("SAMPLE"));
121+
return Samplers.emptySamplingResult(
122+
name.contains("SAMPLE") ? Decision.RECORD_AND_SAMPLED : Decision.NOT_RECORD);
121123
}
122124

123125
@Override

0 commit comments

Comments
 (0)