-
Notifications
You must be signed in to change notification settings - Fork 148
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
Tracing support improvements #1819
Changes from all commits
97561e8
6e15b18
47d1002
acc4296
ff21f0a
16fdb02
74028eb
1a44c22
a69f5be
172cf89
aa24cb9
b9744df
412552f
9f1d16f
2e02ef9
c6dc546
355c613
8fb166f
1078bf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,7 @@ public WorkflowOutput execute(WorkflowInput input) { | |
Workflow.getInfo().getRunId(), | ||
rootSpanContext) | ||
.start(); | ||
try (Scope scope = tracer.scopeManager().activate(workflowRunSpan)) { | ||
try (Scope ignored = tracer.scopeManager().activate(workflowRunSpan)) { | ||
return super.execute(input); | ||
} catch (Throwable t) { | ||
if (t instanceof DestroyWorkflowThreadError) { | ||
|
@@ -82,4 +82,83 @@ public WorkflowOutput execute(WorkflowInput input) { | |
workflowRunSpan.finish(); | ||
} | ||
} | ||
|
||
@Override | ||
public void handleSignal(SignalInput input) { | ||
Tracer tracer = options.getTracer(); | ||
SpanContext rootSpanContext = | ||
contextAccessor.readSpanContextFromHeader(input.getHeader(), tracer); | ||
Span workflowSignalSpan = | ||
spanFactory | ||
.createWorkflowHandleSignalSpan( | ||
tracer, | ||
input.getSignalName(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend, to match other SDKs, that workflow inbound signal, query, and update span names be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
Workflow.getInfo().getWorkflowId(), | ||
Workflow.getInfo().getRunId(), | ||
rootSpanContext) | ||
.start(); | ||
try (Scope ignored = tracer.scopeManager().activate(workflowSignalSpan)) { | ||
super.handleSignal(input); | ||
} catch (Throwable t) { | ||
if (t instanceof DestroyWorkflowThreadError) { | ||
spanFactory.logEviction(workflowSignalSpan); | ||
} else { | ||
spanFactory.logFail(workflowSignalSpan, t); | ||
} | ||
throw t; | ||
} finally { | ||
workflowSignalSpan.finish(); | ||
} | ||
} | ||
|
||
@Override | ||
public QueryOutput handleQuery(QueryInput input) { | ||
Tracer tracer = options.getTracer(); | ||
SpanContext rootSpanContext = | ||
contextAccessor.readSpanContextFromHeader(input.getHeader(), tracer); | ||
Span workflowQuerySpan = | ||
spanFactory | ||
.createWorkflowHandleQuerySpan(tracer, input.getQueryName(), rootSpanContext) | ||
.start(); | ||
try (Scope ignored = tracer.scopeManager().activate(workflowQuerySpan)) { | ||
return super.handleQuery(input); | ||
} catch (Throwable t) { | ||
if (t instanceof DestroyWorkflowThreadError) { | ||
spanFactory.logEviction(workflowQuerySpan); | ||
} else { | ||
spanFactory.logFail(workflowQuerySpan, t); | ||
} | ||
throw t; | ||
} finally { | ||
workflowQuerySpan.finish(); | ||
} | ||
} | ||
|
||
@Override | ||
public UpdateOutput executeUpdate(UpdateInput input) { | ||
Tracer tracer = options.getTracer(); | ||
SpanContext rootSpanContext = | ||
contextAccessor.readSpanContextFromHeader(input.getHeader(), tracer); | ||
Span workflowSignalSpan = | ||
spanFactory | ||
.createWorkflowExecuteUpdateSpan( | ||
tracer, | ||
input.getUpdateName(), | ||
Workflow.getInfo().getWorkflowId(), | ||
Workflow.getInfo().getRunId(), | ||
rootSpanContext) | ||
.start(); | ||
try (Scope ignored = tracer.scopeManager().activate(workflowSignalSpan)) { | ||
return super.executeUpdate(input); | ||
} catch (Throwable t) { | ||
if (t instanceof DestroyWorkflowThreadError) { | ||
spanFactory.logEviction(workflowSignalSpan); | ||
} else { | ||
spanFactory.logFail(workflowSignalSpan, t); | ||
} | ||
throw t; | ||
} finally { | ||
workflowSignalSpan.finish(); | ||
} | ||
} | ||
} |
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.
In our other SDKs, query spans also have workflow ID and run ID.
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.
The problem here is that
handleQuery
is not executed within a workflow thread, leading to non-deterministic errors.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.
To confirm, are you saying change this to the above errors?
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.
Yes
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.
I see, you are not setting the workflow ID and run ID on
HANDLE_QUERY
. You should set those the same way you do forHANDLE_SIGNAL
.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.
I'm not sure that a span without these tags is ok, but I'll let y'all decide
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.
Well the options are either no span or a span without those tags. I have no preference.
Regardless of which we go with we will need to open an issue to address this when we fix
getInfo
in query handlers , but I don't think that should block this PR.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.
Concur, will let you make the call on tagless span vs no span. I don't have a super-strong opinion here.
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.
I believe it would be better to have a tagless span since the span itself is useful for tracing.
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.
Works for me