Skip to content

opentelemetry-instrumentation-celery: normalize Kombu routing span attributes - #5105

Open
EM-Tim wants to merge 1 commit into
open-telemetry:mainfrom
EM-Tim:fix/celery-kombu-exchange-attributes
Open

EM-Tim wants to merge 1 commit into
open-telemetry:mainfrom
EM-Tim:fix/celery-kombu-exchange-attributes

Conversation

@EM-Tim

@EM-Tim EM-Tim commented Sep 25, 2026 •

Copy link
Copy Markdown

Description

Kombu routing objects can reach Celery publish signals and be passed directly to span.set_attribute, producing an invalid type warning for celery.exchange. Normalize known Kombu Exchange and Queue values to their .name, and skip names that are empty. Normal string names, valid OpenTelemetry primitives, and homogeneous sequences remain unchanged; unknown objects are not generically stringified.

The custom-routing report is in #1195. Source inspection of Celery 5.6.3 found an additional native delayed-delivery path: it requires quorum queues to be detected, a non-direct selected exchange, and a countdown/ETA that resolves to a positive delay. Under those conditions Celery can construct Exchange("celery_delayed_27", type="topic") and pass it through before_task_publish. This is source-level evidence only; the delayed-delivery trigger has not been reproduced with RabbitMQ or in deployed services.

Related earlier proposals #1196 and #4393 closed without merging. This change uses Kombu public types and avoids generic stringification; thanks to Heatstealer for the earlier work on this issue.

Fixes #1195

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update required

How Has This Been Tested?

Local checks on the current single-commit PR head (10d5261):

  • uv tool run --from tox tox -e py312-test-instrumentation-celery — 34 passed, 31 dependency/Celery deprecation warnings. This tox environment uses the repository-pinned Celery 5.3.6 and Kombu 5.3.5.
  • uv tool run --from tox tox -e lint-instrumentation-celery — pylint 10.00/10.
  • Ruff check and Ruff format check passed for all three changed Python files.
  • The strengthened empty-name regression test passes and asserts there are no opentelemetry.attributes warnings.
  • Public Exchange/Queue imports and .name checks passed with Celery 5.6.3 and Kombu 5.6.2.
  • Exchange-value and empty-name regression tests were observed failing before the corresponding fixes; the full package suite passes on this head.

The publish-signal regression dispatches Celery signals locally and does not require RabbitMQ. The native delayed-delivery path has not been reproduced against RabbitMQ or in production. GitHub Actions CI and changelog runs for this head are action_required with no jobs started (CI run, changelog run). The run-approval API requires repository admin rights, which this account does not have. Local test and lint results above are reproducible but are not GitHub-hosted checks. This PR remains a draft and no review was requested.

Does This PR Require a Core Repo Change?

  • Yes
  • No

Checklist

  • Followed the style guidelines
  • Changelog fragment added
  • Unit tests added
  • Documentation updated (not required)

@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@EM-Tim
EM-Tim force-pushed the fix/celery-kombu-exchange-attributes branch from 1d85ec9 to 10d5261 Compare September 25, 2026 20:49
@EM-Tim
EM-Tim marked this pull request as ready for review September 25, 2026 20:54
@EM-Tim
EM-Tim requested a review from a team as a code owner September 25, 2026 20:54
@EM-Tim EM-Tim changed the title Fix Celery span attributes for Kombu Exchange objects opentelemetry-instrumentation-celery: normalize Kombu routing span attributes Sep 26, 2026
@EM-Tim
EM-Tim force-pushed the fix/celery-kombu-exchange-attributes branch from 10d5261 to 3377320 Compare September 26, 2026 09:49
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-10-01 16:11 UTC

Merge when ready.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Normalize known Exchange and Queue names and skip empty names while preserving valid span attribute values.

Assisted-by: OpenCode (openai/gpt-6-luna-pro)
@EM-Tim
EM-Tim force-pushed the fix/celery-kombu-exchange-attributes branch from 3377320 to ac5eba2 Compare October 1, 2026 12:06

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

Status: Approved PRs

2 participants