Add OpenTelemetry annotations support#5593
Conversation
BenchmarksParameters
See matching parameters
SummaryFound 3 performance improvements and 0 performance regressions! Performance is the same for 19 cases.
|
7f229e7 to
871717b
Compare
1ebdeb5 to
ba5be8c
Compare
| } | ||
| } else if (result instanceof CompletionStage<?>) { | ||
| CompletionStage<?> completionStage = (CompletionStage<?>) result; | ||
| completionStage.whenComplete(finishSpan(span)); |
There was a problem hiding this comment.
shouldn't we be returning the new CompletionStage which also finishes the span?
There was a problem hiding this comment.
Indeed. It should otherwise the span will be closed twice (the first time too early, and the second time as expected).
The tests didn't catch the issue because they contain an issue about span duration test I fix in the next PR... #5737
I wanted to avoid update this old PR but I guess it's time to do it and andl backport the test fix (and your add the CompletionStage return).
8ac8f53 to
8bf0cb2
Compare
aaded4c to
b11bc2a
Compare
|
So does It seems I would have to wrap all my code in ugly Mono.defers() to get the tracer context etc which leads to a lot of code changes just to get some custom spans injected. Any sample code if that is the case? |
|
Hello @AlexeiZenin It should be working but you would have to enable
If not, I would recommend to contact the support so we can properly track the missing feature. |
|
I set the DD_TRACE_ANNOTATION_ASYNC env var, seems it still takes microseconds in my spans. Wondering if it has to be set as a property on the command line. |
|
Assuming you are running tracer version 1.21+, setting |
What Does This Do
This PR brings initial support for OpenTelemetry
@WithSpan,@SpanAttributesand@AddingSpanAttributesannotations.@WithSpanannotation is similar to the@Traceannotation and create span for the annotated method,@SpanAttritubesannotation can be attached to a method parameter to store its value as span tag(this requires the related method to be annotated either with
@WithSpanattribute or@AddingSpanAttributesannotation),@AddingSpanAttributeswill allow to use@SpanAttributeswithout creating a new span, adding span tag for the current active span if any (doing nothing if no active span).Check the official documentation for more details.
Motivation
This should improve our OpenTelemetry compatibility.
Additional Notes
CompletableFutureandCompletionStagefuture/promise-type return types are supported for@WithSpanwithin this PR,Publishertype support comes with Add generic async result type support for OpenTelemetry annotations and its Reactive Streams extension #5737,Listenabletype support come with Add Guava async result type support for OpenTelemetry annotations #5799,MonoandFluxtypes support come with Add Reactor async result types support for OpenTelemetry annotations #5800,Completable,Maybe,Single,Observable, andFlowabletypes support come with Add RxJava async result types support for OpenTelemetry annotations #5801,@WithSpan&@SpanAttributes: 1.20.0 or later,@AddingSpanAttributes: 1.26.0 or later.