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
7 changes: 6 additions & 1 deletion Datadog.Trace.Minimal.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
"solution": {
"path": "Datadog.Trace.sln",
"projects": [
"tracer\\src\\Datadog.Trace.Annotations\\Datadog.Trace.Annotations.csproj",
"tracer\\src\\Datadog.Trace.ClrProfiler.Managed.Loader\\Datadog.Trace.ClrProfiler.Managed.Loader.csproj",
"tracer\\src\\Datadog.Trace.Manual\\Datadog.Trace.Manual.csproj",
"tracer\\src\\Datadog.Trace.MSBuild\\Datadog.Trace.MSBuild.csproj",
"tracer\\src\\Datadog.Trace.SourceGenerators\\Datadog.Trace.SourceGenerators.csproj",
"tracer\\src\\Datadog.Trace.Tools.Analyzers.CodeFixes\\Datadog.Trace.Tools.Analyzers.CodeFixes.csproj",
"tracer\\src\\Datadog.Trace.Tools.Analyzers\\Datadog.Trace.Tools.Analyzers.csproj",
"tracer\\src\\Datadog.Tracer.Native\\Datadog.Tracer.Native.DLL.vcxproj",
"tracer\\src\\Datadog.Tracer.Native\\Datadog.Tracer.Native.vcxproj",
"tracer\\src\\Datadog.Trace\\Datadog.Trace.csproj",
"tracer\\test\\Datadog.Trace.SourceGenerators.Tests\\Datadog.Trace.SourceGenerators.Tests.csproj"
"tracer\\test\\benchmarks\\Benchmarks.Trace\\Benchmarks.Trace.csproj",
"tracer\\test\\Datadog.Trace.SourceGenerators.Tests\\Datadog.Trace.SourceGenerators.Tests.csproj",
"tracer\\test\\Datadog.Trace.TestHelpers\\Datadog.Trace.TestHelpers.csproj",
"tracer\\test\\Datadog.Trace.Tests\\Datadog.Trace.Tests.csproj"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ private static Span StartMvcCoreSpan(
// these will already be set correctly
rootSpanTags.AspNetCoreRoute = aspNetRoute;
rootSpan.ResourceName = span.ResourceName;
rootSpanTags.HttpRoute = aspNetRoute;
}

return span;
Expand Down Expand Up @@ -569,13 +568,12 @@ private void OnRoutingEndpointMatched(object arg)
// But instead we re-extract them in the MVC endpoint as these are MVC
// constructs. this is likely marginally less efficient, but simplifies the
// already complex logic in the MVC handler
// Overwrite the route in the parent span
trackingFeature.ResourceName = resourceName;
if (isFirstExecution)
{
// Overwrite the route in the parent span
rootSpan.ResourceName = resourceName;
tags.AspNetCoreRoute = normalizedRoute;
tags.HttpRoute = normalizedRoute;
}

_security.CheckPathParamsAndSessionId(httpContext, rootSpan, routeValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ namespace Datadog.Trace.Tagging
{
partial class AspNetCoreMvcTags
{
// SpanKindBytes = MessagePack.Serialize("span.kind");
#if NETCOREAPP
private static ReadOnlySpan<byte> SpanKindBytes => new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
#else
private static readonly byte[] SpanKindBytes = new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
#endif
// InstrumentationNameBytes = MessagePack.Serialize("component");
#if NETCOREAPP
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
#else
private static readonly byte[] InstrumentationNameBytes = new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
#endif
// AspNetCoreControllerBytes = MessagePack.Serialize("aspnet_core.controller");
#if NETCOREAPP
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 };
Expand All @@ -38,15 +50,24 @@ partial class AspNetCoreMvcTags
#else
private static readonly byte[] AspNetCorePageBytes = new byte[] { 176, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 112, 97, 103, 101 };
#endif
// AspNetCoreRouteBytes = MessagePack.Serialize("aspnet_core.route");
#if NETCOREAPP
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 };
#else
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 };
#endif

public override string? GetTag(string key)
{
return key switch
{
"span.kind" => SpanKind,
"component" => InstrumentationName,
"aspnet_core.controller" => AspNetCoreController,
"aspnet_core.action" => AspNetCoreAction,
"aspnet_core.area" => AspNetCoreArea,
"aspnet_core.page" => AspNetCorePage,
"aspnet_core.route" => AspNetCoreRoute,
_ => base.GetTag(key),
};
}
Expand All @@ -67,6 +88,13 @@ public override void SetTag(string key, string? value)
case "aspnet_core.page":
AspNetCorePage = value;
break;
case "aspnet_core.route":
AspNetCoreRoute = value;
break;
case "span.kind":
case "component":
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(AspNetCoreMvcTags));
break;
default:
base.SetTag(key, value);
break;
Expand All @@ -75,6 +103,16 @@ public override void SetTag(string key, string? value)

public override void EnumerateTags<TProcessor>(ref TProcessor processor)
{
if (SpanKind is not null)
{
processor.Process(new TagItem<string>("span.kind", SpanKind, SpanKindBytes));
}

if (InstrumentationName is not null)
{
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
}

if (AspNetCoreController is not null)
{
processor.Process(new TagItem<string>("aspnet_core.controller", AspNetCoreController, AspNetCoreControllerBytes));
Expand All @@ -95,11 +133,30 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
processor.Process(new TagItem<string>("aspnet_core.page", AspNetCorePage, AspNetCorePageBytes));
}

if (AspNetCoreRoute is not null)
{
processor.Process(new TagItem<string>("aspnet_core.route", AspNetCoreRoute, AspNetCoreRouteBytes));
}

base.EnumerateTags(ref processor);
}

protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
{
if (SpanKind is not null)
{
sb.Append("span.kind (tag):")
.Append(SpanKind)
.Append(',');
}

if (InstrumentationName is not null)
{
sb.Append("component (tag):")
.Append(InstrumentationName)
.Append(',');
}

if (AspNetCoreController is not null)
{
sb.Append("aspnet_core.controller (tag):")
Expand Down Expand Up @@ -128,6 +185,13 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
.Append(',');
}

if (AspNetCoreRoute is not null)
{
sb.Append("aspnet_core.route (tag):")
.Append(AspNetCoreRoute)
.Append(',');
}

base.WriteAdditionalTags(sb);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override void SetTag(string key, string? value)
AspNetCoreRoute = value;
break;
case "http.route":
HttpRoute = value;
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(AspNetCoreTags));
break;
default:
base.SetTag(key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ namespace Datadog.Trace.Tagging
{
partial class AspNetCoreMvcTags
{
// SpanKindBytes = MessagePack.Serialize("span.kind");
#if NETCOREAPP
private static ReadOnlySpan<byte> SpanKindBytes => new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
#else
private static readonly byte[] SpanKindBytes = new byte[] { 169, 115, 112, 97, 110, 46, 107, 105, 110, 100 };
#endif
// InstrumentationNameBytes = MessagePack.Serialize("component");
#if NETCOREAPP
private static ReadOnlySpan<byte> InstrumentationNameBytes => new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
#else
private static readonly byte[] InstrumentationNameBytes = new byte[] { 169, 99, 111, 109, 112, 111, 110, 101, 110, 116 };
#endif
// AspNetCoreControllerBytes = MessagePack.Serialize("aspnet_core.controller");
#if NETCOREAPP
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 };
Expand All @@ -38,15 +50,24 @@ partial class AspNetCoreMvcTags
#else
private static readonly byte[] AspNetCorePageBytes = new byte[] { 176, 97, 115, 112, 110, 101, 116, 95, 99, 111, 114, 101, 46, 112, 97, 103, 101 };
#endif
// AspNetCoreRouteBytes = MessagePack.Serialize("aspnet_core.route");
#if NETCOREAPP
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 };
#else
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 };
#endif

public override string? GetTag(string key)
{
return key switch
{
"span.kind" => SpanKind,
"component" => InstrumentationName,
"aspnet_core.controller" => AspNetCoreController,
"aspnet_core.action" => AspNetCoreAction,
"aspnet_core.area" => AspNetCoreArea,
"aspnet_core.page" => AspNetCorePage,
"aspnet_core.route" => AspNetCoreRoute,
_ => base.GetTag(key),
};
}
Expand All @@ -67,6 +88,13 @@ public override void SetTag(string key, string? value)
case "aspnet_core.page":
AspNetCorePage = value;
break;
case "aspnet_core.route":
AspNetCoreRoute = value;
break;
case "span.kind":
case "component":
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(AspNetCoreMvcTags));
break;
default:
base.SetTag(key, value);
break;
Expand All @@ -75,6 +103,16 @@ public override void SetTag(string key, string? value)

