Skip to content

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

Merged
tarekgh merged 3 commits into
dotnet:mainfrom
CodeBlanch:meter-out-of-proc-wildcard-listen
Jul 30, 2024
Merged

[System.Diagnostics.DiagnosticSource] Support listening to meters out-of-proc using a wildcard#105581
tarekgh merged 3 commits into
dotnet:mainfrom
CodeBlanch:meter-out-of-proc-wildcard-listen

Conversation

@CodeBlanch

@CodeBlanch CodeBlanch commented Jul 26, 2024

Copy link
Copy Markdown
Contributor

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

tarekgh commented Jul 26, 2024

Copy link
Copy Markdown
Member

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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

tarekgh commented Jul 27, 2024

Copy link
Copy Markdown
Member

@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

CodeBlanch commented Jul 27, 2024

Copy link
Copy Markdown
Contributor Author

@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

@tarekgh tarekgh Jul 28, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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
@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