opentelemetry-instrumentation-celery: don't detach a None token#2927
Merged
lzchen merged 4 commits intoopen-telemetry:mainfrom Oct 28, 2024
Merged
opentelemetry-instrumentation-celery: don't detach a None token#2927lzchen merged 4 commits intoopen-telemetry:mainfrom
lzchen merged 4 commits intoopen-telemetry:mainfrom
Conversation
Without the fix we have this in stdout:
[2024-10-28 12:14:18,868: ERROR/MainProcess] Failed to detach context
Traceback (most recent call last):
File "/home/rm/src/opentelemetry-python-contrib/.tox/py310-test-instrumentation-celery-1/lib/python3.10/site-packages/opentelemetry/context/__init__.py", line 152, in detach
_RUNTIME_CONTEXT.detach(token)
File "/home/rm/src/opentelemetry-python-contrib/.tox/py310-test-instrumentation-celery-1/lib/python3.10/site-packages/opentelemetry/context/contextvars_context.py", line 50, in detach
self._current_context.reset(token) # type: ignore
TypeError: expected an instance of Token, got None
9b16dcd to
c07fabe
Compare
lzchen
approved these changes
Oct 28, 2024
xrmx
added a commit
to xrmx/opentelemetry-python-contrib
that referenced
this pull request
Jan 24, 2025
GareArc
added a commit
to langgenius/dify
that referenced
this pull request
Mar 2, 2026
Upgrade OTEL packages from 0.48b0/1.27.0 to 0.49b0/1.28.0 to fix "Failed to detach context" error. Root cause: opentelemetry-instrumentation-celery 0.48b0 and opentelemetry-instrumentation-flask 0.48b0 pass None tokens to context.detach(), causing TypeError. Fixed upstream in 0.49b0 via PR #2927. Changes: - opentelemetry-* packages: 0.48b0 → 0.49b0 (instrumentation) / 1.27.0 → 1.28.0 (SDK/API) - protobuf: 4.25.8 → 5.29.6 (required by OTEL 1.28.0) - google-api-core: 2.18.0 → >=2.19.1 (protobuf 5.x support) - google-auth: 2.29.0 → >=2.47.0 (required by google-cloud-aiplatform 1.123+) - google-cloud-aiplatform: 1.49.0 → >=1.123.0 (google-cloud-storage 3.x support) - googleapis-common-protos: 1.63.0 → >=1.65.0 (protobuf 5.x support) - google-cloud-storage: 2.16.0 → >=3.0.0 (protobuf 5.x support) - httpx: ~=0.27.0 → ~=0.28.0 (required by google-genai 1.37+) Testing: All 26 OTEL unit tests pass. Refs: - open-telemetry/opentelemetry-python#4163 - open-telemetry/opentelemetry-python-contrib#2855 - open-telemetry/opentelemetry-python-contrib#2927
GareArc
added a commit
to langgenius/dify
that referenced
this pull request
Mar 2, 2026
Upgrade OTEL packages from 0.48b0/1.27.0 to 0.49b0/1.28.0 to fix "Failed to detach context" error. Root cause: opentelemetry-instrumentation-celery 0.48b0 and opentelemetry-instrumentation-flask 0.48b0 pass None tokens to context.detach(), causing TypeError. Fixed upstream in 0.49b0 via PR #2927. Changes: - opentelemetry-* packages: 0.48b0 → 0.49b0 (instrumentation) / 1.27.0 → 1.28.0 (SDK/API) - protobuf: 4.25.8 → 5.29.6 (required by OTEL 1.28.0) - google-api-core: 2.18.0 → >=2.19.1 (protobuf 5.x support) - google-auth: 2.29.0 → >=2.47.0 (required by google-cloud-aiplatform 1.123+) - google-cloud-aiplatform: 1.49.0 → >=1.123.0 (google-cloud-storage 3.x support) - googleapis-common-protos: 1.63.0 → >=1.65.0 (protobuf 5.x support) - google-cloud-storage: 2.16.0 → >=3.0.0 (protobuf 5.x support) - httpx: ~=0.27.0 → ~=0.28.0 (required by google-genai 1.37+) Testing: All 26 OTEL unit tests pass. Refs: - open-telemetry/opentelemetry-python#4163 - open-telemetry/opentelemetry-python-contrib#2855 - open-telemetry/opentelemetry-python-contrib#2927
GareArc
added a commit
to langgenius/dify
that referenced
this pull request
Mar 2, 2026
Upgrade OTEL packages from 0.48b0/1.27.0 to 0.49b0/1.28.0 to fix "Failed to detach context" error. Root cause: opentelemetry-instrumentation-celery 0.48b0 and opentelemetry-instrumentation-flask 0.48b0 pass None tokens to context.detach(), causing TypeError. Fixed upstream in 0.49b0 via PR #2927. Changes: - opentelemetry-* packages: 0.48b0 → 0.49b0 (instrumentation) / 1.27.0 → 1.28.0 (SDK/API) - protobuf: 4.25.8 → 5.29.6 (required by OTEL 1.28.0) - google-api-core: 2.18.0 → >=2.19.1 (protobuf 5.x support) - google-auth: 2.29.0 → >=2.47.0 (required by google-cloud-aiplatform 1.123+) - google-cloud-aiplatform: 1.49.0 → >=1.123.0 (google-cloud-storage 3.x support) - googleapis-common-protos: 1.63.0 → >=1.65.0 (protobuf 5.x support) - google-cloud-storage: 2.16.0 → >=3.0.0 (protobuf 5.x support) - httpx: ~=0.27.0 → ~=0.28.0 (required by google-genai 1.37+) Testing: All 26 OTEL unit tests pass. Refs: - open-telemetry/opentelemetry-python#4163 - open-telemetry/opentelemetry-python-contrib#2855 - open-telemetry/opentelemetry-python-contrib#2927
GareArc
added a commit
to langgenius/dify
that referenced
this pull request
Mar 2, 2026
Upgrade OTEL packages from 0.48b0/1.27.0 to 0.49b0/1.28.0 to fix "Failed to detach context" error. Root cause: opentelemetry-instrumentation-celery 0.48b0 and opentelemetry-instrumentation-flask 0.48b0 pass None tokens to context.detach(), causing TypeError. Fixed upstream in 0.49b0 via PR #2927. Changes: - opentelemetry-* packages: 0.48b0 → 0.49b0 (instrumentation) / 1.27.0 → 1.28.0 (SDK/API) - protobuf: 4.25.8 → 5.29.6 (required by OTEL 1.28.0) - google-api-core: 2.18.0 → >=2.19.1 (protobuf 5.x support) - google-auth: 2.29.0 → >=2.47.0 (required by google-cloud-aiplatform 1.123+) - google-cloud-aiplatform: 1.49.0 → >=1.123.0 (google-cloud-storage 3.x support) - googleapis-common-protos: 1.63.0 → >=1.65.0 (protobuf 5.x support) - google-cloud-storage: 2.16.0 → >=3.0.0 (protobuf 5.x support) - httpx: ~=0.27.0 → ~=0.28.0 (required by google-genai 1.37+) Testing: All 26 OTEL unit tests pass. Refs: - open-telemetry/opentelemetry-python#4163 - open-telemetry/opentelemetry-python-contrib#2855 - open-telemetry/opentelemetry-python-contrib#2927
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Don't detach a None token in postrun.
Avoids this in celery logs:
Since celery catches everything this does not change anything in practice. I've added a test that exercise the error but I have no clue on how to get celery stdout. I've tested that with
pytest -swe don't get the message.Closes #2855
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.