Skip to content

Commit 8dc6ea7

Browse files
committed
Update celery instrumentation to follow semantic conventions
1 parent 0bb7870 commit 8dc6ea7

File tree

1 file changed

+6
-5
lines changed
  • instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery

1 file changed

+6
-5
lines changed

instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
from celery import registry # pylint: disable=no-name-in-module
2121
from celery.app.task import Task
2222

23-
from opentelemetry.semconv.trace import SpanAttributes
23+
from opentelemetry.semconv._incubating.attributes import (
24+
messaging_attributes as SpanAttributes,
25+
)
2426
from opentelemetry.trace import Span
2527

2628
if TYPE_CHECKING:
@@ -92,7 +94,7 @@ def set_attributes_from_context(span, context):
9294

9395
if routing_key is not None:
9496
span.set_attribute(
95-
SpanAttributes.MESSAGING_DESTINATION, routing_key
97+
SpanAttributes.MESSAGING_DESTINATION_NAME, routing_key
9698
)
9799

98100
value = str(value)
@@ -101,14 +103,13 @@ def set_attributes_from_context(span, context):
101103
attribute_name = SpanAttributes.MESSAGING_MESSAGE_ID
102104

103105
elif key == "correlation_id":
104-
attribute_name = SpanAttributes.MESSAGING_CONVERSATION_ID
106+
attribute_name = SpanAttributes.MESSAGING_MESSAGE_CONVERSATION_ID
105107

106108
elif key == "routing_key":
107-
attribute_name = SpanAttributes.MESSAGING_DESTINATION
109+
attribute_name = SpanAttributes.MESSAGING_DESTINATION_NAME
108110

109111
# according to https://docs.celeryproject.org/en/stable/userguide/routing.html#exchange-types
110112
elif key == "declare":
111-
attribute_name = SpanAttributes.MESSAGING_DESTINATION_KIND
112113
for declare in value:
113114
if declare.exchange.type == "direct":
114115
value = "queue"

0 commit comments

Comments
 (0)