From 3d708a8b118e5305be0aec060f4f83c7db07e489 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Wed, 30 Oct 2024 10:56:58 -0500 Subject: [PATCH 1/5] Change OTel attribute messaging.operation to messaging.operation.type --- projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs b/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs index 66a3830932..94ad1124eb 100644 --- a/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs +++ b/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs @@ -15,7 +15,7 @@ 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 MessagingSystem = "messaging.system"; internal const string MessagingDestination = "messaging.destination.name"; internal const string MessagingDestinationRoutingKey = "messaging.rabbitmq.destination.routing_key"; @@ -90,7 +90,7 @@ public static class RabbitMQActivitySource if (activity != null && activity.IsAllDataRequested) { activity - .SetTag(MessagingOperation, "receive") + .SetTag(MessagingOperationType, "receive") .SetTag(MessagingDestination, "amq.default"); } @@ -174,7 +174,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); From f71273b7fb00c31204d1fd68c21d12e053949dc4 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Wed, 30 Oct 2024 11:20:26 -0500 Subject: [PATCH 2/5] Update span operation names to comply with OTel semantic conventions --- .../RabbitMQ.Client/Impl/RabbitMQActivitySource.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs b/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs index 94ad1124eb..f82b856a01 100644 --- a/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs +++ b/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs @@ -63,14 +63,14 @@ public static class RabbitMQActivitySource Activity? activity = linkedContext == default ? s_publisherSource.StartRabbitMQActivity( - UseRoutingKeyAsOperationName ? $"{routingKey} publish" : "publish", + UseRoutingKeyAsOperationName ? $"{routingKey} send" : "send", ActivityKind.Producer) : s_publisherSource.StartLinkedRabbitMQActivity( - UseRoutingKeyAsOperationName ? $"{routingKey} publish" : "publish", + UseRoutingKeyAsOperationName ? $"{routingKey} send" : "send", ActivityKind.Producer, linkedContext); if (activity != null && activity.IsAllDataRequested) { - PopulateMessagingTags("publish", routingKey, exchange, 0, bodySize, activity); + PopulateMessagingTags("send", routingKey, exchange, 0, bodySize, activity); } return activity; @@ -128,11 +128,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} process" : "process", ActivityKind.Consumer, ContextExtractor(basicProperties)); if (activity != null && activity.IsAllDataRequested) { - PopulateMessagingTags("deliver", routingKey, exchange, + PopulateMessagingTags("process", routingKey, exchange, deliveryTag, basicProperties, bodySize, activity); } From c4d10450b53c067c73abcf495d391df2097c35c3 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Wed, 30 Oct 2024 12:09:50 -0500 Subject: [PATCH 3/5] Use const strings for OTel operation types --- .../Impl/RabbitMQActivitySource.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs b/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs index f82b856a01..45c11b5900 100644 --- a/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs +++ b/projects/RabbitMQ.Client/Impl/RabbitMQActivitySource.cs @@ -16,6 +16,9 @@ public static class RabbitMQActivitySource internal const string MessageId = "messaging.message.id"; internal const string MessageConversationId = "messaging.message.conversation_id"; 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} send" : "send", + UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend, ActivityKind.Producer) : s_publisherSource.StartLinkedRabbitMQActivity( - UseRoutingKeyAsOperationName ? $"{routingKey} send" : "send", + UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeSend}" : MessagingOperationTypeSend, ActivityKind.Producer, linkedContext); if (activity != null && activity.IsAllDataRequested) { - PopulateMessagingTags("send", routingKey, exchange, 0, bodySize, activity); + PopulateMessagingTags(MessagingOperationTypeSend, routingKey, exchange, 0, bodySize, activity); } return activity; @@ -85,12 +88,12 @@ public static class RabbitMQActivitySource } Activity? activity = s_subscriberSource.StartRabbitMQActivity( - UseRoutingKeyAsOperationName ? $"{queue} receive" : "receive", + UseRoutingKeyAsOperationName ? $"{queue} {MessagingOperationTypeReceive}" : MessagingOperationTypeReceive, ActivityKind.Consumer); if (activity != null && activity.IsAllDataRequested) { activity - .SetTag(MessagingOperationType, "receive") + .SetTag(MessagingOperationType, MessagingOperationTypeReceive) .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, 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} process" : "process", + UseRoutingKeyAsOperationName ? $"{routingKey} {MessagingOperationTypeProcess}" : MessagingOperationTypeProcess, ActivityKind.Consumer, ContextExtractor(basicProperties)); if (activity != null && activity.IsAllDataRequested) { - PopulateMessagingTags("process", routingKey, exchange, + PopulateMessagingTags(MessagingOperationTypeProcess, routingKey, exchange, deliveryTag, basicProperties, bodySize, activity); } From fe9ccbe3b62c9d29ed8275a5e7c1612a1ea5fc38 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Wed, 30 Oct 2024 12:49:26 -0500 Subject: [PATCH 4/5] Update tests for Activity source operation name and attribute value --- projects/Test/SequentialIntegration/TestActivitySource.cs | 4 ++-- projects/Test/SequentialIntegration/TestOpenTelemetry.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/Test/SequentialIntegration/TestActivitySource.cs b/projects/Test/SequentialIntegration/TestActivitySource.cs index 7ea58dc227..1143b95514 100644 --- a/projects/Test/SequentialIntegration/TestActivitySource.cs +++ b/projects/Test/SequentialIntegration/TestActivitySource.cs @@ -402,7 +402,7 @@ private static ActivityListener StartActivityListener(List activities) private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueName, List activityList, bool isDeliver = false) { - string childName = isDeliver ? "deliver" : "receive"; + string childName = isDeliver ? "process" : "receive"; Activity[] activities = activityList.ToArray(); Assert.NotEmpty(activities); @@ -418,7 +418,7 @@ private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueN } Activity sendActivity = activities.First(x => - x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} publish" : "publish") && + x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} send" : "send") && x.GetTagItem(RabbitMQActivitySource.MessagingDestinationRoutingKey) is string routingKeyTag && routingKeyTag == $"{queueName}"); Activity receiveActivity = activities.Single(x => diff --git a/projects/Test/SequentialIntegration/TestOpenTelemetry.cs b/projects/Test/SequentialIntegration/TestOpenTelemetry.cs index 2a2fb65670..4ecff875df 100644 --- a/projects/Test/SequentialIntegration/TestOpenTelemetry.cs +++ b/projects/Test/SequentialIntegration/TestOpenTelemetry.cs @@ -342,7 +342,7 @@ public async Task TestPublisherAndBasicGetActivityTags(bool useRoutingKeyAsOpera private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueName, List activityList, bool isDeliver = false, string baggageGuid = null) { - string childName = isDeliver ? "deliver" : "receive"; + string childName = isDeliver ? "process" : "receive"; Activity[] activities = activityList.ToArray(); Assert.NotEmpty(activities); foreach (var item in activities) @@ -354,7 +354,7 @@ private void AssertActivityData(bool useRoutingKeyAsOperationName, string queueN } Activity sendActivity = activities.First(x => - x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} publish" : "publish") && + x.OperationName == (useRoutingKeyAsOperationName ? $"{queueName} send" : "send") && x.GetTagItem(RabbitMQActivitySource.MessagingDestinationRoutingKey) is string routingKeyTag && routingKeyTag == $"{queueName}"); Activity receiveActivity = activities.Single(x => From e2c246f1c251949ea0a6c605eb2eb93e891b2662 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Wed, 30 Oct 2024 13:12:01 -0500 Subject: [PATCH 5/5] docs: Add clone and build steps to contributing guide --- CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c33bc7bf67..66c19380be 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,6 +76,39 @@ Here's the recommended workflow: If what you are going to work on is a substantial change, please first ask the core team for their opinion on the [RabbitMQ users mailing list][rmq-users]. +### Building Source + +It is good practice to make sure you can build the project before making any +changes to confirm that your development environment is set up correctly. +Verifying that the tests pass is also a good practice (see +[RUNNING_TESTS.md](/RUNNING_TESTS.md)). + +All together, this looks like: + +* Linux + +```shell +git clone --recurse-submodules https://github.com/rabbitmq/rabbitmq-dotnet-client +cd rabbitmq-dotnet-client + +# On any Linux distribution with Docker installed +./.ci/ubuntu/gha-setup.sh toxiproxy pull + +make build +make test +``` + +* Windows + +Note that this will _NOT_ run toxiproxy tests. + +```powershell +git clone --recurse-submodules https://github.com/rabbitmq/rabbitmq-dotnet-client +cd rabbitmq-dotnet-client +.\.ci\windows\gha-setup.ps1 # On Windows. Note that this installs RabbitMQ +.\build.ps1 -RunTests:$true +``` + ### Running Tests See [RUNNING_TESTS.md](/RUNNING_TESTS.md).