Skip to content

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Aug 1, 2025

In constructing metadata in #115265, it was missed that ProviderName and Metadata ID are prepended to the metadata block instead of being a part of the EventPipeEvent's Metadata. Those two fields assist in correlating Event blocks with Metadata blocks as specified in https://github.com/microsoft/perfview/blob/main/src/TraceEvent/EventPipe/NetTraceFormat_v5.md#metadata-event-encoding.

For User_events EventPipe scenarios, the metadata will be inlined with the event, so there is no need for a MetadataID, and thus we will only prepend the ProviderName to avoid having to encode an unused uint32_t.

Testing

# tracer: nop
#
# entries-in-buffer/entries-written: 34/34   #P:2
#
#                                _-----=> irqs-off/BH-disabled
#                               / _----=> need-resched
#                              | / _---=> hardirq/softirq
#                              || / _--=> preempt-depth
#                              ||| / _-=> migrate-disable
#                              |||| /     delay
#           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
#              | |         |   |||||     |         |
  .NET TP Worker-48238   [001] ..... 16214.532937: mihw: version=(1) event_id=0x50 (80) extension=01,5a,00,00,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2d,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,2d,00,44,00,6f,00,74,00,4e,00,45,00,54,00,52,00,75,00,6e,00,74,00,69,00,6d,00,65,00,00,00,50,00,00,00,00,00,00,80,00,00,02,00,00,00,01,00,00,00,02,00,00,00,00,00,00,00 payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48146   [000] ..... 16214.834897: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48146   [000] ..... 16215.139393: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48146   [000] ..... 16215.441248: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48238   [000] ..... 16215.743354: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48238   [000] ..... 16216.047708: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48238   [000] ..... 16216.350802: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48146   [001] ..... 16216.652679: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48146   [000] ..... 16216.958208: whim: version=(1) event_id=0x12f (303) extension=01,5a,00,00,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2d,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,2d,00,44,00,6f,00,74,00,4e,00,45,00,54,00,52,00,75,00,6e,00,74,00,69,00,6d,00,65,00,00,00,2f,01,00,00,00,00,00,00,00,00,00,08,00,00,00,00,00,00,04,00,00,00,00,00,00,00 payload=01,00,00,00,00,00,f8,20,4f,79,ff,7f,00,00,53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,42,00,79,00,74,00,65,00,5b,00,5d,00,00,00,48,00,c0,62,bf,7f,00,00,18,00,10,00,00,00,00,00,d8,ca,00,00,00,00,00,00
  .NET TP Worker-48146   [000] ..... 16216.958341: mihw: version=(1) event_id=0x50 (80) extension= payload=53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,45,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,00,00,54,00,68,00,69,00,73,00,20,00,69,00,73,00,20,00,61,00,20,00,74,00,65,00,73,00,74,00,20,00,65,00,78,00,63,00,65,00,70,00,74,00,69,00,6f,00,6e,00,20,00,74,00,6f,00,20,00,64,00,65,00,6d,00,6f,00,6e,00,73,00,74,00,72,00,61,00,74,00,65,00,20,00,65,00,72,00,72,00,6f,00,72,00,20,00,68,00,61,00,6e,00,64,00,6c,00,69,00,6e,00,67,00,2e,00,00,00,00,00,00,00,00,00,00,00,00,15,13,80,10,00,00,00
  .NET TP Worker-48238   [000] ..... 16217.259988: whim: version=(1) event_id=0x12f (303) extension= payload=01,00,00,00,00,00,f8,20,4f,79,ff,7f,00,00,53,00,79,00,73,00,74,00,65,00,6d,00,2e,00,42,00,79,00,74,00,65,00,5b,00,5d,00,00,00,80,00,d0,62,bf,7f,00,00,18,00,10,00,00,00,00,00,b6,1a,00,00,00,00,00,00

Copy link
Contributor

@Copilot 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 modifies the EventPipe metadata serialization to include the ProviderName as part of the metadata payload, aligning with the NetTrace format specification. The key change addresses a gap where the ProviderName wasn't being prepended to metadata blocks as required for proper event-to-metadata correlation.

  • Adds ProviderName (UTF-16 string) to the metadata payload structure
  • Updates metadata length calculation to include the provider name size
  • Adjusts the maximum iovec array size to accommodate the additional metadata component

@mdh1418 mdh1418 force-pushed the user_events_fix_metadata_bytes branch from 2ed2c7a to c4170c7 Compare August 1, 2025 22:31
@mdh1418 mdh1418 force-pushed the user_events_fix_metadata_bytes branch from c4170c7 to 858070b Compare August 1, 2025 22:32
@mdh1418 mdh1418 merged commit bb20ad0 into dotnet:main Aug 2, 2025
129 of 131 checks passed
noahfalk pushed a commit to dotnet/diagnostics that referenced this pull request Aug 11, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants