Skip to content

Export OpenTelemetry spans for rejected updates and failed queries - #2057

Open
parbhatkapila4 wants to merge 1 commit into
temporalio:mainfrom
parbhatkapila4:fix/otel-readonly-spans
Open

parbhatkapila4 wants to merge 1 commit into
temporalio:mainfrom
parbhatkapila4:fix/otel-readonly-spans

Conversation

@parbhatkapila4

Copy link
Copy Markdown
Contributor

What was changed

_ReplaySafeSpan.end() skips ending an in-workflow span that recorded an exception that isn't a workflow failure exception. That avoids a duplicate span on every retried workflow task. But exceptions from update validators and query handlers never fail the workflow task: they only reject the update or fail the query. So with OpenTelemetryPlugin(add_temporal_spans=True), the worker-side ValidateUpdate span of a rejected update and the HandleQuery span of a failed query were never ended or exported. The client spans showed up with no worker child.

Queries and update validators run in read-only mode, so the skip now only applies when workflow.unsafe.is_read_only() is false.

How was this tested

Added test_otel_tracing_rejected_update_and_failed_query to test_opentelemetry_plugin.py. It sends an update the validator rejects, a query that raises, and a valid update, then checks the span hierarchy and that the two failed spans have ERROR status. On main, the ValidateUpdate span of the rejected update and the HandleQuery span are missing. With the fix, the test passes, and the rest of tests/contrib/opentelemetry passes the same as on main.

@parbhatkapila4
parbhatkapila4 requested a review from a team as a code owner October 31, 2026 10:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant