Skip to content

Commit 4525c6d

Browse files
Merge pull request #1716 from iinuwa/fix/change-otel-attribute-name
Change OTel attribute messaging.operation to messaging.operation.type
2 parents 898c21f + e2c246f commit 4525c6d

File tree

4 files changed

+51
-15
lines changed

4 files changed

+51
-15
lines changed

CONTRIBUTING.md

+33
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,39 @@ Here's the recommended workflow:
7676
If what you are going to work on is a substantial change, please first
7777
ask the core team for their opinion on the [RabbitMQ users mailing list][rmq-users].
7878

79+
### Building Source
80+
81+
It is good practice to make sure you can build the project before making any
82+
changes to confirm that your development environment is set up correctly.
83+
Verifying that the tests pass is also a good practice (see
84+
[RUNNING_TESTS.md](/RUNNING_TESTS.md)).
85+
86+
All together, this looks like:
87+
88+
* Linux
89+
90+
```shell
91+
git clone --recurse-submodules https://github.com/rabbitmq/rabbitmq-dotnet-client
92+
cd rabbitmq-dotnet-client
93+
94+
# On any Linux distribution with Docker installed
95+
./.ci/ubuntu/gha-setup.sh toxiproxy pull
96+
97+
make build
98+
make test
99+
```
100+
101+
* Windows
102+
103+
Note that this will _NOT_ run toxiproxy tests.
104+
105+
```powershell
106+
git clone --recurse-submodules https://github.com/rabbitmq/rabbitmq-dotnet-client
107+
cd rabbitmq-dotnet-client
108+
.\.ci\windows\gha-setup.ps1 # On Windows. Note that this installs RabbitMQ
109+
.\build.ps1 -RunTests:$true
110+
```
111+
79112
### Running Tests
80113

81114
See [RUNNING_TESTS.md](/RUNNING_TESTS.md).

projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs

+14-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ public static class RabbitMQActivitySource
1515
// https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#messaging-attributes
1616
internal const string MessageId = "messaging.message.id";
1717
internal const string MessageConversationId = "messaging.message.conversation_id";
18-
internal const string MessagingOperation = "messaging.operation";
18+
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} publish" : "publish",
69+
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend,
6770
ActivityKind.Producer)
6871
: s_publisherSource.StartLinkedRabbitMQActivity(
69-
UseRoutingKeyAsOperationName ? $"{routingKey} publish" : "publish",
72+
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend,
7073
ActivityKind.Producer, linkedContext);
7174
if (activity != null && activity.IsAllDataRequested)
7275
{
73-
PopulateMessagingTags("publish", 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(MessagingOperation, "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} deliver" : "deliver",
134+
UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeProcess}" : MessagingOperationTypeProcess,
132135
ActivityKind.Consumer, ContextExtractor(basicProperties));
133136
if (activity != null && activity.IsAllDataRequested)
134137
{
135-
PopulateMessagingTags("deliver", routingKey, exchange,
138+
PopulateMessagingTags(MessagingOperationTypeProcess, routingKey, exchange,
136139
deliveryTag, basicProperties, bodySize, activity);
137140
}
138141

@@ -174,7 +177,7 @@ private static void PopulateMessagingTags(string operation, string routingKey, s
174177
ulong deliveryTag, int bodySize, Activity activity)
175178
{
176179
activity
177-
.SetTag(MessagingOperation, operation)
180+
.SetTag(MessagingOperationType, operation)
178181
.SetTag(MessagingDestination, string.IsNullOrEmpty(exchange) ? "amq.default" : exchange)
179182
.SetTag(MessagingDestinationRoutingKey, routingKey)
180183
.SetTag(MessagingBodySize, bodySize);

projects/Test/SequentialIntegration/TestActivitySource.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ private static ActivityListener StartActivityListener(List<Activity> activities)
402402
private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueName,
403403
List<Activity> activityList, bool isDeliver = false)
404404
{
405-
string childName = isDeliver ? "deliver" : "receive";
405+
string childName = isDeliver ? "process" : "receive";
406406
Activity[] activities = activityList.ToArray();
407407
Assert.NotEmpty(activities);
408408

@@ -418,7 +418,7 @@ private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueN
418418
}
419419

420420
Activity sendActivity = activities.First(x =>
421-
x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} publish" : "publish") &&
421+
x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} send" : "send") &&
422422
x.GetTagItem(RabbitMQActivitySource.MessagingDestinationRoutingKey) is string routingKeyTag &&
423423
routingKeyTag == $"{queueName}");
424424
Activity receiveActivity = activities.Single(x =>

projects/Test/SequentialIntegration/TestOpenTelemetry.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public async Task TestPublisherAndBasicGetActivityTags(bool useRoutingKeyAsOpera
342342
private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueName,
343343
List<Activity> activityList, bool isDeliver = false, string baggageGuid = null)
344344
{
345-
string childName = isDeliver ? "deliver" : "receive";
345+
string childName = isDeliver ? "process" : "receive";
346346
Activity[] activities = activityList.ToArray();
347347
Assert.NotEmpty(activities);
348348
foreach (var item in activities)
@@ -354,7 +354,7 @@ private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueN
354354
}
355355

356356
Activity sendActivity = activities.First(x =>
357-
x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} publish" : "publish") &&
357+
x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} send" : "send") &&
358358
x.GetTagItem(RabbitMQActivitySource.MessagingDestinationRoutingKey) is string routingKeyTag &&
359359
routingKeyTag == $"{queueName}");
360360
Activity receiveActivity = activities.Single(x =>

0 commit comments

Comments
 (0)