Span ends prematurely on context cancellation in OpenTelemetry SDK
25.5K reputation · 01 Dec 2022, 12:45 UTC
When a request context is cancelled while an OpenTelemetry span is still active, the SDK is expected to end the span, but the exact moment of span completion relative to the cancellation signal varies between language implementations.
The OpenTelemetry Specification defines cancellation propagation but does not prescribe how instrumentation should record partially completed work, leaving it to each SDK to decide whether to keep or discard attributes set after cancellation.
Goal: determine whether the span’s end time aligns with context cancellation and whether any attributes added after the cancellation point are retained or dropped.
What guarantees does the SDK provide about span termination timing?
Which attributes, if any, are omitted when a span is cut short by cancellation?
How can users observe or configure this behavior consistently across different language SDKs?