Skip to content

Commit 7f0d3fc

Browse files
[2.0] Split integration id AdoNet into individual ids per db type (#2008)
Co-authored-by: Zach Montoya <zach.montoya@datadoghq.com>
1 parent c502c6b commit 7f0d3fc

File tree

50 files changed

+716
-896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+716
-896
lines changed

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetClientInstrumentMethodAttribute.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// </copyright>
55

66
using System;
7+
using Datadog.Trace.Configuration;
78

89
namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet
910
{
@@ -17,7 +18,10 @@ public AdoNetClientInstrumentMethodAttribute(Type adoNetClientDataType)
1718
TypeName = AdoNetClientData.SqlCommandType;
1819
MinimumVersion = AdoNetClientData.MinimumVersion;
1920
MaximumVersion = AdoNetClientData.MaximumVersion;
20-
IntegrationName = AdoNetConstants.IntegrationName;
21+
22+
// Not used for ADO.NET integration.
23+
// Integration name is determined by type of DbCommand in DbScopeFactory
24+
IntegrationName = null;
2125
}
2226

2327
protected IAdoNetClientData AdoNetClientData { get; }

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetConstants.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
44
// </copyright>
55

6-
using System;
7-
using Datadog.Trace.Configuration;
8-
96
namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AdoNet
107
{
118
internal static class AdoNetConstants
129
{
13-
internal const string IntegrationName = nameof(Configuration.IntegrationId.AdoNet);
14-
internal const IntegrationId IntegrationId = Configuration.IntegrationId.AdoNet;
15-
1610
internal struct SystemDataClientData : IAdoNetClientData
1711
{
12+
// note: not a real integration id, cannot be used for configuration
13+
public string IntegrationName => "AdoNet";
14+
1815
public string AssemblyName => "System.Data";
1916

2017
public string SqlCommandType => "System.Data.Common.DbCommand";
@@ -23,13 +20,16 @@ internal struct SystemDataClientData : IAdoNetClientData
2320

2421
public string MaximumVersion => "4.*.*";
2522

26-
public string DataReaderType => AdoNet.AdoNetConstants.TypeNames.DbDataReaderType;
23+
public string DataReaderType => TypeNames.DbDataReaderType;
2724

28-
public string DataReaderTaskType => AdoNet.AdoNetConstants.TypeNames.DbDataReaderTaskType;
25+
public string DataReaderTaskType => TypeNames.DbDataReaderTaskType;
2926
}
3027

3128
internal struct SystemDataCommonClientData : IAdoNetClientData
3229
{
30+
// note: not a real integration id, cannot be used for configuration
31+
public string IntegrationName => "AdoNet";
32+
3333
public string AssemblyName => "System.Data.Common";
3434

3535
public string SqlCommandType => "System.Data.Common.DbCommand";
@@ -38,9 +38,9 @@ internal struct SystemDataCommonClientData : IAdoNetClientData
3838

3939
public string MaximumVersion => "6.*.*";
4040

41-
public string DataReaderType => AdoNet.AdoNetConstants.TypeNames.DbDataReaderType;
41+
public string DataReaderType => TypeNames.DbDataReaderType;
4242

43-
public string DataReaderTaskType => AdoNet.AdoNetConstants.TypeNames.DbDataReaderTaskType;
43+
public string DataReaderTaskType => TypeNames.DbDataReaderTaskType;
4444
}
4545

4646
public static class TypeNames

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetDefinitions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
* Task<int> .ExecuteNonQueryAsync(CancellationToken)
1111
********************************************************************************/
1212

13-
// Task<int> System.Data.Common.DBCommand.ExecuteNonQueryAsync(CancellationToken)
13+
// Task<int> System.Data.Common.DbCommand.ExecuteNonQueryAsync(CancellationToken)
1414
[assembly: CommandExecuteNonQueryAsync(typeof(SystemDataClientData))]
1515
[assembly: CommandExecuteNonQueryAsync(typeof(SystemDataCommonClientData))]
1616

1717
/********************************************************************************
1818
* Task<DbDataReader> .ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)
1919
********************************************************************************/
2020

21-
// Task<DbDataReader> System.Data.Common.DBCommand.ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)
21+
// Task<DbDataReader> System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)
2222
[assembly: CommandExecuteDbDataReaderWithBehaviorAndCancellationAsync(typeof(SystemDataClientData))]
2323
[assembly: CommandExecuteDbDataReaderWithBehaviorAndCancellationAsync(typeof(SystemDataCommonClientData))]
2424

2525
/********************************************************************************
2626
* Task<object> .ExecuteScalarAsync(CancellationToken)
2727
********************************************************************************/
2828

29-
// Task<object> System.Data.Common.DBCommand.ExecuteScalarAsync(CancellationToken)
29+
// Task<object> System.Data.Common.DbCommand.ExecuteScalarAsync(CancellationToken)
3030
[assembly: CommandExecuteScalarAsync(typeof(SystemDataClientData))]
3131
[assembly: CommandExecuteScalarAsync(typeof(SystemDataCommonClientData))]

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryAsyncIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CommandExecuteNonQueryAsyncIntegration
2828
/// <returns>Calltarget state value</returns>
2929
public static CallTargetState OnMethodBegin<TTarget>(TTarget instance, CancellationToken cancellationToken)
3030
{
31-
return new CallTargetState(ScopeDBFactory<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
31+
return new CallTargetState(DbScopeFactory.Cache<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
3232
}
3333

3434
/// <summary>

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CommandExecuteNonQueryIntegration
2626
/// <returns>Calltarget state value</returns>
2727
public static CallTargetState OnMethodBegin<TTarget>(TTarget instance)
2828
{
29-
return new CallTargetState(ScopeDBFactory<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
29+
return new CallTargetState(DbScopeFactory.Cache<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
3030
}
3131

3232
/// <summary>

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteNonQueryWithBehaviorIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CommandExecuteNonQueryWithBehaviorIntegration
2828
/// <returns>Calltarget state value</returns>
2929
public static CallTargetState OnMethodBegin<TTarget, TBehavior>(TTarget instance, TBehavior commandBehavior)
3030
{
31-
return new CallTargetState(ScopeDBFactory<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
31+
return new CallTargetState(DbScopeFactory.Cache<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
3232
}
3333

3434
/// <summary>

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderAsyncIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class CommandExecuteReaderAsyncIntegration
2727
/// <returns>Calltarget state value</returns>
2828
public static CallTargetState OnMethodBegin<TTarget>(TTarget instance)
2929
{
30-
return new CallTargetState(ScopeDBFactory<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
30+
return new CallTargetState(DbScopeFactory.Cache<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
3131
}
3232

3333
/// <summary>

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CommandExecuteReaderIntegration
2626
/// <returns>Calltarget state value</returns>
2727
public static CallTargetState OnMethodBegin<TTarget>(TTarget instance)
2828
{
29-
return new CallTargetState(ScopeDBFactory<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
29+
return new CallTargetState(DbScopeFactory.Cache<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
3030
}
3131

3232
/// <summary>

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class CommandExecuteReaderWithBehaviorAndCancellationAsyncIntegration
3131
/// <returns>Calltarget state value</returns>
3232
public static CallTargetState OnMethodBegin<TTarget, TBehavior>(TTarget instance, TBehavior commandBehavior, CancellationToken cancellationToken)
3333
{
34-
return new CallTargetState(ScopeDBFactory<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
34+
return new CallTargetState(DbScopeFactory.Cache<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
3535
}
3636

3737
/// <summary>

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/CommandExecuteReaderWithBehaviorAsyncIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CommandExecuteReaderWithBehaviorAsyncIntegration
2828
/// <returns>Calltarget state value</returns>
2929
public static CallTargetState OnMethodBegin<TTarget, TBehavior>(TTarget instance, TBehavior commandBehavior)
3030
{
31-
return new CallTargetState(ScopeDBFactory<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
31+
return new CallTargetState(DbScopeFactory.Cache<TTarget>.CreateDbCommandScope(Tracer.Instance, (IDbCommand)instance));
3232
}
3333

3434
/// <summary>

0 commit comments

Comments
 (0)