-
Notifications
You must be signed in to change notification settings - Fork 773
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
Support question mark in wildcard #2875
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Need changelog entry
- I suppose we didn't have unit test for tracing's AddSource with wildcard?
Codecov Report
@@ Coverage Diff @@
## main #2875 +/- ##
==========================================
- Coverage 84.22% 84.20% -0.03%
==========================================
Files 250 251 +1
Lines 8883 8883
==========================================
- Hits 7482 7480 -2
- Misses 1401 1403 +2
|
Changelog is already included in the PR. |
if (meterSources.Any(s => s.Contains('*'))) | ||
{ | ||
var regex = GetWildcardRegex(meterSources); | ||
var regex = this.GetWildcardRegex(meterSources); | ||
shouldListenTo = instrument => regex.IsMatch(instrument.Meter.Name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a to a contains check for * and ? now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed this and added test cases.
Not sure if it'll be better to extract the s.Contains('*') || s.Contains('?')
logic into a common helper, looks like it is currently used in 3 places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it'll be better to extract the
s.Contains('*') || s.Contains('?')
logic into a common helper, looks like it is currently used in 3 places.
I think it'd be a decent minor improvement, so something like:
internal static bool ContainsWildcard(string s)
{
return s.Contains('*') || s.Contains('?');
}
...
if (meterSources.Any(ContainsWildcard))
but, I'm ok 👍 without if you think it reads better without the helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an extension method on String class? 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd work too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR by extracting the wildcard logics to WildcardHelper
.
I didn't use String extension method because it could be too noisy (e.g. if someone is using Intellisense).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use String extension method because it could be too noisy (e.g. if someone is using Intellisense).
Yea I think that's a good call. I was thinking that too, but thought maybe since it'd be internal it'd just affect us and not the whole 🌏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LWTM (Looks wild to me)
Co-authored-by: Cijo Thomas <[email protected]>
Considering we are close to 1.2 stable release, i'll leave it open for a day to give more reviewers an opportunity to spot anything risky in this PR. |
Previously we only support
*
in wildcards, not?
.This PR added
?
support."Indirectly" related to open-telemetry/opentelemetry-specification#2325 (this PR only touches the provider/source part, not the View part).