Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[System.Diagnostics.DiagnosticSource] Support listening to meters out-of-proc using a wildcard #105581

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

CodeBlanch
Copy link
Contributor

@CodeBlanch CodeBlanch commented Jul 26, 2024

Changes

  • Adds support inside MetricsEventSource for listening to meters out-of-proc by using a wildcard\prefix style (ex: *, Company.Library*) for meter name in spec

/cc @noahfalk @samsp-msft @tarekgh @rajkumar-rangaraj

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 26, 2024
@tarekgh
Copy link
Member

tarekgh commented Jul 26, 2024

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tarekgh tarekgh added this to the 9.0.0 milestone Jul 26, 2024
@tarekgh
Copy link
Member

tarekgh commented Jul 27, 2024

@ericstj this fix is needed for enabling scenarios of dotnet-monitor with OpenTelemetry. Please let us know if you have any feedback or we good to go.

@noahfalk please have a look it is one line fix.

@CodeBlanch
Copy link
Contributor Author

CodeBlanch commented Jul 27, 2024

@tarekgh I added support for doing a prefix as well as the blanket wildcard. Thinking more about this, that will probably be very useful for users who may want to do things like listen to all runtime or aspnetcore metrics but may not care about other things so much.

Also had to fix up the tests a bit for introduction of runtime metrics. And there was a cast issue seems to have been introduced recently 🤷

spec.MeterName.EndsWith('*'))
#else
spec.MeterName.EndsWith("*", StringComparison.Ordinal))
#endif
Copy link
Member

@tarekgh tarekgh Jul 28, 2024

Choose a reason for hiding this comment

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

This is not worth the ifdef you can write it like

spec.MeterName.Length > 0 && spec.MeterName[spec.MeterName.Length - 1] == '*'

Or just use spec.MeterName.EndsWith("*", StringComparison.Ordinal)) which still fast enough even in .NET 8.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated! I also made all the string comparisons StringComparison.OrdinalIgnoreCase. My thinking there is these values are likely coming from config so it is nice to make them as forgiving as possible 😄

@tarekgh tarekgh merged commit d7fc2f5 into dotnet:main Jul 30, 2024
79 of 84 checks passed
@CodeBlanch CodeBlanch deleted the meter-out-of-proc-wildcard-listen branch August 1, 2024 16:37
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Diagnostics.Metric community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants