Skip to content

fix(celery): coerce timelimit values to strings in span attributes#4361

Open
DrMeers wants to merge 2 commits intoopen-telemetry:mainfrom
DrMeers:fix/celery-timelimit-mixed-types
Open

fix(celery): coerce timelimit values to strings in span attributes#4361
DrMeers wants to merge 2 commits intoopen-telemetry:mainfrom
DrMeers:fix/celery-timelimit-mixed-types

Conversation

@DrMeers
Copy link
Copy Markdown

@DrMeers DrMeers commented Mar 26, 2026

Description

When only one of the two Celery time limits is set (e.g. soft_time_limit=42 but no time_limit), set_attributes_from_context() replaces None with "" but leaves the integer as-is, producing a mixed-type list ["", 42]. This triggers an OTel mixed-type attribute warning.

The fix coerces all values in the timelimit tuple to strings.

Fixes #2022

Type of change

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

How Has This Been Tested?

  • Verified the fix resolves the mixed-type warning in a production Celery worker

Does This PR Require a Core Repo Change?

  • No.

Checklist:

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

When only one of the two time limits is set (e.g. soft_time_limit=42
but no time_limit), the None replacement produced a mixed-type list
["", 42] which triggers an OTel mixed-type attribute warning. Coerce
all values to strings for consistency.

See open-telemetry#2022
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 26, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@DrMeers
Copy link
Copy Markdown
Author

DrMeers commented Mar 26, 2026

EasyCLA signed as per #4360 (comment)

@tammy-baylis-swi tammy-baylis-swi moved this to Ready for review in Python PR digest Mar 26, 2026
@DrMeers DrMeers requested a review from a team as a code owner March 26, 2026 23:11
Copy link
Copy Markdown
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

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

Nice catch

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

Labels

None yet

Projects

Status: Ready for review

2 participants