Skip to content

Diagnostic logs for loaded assemblies and remove dotnet process startup hook file noise#2774

Merged
stevejgordon merged 4 commits into
mainfrom
logging-improvements
Jun 26, 2026
Merged

Diagnostic logs for loaded assemblies and remove dotnet process startup hook file noise#2774
stevejgordon merged 4 commits into
mainfrom
logging-improvements

Conversation

@stevejgordon

Copy link
Copy Markdown
Contributor

Skips startup hook logging for "dotnet" processes which occurs due to the startup hook mechanism and causes extra log files to be generated, adding noise and overhead.

When an application is run voa the dotnet CLI and startup hook env vars are set for the current sessions or system wide, it results in the dotnet process itself being instrumented, causing two log files. At termination, dotnet stop also runs causing two additional log files. These are noise and the instrumentation adds overhead. This change skips instrumentation of all dotnet processes to avoid these problems.

This change also ports (and improves) an EDOT .NET logging enhancement to track loaded assemblies which may be diagnosticly helpful for complex scenarios.

@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!)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request reduces startup hook logging noise by skipping agent initialization for dotnet CLI host processes, and adds debug-level diagnostics that log assemblies as they load to help troubleshoot complex dependency/versioning scenarios.

Changes:

  • Early-exit from startup hook initialization when the entry assembly is dotnet to avoid instrumenting dotnet run/build/watch host processes.
  • Add an AppDomain.AssemblyLoad subscriber to log loaded assemblies (including version/token/location) at debug level, plus an initial scan of already-loaded assemblies.
  • Ensure the configured log directory exists when file logging is enabled (best-effort).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/startuphook/ElasticApmAgentStartupHook/StartupHook.cs Skips startup hook initialization for dotnet CLI host processes to prevent extra log files/overhead.
src/startuphook/Elastic.Apm.StartupHook.Loader/Loader.cs Hooks in the new assembly-load diagnostic logging during loader initialization.
src/startuphook/Elastic.Apm.StartupHook.Loader/AssemblyLoadLogger.cs New utility that logs assemblies as they load (debug-only, de-duped).
src/Elastic.Apm/Logging/GlobalLogConfiguration.cs Best-effort creation of the log directory when file logging is enabled.

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

Comment thread src/startuphook/ElasticApmAgentStartupHook/StartupHook.cs Outdated
@stevejgordon stevejgordon force-pushed the logging-improvements branch from 78e8d6d to df6b2bf Compare June 26, 2026 08:46
@stevejgordon stevejgordon force-pushed the logging-improvements branch from df6b2bf to 4aca1d6 Compare June 26, 2026 08:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@stevejgordon stevejgordon requested a review from a team June 26, 2026 09:20
jackshirazi
jackshirazi previously approved these changes Jun 26, 2026
@stevejgordon stevejgordon merged commit ef27e81 into main Jun 26, 2026
19 checks passed
@stevejgordon stevejgordon deleted the logging-improvements branch June 26, 2026 10:46
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