Skip to content

Commit cb4647c

Browse files
[IAST] Added IAST instrumentation category to ado net Reader integrations (#6523)
## Summary of changes Added Instrumentation category to AdoNetSignature attribute and set it to IAST for all ado net Reader integrations ## Reason for change IAST integrations were being active in non IAST scenarios ## Implementation details Default category was Tracer. Added the InstrumentationCategory field to the attribute and generate the call targets properly ## Test coverage None, to avoid build clutter (as discussed in the comments) ## Other details <!-- Fixes #{issue} --> <!-- ⚠️ Note: where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. -->
1 parent f8a75eb commit cb4647c

File tree

13 files changed

+292
-272
lines changed

13 files changed

+292
-272
lines changed

tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs

+20-11
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,31 @@ static AdoNetSignature GetAdoNetSignature(TypeDefinition type, CustomAttribute a
231231
int? integrationKind = null;
232232
int? returnType = null;
233233
string callTargetType = null;
234+
var instrumentationCategory = InstrumentationCategory.Tracing;
234235

235236
foreach (var namedArgument in attribute.Properties)
236237
{
237238
switch (namedArgument.Name)
238239
{
239-
case nameof(AdoNetSignatureAttributeProperties.MethodName):
240+
case nameof(AdoNetTargetSignatureAttributeProperties.MethodName):
240241
methodName = namedArgument.Argument.Value?.ToString();
241242
break;
242-
case nameof(AdoNetSignatureAttributeProperties.ReturnTypeName):
243+
case nameof(AdoNetTargetSignatureAttributeProperties.ReturnTypeName):
243244
returnTypeName = namedArgument.Argument.Value?.ToString();
244245
break;
245-
case nameof(AdoNetSignatureAttributeProperties.ParameterTypeNames):
246+
case nameof(AdoNetTargetSignatureAttributeProperties.ParameterTypeNames):
246247
parameterTypeNames = GetStringArray(namedArgument.Argument.Value);
247248
break;
248-
case nameof(AdoNetSignatureAttributeProperties.CallTargetType):
249+
case nameof(AdoNetTargetSignatureAttributeProperties.CallTargetType):
249250
callTargetType = ((TypeDefinition)namedArgument.Argument.Value).FullName;
250251
break;
251-
case nameof(AdoNetSignatureAttributeProperties.CallTargetIntegrationKind):
252+
case nameof(AdoNetTargetSignatureAttributeProperties.CallTargetIntegrationKind):
252253
integrationKind = namedArgument.Argument.Value as int?;
253254
break;
254-
case nameof(AdoNetSignatureAttributeProperties.ReturnType):
255+
case nameof(AdoNetTargetSignatureAttributeProperties.InstrumentationCategory):
256+
instrumentationCategory = (InstrumentationCategory)(namedArgument.Argument.Value as uint?).GetValueOrDefault();
257+
break;
258+
case nameof(AdoNetTargetSignatureAttributeProperties.ReturnType):
255259
returnType = namedArgument.Argument.Value as int?;
256260
break;
257261
default:
@@ -279,9 +283,10 @@ static AdoNetSignature GetAdoNetSignature(TypeDefinition type, CustomAttribute a
279283
targetMethodName: methodName!,
280284
targetReturnType: returnTypeName,
281285
targetParameterTypes: parameterTypeNames ?? Array.Empty<string>(),
286+
returnType: returnType ?? 0,
282287
instrumentationTypeName: callTargetType!.ToString(),
283288
callTargetIntegrationKind: integrationKind ?? 0,
284-
returnType: returnType ?? 0);
289+
instrumentationCategory: instrumentationCategory);
285290
}
286291

287292
static List<AssemblyCallTargetDefinitionSource> GetAdoNetClientInstruments(CustomAttribute attribute)
@@ -421,7 +426,7 @@ static List<CallTargetDefinitionSource> MergeAdoNetAttributes(List<AssemblyCallT
421426
instrumentationTypeName: signature.InstrumentationTypeName,
422427
integrationKind: signature.CallTargetIntegrationKind,
423428
isAdoNetIntegration: true,
424-
instrumentationCategory: InstrumentationCategory.Tracing);
429+
instrumentationCategory: signature.InstrumentationCategory);
425430

426431
res.Add(callTargetSource);
427432
}
@@ -716,14 +721,15 @@ public CallTargetDefinitionSource(string integrationName, string assemblyName, s
716721

717722
internal record AdoNetSignature
718723
{
719-
public AdoNetSignature(string className, string targetMethodName, string targetReturnType, string[] targetParameterTypes, string instrumentationTypeName, int callTargetIntegrationKind, int returnType)
724+
public AdoNetSignature(string className, string targetMethodName, string targetReturnType, string[] targetParameterTypes, string instrumentationTypeName, int callTargetIntegrationKind, int returnType, InstrumentationCategory instrumentationCategory)
720725
{
721726
ClassName = className;
722727
TargetMethodName = targetMethodName;
723728
TargetReturnType = targetReturnType;
724729
TargetParameterTypes = new(targetParameterTypes);
725730
InstrumentationTypeName = instrumentationTypeName;
726731
CallTargetIntegrationKind = callTargetIntegrationKind;
732+
InstrumentationCategory = instrumentationCategory;
727733
ReturnType = returnType;
728734
}
729735

@@ -739,6 +745,8 @@ public AdoNetSignature(string className, string targetMethodName, string targetR
739745

740746
public int CallTargetIntegrationKind { get; }
741747

748+
public InstrumentationCategory InstrumentationCategory { get; }
749+
742750
public int ReturnType { get; }
743751
}
744752

@@ -796,14 +804,15 @@ private static class InstrumentAttributeProperties
796804
public const string InstrumentationCategory = nameof(InstrumentationCategory);
797805
}
798806

799-
private static class AdoNetSignatureAttributeProperties
807+
private static class AdoNetTargetSignatureAttributeProperties
800808
{
801809
public const string MethodName = nameof(MethodName);
802810
public const string ReturnTypeName = nameof(ReturnTypeName);
803811
public const string ParameterTypeNames = nameof(ParameterTypeNames);
812+
public const string ReturnType = nameof(ReturnType);
804813
public const string CallTargetType = nameof(CallTargetType);
805814
public const string CallTargetIntegrationKind = nameof(CallTargetIntegrationKind);
806-
public const string ReturnType = nameof(ReturnType);
815+
public const string InstrumentationCategory = nameof(InstrumentationCategory);
807816
}
808817

809818
private static class AdoNetInstrumentAttributeProperties

0 commit comments

Comments
 (0)