From 26a551d972ecad3e5fec275113f47d568a3e59c9 Mon Sep 17 00:00:00 2001 From: Simon Meers Date: Thu, 26 Mar 2026 13:15:28 +1100 Subject: [PATCH 1/2] fix(celery): coerce timelimit values to strings in span attributes 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 #2022 --- .../src/opentelemetry/instrumentation/celery/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py index c6bd7b9d86..6b33b58832 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py +++ b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py @@ -76,7 +76,7 @@ def set_attributes_from_context(span, context): if value in [(None, None), [None, None]]: continue if None in value: - value = ["" if tl is None else tl for tl in value] + value = ["" if tl is None else str(tl) for tl in value] # Skip `retries` if it's value is `0` if key == "retries" and value == 0: From ebf6c4f2a7d26ac8c4d9f4907d65a02988444a04 Mon Sep 17 00:00:00 2001 From: Simon Meers Date: Fri, 27 Mar 2026 10:11:13 +1100 Subject: [PATCH 2/2] Add CHANGELOG entry for timelimit fix --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c9c67be4b..93e31cfd63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- `opentelemetry-instrumentation-celery`: Coerce timelimit values to strings in `set_attributes_from_context()` to prevent mixed-type span attribute warning + ([#4361](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4361)) - `opentelemetry-docker-tests`: Replace deprecated `SpanAttributes` from `opentelemetry.semconv.trace` with `opentelemetry.semconv._incubating.attributes` ([#4339](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4339)) - `opentelemetry-instrumentation-confluent-kafka`: Skip `recv` span creation when `poll()` returns no message or `consume()` returns an empty list, avoiding empty spans on idle polls