Skip to content

Commit c4d1045

Browse files
iinuwalukebakken
authored andcommitted
Use const strings for OTel operation types
1 parent f71273b commit c4d1045

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs

+12-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public static class RabbitMQActivitySource
1616
internal const string MessageId = "messaging.message.id";
1717
internal const string MessageConversationId = "messaging.message.conversation_id";
1818
internal const string MessagingOperationType = "messaging.operation.type";
19+
internal const string MessagingOperationTypeSend = "send";
20+
internal const string MessagingOperationTypeProcess = "process";
21+
internal const string MessagingOperationTypeReceive = "receive";
1922
internal const string MessagingSystem = "messaging.system";
2023
internal const string MessagingDestination = "messaging.destination.name";
2124
internal const string MessagingDestinationRoutingKey = "messaging.rabbitmq.destination.routing_key";
@@ -63,14 +66,14 @@ public static class RabbitMQActivitySource
6366

6467
Activity? activity = linkedContext == default
6568
? s_publisherSource.StartRabbitMQActivity(
66-
UseRoutingKeyAsOperationName ? $"{routingKey} send" : "send",
69+
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend,
6770
ActivityKind.Producer)
6871
: s_publisherSource.StartLinkedRabbitMQActivity(
69-
UseRoutingKeyAsOperationName ? $"{routingKey} send" : "send",
72+
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend,
7073
ActivityKind.Producer, linkedContext);
7174
if (activity != null && activity.IsAllDataRequested)
7275
{
73-
PopulateMessagingTags("send", routingKey, exchange, 0, bodySize, activity);
76+
PopulateMessagingTags(MessagingOperationTypeSend, routingKey, exchange, 0, bodySize, activity);
7477
}
7578

7679
return activity;
@@ -85,12 +88,12 @@ public static class RabbitMQActivitySource
8588
}
8689

8790
Activity? activity = s_subscriberSource.StartRabbitMQActivity(
88-
UseRoutingKeyAsOperationName ? $"{queue} receive" : "receive",
91+
UseRoutingKeyAsOperationName ? $"{queue} {MessagingOperationTypeReceive}" : MessagingOperationTypeReceive,
8992
ActivityKind.Consumer);
9093
if (activity != null && activity.IsAllDataRequested)
9194
{
9295
activity
93-
.SetTag(MessagingOperationType, "receive")
96+
.SetTag(MessagingOperationType, MessagingOperationTypeReceive)
9497
.SetTag(MessagingDestination, "amq.default");
9598
}
9699

@@ -107,11 +110,11 @@ public static class RabbitMQActivitySource
107110

108111
// Extract the PropagationContext of the upstream parent from the message headers.
109112
Activity? activity = s_subscriberSource.StartLinkedRabbitMQActivity(
110-
UseRoutingKeyAsOperationName ? $"{routingKey} receive" : "receive", ActivityKind.Consumer,
113+
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeReceive}" : MessagingOperationTypeReceive, ActivityKind.Consumer,
111114
ContextExtractor(readOnlyBasicProperties));
112115
if (activity != null && activity.IsAllDataRequested)
113116
{
114-
PopulateMessagingTags("receive", routingKey, exchange, deliveryTag, readOnlyBasicProperties,
117+
PopulateMessagingTags(MessagingOperationTypeReceive, routingKey, exchange, deliveryTag, readOnlyBasicProperties,
115118
bodySize, activity);
116119
}
117120

@@ -128,11 +131,11 @@ public static class RabbitMQActivitySource
128131

129132
// Extract the PropagationContext of the upstream parent from the message headers.
130133
Activity? activity = s_subscriberSource.StartLinkedRabbitMQActivity(
131-
UseRoutingKeyAsOperationName ? $"{routingKey} process" : "process",
134+
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeProcess}" : MessagingOperationTypeProcess,
132135
ActivityKind.Consumer, ContextExtractor(basicProperties));
133136
if (activity != null && activity.IsAllDataRequested)
134137
{
135-
PopulateMessagingTags("process", routingKey, exchange,
138+
PopulateMessagingTags(MessagingOperationTypeProcess, routingKey, exchange,
136139
deliveryTag, basicProperties, bodySize, activity);
137140
}
138141

0 commit comments

Comments
 (0)