-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1962] Wrap returned promises in OpenTracingOutboundCallsInterceptor #2366
Conversation
Hrmm, this is a very specific interceptor-oriented solution to a general problem of contextual state across promises. I wonder if a |
@cretz, if I understand what you are saying, I think we'd still need to use interception at some level unless OTEL can be made to utilize the WorkflowAsyncLocal instead of ThreadLocal because something would need to initialize the state in the callback context, which currently runs outside of the RootThread complex. I'm not saying OTEL can't use WorkflowAsyncLocal; I just don't know |
temporal-sdk/src/main/java/io/temporal/internal/sync/CompletablePromiseImpl.java
Outdated
Show resolved
Hide resolved
temporal-opentracing/src/test/java/io/temporal/opentracing/CallbackContextTest.java
Outdated
Show resolved
Hide resolved
.../main/java/io/temporal/opentracing/internal/OpenTracingWorkflowOutboundCallsInterceptor.java
Outdated
Show resolved
Hide resolved
e714fc3
to
5bd97da
Compare
.../main/java/io/temporal/opentracing/internal/OpenTracingWorkflowOutboundCallsInterceptor.java
Outdated
Show resolved
Hide resolved
.../main/java/io/temporal/opentracing/internal/OpenTracingWorkflowOutboundCallsInterceptor.java
Outdated
Show resolved
Hide resolved
.../main/java/io/temporal/opentracing/internal/OpenTracingWorkflowOutboundCallsInterceptor.java
Outdated
Show resolved
Hide resolved
.../main/java/io/temporal/opentracing/internal/OpenTracingWorkflowOutboundCallsInterceptor.java
Outdated
Show resolved
Hide resolved
This change allows the OpenTracing interceptor to transfer any active trace/span from the point of invocation to the point of promise callback execution, thus preserving the span within the callback. Without this, spans become disjoint across Promise.thenCompose, due to the nature of the deferring the execution of the .thenCompose to a callback thread. Fixes temporalio#1962 Signed-off-by: Greg Haskins <[email protected]>
@ghaskins Looks like part of CI is failing because your branch is missing the version tags, can you make sure you fetched tags when fetched? I will try to prioritize adding a fallback in our CI but for now the quickest would be just to push make sure tags are present. |
@@ -51,13 +126,16 @@ public OpenTracingWorkflowOutboundCallsInterceptor( | |||
@Override | |||
public <R> ActivityOutput<R> executeActivity(ActivityInput<R> input) { | |||
if (!WorkflowUnsafe.isReplaying()) { | |||
Span capturedSpan = tracer.scopeManager().activeSpan(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of futures in the interceptor that are not wrapped, I will need to go and wrap them, that is one big drawback with this approach, but given the other constraints I can't think of a better approach.
@Quinn-With-Two-Ns pushed tags |
This change allows the OpenTracing interceptor to transfer any active trace/span from
the point of invocation to the point of promise callback execution, thus preserving
the span within the callback.
Without this, spans become disjoint across Promise.thenCompose, due
to the nature of the deferring the execution of the .thenCompose to a callback thread.
Fixes #1962
Checklist
Closes Tracing context does not propagate into .thenCompose #1962
How was this tested:
A unit test was developed first to confirm the issue. The solution was iterated over until the unit test passed satisfactorily. The unit-test is included in the MR for inclusion with the code-base
Any docs updates needed?
No.