Skip to content

Initialize EventPipe tracee logging before collection - #6028

Merged
max-charlamb merged 2 commits into
dotnet:mainfrom
max-charlamb:max-charlamb/deterministic-eventlogs-test
Sep 15, 2026
Merged

max-charlamb merged 2 commits into
dotnet:mainfrom
max-charlamb:max-charlamb/deterministic-eventlogs-test

Conversation

@max-charlamb

@max-charlamb max-charlamb commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • construct the EventPipe tracee logger factory and loggers before signaling that the tracee is ready
  • prevent EventPipe filter updates from racing logger options-monitor initialization and leaving application filters active
  • re-enable the previously skipped EventLogs tests while retaining their original strict ordering assertions

Root cause

The tracee connected its readiness pipe before constructing ILoggerFactory. The parent treats that connection as permission to enable EventPipe. If the EventPipe filter update raced logger-factory initialization, the options monitor could miss the change notification and retain the application filters (Error by default and Warning for AppLoggerCategory). This dropped the three LoggerRemoteTest records and the app Information record, leaving exactly the app Warning and Error records.

The original tests reproduced this locally: LogsPipelineUnitTests received 2 of 5 records after 45 iterations, and EventLogsPipelineUnitTests subsequently observed Warning message. where the first custom Information record was expected. TraceEvent already merges EventPipe events by timestamp, so the failure was missing events rather than a lack of consumer-side sorting.

Testing

  • rebuilt EventPipeTracee for .NET 8, 9, 10, and 11
  • ran the original ordered EventLogsPipelineUnitTests and LogsPipelineUnitTests 100 consecutive times
  • 32 tests per iteration, 3,200 executions total, with 0 failures and 0 skips

Fixes #2541
Fixes #5659

Match expected log records by message instead of assuming global ordering across EventPipe producer threads, and re-enable the previously skipped coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d5c60f7-9c89-42e6-b9fc-04ef78c8f8d8
@max-charlamb
max-charlamb requested a review from a team as a code owner September 14, 2026 15:24
Copilot AI lite review requested due to automatic review settings September 14, 2026 15:24

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.

🟢 Approval recommended

No unresolved review issues remain, and the tests retain full validation.

Pull request overview

Updates EventLogs tests to validate records independently of cross-thread delivery order.

Changes:

  • Matches records by message identity.
  • Preserves exact count and metadata validation.
  • Re-enables previously skipped tests.
File summaries
File Description
src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventLogsPipelineUnitTests.cs Makes EventLogs assertions order-independent and re-enables skipped tests.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Construct the tracee logger factory before signaling readiness so EventPipe filter updates cannot race options-monitor initialization and drop the initial log records.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d5c60f7-9c89-42e6-b9fc-04ef78c8f8d8
@max-charlamb max-charlamb changed the title Make EventLogs tests order-independent Initialize EventPipe tracee logging before collection Sep 14, 2026
@max-charlamb
max-charlamb enabled auto-merge (squash) September 14, 2026 20:33
@max-charlamb
max-charlamb merged commit 7612e4c into dotnet:main Sep 15, 2026
23 checks passed
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.

[Tests] LogsPipelineUnitTests TestLogsPipeline fails with Assert.Equal() Failure TestLogsAllCategoriesDefaultLevelFallback fails frequently

3 participants