Skip to content

fix(celery): populate origin and hostname as distinct span attributes#4827

Open
ahmed5145 wants to merge 2 commits into
open-telemetry:mainfrom
ahmed5145:fix/celery-hostname-origin-3096
Open

fix(celery): populate origin and hostname as distinct span attributes#4827
ahmed5145 wants to merge 2 commits into
open-telemetry:mainfrom
ahmed5145:fix/celery-hostname-origin-3096

Conversation

@ahmed5145

Copy link
Copy Markdown

Description

Celery's set_attributes_from_context aliased origin to hostname, so on
prefork workers the worker-thread origin (e.g. gen8@host) overwrote the real
worker hostname (e.g. celery@host) in the celery.hostname span attribute.
Metrics already used the correct hostname (task.request.hostname), so spans
and metrics disagreed. This drops the alias so celery.origin and
celery.hostname are emitted as distinct span attributes, matching the actual
Celery request fields.

Fixes #3096

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • tox -r -e py314-test-instrumentation-celery (30 passed) on Windows /
    Python 3.14 against core commit d9f34e7.
  • Extended test_set_attributes_from_context to assert that a context
    containing both origin and hostname sets celery.origin and
    celery.hostname to their own values independently.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added (extended test_set_attributes_from_context)
  • Documentation has been updated

@ahmed5145
ahmed5145 requested a review from a team as a code owner July 16, 2026 18:25
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 16, 2026

Copy link
Copy Markdown

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

  • ✅ login: ahmed5145 / name: Ahmed Mohamed (fd511b8)

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Celery.Hostname getting overridden by Celery.Origin

1 participant