Do not attempt to end a span if ctx wasn't found (#59)

* Do not attempt to end a span if ctx is undefined
This commit is contained in:
Bryan Naegele 2022-01-05 10:23:10 -07:00 committed by GitHub
parent f281a90f3c
commit fb2595d2fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## Unreleased
### Fixes
* Do not attempt to end a span with if the ctx is undefined.
## 1.0.0-beta.7
### Changes

View File

@ -56,10 +56,15 @@ set_current_telemetry_span(TracerId, EventMetadata) ->
-spec end_telemetry_span(atom(), telemetry:event_metadata()) -> ok.
end_telemetry_span(TracerId, EventMetadata) ->
{ParentCtx, Ctx} = pop_ctx(TracerId, EventMetadata),
otel_span:end_span(Ctx),
otel_tracer:set_current_span(ParentCtx),
ok.
Ctx = pop_ctx(TracerId, EventMetadata),
case Ctx of
{ParentCtx, SpanCtx} ->
otel_span:end_span(SpanCtx),
otel_tracer:set_current_span(ParentCtx),
ok;
undefined ->
ok
end.
-spec store_ctx(ctx_set(), atom(), telemetry:event_metadata()) -> ok.
store_ctx(SpanCtxSet, TracerId, EventMetadata) ->