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

Unify with logging category matching #90559

Merged
merged 3 commits into from
Aug 15, 2023
Merged

Conversation

Tratcher
Copy link
Member

Follow up to #90201. I'd implemented the meter name matching to follow logging's documented behaviors, and what we'd thought was plausibly useful. However, logging's category matching has a lot of undocumented behaviors and odd assumptions.

This change makes meter matching work the same as category matching.

@Tratcher Tratcher self-assigned this Aug 15, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 15, 2023
@jkotas jkotas added area-System.Diagnostics.Metric and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Aug 15, 2023
Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

👍

}

if (!instrument.Meter.Name.AsSpan().StartsWith(prefix, StringComparison.OrdinalIgnoreCase) ||
!instrument.Meter.Name.AsSpan().EndsWith(suffix, StringComparison.OrdinalIgnoreCase))
Copy link
Member

Choose a reason for hiding this comment

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

what the behavior will be if have like, meter name ABCDE and have searching for ABC*CDE. This search should fail but with current code it will succeed I guess. Maybe we need to check the length of prefix and suffix against the meter name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we're going for complete compatibility with logging's matching I'd rather not adjust the behavior for corner cases like this. We can revisit this in 9 for both of them if you want.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be a good idea to stick with the wrong behavior? This will be compatibility issue if we don't do it from now. I prefer doing it but I'll leave it to you if you think otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does match when it shouldn't. Even weirder, ABCDE*ABCDE matches "ABCDE" since it's just StartsWith and EndsWith checks. I'm going to leave it for now since logging works the same way.

Copy link
Member

Choose a reason for hiding this comment

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

I agree its weird, but my rationale has remained that if people aren't complaining about it via ILogger then we should remain compatible. If someone did complain about it I assume we'd want to change it uniformly, not change it just for metrics.

@tarekgh
Copy link
Member

tarekgh commented Aug 15, 2023

    public void RuleMatchesNegativeTest(string meterName, string instrumentName, string listenerName)

could you please add a test for the case I mentioned earlier? meter name ABCDE and search ABC*CDE.


Refers to: src/libraries/Microsoft.Extensions.Diagnostics/tests/ListenerSubscriptionTests.cs:258 in 6b0484e. [](commit_id = 6b0484e, deletion_comment = False)

Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

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

Added a few comments/questions. Otherwise LGTM.

@tarekgh tarekgh added this to the 8.0.0 milestone Aug 15, 2023
@Tratcher Tratcher merged commit 79c021d into dotnet:main Aug 15, 2023
1 check passed
@Tratcher Tratcher deleted the tratcher/matching branch August 15, 2023 21:06
@Tratcher
Copy link
Member Author

Tratcher commented Aug 15, 2023

/backport to release/8.0

@Tratcher
Copy link
Member Author

/backport to release/8.0-rc1

@github-actions
Copy link
Contributor

Started backporting to release/8.0-rc1: https://github.com/dotnet/runtime/actions/runs/5872147388

@ghost ghost locked as resolved and limited conversation to collaborators Sep 15, 2023
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.

4 participants