Support question mark in wildcard - #2875
Conversation
cijothomas
left a comment
There was a problem hiding this comment.
- 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.
Do we need a to a contains check for * and ? now?
There was a problem hiding this comment.
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.
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.
Maybe an extension method on String class? 😆
There was a problem hiding this comment.
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.
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 🌏
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
|
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).