Skip to content

Commit 15c0409

Browse files
Revert "Add modified WCF CallTarget instrumentation via opt-in environment variable (#1992)" (#2081)
This reverts commit d009bf0. The previous commit introduced a change to the CallTarget definition structure that passes integration information to the profiler, but this can cause issues if the profiler and the NuGet package versions mismatch.
1 parent 1b75be0 commit 15c0409

File tree

50 files changed

+402
-2867
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

+402
-2867
lines changed

tracer/build/_build/PrepareRelease/CallTargetDefinitionSource.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public class CallTargetDefinitionSource
1717

1818
public string TargetMethod { get; init; }
1919

20-
public ushort[] TargetMethodArgumentsToLoad { get; init; }
21-
2220
public string[] TargetSignatureTypes { get; init; }
2321

2422
public ushort TargetMinimumMajor { get; init; }

tracer/build/_build/PrepareRelease/GenerateIntegrationDefinitions.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ from assemblyNames in GetPropertyValue<string[]>(attribute, "AssemblyNames")
130130
TargetAssembly = assemblyNames,
131131
TargetType = GetPropertyValue<string>(attribute, "TypeName"),
132132
TargetMethod = GetPropertyValue<string>(attribute, "MethodName"),
133-
TargetMethodArgumentsToLoad = (GetPropertyValue<ushort[]>(attribute, "TargetMethodArgumentsToLoad") ?? Enumerable.Empty<ushort>()).ToArray(),
134133
TargetSignatureTypes = new string[] { GetPropertyValue<string>(attribute, "ReturnTypeName") }
135134
.Concat(GetPropertyValue<string[]>(attribute, "ParameterTypeNames") ?? Enumerable.Empty<string>())
136135
.ToArray(),
@@ -188,28 +187,6 @@ static void WriteCallTargetDefinitionFile(StreamWriter swriter, IEnumerable<Call
188187

189188
swriter.Write(" }, ");
190189

191-
if (integration.TargetMethodArgumentsToLoad.Length > 0)
192-
{
193-
swriter.Write($" new ushort[] {{ ");
194-
for (var s = 0; s < integration.TargetMethodArgumentsToLoad.Length; s++)
195-
{
196-
if (s == integration.TargetMethodArgumentsToLoad.Length - 1)
197-
{
198-
swriter.Write($"{integration.TargetMethodArgumentsToLoad[s]}");
199-
}
200-
else
201-
{
202-
swriter.Write($"{integration.TargetMethodArgumentsToLoad[s]}, ");
203-
}
204-
}
205-
206-
swriter.Write(" }, ");
207-
}
208-
else
209-
{
210-
swriter.Write("null, ");
211-
}
212-
213190
swriter.Write($"{integration.TargetMinimumMajor}, ");
214191
swriter.Write($"{integration.TargetMinimumMinor}, ");
215192
swriter.Write($"{integration.TargetMinimumPatch}, ");

tracer/src/Datadog.Trace.ClrProfiler.Native/calltarget_tokens.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,7 @@ HRESULT CallTargetTokens::ModifyLocalSigAndInitialize(void* rewriterWrapperPtr,
873873

874874
HRESULT CallTargetTokens::WriteBeginMethod(void* rewriterWrapperPtr, mdTypeRef integrationTypeRef,
875875
const TypeInfo* currentType,
876-
const std::vector<FunctionMethodArgument>& methodArguments,
877-
const std::vector<USHORT>& argsToLoad, ILInstr** instruction)
876+
std::vector<FunctionMethodArgument>& methodArguments, ILInstr** instruction)
878877
{
879878
auto hr = EnsureBaseCalltargetTokens();
880879
if (FAILED(hr))
@@ -885,9 +884,7 @@ HRESULT CallTargetTokens::WriteBeginMethod(void* rewriterWrapperPtr, mdTypeRef i
885884
ILRewriterWrapper* rewriterWrapper = (ILRewriterWrapper*) rewriterWrapperPtr;
886885
ModuleMetadata* module_metadata = GetMetadata();
887886

888-
auto numArgsToLoad = argsToLoad.size();
889-
bool useArgToLoad = numArgsToLoad > 0;
890-
auto numArguments = useArgToLoad ? (int) numArgsToLoad : (int) methodArguments.size();
887+
auto numArguments = (int) methodArguments.size();
891888
if (numArguments >= FASTPATH_COUNT)
892889
{
893890
return WriteBeginMethodWithArgumentsArray(rewriterWrapperPtr, integrationTypeRef, currentType, instruction);
@@ -950,17 +947,7 @@ HRESULT CallTargetTokens::WriteBeginMethod(void* rewriterWrapperPtr, mdTypeRef i
950947
ULONG argumentsSignatureSize[FASTPATH_COUNT];
951948
for (auto i = 0; i < numArguments; i++)
952949
{
953-
FunctionMethodArgument methodArgument;
954-
if (useArgToLoad)
955-
{
956-
methodArgument = methodArguments[argsToLoad[i]];
957-
}
958-
else
959-
{
960-
methodArgument = methodArguments[i];
961-
}
962-
963-
auto signatureSize = methodArgument.GetSignature(argumentsSignatureBuffer[i]);
950+
auto signatureSize = methodArguments[i].GetSignature(argumentsSignatureBuffer[i]);
964951
argumentsSignatureSize[i] = signatureSize;
965952
signatureLength += signatureSize;
966953
}

tracer/src/Datadog.Trace.ClrProfiler.Native/calltarget_tokens.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ class CallTargetTokens
8686
mdToken* callTargetReturnToken, ILInstr** firstInstruction);
8787

8888
HRESULT WriteBeginMethod(void* rewriterWrapperPtr, mdTypeRef integrationTypeRef, const TypeInfo* currentType,
89-
const std::vector<FunctionMethodArgument>& methodArguments, const std::vector<USHORT>& argsToLoad,
90-
ILInstr** instruction);
89+
std::vector<FunctionMethodArgument>& methodArguments, ILInstr** instruction);
9190

9291
HRESULT WriteEndVoidReturnMemberRef(void* rewriterWrapperPtr, mdTypeRef integrationTypeRef,
9392
const TypeInfo* currentType, ILInstr** instruction);

tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.cpp

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,14 +1251,6 @@ void CorProfiler::InitializeProfiler(WCHAR* id, CallTargetDefinition* items, int
12511251
wrapperType = WSTRING(current.wrapperType);
12521252
}
12531253

1254-
bool useTargetMethodArgumentsToLoad = current.useTargetMethodArgumentsToLoad;
1255-
std::vector<USHORT> targetMethodArgumentsToLoad;
1256-
for (int sIdx = 0; sIdx < current.targetMethodArgumentsToLoadLength; sIdx++)
1257-
{
1258-
const auto currentArgumentIndex = current.targetMethodArgumentsToLoad[sIdx];
1259-
targetMethodArgumentsToLoad.push_back(currentArgumentIndex);
1260-
}
1261-
12621254
std::vector<WSTRING> signatureTypes;
12631255
for (int sIdx = 0; sIdx < current.signatureTypesLength; sIdx++)
12641256
{
@@ -1279,9 +1271,9 @@ void CorProfiler::InitializeProfiler(WCHAR* id, CallTargetDefinition* items, int
12791271
MethodReplacement(
12801272
{},
12811273
MethodReference(targetAssembly, targetType, targetMethod, EmptyWStr, minVersion, maxVersion,
1282-
{}, signatureTypes, useTargetMethodArgumentsToLoad, targetMethodArgumentsToLoad),
1274+
{}, signatureTypes),
12831275
MethodReference(wrapperAssembly, wrapperType, EmptyWStr, calltarget_modification_action, {}, {}, {},
1284-
{}, false, {})));
1276+
{})));
12851277

12861278
if (Logger::IsDebugEnabled())
12871279
{
@@ -3440,11 +3432,7 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl
34403432
bool isVoid = (retTypeFlags & TypeFlagVoid) > 0;
34413433
bool isStatic = !(caller->method_signature.CallingConvention() & IMAGE_CEE_CS_CALLCONV_HASTHIS);
34423434
std::vector<FunctionMethodArgument> methodArguments = caller->method_signature.GetMethodArguments();
3443-
bool useCustomArgumentsTargetMethodArguments = method_replacement->target_method.use_target_method_arguments_to_load;
3444-
std::vector<USHORT> methodArgumentsToLoad = method_replacement->target_method.target_method_arguments_to_load;
3445-
int numArgs = useCustomArgumentsTargetMethodArguments
3446-
? (int) methodArgumentsToLoad.size()
3447-
: caller->method_signature.NumberOfArguments();
3435+
int numArgs = caller->method_signature.NumberOfArguments();
34483436
auto metaEmit = module_metadata->metadata_emit;
34493437
auto metaImport = module_metadata->metadata_import;
34503438

@@ -3559,11 +3547,8 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl
35593547
// Load the arguments directly (FastPath)
35603548
for (int i = 0; i < numArgs; i++)
35613549
{
3562-
int loadIndex = useCustomArgumentsTargetMethodArguments
3563-
? methodArgumentsToLoad[i]
3564-
: i;
3565-
reWriterWrapper.LoadArgument(loadIndex + (isStatic ? 0 : 1));
3566-
auto argTypeFlags = methodArguments[loadIndex].GetTypeFlags(elementType);
3550+
reWriterWrapper.LoadArgument(i + (isStatic ? 0 : 1));
3551+
auto argTypeFlags = methodArguments[i].GetTypeFlags(elementType);
35673552
if (argTypeFlags & TypeFlagByRef)
35683553
{
35693554
Logger::Warn("*** CallTarget_RewriterCallback(): Methods with ref parameters "
@@ -3579,12 +3564,8 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl
35793564
for (int i = 0; i < numArgs; i++)
35803565
{
35813566
reWriterWrapper.BeginLoadValueIntoArray(i);
3582-
3583-
int loadIndex = useCustomArgumentsTargetMethodArguments
3584-
? methodArgumentsToLoad[i]
3585-
: i;
3586-
reWriterWrapper.LoadArgument(loadIndex + (isStatic ? 0 : 1));
3587-
auto argTypeFlags = methodArguments[loadIndex].GetTypeFlags(elementType);
3567+
reWriterWrapper.LoadArgument(i + (isStatic ? 0 : 1));
3568+
auto argTypeFlags = methodArguments[i].GetTypeFlags(elementType);
35883569
if (argTypeFlags & TypeFlagByRef)
35893570
{
35903571
Logger::Warn("*** CallTarget_RewriterCallback(): Methods with ref parameters "
@@ -3593,7 +3574,7 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl
35933574
}
35943575
if (argTypeFlags & TypeFlagBoxedType)
35953576
{
3596-
auto tok = methodArguments[loadIndex].GetTypeTok(metaEmit, callTargetTokens->GetCorLibAssemblyRef());
3577+
auto tok = methodArguments[i].GetTypeTok(metaEmit, callTargetTokens->GetCorLibAssemblyRef());
35973578
if (tok == mdTokenNil)
35983579
{
35993580
return S_FALSE;
@@ -3640,7 +3621,6 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl
36403621

36413622
ILInstr* beginCallInstruction;
36423623
hr = callTargetTokens->WriteBeginMethod(&reWriterWrapper, wrapper_type_ref, &caller->type, methodArguments,
3643-
methodArgumentsToLoad,
36443624
&beginCallInstruction);
36453625
if (FAILED(hr))
36463626
{

tracer/src/Datadog.Trace.ClrProfiler.Native/integration.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,27 +247,23 @@ struct MethodReference
247247
const Version min_version;
248248
const Version max_version;
249249
const std::vector<WSTRING> signature_types;
250-
const bool use_target_method_arguments_to_load;
251-
const std::vector<USHORT> target_method_arguments_to_load;
252250

253251
MethodReference() :
254-
min_version(Version(0, 0, 0, 0)), max_version(Version(USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX)), use_target_method_arguments_to_load(false)
252+
min_version(Version(0, 0, 0, 0)), max_version(Version(USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX))
255253
{
256254
}
257255

258256
MethodReference(const WSTRING& assembly_name, WSTRING type_name, WSTRING method_name, WSTRING action,
259257
Version min_version, Version max_version, const std::vector<BYTE>& method_signature,
260-
const std::vector<WSTRING>& signature_types, const bool use_target_method_arguments_to_load, const std::vector<USHORT>& target_method_arguments_to_load) :
258+
const std::vector<WSTRING>& signature_types) :
261259
assembly(*AssemblyReference::GetFromCache(assembly_name)),
262260
type_name(type_name),
263261
method_name(method_name),
264262
action(action),
265263
method_signature(method_signature),
266264
min_version(min_version),
267265
max_version(max_version),
268-
signature_types(signature_types),
269-
use_target_method_arguments_to_load(use_target_method_arguments_to_load),
270-
target_method_arguments_to_load(target_method_arguments_to_load)
266+
signature_types(signature_types)
271267
{
272268
}
273269

@@ -340,9 +336,6 @@ typedef struct _CallTargetDefinition
340336
WCHAR* targetMethod;
341337
WCHAR** signatureTypes;
342338
USHORT signatureTypesLength;
343-
bool useTargetMethodArgumentsToLoad;
344-
USHORT* targetMethodArgumentsToLoad;
345-
USHORT targetMethodArgumentsToLoadLength;
346339
USHORT targetMinimumMajor;
347340
USHORT targetMinimumMinor;
348341
USHORT targetMinimumPatch;

tracer/src/Datadog.Trace.ClrProfiler.Native/integration_loader.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ namespace
212212
USHORT max_minor = USHRT_MAX;
213213
USHORT max_patch = USHRT_MAX;
214214
std::vector<WSTRING> signature_type_array;
215-
std::vector<USHORT> target_method_arguments_to_load_array; // Do not populate this because this only applies to CallTarget and we no longer use integrations.json
216215
WSTRING action = EmptyWStr;
217216

218217
if (is_target_method)
@@ -307,7 +306,7 @@ namespace
307306
}
308307
}
309308
return MethodReference(assembly, type, method, action, Version(min_major, min_minor, min_patch, 0),
310-
Version(max_major, max_minor, max_patch, USHRT_MAX), signature, signature_type_array, false, target_method_arguments_to_load_array);
309+
Version(max_major, max_minor, max_patch, USHRT_MAX), signature, signature_type_array);
311310
}
312311

313312
} // namespace

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeBegin_Integration.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/AsyncMethodInvoker_InvokeEnd_Integration.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/ChannelHandlerIntegration.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ public class ChannelHandlerIntegration
4242
/// <returns>Calltarget state value</returns>
4343
public static CallTargetState OnMethodBegin<TTarget, TRequestContext, TOperationContext>(TTarget instance, TRequestContext request, TOperationContext currentOperationContext)
4444
{
45-
if (Tracer.Instance.Settings.DelayWcfInstrumentationEnabled)
46-
{
47-
return CallTargetState.GetDefault();
48-
}
49-
5045
return new CallTargetState(WcfIntegration.CreateScope(request));
5146
}
5247

0 commit comments

Comments
 (0)