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 # Changelog
## Unreleased
### Fixes
* Do not attempt to end a span with if the ctx is undefined.
## 1.0.0-beta.7 ## 1.0.0-beta.7
### Changes ### Changes

View File

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