Ensure we handle the scenario the payment service code expects there to be an active span but finds none#2129
Conversation
|
@pichlermarc I would love to hear your opinion here |
|
I understand if the SDK is disabled, the service should not throw an error which is what #2124 discusses. I struggle to understand in what scenario we need to start a trace if one does not exists. |
pichlermarc
left a comment
There was a problem hiding this comment.
I struggle to understand in what scenario we need to start a trace if one does not exists.
I agree - in my opinion the way to address the problem of the crashing app would be either to:
- optional chain on the span object obtained via
getActiveSpan()wherever it's used- example:
span.setAttributes({...})->span?.setAttributes({...})
- example:
- create and end an internal span always no matter if a trace was already started or not to which you can attach any attributes and errors you like, while retaining semantics for the grpc span that's likely being modified here (since that one is strictly supposed to follow the gRPC semconv anyway and modifying error status may interfere with that).
|
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
|
@pichlermarc this is the issue I've mentioned to you during KubeCon. |
|
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
|
@julianocosta89 - sorry for the delay. This looks good. |
…to be an active span but finds none (open-telemetry#2129) * Ensure we handle the scenario where there is currently no active span for e.g. open-telemetry#2124 * Mark this new span as active * incorporate review comments * revert var def change --------- Co-authored-by: Juliano Costa <julianocosta89@outlook.com> Co-authored-by: Pierre Tessier <pierre@pierretessier.com>
I am proposing a very minor change to handle when auto-instrumentation is disabled( similar to #2124 ) for the payment service. In this scenario, an exception is raised but I would expect it to be handled gracefully.
Changes
Added some very simple logic to check if the current active span is undefined, if it is we create a new span & mark this as the active span.
Merge Requirements
For new features contributions, please make sure you have completed the following
essential items:
CHANGELOG.mdupdated to document new feature additionsMaintainers will not merge until the above have been completed. If you're unsure
which docs need to be changed ping the
@open-telemetry/demo-approvers.