From a497c3958479c21ff262567d7916b181431109c2 Mon Sep 17 00:00:00 2001 From: Kevin Gosse Date: Mon, 6 Jan 2025 15:01:58 +0100 Subject: [PATCH 1/3] Log an error message when the profiler is loaded multiple times --- tracer/src/Datadog.Tracer.Native/cor_profiler.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp index d9c69641405a..1ec8d07a80d8 100644 --- a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp +++ b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp @@ -51,6 +51,13 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un Logger::EnableDebug(true); } + if (profiler != nullptr) + { + Logger::Error("The Tracer Profiler is initialized multiple times. This may cause unpredictable failures.", + " When running aspnetcore in IIS, make sure to disable managed code in the application pool settings.", + " https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-9.0#create-the-iis-site"); + } + CorProfilerBase::Initialize(cor_profiler_info_unknown); // we used to bail-out if tracing was disabled, but we now allow the tracer to be loaded From eea5d39263b09512c6a64b7549273712f91f45f7 Mon Sep 17 00:00:00 2001 From: Kevin Gosse Date: Mon, 6 Jan 2025 15:20:05 +0100 Subject: [PATCH 2/3] Info log when running in AAS --- .../src/Datadog.Tracer.Native/cor_profiler.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp index 1ec8d07a80d8..ecf8ccfb1f87 100644 --- a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp +++ b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp @@ -51,11 +51,20 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un Logger::EnableDebug(true); } + auto isRunningInAas = IsAzureAppServices(); + if (profiler != nullptr) { - Logger::Error("The Tracer Profiler is initialized multiple times. This may cause unpredictable failures.", - " When running aspnetcore in IIS, make sure to disable managed code in the application pool settings.", - " https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-9.0#create-the-iis-site"); + if (isRunningInAas) + { + Logger::Info("The Tracer Profiler is initialized multiple times. This is expected when running in AAS."); + } + else + { + Logger::Error("The Tracer Profiler is initialized multiple times. This may cause unpredictable failures.", + " When running aspnetcore in IIS, make sure to disable managed code in the application pool settings.", + " https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-9.0#create-the-iis-site"); + } } CorProfilerBase::Initialize(cor_profiler_info_unknown); @@ -164,7 +173,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un } } - if (IsAzureAppServices()) + if (isRunningInAas) { Logger::Info("Profiler is operating within Azure App Services context."); From 738a87cac5bd5f042207f8e2514c2c8adf568b17 Mon Sep 17 00:00:00 2001 From: Kevin Gosse Date: Mon, 6 Jan 2025 15:25:27 +0100 Subject: [PATCH 3/3] Update cor_profiler.cpp --- tracer/src/Datadog.Tracer.Native/cor_profiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp index ecf8ccfb1f87..066bf36dbe7f 100644 --- a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp +++ b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp @@ -57,7 +57,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un { if (isRunningInAas) { - Logger::Info("The Tracer Profiler is initialized multiple times. This is expected when running in AAS."); + Logger::Info("The Tracer Profiler is initialized multiple times. This is expected and currently unavoidable when running in AAS."); } else {