Skip to content

Commit

Permalink
Fix examples from the latest updates. (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkwatson authored Aug 3, 2020
1 parent 70e8433 commit 4680c3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions examples/grpc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Link> 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
Expand Down

0 comments on commit 4680c3a

Please sign in to comment.