dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.54k stars 4.54k forks source link

Microsoft-Diagnostic-DiagnosticSource does not support wildcard filtering for listener names in ETW #37328

Open kzu opened 4 years ago

kzu commented 4 years ago

Description

When libraries and apps use DiagnosticSource (which is really nice!), there is an automatic bridge to also automatically get ETW events "for free", pretty much. This is immensely useful!

There is one big drawback, however: the only supported listener filter is an exact match for a listener name (or no filter at all). This is less than ideal, since an app that uses DiagnosticSource extensively and has extensions contributing to it too, can no longer selectively collect traces for areas of the app and not others. This is specially problematic when using PerfView since you'd get machine-wide logs from anything that's using DiagnosticSource, basically.

Proposal:

Extend the supported format for event name so that it can also include a * character at the end of the DIAGNOSTIC_SOURCE_NAME part. This would indicate that the filter should do a StartsWith match instead of an == comparison with the listener name.

ghost commented 4 years ago

Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti Notify danmosemsft if you want to be subscribed.

tarekgh commented 4 years ago

@tommcdon @noahfalk I assume you'll triage this as the owners.

tommcdon commented 4 years ago

@kzu thank you for the suggestion. I'm marking this as milestone 5.0 for now, though depending on other competing priorities and remaining time left in the 5.0, we may defer this issue to the next milestone. If you are interested in contributing a pull request, please feel free to do so. cc @josalem

kzu commented 4 years ago

Cool, thanks! Yes, the plan is to contribute the fix, if you'd be willing to take it in once approved 👍

noahfalk commented 4 years ago

Seems like a very reasonable proposal to me : ) If you want to submit a PR including a working test case I'd be glad to review it. If all looks good we'll merge it.