Skip to content

Commit 8b26eb2

Browse files
authored
[Dynamic Instrumentation] Disable AppDomain related log flooding on .NET Framework (#8025)
## Summary of changes In legacy .NET Framework, a single process can host multiple logically isolated applications ("AppDomains") managed by the runtime. The machine code produced from jitting a method is used among the app domains. Thus, instrumentation is also being shared. The runtime isolates those different domains and prevents data sharing (that is only possible through marshalling/proxying). Each probe has metadata associated with it that is either received through the network (Remote Configuration) or created locally as in Exception Replay. This metadata is kept in memory and is crucial for the instrumentation to function correctly. When a method with an instrumentation is executed in a different domain from the one that kept this metadata, it can't retrieve it, thus bails out with a log message. If such method executes many times, we may log plenty of time, result in log files rotation and flooding the disk. We have a customer that complaint about it. As a quick fix for now, I'm disabling those log messages on .NET Framework. ## Reason for change Flooding log files with the log message `BeginMethod_StartMarker: Failed to receive the ProbeData associated with the executing probe <...>` ## Implementation details Disabling the log message on .NET Framework using a preprocessor directive that prevents the compilation of this log message on .NET Framework builds.
1 parent 5d1df24 commit 8b26eb2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tracer/src/Datadog.Trace/Debugger/Instrumentation/AsyncMethodDebuggerInvoker.SingleProbe.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,14 @@ public static void BeginMethod<TTarget>(TTarget instance, int methodMetadataInde
161161
ref var probeData = ref ProbeDataCollection.Instance.TryCreateProbeDataIfNotExists(probeMetadataIndex, probeId);
162162
if (probeData.IsEmpty())
163163
{
164+
// In .NET Framework, we have en issue with multiple AppDomains. We can't easily share probe metadata
165+
// between different AppDomain. The domain that request to put a probe might be different from the one that executes it.
166+
// It results in entering into this branch. There is ongoing effort to fix this issue entirely in .NET Framework,
167+
// for now as a quick fix to unblock a customer, this patch is being applied, to avoid logging tremendous amount of
168+
// log entries.
169+
#if !NETFRAMEWORK
164170
Log.Warning("BeginMethod: Failed to receive the ProbeData associated with the executing probe. type = {Type}, instance type name = {Name}, probeMetadataIndex = {ProbeMetadataIndex}, probeId = {ProbeId}", new object[] { typeof(TTarget), instance?.GetType().Name, probeMetadataIndex, probeId });
171+
#endif
165172
state = AsyncMethodDebuggerState.CreateInvalidatedDebuggerState();
166173
return;
167174
}

tracer/src/Datadog.Trace/Debugger/Instrumentation/MethodDebuggerInvoker.SingleProbe.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ public static MethodDebuggerState BeginMethod_StartMarker<TTarget>(TTarget insta
8787
ref var probeData = ref ProbeDataCollection.Instance.TryCreateProbeDataIfNotExists(probeMetadataIndex, probeId);
8888
if (probeData.IsEmpty())
8989
{
90+
// In .NET Framework, we have en issue with multiple AppDomains. We can't easily share probe metadata
91+
// between different AppDomain. The domain that request to put a probe might be different from the one that executes it.
92+
// It results in entering into this branch. There is ongoing effort to fix this issue entirely in .NET Framework,
93+
// for now as a quick fix to unblock a customer, this patch is being applied, to avoid logging tremendous amount of
94+
// log entries.
95+
#if !NETFRAMEWORK
9096
Log.Warning("BeginMethod_StartMarker: Failed to receive the ProbeData associated with the executing probe. type = {Type}, instance type name = {Name}, probeMetadataIndex = {ProbeMetadataIndex}, probeId = {ProbeId}", new object[] { typeof(TTarget), instance?.GetType().Name, probeMetadataIndex, probeId });
97+
#endif
9198
return CreateInvalidatedDebuggerState();
9299
}
93100

0 commit comments

Comments
 (0)