Skip to content

EventSource WriteEvent params overload doesn't get written to EventPipe #124518

Closed

Description

@PJB3005

Description

I'm writing some logging using EventSource. It seems that events written via the params overload does not get written to EventPipe. ETW is fine.

Reproduction Steps

Code:

using System.Diagnostics.Tracing;

for (var i = 0; i < 10000; i++)
{
    Thread.Sleep(TimeSpan.FromSeconds(0.01));

    TestEventSource.Log.Works(i, Random.Shared.GetString("asdf", 10));
    TestEventSource.Log.DoesntWork(i, Random.Shared.GetString("asdf", 10));
}

[EventSource(Name = "TestEventSource")]
internal sealed class TestEventSource : EventSource
{
    public static readonly TestEventSource Log = new();

    [Event(1)]
    public void Works(int id, string name) => WriteEvent(1, id, name);

    // params EventSourcePrimitive[] overload.
    [Event(2)]
    public void DoesntWork(int id, string name) => WriteEvent(2, [id, name]);
}

Tracing using this for EventPipe:

C:\Users\Luna\Documents\traces
> dotnet trace collect -n ConsoleApp1 --providers TestEventSource --rundown false

Provider Name                           Keywords            Level               Enabled By
TestEventSource                         0x0000000000000000  Informational(4)    --providers

Process        : E:\Projects\scratch\dotnet_eventpipe_eventsource_vararg\ConsoleApp1\bin\Debug\net10.0\ConsoleApp1.exe
Output File    : C:\Users\Luna\Documents\traces\ConsoleApp1.exe_20260217_165130.nettrace

[00:00:00:22]   Recording trace 57.344   (KB)
Press <Enter> or <Ctrl+C> to exit...
Stopping the trace. This may take several minutes depending on the application being traced.

Trace completed.

And this for ETW:

Image

Expected behavior

Both events being present in the trace file, like ETW:

Image

Actual behavior

DoesntWork event is missing in EventPipe trace file:

Image

Regression?

No idea

Known Workarounds

Make a custom overload of WriteEvent() that doesn't use the params overload.

Configuration

.NET: 10.0.3
OS:

Edition	Windows 11 Pro
Version	24H2
Installed on	‎02/‎03/‎2025
OS build	26100.7840
Experience	Windows Feature Experience Pack 1000.26100.291.0

x64

Other information

No response

Activity

  1. added
    untriaged
    on Feb 17, 2026
  2. removed
    untriaged
    on Jul 10, 2026
  3. added this to the 11.0.0 milestone on Jul 10, 2026
  4. self-assigned this
    on Jul 10, 2026
  5. mdh1418 commented on Jul 10, 2026

    @mdh1418
    Member

    Hi @PJB3005, sorry we didn't get to this until now.

    It looks like a combination of factors are causing the discrepancy for the params overloaded Event to not be emitted.
    One of which is dotnet-trace treating providers with no specified keywords as nothing enabled https://github.com/dotnet/diagnostics/blob/f4c4ac378cba26df6c3c5899a3cecd0b8fa802b4/src/Tools/dotnet-trace/ProviderUtils.cs#L22, whereas PerfView defaults the keywords to all enabled https://github.com/microsoft/perfview/blob/226c25a3c2c9779fee173fc029c203a50e7330b0/src/PerfView/CommandProcessor.cs#L3706.

    The other discrepancy is being addressed in #130525,
    but the workarounds you can use to collect events with params overload is

    1. Collect a trace and specify a sessionmask in the keyword dotnet-trace collect --providers TestEventSource:0x100000000000:4
    2. Use an explicit keyword in the params overload event
    [Event(2, Keywords=(EventKeywords)0x1)]
    public void DoesntWork(int id, string name) => WriteEvent(2, [id, name]);

    and trace with that keyword enabled dotnet-trace collect --providers TestEventSource:0x1:4

  6. added a commit that references this issue on Jul 24, 2026
    c6ece1e
  7. added a commit that references this issue on Jul 26, 2026
    887e098
  8. locked and limited conversation to collaborators on Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions