Skip to content

Differentiate between error states #7030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ internal static CallTargetState OnMethodBegin<TTarget, TSpanContext>(TTarget ins

if (instance.AutomaticTracer is not Datadog.Trace.Tracer tracer)
{
Log.Error(
"Error: instance.AutomaticTracer is not a Datadog.Trace.Tracer: {TracerType}. This should never happen, and indicates a problem with automatic instrumentation.",
instance.AutomaticTracer?.GetType());
LogInvalidAutomaticTracer(instance.AutomaticTracer);
return CallTargetState.GetDefault();
}

Expand All @@ -65,4 +63,27 @@ internal static CallTargetReturn<TReturn> OnMethodEnd<TTarget, TReturn>(TTarget
: returnValue;
return new CallTargetReturn<TReturn>(duckScope);
}

internal static void LogInvalidAutomaticTracer(object? autoTracer)
{
try
{
// Throwing and catching to grab to call stack and redact it for telemetry
throw new Exception("instance.AutomaticTracer was not a Datadog.Trace.Tracer");
}
catch (Exception ex)
{
if (autoTracer is null)
{
Log.Error(ex, "Error: instance.AutomaticTracer is null. This should never happen, and indicates a problem with automatic instrumentation.");
}
else
{
Log.Error(
ex,
"Error: instance.AutomaticTracer is not a Datadog.Trace.Tracer: {TracerType}. This should never happen, and indicates a problem with automatic instrumentation.",
autoTracer.GetType());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ internal static CallTargetState OnMethodBegin<TTarget, TSpanContext>(TTarget ins
// This is only used by the OpenTracing public API
if (instance.AutomaticTracer is not Datadog.Trace.Tracer tracer)
{
Log.Error(
"Error: instance.AutomaticTracer is not a Datadog.Trace.Tracer: {TracerType}. This should never happen, and indicates a problem with automatic instrumentation.",
instance.AutomaticTracer?.GetType());
StartActiveImplementationIntegration.LogInvalidAutomaticTracer(instance.AutomaticTracer);
return CallTargetState.GetDefault();
}

Expand Down
Loading