Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task ReceiveMessageAsync(BasicDeliverEventArgs ea)

// Start an activity with a name following the semantic convention of the OpenTelemetry messaging specification.
// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/messaging-spans.md#span-name
var activityName = $"{ea.RoutingKey} receive";
var activityName = $"{RabbitMqHelper.ProcessOperationName} {ea.RoutingKey}";

using var activity = ActivitySource.StartActivity(activityName, ActivityKind.Consumer, parentContext.ActivityContext);
try
Expand All @@ -63,7 +63,7 @@ public async Task ReceiveMessageAsync(BasicDeliverEventArgs ea)
activity?.SetTag("message", message);

// The OpenTelemetry messaging specification defines a number of attributes. These attributes are added here.
RabbitMqHelper.AddMessagingTags(activity);
RabbitMqHelper.AddMessagingTags(activity, RabbitMqHelper.ProcessOperationName);

// Simulate some work
await Task.Delay(1_000).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task<string> SendMessageAsync()

// Start an activity with a name following the semantic convention of the OpenTelemetry messaging specification.
// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/messaging-spans.md#span-name
var activityName = $"{RabbitMqHelper.TestQueueName} send";
var activityName = $"{RabbitMqHelper.SendOperationName} {RabbitMqHelper.TestQueueName}";

using var activity = ActivitySource.StartActivity(activityName, ActivityKind.Producer);
var props = new BasicProperties();
Expand All @@ -66,7 +66,7 @@ public async Task<string> SendMessageAsync()
Propagator.Inject(new PropagationContext(contextToInject, Baggage.Current), props, this.InjectTraceContextIntoBasicProperties);

// The OpenTelemetry messaging specification defines a number of attributes. These attributes are added here.
RabbitMqHelper.AddMessagingTags(activity);
RabbitMqHelper.AddMessagingTags(activity, RabbitMqHelper.SendOperationName);
var body = $"Published message: DateTime.Now = {DateTime.Now}.";

await this.channel.BasicPublishAsync(
Expand Down
15 changes: 9 additions & 6 deletions examples/MicroserviceExample/Utils/Messaging/RabbitMqHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public static class RabbitMqHelper
{
public const string DefaultExchangeName = "";
public const string TestQueueName = "TestQueue";
public const string SendOperationName = "send";
public const string ProcessOperationName = "process";

private static readonly ConnectionFactory ConnectionFactory = new()
{
Expand Down Expand Up @@ -49,15 +51,16 @@ public static async Task StartConsumerAsync(IChannel channel, Func<BasicDeliverE
await channel.BasicConsumeAsync(queue: TestQueueName, autoAck: true, consumer: consumer).ConfigureAwait(false);
}

public static void AddMessagingTags(Activity? activity)
public static void AddMessagingTags(Activity? activity, string operationName)
{
// These tags are added demonstrating the semantic conventions of the OpenTelemetry messaging specification
// See:
// * https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/messaging-spans.md#messaging-attributes
// * https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/messaging-spans.md#messaging-spans
// * https://github.com/open-telemetry/semantic-conventions/blob/main/docs/messaging/rabbitmq.md
activity?.SetTag("messaging.system", "rabbitmq");
activity?.SetTag("messaging.destination_kind", "queue");
activity?.SetTag("messaging.destination", DefaultExchangeName);
activity?.SetTag("messaging.rabbitmq.routing_key", TestQueueName);
activity?.SetTag("messaging.system.name", "rabbitmq");
activity?.SetTag("messaging.operation.name", operationName);
activity?.SetTag("messaging.operation.type", operationName);
activity?.SetTag("messaging.destination.name", TestQueueName);
activity?.SetTag("rabbitmq.destination.routing_key", TestQueueName);
}
}
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Notes](../../RELEASENOTES.md).
values cannot be read.
([#8070](https://github.com/open-telemetry/opentelemetry-dotnet/pull/8070))

* Updated the schema URL of resources created by the host environment resource
detector to use OpenTelemetry Semantic Conventions version `1.45.0`.
([#8079](https://github.com/open-telemetry/opentelemetry-dotnet/pull/8079))

## 1.21.0-rc.1

Released 2026-Oct-28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal bool IsAttributeInOtelResourceAttributes(string attributeName)
return false;
}

// The spec (https://github.com/open-telemetry/semantic-conventions/blob/v1.44.0/docs/registry/attributes/deployment.md) mandates these four well-known values in lowercase.
// The spec (https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/registry/attributes/deployment.md) mandates these four well-known values in lowercase.
private static string NormalizeEnvironmentName(string name) => name switch
{
_ when string.Equals(name, "development", StringComparison.OrdinalIgnoreCase) => "development",
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Notes](../../RELEASENOTES.md).
the Resource SDK specification.
([#8074](https://github.com/open-telemetry/opentelemetry-dotnet/pull/8074))

* Updated the schema URL of resources created by the SDK to use OpenTelemetry
Semantic Conventions version `1.45.0`.
([#8079](https://github.com/open-telemetry/opentelemetry-dotnet/pull/8079))

## 1.21.0-rc.1

Released 2026-Oct-28
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/SemanticConventionsVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace OpenTelemetry;

internal static class SemanticConventionsVersion
{
internal static readonly Version Current = new(1, 44, 0);
internal static readonly Version Current = new(1, 45, 0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ public void Detect_SchemaUrlConflictsWithOtherDetectors_ResourceSchemaUrlIsNull(
- name: service.name
value: "svc"
""",
"https://opentelemetry.io/schemas/1.44.0");
"https://opentelemetry.io/schemas/1.45.0");

Assert.Null(resource.SchemaUrl);
Assert.Contains(resource.Attributes, a => a.Key == "service.name" && (string)a.Value == "svc");
Expand Down
Loading