Improve logging and profiler diagnostics#2759
Merged
Merged
Conversation
🤖 GitHub commentsJust comment with:
|
There was a problem hiding this comment.
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.Idand a UTC timestamp. - Prevent multiple
TextWriterTraceListenerregistrations 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.Load → LoadFrom 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.
LikeTheSalad
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.