Skip to content

Add temporalNamespace tag to tracing spans - #1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1794511169-temporal-namespace-span-tag
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1794511169-temporal-namespace-span-tag

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

Implements temporalio/features#592 for Python. Every span created by temporalio.contrib.opentelemetry now has a temporalNamespace attribute, next to the existing temporalWorkflowID / temporalRunID. This applies to both TracingInterceptor and the experimental OpenTelemetryInterceptor / OpenTelemetryPlugin (add_temporal_spans=True). The same change is going into the other SDKs in parallel.

Where the value comes from:

Spans Namespace source
Client: StartWorkflow, SignalWithStartWorkflow, QueryWorkflow, SignalWorkflow, StartWorkflowUpdate, StartUpdateWithStartWorkflow, StartActivity (standalone) Client.namespace
Workflow: RunWorkflow, HandleSignal, HandleQuery, ValidateUpdate, HandleUpdate, CompleteWorkflow, StartActivity (incl. local), StartChildWorkflow, SignalChildWorkflow, SignalExternalWorkflow, StartNexusOperation, SignalWithStartWorkflow, plus workflow.completed_span(...) workflow.info().namespace
Activity: RunActivity activity.info().namespace
Nexus: RunStartNexusOperationHandler, RunCancelNexusOperationHandler nexus.info().namespace

Client outbound interceptors are never handed the Client. So _client_namespace(next) walks the next chain down to the SDK's terminal _ClientImpl and reads client.namespace once, at interceptor construction. Interceptors layered under the tracing one still work, and the test covers that case. If no client is found, the attribute is left off and nothing errors.

SignalExternalWorkflow gets the workflow's own namespace, not input.namespace (the target's). That keeps the rule "the namespace the operation runs in" the same for every span.

Python tag names are hardcoded literals with no configuration option, so this PR adds no new option. The changelog fragment is changelog/added/namespace-tagged-breadcrumbs.md.

Validation

  • poe test -s tests/contrib/opentelemetry → 93 passed
  • poe test -s tests/contrib/opentelemetry --workflow-environment time-skipping-v2 → 93 passed
  • poe lint (ruff import check, ruff format --check, pyright, mypy, basedpyright, pydocstyle) → all passed
  • Negative check: I reverted only the two interceptor source files and ran the namespace-related tests → 7 failed, 1 passed. The one that passed is an unmodified test.

New and extended tests:

  • assert_namespace_on_spans helper, now asserted in test_opentelemetry_tracing, test_opentelemetry_tracing_update_with_start, test_opentelemetry_tracing_nexus, test_opentelemetry_standalone_activity_tracing and the plugin's test_opentelemetry_comprehensive_tracing (only spans created by the interceptor; user-created spans are untouched).
  • test_opentelemetry_client_span_namespace_from_client[tracing|otel] uses a non-default client namespace with a passthrough client interceptor underneath. It checks that the client span carries that namespace. The namespace doesn't exist, so the RPC fails after the span is recorded and no namespace has to be registered.

Not run: the time-skipping-v1 (Java test server) environment, and the full repo test suite outside tests/contrib/opentelemetry.

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/c98adab36c654fad81d542846271b694
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/c98adab36c654fad81d542846271b694?variant=devin
Requested by: @freyatcog


🟢 Devin Review found nothing to fix · View findings

Devin Review

Co-Authored-By: Jeffrey Liu <jeffrey.liu@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Custom reviewers

  • 🧪 Test reviewer: no findings · View
  • 🧪 Test 2 reviewer: no findings · View

Devin Review

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