-
Notifications
You must be signed in to change notification settings - Fork 369
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
Rack: Fix missing active trace #3420
Rack: Fix missing active trace #3420
Conversation
|
||
# When tracing and distributed tracing are both disabled, `.active_trace` will be `nil`, | ||
# Return a null object to continue operation | ||
request_trace = Tracing.active_trace || TraceOperation.new |
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 exception happens in the call to set_request_tags!
made in this method. Wouldn't it be better to expand the condition on line 72 to check if tracing is disabled, and if so, skip the remainder of the method?
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.
👋 @p-datadog , your suggested alternative will definitely also mitigate this error.
The reason for my change is because it follows the same null object pattern from our API .trace(..)
when invoke with a block (Yeah, it is kinda flawed that the blockless form only return a span_operation, hence the trace_operation is only accessible through .active_trace
)
I think the best solution for this would be to instrument with a block, this would by default yield null objects for both span_operation and trace_operation, that would made all those conditionals obsolete.
However, that is a much bigger change for this already messy instrumentation.
What does this PR do?
closes #3389
When
tracing
anddistributed_tracing
both disabled, The reference ofDatadog::Tracing.active_trace
in rackinstrumentation returns
nil
.Causing