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
15 changes: 15 additions & 0 deletions Datadog.Trace.sln
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceBus.Minimal.Rebus",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceBus.Minimal.MassTransit", "tracer\test\test-applications\regression\ServiceBus.Minimal.MassTransit\ServiceBus.Minimal.MassTransit.csproj", "{B0E671B9-78DE-410F-A0AA-612FF1F900F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.AspNetAsyncHandler", "tracer\test\test-applications\aspnet\Samples.AspNetAsyncHandler\Samples.AspNetAsyncHandler.csproj", "{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.GraphQL3", "tracer\test\test-applications\integrations\Samples.GraphQL3\Samples.GraphQL3.csproj", "{CA3D605F-8DD7-4041-B024-70A24036AFA1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.GraphQL4", "tracer\test\test-applications\integrations\Samples.GraphQL4\Samples.GraphQL4.csproj", "{DA81EF3E-FDB3-417F-AA20-60FC495E3596}"
Expand Down Expand Up @@ -1732,6 +1734,18 @@ Global
{B0E671B9-78DE-410F-A0AA-612FF1F900F2}.Release|x64.Build.0 = Release|x64
{B0E671B9-78DE-410F-A0AA-612FF1F900F2}.Release|x86.ActiveCfg = Release|x86
{B0E671B9-78DE-410F-A0AA-612FF1F900F2}.Release|x86.Build.0 = Release|x86
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Debug|x64.ActiveCfg = Debug|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Debug|x64.Build.0 = Debug|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Debug|x86.ActiveCfg = Debug|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Debug|x86.Build.0 = Debug|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Release|Any CPU.Build.0 = Release|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Release|x64.ActiveCfg = Release|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Release|x64.Build.0 = Release|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Release|x86.ActiveCfg = Release|Any CPU
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C}.Release|x86.Build.0 = Release|Any CPU
{CA3D605F-8DD7-4041-B024-70A24036AFA1}.Debug|Any CPU.ActiveCfg = Debug|x86
{CA3D605F-8DD7-4041-B024-70A24036AFA1}.Debug|x64.ActiveCfg = Debug|x64
{CA3D605F-8DD7-4041-B024-70A24036AFA1}.Debug|x64.Build.0 = Debug|x64
Expand Down Expand Up @@ -1892,6 +1906,7 @@ Global
{9D5935CB-2DF2-46CB-A5E1-98BE134CAFCC} = {498A300E-D036-49B7-A43D-821D1CAF11A5}
{6C599D79-87D0-476B-9CBA-F731E5627622} = {498A300E-D036-49B7-A43D-821D1CAF11A5}
{B0E671B9-78DE-410F-A0AA-612FF1F900F2} = {498A300E-D036-49B7-A43D-821D1CAF11A5}
{B6A98887-4A47-4C19-9C6F-D833E24F4B1C} = {AFA0AB23-64F0-4AC1-9050-6CE8FE06F580}
{CA3D605F-8DD7-4041-B024-70A24036AFA1} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
{DA81EF3E-FDB3-417F-AA20-60FC495E3596} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
EndGlobalSection
Expand Down
53 changes: 53 additions & 0 deletions tracer/integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,59 @@
"signature": "00 00 01",
"action": "InsertFirst"
}
},
{
"caller": {
"assembly": "System.Web"
},
"target": {
"assembly": "System.Web",
"type": "System.Web.ThreadContext",
"method": "AssociateWithCurrentThread",
"signature_types": [
"System.Void",
"System.Boolean"
],
"minimum_major": 4,
"minimum_minor": 0,
"minimum_patch": 0,
"maximum_major": 4,
"maximum_minor": 65535,
"maximum_patch": 65535
},
"wrapper": {
"assembly": "Datadog.Trace, Version=1.28.6.0, Culture=neutral, PublicKeyToken=def86d061d0d2eeb",
"type": "Datadog.Trace.ClrProfiler.Integrations.AspNet.AspNetThreadContextIntegration",
"method": "AssociateWithCurrentThread",
"signature": "00 05 01 1C 02 08 08 0A",
"action": "ReplaceTargetMethod"
}
},
{
"caller": {
"assembly": "System.Web"
},
"target": {
"assembly": "System.Web",
"type": "System.Web.ThreadContext",
"method": "DisassociateFromCurrentThread",
"signature_types": [
"System.Void"
],
"minimum_major": 4,
"minimum_minor": 0,
"minimum_patch": 0,
"maximum_major": 4,
"maximum_minor": 65535,
"maximum_patch": 65535
},
"wrapper": {
"assembly": "Datadog.Trace, Version=1.28.6.0, Culture=neutral, PublicKeyToken=def86d061d0d2eeb",
"type": "Datadog.Trace.ClrProfiler.Integrations.AspNet.AspNetThreadContextIntegration",
"method": "DisassociateFromCurrentThread",
"signature": "00 04 01 1C 08 08 0A",
"action": "ReplaceTargetMethod"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <copyright file="IHttpContext.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using System.Collections;
using System.ComponentModel;
using Datadog.Trace.DuckTyping;

namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet
{
/// <summary>
/// System.Web.HttpContext interface for ducktyping
/// </summary>
[DuckCopy]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public struct IHttpContext
{
/// <summary>
/// Gets the items dictionary
/// </summary>
public IDictionary Items;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// <copyright file="IThreadContext.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using System.ComponentModel;

namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet
{
/// <summary>
/// System.Web.HttpApplication interface for ducktyping
/// </summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public interface IThreadContext
{
/// <summary>
/// Gets the HttpContext of the thread context
/// </summary>
IHttpContext HttpContext { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// <copyright file="ThreadContext_AssociateWithCurrentThread_Integration.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using System.ComponentModel;
using Datadog.Trace.ClrProfiler.CallTarget;
using Datadog.Trace.Configuration;

namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet
{
/// <summary>
/// System.Web.ThreadContext.AssociateWithCurrentThread calltarget instrumentation
/// </summary>
[InstrumentMethod(
AssemblyName = "System.Web",
TypeName = "System.Web.ThreadContext",
MethodName = "AssociateWithCurrentThread",
ReturnTypeName = ClrNames.Void,
ParameterTypeNames = new[] { ClrNames.Bool },
MinimumVersion = "4.0.0",
MaximumVersion = "4.*.*",
IntegrationName = IntegrationName)]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public class ThreadContext_AssociateWithCurrentThread_Integration
{
private const string IntegrationName = nameof(IntegrationIds.AspNet);
private const string HttpContextScopeKey = "__Datadog.Trace.AspNet.TracingHttpModule-aspnet.request";

/// <summary>
/// OnMethodBegin callback
/// </summary>
/// <typeparam name="TTarget">Type of the target</typeparam>
/// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
/// <param name="setImpersonationContext">A flag to set the impersonation context</param>
/// <returns>Calltarget state value</returns>
public static CallTargetState OnMethodBegin<TTarget>(TTarget instance, bool setImpersonationContext)
where TTarget : IThreadContext
{
var httpContext = instance.HttpContext;
if (httpContext.Items[HttpContextScopeKey] is Scope scope && ((IDatadogTracer)Tracer.Instance).ScopeManager is IScopeRawAccess rawAccess)
{
rawAccess.Active = scope;
}

return CallTargetState.GetDefault();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// <copyright file="ThreadContext_DisassociateFromCurrentThread_Integration.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using System.ComponentModel;
using Datadog.Trace.ClrProfiler.CallTarget;
using Datadog.Trace.Configuration;

namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AspNet
{
/// <summary>
/// System.Web.ThreadContext.DisassociateFromCurrentThread calltarget instrumentation
/// </summary>
[InstrumentMethod(
AssemblyName = "System.Web",
TypeName = "System.Web.ThreadContext",
MethodName = "DisassociateFromCurrentThread",
ReturnTypeName = ClrNames.Void,
ParameterTypeNames = new string[0],
MinimumVersion = "4.0.0",
MaximumVersion = "4.*.*",
IntegrationName = IntegrationName)]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public class ThreadContext_DisassociateFromCurrentThread_Integration
{
private const string IntegrationName = nameof(IntegrationIds.AspNet);

/// <summary>
/// OnMethodBegin callback
/// </summary>
/// <typeparam name="TTarget">Type of the target</typeparam>
/// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
/// <returns>Calltarget state value</returns>
public static CallTargetState OnMethodBegin<TTarget>(TTarget instance)
where TTarget : IThreadContext
{
if (((IDatadogTracer)Tracer.Instance).ScopeManager is IScopeRawAccess rawAccess)
{
rawAccess.Active = null;
}

return CallTargetState.GetDefault();
}
}
}
Loading