Skip to content

Commit 4a57c08

Browse files
committed
Fix for net2.2 > net3.1
1 parent 3f3c574 commit 4a57c08

File tree

10 files changed

+1033
-906
lines changed

10 files changed

+1033
-906
lines changed

tracer/build/supported_calltargets.g.json

+57-6
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,37 @@
10321032
"TargetParameterTypes": [
10331033
"Microsoft.AspNetCore.Builder.IApplicationBuilder",
10341034
"Microsoft.AspNetCore.Http.PathString",
1035-
"System.Boolean",
10361035
"System.Action`1[Microsoft.AspNetCore.Builder.IApplicationBuilder]"
10371036
],
10381037
"MinimumVersion": {
10391038
"Item1": 2,
1039+
"Item2": 2,
1040+
"Item3": 0
1041+
},
1042+
"MaximumVersion": {
1043+
"Item1": 3,
1044+
"Item2": 65535,
1045+
"Item3": 65535
1046+
},
1047+
"InstrumentationTypeName": "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegrationV2V3",
1048+
"IntegrationKind": 0,
1049+
"IsAdoNetIntegration": false,
1050+
"InstrumentationCategory": 2
1051+
},
1052+
{
1053+
"IntegrationName": "AspNetCore",
1054+
"AssemblyName": "Microsoft.AspNetCore.Http.Abstractions",
1055+
"TargetTypeName": "Microsoft.AspNetCore.Builder.MapExtensions",
1056+
"TargetMethodName": "Map",
1057+
"TargetReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder",
1058+
"TargetParameterTypes": [
1059+
"Microsoft.AspNetCore.Builder.IApplicationBuilder",
1060+
"Microsoft.AspNetCore.Http.PathString",
1061+
"System.Boolean",
1062+
"System.Action`1[Microsoft.AspNetCore.Builder.IApplicationBuilder]"
1063+
],
1064+
"MinimumVersion": {
1065+
"Item1": 5,
10401066
"Item2": 0,
10411067
"Item3": 0
10421068
},
@@ -1045,10 +1071,10 @@
10451071
"Item2": 65535,
10461072
"Item3": 65535
10471073
},
1048-
"InstrumentationTypeName": "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegration",
1074+
"InstrumentationTypeName": "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegrationV5Plus",
10491075
"IntegrationKind": 0,
10501076
"IsAdoNetIntegration": false,
1051-
"InstrumentationCategory": 1
1077+
"InstrumentationCategory": 2
10521078
},
10531079
{
10541080
"IntegrationName": "AspNetCore",
@@ -1062,7 +1088,7 @@
10621088
],
10631089
"MinimumVersion": {
10641090
"Item1": 2,
1065-
"Item2": 0,
1091+
"Item2": 2,
10661092
"Item3": 0
10671093
},
10681094
"MaximumVersion": {
@@ -1073,7 +1099,7 @@
10731099
"InstrumentationTypeName": "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.RunExtensionsRunIntegration",
10741100
"IntegrationKind": 0,
10751101
"IsAdoNetIntegration": false,
1076-
"InstrumentationCategory": 1
1102+
"InstrumentationCategory": 2
10771103
},
10781104
{
10791105
"IntegrationName": "AspNetCore",
@@ -1297,6 +1323,31 @@
12971323
"IsAdoNetIntegration": false,
12981324
"InstrumentationCategory": 6
12991325
},
1326+
{
1327+
"IntegrationName": "AspNetCore",
1328+
"AssemblyName": "Microsoft.AspNetCore.Server.Kestrel.Core",
1329+
"TargetTypeName": "Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer",
1330+
"TargetMethodName": "StartAsync",
1331+
"TargetReturnType": "System.Threading.Tasks.Task",
1332+
"TargetParameterTypes": [
1333+
"Microsoft.AspNetCore.Hosting.Server.IHttpApplication`1[!!0]",
1334+
"System.Threading.CancellationToken"
1335+
],
1336+
"MinimumVersion": {
1337+
"Item1": 2,
1338+
"Item2": 2,
1339+
"Item3": 0
1340+
},
1341+
"MaximumVersion": {
1342+
"Item1": 3,
1343+
"Item2": 65535,
1344+
"Item3": 65535
1345+
},
1346+
"InstrumentationTypeName": "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.KestrelServerImplStartAsyncIntegration",
1347+
"IntegrationKind": 0,
1348+
"IsAdoNetIntegration": false,
1349+
"InstrumentationCategory": 2
1350+
},
13001351
{
13011352
"IntegrationName": "AspNetCore",
13021353
"AssemblyName": "Microsoft.AspNetCore.Server.Kestrel.Core",
@@ -1320,7 +1371,7 @@
13201371
"InstrumentationTypeName": "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.KestrelServerImplStartAsyncIntegration",
13211372
"IntegrationKind": 0,
13221373
"IsAdoNetIntegration": false,
1323-
"InstrumentationCategory": 1
1374+
"InstrumentationCategory": 2
13241375
},
13251376
{
13261377
"IntegrationName": "AspNetCore",

tracer/src/Datadog.Trace/AppSec/ApiSec/MapEndpointsCollection.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public static void BeggingMapEndpoint(string path)
2626

2727
public static void EndMapEndpoint()
2828
{
29-
_buildingMapEndpoints?.Pop();
29+
if (_buildingMapEndpoints?.Count > 0)
30+
{
31+
_buildingMapEndpoints.Pop();
32+
}
3033
}
3134

3235
public static void DetectedAvailableEndpoint()

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNetCore/EndpointsCollection/KestrelServerImplStartAsyncIntegration.cs

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsColl
2929
ParameterTypeNames = ["Microsoft.AspNetCore.Hosting.Server.IHttpApplication`1[!!0]", ClrNames.CancellationToken],
3030
MinimumVersion = "2.2.0",
3131
MaximumVersion = SupportedVersions.LatestDotNet,
32+
InstrumentationCategory = InstrumentationCategory.AppSec,
33+
IntegrationName = nameof(IntegrationId.AspNetCore))]
34+
[InstrumentMethod(
35+
AssemblyName = "Microsoft.AspNetCore.Server.Kestrel.Core",
36+
TypeName = "Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer",
37+
MethodName = "StartAsync",
38+
ReturnTypeName = ClrNames.Task,
39+
ParameterTypeNames = ["Microsoft.AspNetCore.Hosting.Server.IHttpApplication`1[!!0]", ClrNames.CancellationToken],
40+
MinimumVersion = "2.2.0",
41+
MaximumVersion = "3.*.*",
42+
InstrumentationCategory = InstrumentationCategory.AppSec,
3243
IntegrationName = nameof(IntegrationId.AspNetCore))]
3344
[Browsable(false)]
3445
[EditorBrowsable(EditorBrowsableState.Never)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// <copyright file="MapExtensionsMapIntegrationV2V3.cs" company="Datadog">
2+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
4+
// </copyright>
5+
#nullable enable
6+
7+
#if NETCOREAPP2_2_OR_GREATER
8+
9+
using System;
10+
using System.ComponentModel;
11+
using Datadog.Trace.AppSec;
12+
using Datadog.Trace.ClrProfiler.CallTarget;
13+
using Datadog.Trace.Configuration;
14+
15+
namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection;
16+
17+
/// <summary>
18+
/// Microsoft.AspNetCore.Builder.IApplicationBuilder Microsoft.AspNetCore.Builder.MapExtensions::Map(Microsoft.AspNetCore.Builder.IApplicationBuilder,Microsoft.AspNetCore.Http.PathString,System.Boolean,System.Action`1[Microsoft.AspNetCore.Builder.IApplicationBuilder]) calltarget instrumentation
19+
/// </summary>
20+
[InstrumentMethod(
21+
AssemblyName = "Microsoft.AspNetCore.Http.Abstractions",
22+
TypeName = "Microsoft.AspNetCore.Builder.MapExtensions",
23+
MethodName = "Map",
24+
ReturnTypeName = "Microsoft.AspNetCore.Builder.IApplicationBuilder",
25+
ParameterTypeNames = ["Microsoft.AspNetCore.Builder.IApplicationBuilder", "Microsoft.AspNetCore.Http.PathString", "System.Action`1[Microsoft.AspNetCore.Builder.IApplicationBuilder]"],
26+
MinimumVersion = "2.2.0",
27+
MaximumVersion = "3.*.*",
28+
InstrumentationCategory = InstrumentationCategory.AppSec,
29+
IntegrationName = nameof(IntegrationId.AspNetCore))]
30+
[Browsable(false)]
31+
[EditorBrowsable(EditorBrowsableState.Never)]
32+
public class MapExtensionsMapIntegrationV2V3
33+
{
34+
internal static CallTargetState OnMethodBegin<TTarget, TApp, TPathMatch, TConfiguration>(ref TApp? app, ref TPathMatch pathMatch, ref TConfiguration? configuration)
35+
{
36+
if (Security.Instance.ApiSecurity.CanCollectEndpoints())
37+
{
38+
MapEndpointsCollection.BeggingMapEndpoint(pathMatch!.ToString()!);
39+
}
40+
41+
return CallTargetState.GetDefault();
42+
}
43+
44+
internal static CallTargetReturn<TReturn?> OnMethodEnd<TTarget, TReturn>(TReturn? returnValue, Exception? exception, in CallTargetState state)
45+
{
46+
if (Security.Instance.ApiSecurity.CanCollectEndpoints())
47+
{
48+
MapEndpointsCollection.EndMapEndpoint();
49+
}
50+
51+
return new CallTargetReturn<TReturn?>(returnValue);
52+
}
53+
}
54+
55+
#endif

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNetCore/EndpointsCollection/MapExtensionsMapIntegration.cs tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNetCore/EndpointsCollection/MapExtensionsMapIntegrationV5Plus.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// <copyright file="MapExtensionsMapIntegration.cs" company="Datadog">
1+
// <copyright file="MapExtensionsMapIntegrationV5Plus.cs" company="Datadog">
22
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
33
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
44
// </copyright>
55
#nullable enable
66

7-
#if !NETFRAMEWORK
7+
#if NETCOREAPP2_2_OR_GREATER
88

99
using System;
1010
using System.ComponentModel;
@@ -23,12 +23,13 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsColl
2323
MethodName = "Map",
2424
ReturnTypeName = "Microsoft.AspNetCore.Builder.IApplicationBuilder",
2525
ParameterTypeNames = ["Microsoft.AspNetCore.Builder.IApplicationBuilder", "Microsoft.AspNetCore.Http.PathString", ClrNames.Bool, "System.Action`1[Microsoft.AspNetCore.Builder.IApplicationBuilder]"],
26-
MinimumVersion = "2.0.0",
27-
MaximumVersion = "9.*.*",
26+
MinimumVersion = "5.0.0",
27+
MaximumVersion = SupportedVersions.LatestDotNet,
28+
InstrumentationCategory = InstrumentationCategory.AppSec,
2829
IntegrationName = nameof(IntegrationId.AspNetCore))]
2930
[Browsable(false)]
3031
[EditorBrowsable(EditorBrowsableState.Never)]
31-
public class MapExtensionsMapIntegration
32+
public class MapExtensionsMapIntegrationV5Plus
3233
{
3334
internal static CallTargetState OnMethodBegin<TTarget, TApp, TPathMatch, TConfiguration>(ref TApp? app, ref TPathMatch pathMatch, ref bool preserveMatchedPathSegment, ref TConfiguration? configuration)
3435
{

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNetCore/EndpointsCollection/RunExtensionsRunIntegration.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// </copyright>
55
#nullable enable
66

7-
#if !NETFRAMEWORK
7+
#if NETCOREAPP2_2_OR_GREATER
88

99
using System.ComponentModel;
1010
using Datadog.Trace.AppSec;
@@ -22,8 +22,9 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsColl
2222
MethodName = "Run",
2323
ReturnTypeName = ClrNames.Void,
2424
ParameterTypeNames = ["Microsoft.AspNetCore.Builder.IApplicationBuilder", "Microsoft.AspNetCore.Http.RequestDelegate"],
25-
MinimumVersion = "2.0.0",
26-
MaximumVersion = "9.*.*",
25+
MinimumVersion = "2.2.0",
26+
MaximumVersion = SupportedVersions.LatestDotNet,
27+
InstrumentationCategory = InstrumentationCategory.AppSec,
2728
IntegrationName = nameof(IntegrationId.AspNetCore))]
2829
[Browsable(false)]
2930
[EditorBrowsable(EditorBrowsableState.Never)]

tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/InstrumentationDefinitionsGenerator/InstrumentationDefinitions.g.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ internal static bool IsInstrumentedAssembly(string assemblyName)
8080
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.AspNetCoreBlockMiddlewareIntegrationEnd"
8181
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.AspNetCoreBlockMiddlewareIntegrationEnd"
8282
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.HttpContextSetUser"
83-
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegration"
83+
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegrationV2V3"
84+
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegrationV5Plus"
8485
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.RunExtensionsRunIntegration"
8586
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.SignInManagerPasswordSignInIntegration"
8687
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.SignInManagerPasswordSignInIntegration"
@@ -92,6 +93,7 @@ internal static bool IsInstrumentedAssembly(string assemblyName)
9293
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.FireOnStartCommon"
9394
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.FireOnStartCommon"
9495
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.KestrelServerImplStartAsyncIntegration"
96+
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.KestrelServerImplStartAsyncIntegration"
9597
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.Session.SessionOptionsIdleTimeoutIntegration"
9698
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.StaticFiles.DirectoryBrowserExtensionsUseDirectoryBrowserIntegration"
9799
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.StaticFiles.DirectoryBrowserExtensionsUseDirectoryBrowserIntegration"

tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/InstrumentationDefinitionsGenerator/InstrumentationDefinitions.g.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ internal static bool IsInstrumentedAssembly(string assemblyName)
7878
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.AspNetCoreBlockMiddlewareIntegrationEnd"
7979
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.AspNetCoreBlockMiddlewareIntegrationEnd"
8080
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.HttpContextSetUser"
81-
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegration"
81+
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegrationV2V3"
82+
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegrationV5Plus"
8283
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.RunExtensionsRunIntegration"
8384
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.SignInManagerPasswordSignInIntegration"
8485
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.SignInManagerPasswordSignInIntegration"
@@ -90,6 +91,7 @@ internal static bool IsInstrumentedAssembly(string assemblyName)
9091
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.FireOnStartCommon"
9192
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.FireOnStartCommon"
9293
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.KestrelServerImplStartAsyncIntegration"
94+
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.KestrelServerImplStartAsyncIntegration"
9395
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.Session.SessionOptionsIdleTimeoutIntegration"
9496
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.StaticFiles.DirectoryBrowserExtensionsUseDirectoryBrowserIntegration"
9597
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.StaticFiles.DirectoryBrowserExtensionsUseDirectoryBrowserIntegration"

tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/InstrumentationDefinitionsGenerator/InstrumentationDefinitions.g.cs

-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ internal static bool IsInstrumentedAssembly(string assemblyName)
7878
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.AspNetCoreBlockMiddlewareIntegrationEnd"
7979
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.AspNetCoreBlockMiddlewareIntegrationEnd"
8080
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.HttpContextSetUser"
81-
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.MapExtensionsMapIntegration"
82-
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.EndpointsCollection.RunExtensionsRunIntegration"
8381
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.SignInManagerPasswordSignInIntegration"
8482
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.SignInManagerPasswordSignInIntegration"
8583
or "Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNetCore.UserEvents.SignInManagerPasswordSignInUserIntegration"

0 commit comments

Comments
 (0)