Skip to content

Commit 5a666d8

Browse files
committed
Stop deriving AspNetCoreMvcTags from WebTags
We never set any of the additional tags anyway, so it's just extra allocations
1 parent 680b9d9 commit 5a666d8

5 files changed

Lines changed: 268 additions & 1 deletion

File tree

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ namespace Datadog.Trace.Tagging
1414
{
1515
partial class AspNetCoreMvcTags
1616
{
17+
// SpanKindBytes = MessagePack.Serialize("span.kind");
18+
#if NETCOREAPP
19+
private static ReadOnlySpan<byte> SpanKindBytes => new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
20+
#else
21+
private static readonly byte[] SpanKindBytes = new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
22+
#endif
23+
// InstrumentationNameBytes = MessagePack.Serialize("component");
24+
#if NETCOREAPP
25+
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
26+
#else
27+
private static readonly byte[] InstrumentationNameBytes = new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
28+
#endif
1729
// AspNetCoreControllerBytes = MessagePack.Serialize("aspnet_core.controller");
1830
#if NETCOREAPP
1931
private static ReadOnlySpan<byte> AspNetCoreControllerBytes => new byte[] { 182, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 99, 111, 110, 116, 114, 111, 108, 108, 101, 114 };
@@ -38,15 +50,24 @@ partial class AspNetCoreMvcTags
3850
#else
3951
private static readonly byte[] AspNetCorePageBytes = new byte[] { 176, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 112, 97, 103, 101 };
4052
#endif
53+
// AspNetCoreRouteBytes = MessagePack.Serialize("aspnet_core.route");
54+
#if NETCOREAPP
55+
private static ReadOnlySpan<byte> AspNetCoreRouteBytes => new byte[] { 177, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 114, 111, 117, 116, 101 };
56+
#else
57+
private static readonly byte[] AspNetCoreRouteBytes = new byte[] { 177, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 114, 111, 117, 116, 101 };
58+
#endif
4159

4260
public override string? GetTag(string key)
4361
{
4462
return key switch
4563
{
64+
"span.kind" => SpanKind,
65+
"component" => InstrumentationName,
4666
"aspnet_core.controller" => AspNetCoreController,
4767
"aspnet_core.action" => AspNetCoreAction,
4868
"aspnet_core.area" => AspNetCoreArea,
4969
"aspnet_core.page" => AspNetCorePage,
70+
"aspnet_core.route" => AspNetCoreRoute,
5071
_ => base.GetTag(key),
5172
};
5273
}
@@ -67,6 +88,13 @@ public override void SetTag(string key, string? value)
6788
case "aspnet_core.page":
6889
AspNetCorePage = value;
6990
break;
91+
case "aspnet_core.route":
92+
AspNetCoreRoute = value;
93+
break;
94+
case "span.kind":
95+
case "component":
96+
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(AspNetCoreMvcTags));
97+
break;
7098
default:
7199
base.SetTag(key, value);
72100
break;
@@ -75,6 +103,16 @@ public override void SetTag(string key, string? value)
75103

76104
public override void EnumerateTags<TProcessor>(ref TProcessor processor)
77105
{
106+
if (SpanKind is not null)
107+
{
108+
processor.Process(new TagItem<string>("span.kind", SpanKind, SpanKindBytes));
109+
}
110+
111+
if (InstrumentationName is not null)
112+
{
113+
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
114+
}
115+
78116
if (AspNetCoreController is not null)
79117
{
80118
processor.Process(new TagItem<string>("aspnet_core.controller", AspNetCoreController, AspNetCoreControllerBytes));
@@ -95,11 +133,30 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
95133
processor.Process(new TagItem<string>("aspnet_core.page", AspNetCorePage, AspNetCorePageBytes));
96134
}
97135

136+
if (AspNetCoreRoute is not null)
137+
{
138+
processor.Process(new TagItem<string>("aspnet_core.route", AspNetCoreRoute, AspNetCoreRouteBytes));
139+
}
140+
98141
base.EnumerateTags(ref processor);
99142
}
100143

101144
protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
102145
{
146+
if (SpanKind is not null)
147+
{
148+
sb.Append("span.kind (tag):")
149+
.Append(SpanKind)
150+
.Append(',');
151+
}
152+
153+
if (InstrumentationName is not null)
154+
{
155+
sb.Append("component (tag):")
156+
.Append(InstrumentationName)
157+
.Append(',');
158+
}
159+
103160
if (AspNetCoreController is not null)
104161
{
105162
sb.Append("aspnet_core.controller (tag):")
@@ -128,6 +185,13 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
128185
.Append(',');
129186
}
130187

188+
if (AspNetCoreRoute is not null)
189+
{
190+
sb.Append("aspnet_core.route (tag):")
191+
.Append(AspNetCoreRoute)
192+
.Append(',');
193+
}
194+
131195
base.WriteAdditionalTags(sb);
132196
}
133197
}

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ namespace Datadog.Trace.Tagging
1414
{
1515
partial class AspNetCoreMvcTags
1616
{
17+
// SpanKindBytes = MessagePack.Serialize("span.kind");
18+
#if NETCOREAPP
19+
private static ReadOnlySpan<byte> SpanKindBytes => new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
20+
#else
21+
private static readonly byte[] SpanKindBytes = new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
22+
#endif
23+
// InstrumentationNameBytes = MessagePack.Serialize("component");
24+
#if NETCOREAPP
25+
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
26+
#else
27+
private static readonly byte[] InstrumentationNameBytes = new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
28+
#endif
1729
// AspNetCoreControllerBytes = MessagePack.Serialize("aspnet_core.controller");
1830
#if NETCOREAPP
1931
private static ReadOnlySpan<byte> AspNetCoreControllerBytes => new byte[] { 182, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 99, 111, 110, 116, 114, 111, 108, 108, 101, 114 };
@@ -38,15 +50,24 @@ partial class AspNetCoreMvcTags
3850
#else
3951
private static readonly byte[] AspNetCorePageBytes = new byte[] { 176, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 112, 97, 103, 101 };
4052
#endif
53+
// AspNetCoreRouteBytes = MessagePack.Serialize("aspnet_core.route");
54+
#if NETCOREAPP
55+
private static ReadOnlySpan<byte> AspNetCoreRouteBytes => new byte[] { 177, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 114, 111, 117, 116, 101 };
56+
#else
57+
private static readonly byte[] AspNetCoreRouteBytes = new byte[] { 177, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 114, 111, 117, 116, 101 };
58+
#endif
4159

4260
public override string? GetTag(string key)
4361
{
4462
return key switch
4563
{
64+
"span.kind" => SpanKind,
65+
"component" => InstrumentationName,
4666
"aspnet_core.controller" => AspNetCoreController,
4767
"aspnet_core.action" => AspNetCoreAction,
4868
"aspnet_core.area" => AspNetCoreArea,
4969
"aspnet_core.page" => AspNetCorePage,
70+
"aspnet_core.route" => AspNetCoreRoute,
5071
_ => base.GetTag(key),
5172
};
5273
}
@@ -67,6 +88,13 @@ public override void SetTag(string key, string? value)
6788
case "aspnet_core.page":
6889
AspNetCorePage = value;
6990
break;
91+
case "aspnet_core.route":
92+
AspNetCoreRoute = value;
93+
break;
94+
case "span.kind":
95+
case "component":
96+
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(AspNetCoreMvcTags));
97+
break;
7098
default:
7199
base.SetTag(key, value);
72100
break;
@@ -75,6 +103,16 @@ public override void SetTag(string key, string? value)
75103

76104
public override void EnumerateTags<TProcessor>(ref TProcessor processor)
77105
{
106+
if (SpanKind is not null)
107+
{
108+
processor.Process(new TagItem<string>("span.kind", SpanKind, SpanKindBytes));
109+
}
110+
111+
if (InstrumentationName is not null)
112+
{
113+
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
114+
}
115+
78116
if (AspNetCoreController is not null)
79117
{
80118
processor.Process(new TagItem<string>("aspnet_core.controller", AspNetCoreController, AspNetCoreControllerBytes));
@@ -95,11 +133,30 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
95133
processor.Process(new TagItem<string>("aspnet_core.page", AspNetCorePage, AspNetCorePageBytes));
96134
}
97135

136+
if (AspNetCoreRoute is not null)
137+
{
138+
processor.Process(new TagItem<string>("aspnet_core.route", AspNetCoreRoute, AspNetCoreRouteBytes));
139+
}
140+
98141
base.EnumerateTags(ref processor);
99142
}
100143

101144
protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
102145
{
146+
if (SpanKind is not null)
147+
{
148+
sb.Append("span.kind (tag):")
149+
.Append(SpanKind)
150+
.Append(',');
151+
}
152+
153+
if (InstrumentationName is not null)
154+
{
155+
sb.Append("component (tag):")
156+
.Append(InstrumentationName)
157+
.Append(',');
158+
}
159+
103160
if (AspNetCoreController is not null)
104161
{
105162
sb.Append("aspnet_core.controller (tag):")
@@ -128,6 +185,13 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
128185
.Append(',');
129186
}
130187

188+
if (AspNetCoreRoute is not null)
189+
{
190+
sb.Append("aspnet_core.route (tag):")
191+
.Append(AspNetCoreRoute)
192+
.Append(',');
193+
}
194+
131195
base.WriteAdditionalTags(sb);
132196
}
133197
}

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ namespace Datadog.Trace.Tagging
1414
{
1515
partial class AspNetCoreMvcTags
1616
{
17+
// SpanKindBytes = MessagePack.Serialize("span.kind");
18+
#if NETCOREAPP
19+
private static ReadOnlySpan<byte> SpanKindBytes => new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
20+
#else
21+
private static readonly byte[] SpanKindBytes = new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
22+
#endif
23+
// InstrumentationNameBytes = MessagePack.Serialize("component");
24+
#if NETCOREAPP
25+
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
26+
#else
27+
private static readonly byte[] InstrumentationNameBytes = new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
28+
#endif
1729
// AspNetCoreControllerBytes = MessagePack.Serialize("aspnet_core.controller");
1830
#if NETCOREAPP
1931
private static ReadOnlySpan<byte> AspNetCoreControllerBytes => new byte[] { 182, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 99, 111, 110, 116, 114, 111, 108, 108, 101, 114 };
@@ -38,15 +50,24 @@ partial class AspNetCoreMvcTags
3850
#else
3951
private static readonly byte[] AspNetCorePageBytes = new byte[] { 176, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 112, 97, 103, 101 };
4052
#endif
53+
// AspNetCoreRouteBytes = MessagePack.Serialize("aspnet_core.route");
54+
#if NETCOREAPP
55+
private static ReadOnlySpan<byte> AspNetCoreRouteBytes => new byte[] { 177, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 114, 111, 117, 116, 101 };
56+
#else
57+
private static readonly byte[] AspNetCoreRouteBytes = new byte[] { 177, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 114, 111, 117, 116, 101 };
58+
#endif
4159

4260
public override string? GetTag(string key)
4361
{
4462
return key switch
4563
{
64+
"span.kind" => SpanKind,
65+
"component" => InstrumentationName,
4666
"aspnet_core.controller" => AspNetCoreController,
4767
"aspnet_core.action" => AspNetCoreAction,
4868
"aspnet_core.area" => AspNetCoreArea,
4969
"aspnet_core.page" => AspNetCorePage,
70+
"aspnet_core.route" => AspNetCoreRoute,
5071
_ => base.GetTag(key),
5172
};
5273
}
@@ -67,6 +88,13 @@ public override void SetTag(string key, string? value)
6788
case "aspnet_core.page":
6889
AspNetCorePage = value;
6990
break;
91+
case "aspnet_core.route":
92+
AspNetCoreRoute = value;
93+
break;
94+
case "span.kind":
95+
case "component":
96+
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(AspNetCoreMvcTags));
97+
break;
7098
default:
7199
base.SetTag(key, value);
72100
break;
@@ -75,6 +103,16 @@ public override void SetTag(string key, string? value)
75103

76104
public override void EnumerateTags<TProcessor>(ref TProcessor processor)
77105
{
106+
if (SpanKind is not null)
107+
{
108+
processor.Process(new TagItem<string>("span.kind", SpanKind, SpanKindBytes));
109+
}
110+
111+
if (InstrumentationName is not null)
112+
{
113+
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
114+
}
115+
78116
if (AspNetCoreController is not null)
79117
{
80118
processor.Process(new TagItem<string>("aspnet_core.controller", AspNetCoreController, AspNetCoreControllerBytes));
@@ -95,11 +133,30 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
95133
processor.Process(new TagItem<string>("aspnet_core.page", AspNetCorePage, AspNetCorePageBytes));
96134
}
97135

136+
if (AspNetCoreRoute is not null)
137+
{
138+
processor.Process(new TagItem<string>("aspnet_core.route", AspNetCoreRoute, AspNetCoreRouteBytes));
139+
}
140+
98141
base.EnumerateTags(ref processor);
99142
}
100143

101144
protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
102145
{
146+
if (SpanKind is not null)
147+
{
148+
sb.Append("span.kind (tag):")
149+
.Append(SpanKind)
150+
.Append(',');
151+
}
152+
153+
if (InstrumentationName is not null)
154+
{
155+
sb.Append("component (tag):")
156+
.Append(InstrumentationName)
157+
.Append(',');
158+
}
159+
103160
if (AspNetCoreController is not null)
104161
{
105162
sb.Append("aspnet_core.controller (tag):")
@@ -128,6 +185,13 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
128185
.Append(',');
129186
}
130187

188+
if (AspNetCoreRoute is not null)
189+
{
190+
sb.Append("aspnet_core.route (tag):")
191+
.Append(AspNetCoreRoute)
192+
.Append(',');
193+
}
194+
131195
base.WriteAdditionalTags(sb);
132196
}
133197
}

0 commit comments

Comments
 (0)