-
Notifications
You must be signed in to change notification settings - Fork 805
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
base: main
Are you sure you want to change the base?
Changes from 9 commits
a897a95
0bb7870
8dc6ea7
90666fc
73d3310
9a33772
16e04ef
2a2750e
717f584
1a116f9
ceba850
97f7109
11250a8
c344be7
ce120b8
aef2872
91ebd51
a5a51f7
93499b1
d7a3444
17a9f5c
dd8ebdd
2c93115
cba8dfa
da6abc9
06dba64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||
|
||
| ) | ||
| 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" | ||
|
|
||
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.pyThere 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.
Thanks for the review, I will apply your suggestion asap.
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.
Hello @xrmx I applied your suggestion