-
Notifications
You must be signed in to change notification settings - Fork 774
Update celery instrumentation to follow semantic conventions #3712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mriamah
wants to merge
9
commits into
open-telemetry:main
Choose a base branch
from
mriamah:semconv-celery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−21
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a897a95
Update celery instrumentation to follow semantic conventions
mriamah 0bb7870
Update changelog
mriamah 8dc6ea7
Update celery instrumentation to follow semantic conventions
mriamah 90666fc
Update celery instrumention tests to follow semantic conventions
mriamah 73d3310
Update celery instrumentation to use latest semantic conventions sche…
mriamah 9a33772
Update changelog
mriamah 16e04ef
Merge branch 'main' of github.com:open-telemetry/opentelemetry-python…
mriamah 2a2750e
Merge branch 'main' into semconv-celery
mriamah 717f584
Merge branch 'main' into semconv-celery
mriamah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,9 @@ | |
from celery import registry # pylint: disable=no-name-in-module | ||
from celery.app.task import Task | ||
|
||
from opentelemetry.semconv.trace import SpanAttributes | ||
from opentelemetry.semconv._incubating.attributes import ( | ||
messaging_attributes as SpanAttributes, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes it harder when grepping for the old SpanAttributes module users, please convert the callers from SpanAttributes to messaging_attributes |
||
) | ||
from opentelemetry.trace import Span | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -92,7 +94,7 @@ def set_attributes_from_context(span, context): | |
|
||
if routing_key is not None: | ||
span.set_attribute( | ||
SpanAttributes.MESSAGING_DESTINATION, routing_key | ||
SpanAttributes.MESSAGING_DESTINATION_NAME, routing_key | ||
) | ||
|
||
value = str(value) | ||
|
@@ -101,14 +103,13 @@ def set_attributes_from_context(span, context): | |
attribute_name = SpanAttributes.MESSAGING_MESSAGE_ID | ||
|
||
elif key == "correlation_id": | ||
attribute_name = SpanAttributes.MESSAGING_CONVERSATION_ID | ||
attribute_name = SpanAttributes.MESSAGING_MESSAGE_CONVERSATION_ID | ||
|
||
elif key == "routing_key": | ||
attribute_name = SpanAttributes.MESSAGING_DESTINATION | ||
attribute_name = SpanAttributes.MESSAGING_DESTINATION_NAME | ||
|
||
# according to https://docs.celeryproject.org/en/stable/userguide/routing.html#exchange-types | ||
elif key == "declare": | ||
attribute_name = SpanAttributes.MESSAGING_DESTINATION_KIND | ||
for declare in value: | ||
if declare.exchange.type == "direct": | ||
value = "queue" | ||
|
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semconvs suggest to make the move to a newer semconv opt-in via
OTEL_SEMCONV_STABILITY_OPT_IN
, seehttps://opentelemetry.io/docs/specs/semconv/messaging/
We have already some tooling in place for handling these in
opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py