public override void EnumerateTags<TProcessor>(ref TProcessor processor)
{
if (SpanKind is not null)
{
processor.Process(new TagItem<string>("span.kind", SpanKind, SpanKindBytes));
}

if (InstrumentationName is not null)
{
processor.Process(new TagItem<string>("component", InstrumentationName, InstrumentationNameBytes));
}

if (AspNetCoreController is not null)
{
processor.Process(new TagItem<string>("aspnet_core.controller", AspNetCoreController, AspNetCoreControllerBytes));
Expand All @@ -95,11 +133,30 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
processor.Process(new TagItem<string>("aspnet_core.page", AspNetCorePage, AspNetCorePageBytes));
}

if (AspNetCoreRoute is not null)
{
processor.Process(new TagItem<string>("aspnet_core.route", AspNetCoreRoute, AspNetCoreRouteBytes));
}

base.EnumerateTags(ref processor);
}

protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
{
if (SpanKind is not null)
{
sb.Append("span.kind (tag):")
.Append(SpanKind)
.Append(',');
}

if (InstrumentationName is not null)
{
sb.Append("component (tag):")
.Append(InstrumentationName)
.Append(',');
}

if (AspNetCoreController is not null)
{
sb.Append("aspnet_core.controller (tag):")
Expand Down Expand Up @@ -128,6 +185,13 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
.Append(',');
}

if (AspNetCoreRoute is not null)
{
sb.Append("aspnet_core.route (tag):")
.Append(AspNetCoreRoute)
.Append(',');
}

base.WriteAdditionalTags(sb);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override void SetTag(string key, string? value)
AspNetCoreRoute = value;
break;
case "http.route":
HttpRoute = value;
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(AspNetCoreTags));
break;
default:
base.SetTag(key, value);
Expand Down
Loading
Loading