Skip to content

Stop automatically setting OpenTelemetry span status to OK - #1640

Merged
shakuzen merged 1 commit into
mainfrom
gh-1634-otel-span-status
Nov 2, 2026
Merged

shakuzen merged 1 commit into
mainfrom
gh-1634-otel-span-status

Conversation

@shakuzen

@shakuzen shakuzen commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Successful spans currently end with either OK or UNSET depending on whether their OpenTelemetry delegate implements ReadableSpan. Stop assigning OK when ending regular, timestamped, and scoped spans, following the OpenTelemetry guidance to leave status unset unless there is an error. This also removes the toSpanData() snapshots used to inspect status before ending spans.

Spans that previously received an automatic OK now remain UNSET. Explicitly assigned statuses and error recording are preserved. Regression coverage checks all three ending paths with UNSET, OK, and ERROR, and consistent status for a parent and children created through nextSpan(parent) and spanBuilder().

Closes #1634

Benchmark results

Compared cbd72e2a (before) with eec7f7b1 (after).

Each operation creates and ends one recording span; exporter overhead is excluded.

Latency entries are the mean of three independent JVM fork means, followed by the observed min–max of those fork means in parentheses. These ranges show variation across forks; they are not confidence intervals. Allocation ranges also show variation across forks.

Operation Before ns/op After ns/op Before B/op After B/op
Regular span 112.8 (107.7–115.9) 102.5 (97.3–106.5) 456 456
Explicit end timestamp 110.0 (106.5–115.5) 99.5 (97.4–100.6) 456 456
Scoped span 115.2 (105.5–121.1) 102.3 (100.7–103.7) 488 488
One tag and one event 164.6 (157.2–176.5) 147.4 (145.5–151.0) 1,184–1,200 1,040
Builder child with explicit parent (control) 89.8 (87.7–93.3) 88.4 (86.5–89.8) 592 592

The affected recording paths take about 9–11% less time. The tag-and-event case saves 144–160 B/op by eliminating the pre-end snapshot (toSpanData()) path; empty spans show no allocation change. The wrapped builder-child control already skipped status inspection and shows no clear timing improvement. Non-recording spans also show no allocation change; their small timing differences are less conclusive. These measurements describe span creation and completion.

Signed-off-by: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com>
@shakuzen shakuzen added this to the 1.8.0-RC2 milestone Nov 2, 2026
@shakuzen shakuzen added module: bridge-otel enhancement New feature or request labels Nov 2, 2026
@shakuzen
shakuzen merged commit 5885460 into main Nov 2, 2026
7 checks passed
@shakuzen
shakuzen deleted the gh-1634-otel-span-status branch November 2, 2026 12:49
shakuzen added a commit that referenced this pull request Nov 2, 2026
Signed-off-by: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com>
shakuzen added a commit that referenced this pull request Nov 4, 2026
Signed-off-by: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTel spans should not set the status code to Ok

1 participant