Skip to content

Improve logging and profiler diagnostics#2759

Merged
stevejgordon merged 1 commit into
mainfrom
improve-profiler-diagnostics
May 22, 2026
Merged

Improve logging and profiler diagnostics#2759
stevejgordon merged 1 commit into
mainfrom
improve-profiler-diagnostics

Conversation

@stevejgordon
Copy link
Copy Markdown
Contributor

@stevejgordon stevejgordon commented May 22, 2026

As titled.

The main fix here is ensuring we don't create multiple agent logs per process which can occur on IIS apps and makes support/diagnostics complicated and risks losing a small number of messages.

This also adds some additional diagnostics to the profiler logging to make detecting known problems easier.

@github-actions
Copy link
Copy Markdown

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves agent/profiler diagnostics and reduces log fragmentation by ensuring global TraceSource-based logging is only wired up once per AppDomain, while also making log filenames more diagnostic (AppDomain + timestamp) and expanding profiler loader logging for common failure modes (assembly resolution and IIS shadow-copy/loader-optimization scenarios).

Changes:

  • Update global agent log file naming to include AppDomain.Id and a UTC timestamp.
  • Prevent multiple TextWriterTraceListener registrations in the same AppDomain and emit a one-time log header.
  • Add richer profiler managed-loader and auto-instrumentation diagnostics around IIS hosting detection, registry-based .NET Framework detection, and assembly resolution/load failures.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/Elastic.Apm.Tests/Config/GlobalLogConfigurationTests.cs Adds coverage for the new log filename format (AppDomain + timestamp).
src/Elastic.Apm/Logging/GlobalLogConfiguration.cs Changes log file prefix generation to include AppDomain ID and UTC timestamp.
src/Elastic.Apm/AgentComponents.cs Adds a one-time (per AppDomain) guard for TraceSource listener setup and writes a file header.
src/Elastic.Apm/Config/ConfigurationLogger.cs Extends agent preamble logging with AppDomain and (NETFRAMEWORK) IIS hosting diagnostics.
src/profiler/Elastic.Apm.Profiler.Managed/AutoInstrumentation.cs Adds debug logging when IIS hosting is detected and instantiation is skipped.
src/profiler/Elastic.Apm.Profiler.Managed.Loader/Startup.cs Adds detailed startup diagnostics and a robust Assembly.LoadLoadFrom fallback with warnings.
src/profiler/Elastic.Apm.Profiler.Managed.Loader/Startup.NetFramework.cs Adds debug/warn/error logs for registry probing and AssemblyResolve load outcomes.
src/profiler/Elastic.Apm.Profiler.Managed.Loader/Startup.NetCore.cs Adds AssemblyResolve diagnostics and error logging around load failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stevejgordon stevejgordon requested a review from a team May 22, 2026 11:55
@stevejgordon stevejgordon merged commit 9dfeccc into main May 22, 2026
22 checks passed
@stevejgordon stevejgordon deleted the improve-profiler-diagnostics branch May 22, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants