-
Notifications
You must be signed in to change notification settings - Fork 590
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
Change OTel attribute messaging.operation to messaging.operation.type #1716
Changes from all commits
3d708a8
f71273b
c4d1045
fe9ccbe
e2c246f
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 | ||||
---|---|---|---|---|---|---|
|
@@ -15,7 +15,10 @@ public static class RabbitMQActivitySource | |||||
// https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#messaging-attributes | ||||||
internal const string MessageId = "messaging.message.id"; | ||||||
internal const string MessageConversationId = "messaging.message.conversation_id"; | ||||||
internal const string MessagingOperation = "messaging.operation"; | ||||||
internal const string MessagingOperationType = "messaging.operation.type"; | ||||||
internal const string MessagingOperationTypeSend = "send"; | ||||||
internal const string MessagingOperationTypeProcess = "process"; | ||||||
internal const string MessagingOperationTypeReceive = "receive"; | ||||||
internal const string MessagingSystem = "messaging.system"; | ||||||
internal const string MessagingDestination = "messaging.destination.name"; | ||||||
internal const string MessagingDestinationRoutingKey = "messaging.rabbitmq.destination.routing_key"; | ||||||
|
@@ -63,14 +66,14 @@ public static class RabbitMQActivitySource | |||||
|
||||||
Activity? activity = linkedContext == default | ||||||
? s_publisherSource.StartRabbitMQActivity( | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} publish" : "publish", | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend, | ||||||
ActivityKind.Producer) | ||||||
: s_publisherSource.StartLinkedRabbitMQActivity( | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} publish" : "publish", | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend, | ||||||
ActivityKind.Producer, linkedContext); | ||||||
if (activity != null && activity.IsAllDataRequested) | ||||||
{ | ||||||
PopulateMessagingTags("publish", routingKey, exchange, 0, bodySize, activity); | ||||||
PopulateMessagingTags(MessagingOperationTypeSend, routingKey, exchange, 0, bodySize, activity); | ||||||
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. we'll need to set operation name too - it's required now. |
||||||
} | ||||||
|
||||||
return activity; | ||||||
|
@@ -85,12 +88,12 @@ public static class RabbitMQActivitySource | |||||
} | ||||||
|
||||||
Activity? activity = s_subscriberSource.StartRabbitMQActivity( | ||||||
UseRoutingKeyAsOperationName ? $"{queue} receive" : "receive", | ||||||
UseRoutingKeyAsOperationName ? $"{queue} {MessagingOperationTypeReceive}" : MessagingOperationTypeReceive, | ||||||
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. Is this activity created for See my comment on publish. Also, the order has changed - it's now |
||||||
ActivityKind.Consumer); | ||||||
if (activity != null && activity.IsAllDataRequested) | ||||||
{ | ||||||
activity | ||||||
.SetTag(MessagingOperation, "receive") | ||||||
.SetTag(MessagingOperationType, MessagingOperationTypeReceive) | ||||||
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.
Suggested change
|
||||||
.SetTag(MessagingDestination, "amq.default"); | ||||||
} | ||||||
|
||||||
|
@@ -107,11 +110,11 @@ public static class RabbitMQActivitySource | |||||
|
||||||
// Extract the PropagationContext of the upstream parent from the message headers. | ||||||
Activity? activity = s_subscriberSource.StartLinkedRabbitMQActivity( | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} receive" : "receive", ActivityKind.Consumer, | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeReceive}" : MessagingOperationTypeReceive, ActivityKind.Consumer, | ||||||
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. same here |
||||||
ContextExtractor(readOnlyBasicProperties)); | ||||||
if (activity != null && activity.IsAllDataRequested) | ||||||
{ | ||||||
PopulateMessagingTags("receive", routingKey, exchange, deliveryTag, readOnlyBasicProperties, | ||||||
PopulateMessagingTags(MessagingOperationTypeReceive, routingKey, exchange, deliveryTag, readOnlyBasicProperties, | ||||||
bodySize, activity); | ||||||
} | ||||||
|
||||||
|
@@ -128,11 +131,11 @@ public static class RabbitMQActivitySource | |||||
|
||||||
// Extract the PropagationContext of the upstream parent from the message headers. | ||||||
Activity? activity = s_subscriberSource.StartLinkedRabbitMQActivity( | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} deliver" : "deliver", | ||||||
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeProcess}" : MessagingOperationTypeProcess, | ||||||
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. this one is probably for |
||||||
ActivityKind.Consumer, ContextExtractor(basicProperties)); | ||||||
if (activity != null && activity.IsAllDataRequested) | ||||||
{ | ||||||
PopulateMessagingTags("deliver", routingKey, exchange, | ||||||
PopulateMessagingTags(MessagingOperationTypeProcess, routingKey, exchange, | ||||||
deliveryTag, basicProperties, bodySize, activity); | ||||||
} | ||||||
|
||||||
|
@@ -174,7 +177,7 @@ private static void PopulateMessagingTags(string operation, string routingKey, s | |||||
ulong deliveryTag, int bodySize, Activity activity) | ||||||
{ | ||||||
activity | ||||||
.SetTag(MessagingOperation, operation) | ||||||
.SetTag(MessagingOperationType, operation) | ||||||
.SetTag(MessagingDestination, string.IsNullOrEmpty(exchange) ? "amq.default" : exchange) | ||||||
.SetTag(MessagingDestinationRoutingKey, routingKey) | ||||||
.SetTag(MessagingBodySize, bodySize); | ||||||
|
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.
span name should be
{operation name} {destination}
- https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/messaging-spans.md#span-name.I.e.
publish
stays (as rabbit-friendly operation name), but the order has changed and should now bepublish {routingKey}
Or if you want to call it
basic_publish
instead ofpublish
or anything else (language-agnostic) - go for it - happy to update otel semconv with your preference.