File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
src/main/java/io/opentelemetry/dice Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ repositories {
1515dependencies {
1616 implementation ' org.springframework.boot:spring-boot-starter-web'
1717 implementation ' org.apache.logging.log4j:log4j-core:2.17.2'
18- // implementation 'io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:2.1.0'
19- // implementation 'io.opentelemetry:opentelemetry-api:1.35.0'
18+ implementation ' io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:2.1.0'
19+ implementation ' io.opentelemetry:opentelemetry-api:1.35.0'
2020}
2121
2222tasks. named(' test' ) {
Original file line number Diff line number Diff line change 99
1010import java .util .Optional ;
1111
12- // import io.opentelemetry.api.trace.Span;
13- // import io.opentelemetry.instrumentation.annotations.WithSpan;
14- // import io.opentelemetry.instrumentation.annotations.SpanAttribute;
15- // import io.opentelemetry.instrumentation.annotations.AddingSpanAttributes;
12+ import io .opentelemetry .api .trace .Span ;
13+ import io .opentelemetry .instrumentation .annotations .WithSpan ;
14+ import io .opentelemetry .instrumentation .annotations .SpanAttribute ;
15+ import io .opentelemetry .instrumentation .annotations .AddingSpanAttributes ;
1616
1717@ RestController
1818public class RollController {
@@ -32,6 +32,9 @@ public String index(@RequestParam("player") Optional<String> player) {
3232 } else {
3333 logger .info ("Anonymous player is rolling the dice: " + result );
3434 }
35+ Span span = Span .current ();
36+ span .setAttribute ("result" , result );
37+ span .setAttribute ("player" , player .orElse ("Anonymous" ));
3538 return Integer .toString (result );
3639 }
3740
You can’t perform that action at this time.
0 commit comments