Skip to content

Commit 729efe5

Browse files
component and service tags
1 parent 7083f95 commit 729efe5

File tree

10 files changed

+94
-9
lines changed

10 files changed

+94
-9
lines changed

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/ServiceBus/ServiceBusReceiverReceiveMessagesAsyncIntegration.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,15 @@ private static ContextExtractionResult ExtractContextsFromMessages(Tracer tracer
152152
tags.MessagingDestinationName = entityPath;
153153
tags.MessagingOperation = "receive";
154154
tags.MessagingSystem = "servicebus";
155-
156-
var scope = tracer.StartActiveInternal(OperationName, parent: parentContext, links: spanLinks, tags: tags);
155+
tags.InstrumentationName = "AzureServiceBus";
156+
157+
string serviceName = tracer.CurrentTraceSettings.Schema.Messaging.GetServiceName("azureservicebus");
158+
var scope = tracer.StartActiveInternal(
159+
OperationName,
160+
parent: parentContext,
161+
links: spanLinks,
162+
tags: tags,
163+
serviceName: serviceName);
157164
var span = scope.Span;
158165

159166
span.Type = SpanTypes.Queue;

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/ServiceBus/ServiceBusSenderSendMessagesAsyncIntegration.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ internal static CallTargetState OnMethodBegin<TTarget>(TTarget instance, ref IEn
4848
tags.MessagingDestinationName = entityPath;
4949
tags.MessagingOperation = "send";
5050
tags.MessagingSystem = "servicebus";
51+
tags.InstrumentationName = "AzureServiceBus";
5152

52-
var scope = tracer.StartActiveInternal(OperationName, tags: tags);
53+
string serviceName = tracer.CurrentTraceSettings.Schema.Messaging.GetServiceName("azureservicebus");
54+
var scope = tracer.StartActiveInternal(
55+
OperationName,
56+
tags: tags,
57+
serviceName: serviceName);
5358
var span = scope.Span;
5459

5560
span.Type = SpanTypes.Queue;

tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TagListGenerator/AzureServiceBusTags.g.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ partial class AzureServiceBusTags
1818
private static ReadOnlySpan<byte> AnalyticsSampleRateBytes => new byte[] { 173, 95, 100, 100, 49, 46, 115, 114, 46, 101, 97, 117, 115, 114 };
1919
// MessageQueueTimeMsBytes = MessagePack.Serialize("message.queue_time_ms");
2020
private static ReadOnlySpan<byte> MessageQueueTimeMsBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 101, 46, 113, 117, 101, 117, 101, 95, 116, 105, 109, 101, 95, 109, 115 };
21+
// InstrumentationNameBytes = MessagePack.Serialize("component");
22+
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
2123
// MessagingSourceNameBytes = MessagePack.Serialize("messaging.source.name");
2224
private static ReadOnlySpan<byte> MessagingSourceNameBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 105, 110, 103, 46, 115, 111, 117, 114, 99, 101, 46, 110, 97, 109, 101 };
2325
// MessagingDestinationNameBytes = MessagePack.Serialize("messaging.destination.name");
@@ -33,6 +35,7 @@ partial class AzureServiceBusTags
3335
{
3436
return key switch
3537
{
38+
"component" => InstrumentationName,
3639
"messaging.source.name" => MessagingSourceName,
3740
"messaging.destination.name" => MessagingDestinationName,
3841
"message_bus.destination" => LegacyMessageBusDestination,
@@ -46,6 +49,9 @@ public override void SetTag(string key, string value)
4649
{
4750
switch(key)
4851
{
52+
case "component":
53+
InstrumentationName = value;
54+
break;
4955
case "messaging.source.name":
5056
MessagingSourceName = value;
5157
break;
@@ -69,6 +75,11 @@ public override void SetTag(string key, string value)
6975

7076
public override void EnumerateTags<TProcessor>(ref TProcessor processor)
7177
{
78+
if (InstrumentationName is not null)
79+
{
80+
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
81+
}
82+
7283
if (MessagingSourceName is not null)
7384
{
7485
processor.Process(new TagItem<string>("messaging.source.name", MessagingSourceName, MessagingSourceNameBytes));
@@ -99,6 +110,13 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
99110

100111
protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
101112
{
113+
if (InstrumentationName is not null)
114+
{
115+
sb.Append("component (tag):")
116+
.Append(InstrumentationName)
117+
.Append(',');
118+
}
119+
102120
if (MessagingSourceName is not null)
103121
{
104122
sb.Append("messaging.source.name (tag):")

tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TagListGenerator/AzureServiceBusTags.g.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ partial class AzureServiceBusTags
1818
private static ReadOnlySpan<byte> AnalyticsSampleRateBytes => new byte[] { 173, 95, 100, 100, 49, 46, 115, 114, 46, 101, 97, 117, 115, 114 };
1919
// MessageQueueTimeMsBytes = MessagePack.Serialize("message.queue_time_ms");
2020
private static ReadOnlySpan<byte> MessageQueueTimeMsBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 101, 46, 113, 117, 101, 117, 101, 95, 116, 105, 109, 101, 95, 109, 115 };
21+
// InstrumentationNameBytes = MessagePack.Serialize("component");
22+
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
2123
// MessagingSourceNameBytes = MessagePack.Serialize("messaging.source.name");
2224
private static ReadOnlySpan<byte> MessagingSourceNameBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 105, 110, 103, 46, 115, 111, 117, 114, 99, 101, 46, 110, 97, 109, 101 };
2325
// MessagingDestinationNameBytes = MessagePack.Serialize("messaging.destination.name");
@@ -33,6 +35,7 @@ partial class AzureServiceBusTags
3335
{
3436
return key switch
3537
{
38+
"component" => InstrumentationName,
3639
"messaging.source.name" => MessagingSourceName,
3740
"messaging.destination.name" => MessagingDestinationName,
3841
"message_bus.destination" => LegacyMessageBusDestination,
@@ -46,6 +49,9 @@ public override void SetTag(string key, string value)
4649
{
4750
switch(key)
4851
{
52+
case "component":
53+
InstrumentationName = value;
54+
break;
4955
case "messaging.source.name":
5056
MessagingSourceName = value;
5157
break;
@@ -69,6 +75,11 @@ public override void SetTag(string key, string value)
6975

7076
public override void EnumerateTags<TProcessor>(ref TProcessor processor)
7177
{
78+
if (InstrumentationName is not null)
79+
{
80+
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
81+
}
82+
7283
if (MessagingSourceName is not null)
7384
{
7485
processor.Process(new TagItem<string>("messaging.source.name", MessagingSourceName, MessagingSourceNameBytes));
@@ -99,6 +110,13 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
99110

100111
protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
101112
{
113+
if (InstrumentationName is not null)
114+
{
115+
sb.Append("component (tag):")
116+
.Append(InstrumentationName)
117+
.Append(',');
118+
}
119+
102120
if (MessagingSourceName is not null)
103121
{
104122
sb.Append("messaging.source.name (tag):")

tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TagListGenerator/AzureServiceBusTags.g.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ partial class AzureServiceBusTags
1818
private static ReadOnlySpan<byte> AnalyticsSampleRateBytes => new byte[] { 173, 95, 100, 100, 49, 46, 115, 114, 46, 101, 97, 117, 115, 114 };
1919
// MessageQueueTimeMsBytes = MessagePack.Serialize("message.queue_time_ms");
2020
private static ReadOnlySpan<byte> MessageQueueTimeMsBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 101, 46, 113, 117, 101, 117, 101, 95, 116, 105, 109, 101, 95, 109, 115 };
21+
// InstrumentationNameBytes = MessagePack.Serialize("component");
22+
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
2123
// MessagingSourceNameBytes = MessagePack.Serialize("messaging.source.name");
2224
private static ReadOnlySpan<byte> MessagingSourceNameBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 105, 110, 103, 46, 115, 111, 117, 114, 99, 101, 46, 110, 97, 109, 101 };
2325
// MessagingDestinationNameBytes = MessagePack.Serialize("messaging.destination.name");
@@ -33,6 +35,7 @@ partial class AzureServiceBusTags
3335
{
3436
return key switch
3537
{
38+
"component" => InstrumentationName,
3639
"messaging.source.name" => MessagingSourceName,
3740
"messaging.destination.name" => MessagingDestinationName,
3841
"message_bus.destination" => LegacyMessageBusDestination,
@@ -46,6 +49,9 @@ public override void SetTag(string key, string value)
4649
{
4750
switch(key)
4851
{
52+
case "component":
53+
InstrumentationName = value;
54+
break;
4955
case "messaging.source.name":
5056
MessagingSourceName = value;
5157
break;
@@ -69,6 +75,11 @@ public override void SetTag(string key, string value)
6975

7076
public override void EnumerateTags<TProcessor>(ref TProcessor processor)
7177
{
78+
if (InstrumentationName is not null)
79+
{
80+
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
81+
}
82+
7283
if (MessagingSourceName is not null)
7384
{
7485
processor.Process(new TagItem<string>("messaging.source.name", MessagingSourceName, MessagingSourceNameBytes));
@@ -99,6 +110,13 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
99110

100111
protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
101112
{
113+
if (InstrumentationName is not null)
114+
{
115+
sb.Append("component (tag):")
116+
.Append(InstrumentationName)
117+
.Append(',');
118+
}
119+
102120
if (MessagingSourceName is not null)
103121
{
104122
sb.Append("messaging.source.name (tag):")

tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TagListGenerator/AzureServiceBusTags.g.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ partial class AzureServiceBusTags
1818
private static ReadOnlySpan<byte> AnalyticsSampleRateBytes => new byte[] { 173, 95, 100, 100, 49, 46, 115, 114, 46, 101, 97, 117, 115, 114 };
1919
// MessageQueueTimeMsBytes = MessagePack.Serialize("message.queue_time_ms");
2020
private static ReadOnlySpan<byte> MessageQueueTimeMsBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 101, 46, 113, 117, 101, 117, 101, 95, 116, 105, 109, 101, 95, 109, 115 };
21+
// InstrumentationNameBytes = MessagePack.Serialize("component");
22+
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
2123
// MessagingSourceNameBytes = MessagePack.Serialize("messaging.source.name");
2224
private static ReadOnlySpan<byte> MessagingSourceNameBytes => new byte[] { 181, 109, 101, 115, 115, 97, 103, 105, 110, 103, 46, 115, 111, 117, 114, 99, 101, 46, 110, 97, 109, 101 };
2325
// MessagingDestinationNameBytes = MessagePack.Serialize("messaging.destination.name");
@@ -33,6 +35,7 @@ partial class AzureServiceBusTags
3335
{
3436
return key switch
3537
{
38+
"component" => InstrumentationName,
3639
"messaging.source.name" => MessagingSourceName,
3740
"messaging.destination.name" => MessagingDestinationName,
3841
"message_bus.destination" => LegacyMessageBusDestination,
@@ -46,6 +49,9 @@ public override void SetTag(string key, string value)
4649
{
4750
switch(key)
4851
{
52+
case "component":
53+
InstrumentationName = value;
54+
break;
4955
case "messaging.source.name":
5056
MessagingSourceName = value;
5157
break;
@@ -69,6 +75,11 @@ public override void SetTag(string key, string value)
6975

7076
public override void EnumerateTags<TProcessor>(ref TProcessor processor)
7177
{
78+
if (InstrumentationName is not null)
79+
{
80+
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
81+
}
82+
7283
if (MessagingSourceName is not null)
7384
{
7485
processor.Process(new TagItem<string>("messaging.source.name", MessagingSourceName, MessagingSourceNameBytes));
@@ -99,6 +110,13 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
99110

100111
protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
101112
{
113+
if (InstrumentationName is not null)
114+
{
115+
sb.Append("component (tag):")
116+
.Append(InstrumentationName)
117+
.Append(',');
118+
}
119+
102120
if (MessagingSourceName is not null)
103121
{
104122
sb.Append("messaging.source.name (tag):")

tracer/src/Datadog.Trace/Tagging/AzureServiceBusTags.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ internal partial class AzureServiceBusTags : OpenTelemetryTags
1717
{
1818
private string _spanKind;
1919

20+
[Tag(Trace.Tags.InstrumentationName)]
21+
public string InstrumentationName { get; set; }
22+
2023
[Metric(Trace.Tags.Analytics)]
2124
public double? AnalyticsSampleRate { get; set; }
2225

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Azure/AzureServiceBusAPMTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public async Task TestSendMessagesAsyncIntegration(string packageVersion, string
4949
{
5050
SetEnvironmentVariable("DD_TRACE_SPAN_ATTRIBUTE_SCHEMA", metadataSchemaVersion);
5151

52-
using (var telemetry = this.ConfigureTelemetry())
5352
using (var agent = EnvironmentHelper.GetMockAgent())
5453
using (await RunSampleAndWaitForExit(agent, packageVersion: packageVersion))
5554
{
@@ -86,7 +85,6 @@ public async Task TestReceiveMessagesAsyncIntegration(string packageVersion, str
8685
{
8786
SetEnvironmentVariable("DD_TRACE_SPAN_ATTRIBUTE_SCHEMA", metadataSchemaVersion);
8887

89-
using (var telemetry = this.ConfigureTelemetry())
9088
using (var agent = EnvironmentHelper.GetMockAgent())
9189
using (await RunSampleAndWaitForExit(agent, packageVersion: packageVersion))
9290
{

tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV0Rules.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public static Result IsAzureServiceBusInboundAPMV0(this MockSpan span, ISet<stri
316316
.IsOptional("net.peer.name")
317317
.IsOptional("peer.address")
318318
.IsOptional("server.address")
319-
.IfPresentMatches("component", "servicebus")
319+
.Matches("component", "AzureServiceBus")
320320
.IfPresentMatches("kind", "consumer")
321321
.IsOptional("_dd.base_service")
322322
.Matches("span.kind", "consumer"));
@@ -356,7 +356,7 @@ public static Result IsAzureServiceBusOutboundAPMV0(this MockSpan span, ISet<str
356356
.IsOptional("net.peer.name")
357357
.IsOptional("peer.address")
358358
.IsOptional("server.address")
359-
.IfPresentMatches("component", "servicebus")
359+
.Matches("component", "AzureServiceBus")
360360
.IfPresentMatches("kind", "producer")
361361
.IsOptional("_dd.base_service")
362362
.Matches("span.kind", "producer"));

tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV1Rules.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public static Result IsAzureServiceBusInboundAPMV1(this MockSpan span, ISet<stri
517517
.IsOptional("net.peer.name")
518518
.IsOptional("peer.address")
519519
.IsOptional("server.address")
520-
.IfPresentMatches("component", "servicebus")
520+
.Matches("component", "AzureServiceBus")
521521
.IfPresentMatches("kind", "consumer")
522522
.IsOptional("_dd.base_service")
523523
.Matches("span.kind", "consumer"));
@@ -563,7 +563,7 @@ public static Result IsAzureServiceBusOutboundAPMV1(this MockSpan span, ISet<str
563563
.IsPresent("peer.service")
564564
.IsOptional("peer.service.remapped_from")
565565
.MatchesOneOf("_dd.peer.service.source", "messaging.destination.name", "message_bus.destination", "peer.service")
566-
.IfPresentMatches("component", "servicebus")
566+
.Matches("component", "AzureServiceBus")
567567
.IfPresentMatches("kind", "producer")
568568
.IsOptional("_dd.base_service")
569569
.Matches("span.kind", "producer"));

0 commit comments

Comments
 (0)