diff --git a/src/Elastic.Apm/BackendComm/CentralConfig/RuntimeConfigurationSnapshot.cs b/src/Elastic.Apm/BackendComm/CentralConfig/RuntimeConfigurationSnapshot.cs index 39d894177..519b6fb08 100644 --- a/src/Elastic.Apm/BackendComm/CentralConfig/RuntimeConfigurationSnapshot.cs +++ b/src/Elastic.Apm/BackendComm/CentralConfig/RuntimeConfigurationSnapshot.cs @@ -118,7 +118,7 @@ public ConfigurationKeyValue Lookup(ConfigurationOption option) => _dynamicConfiguration?.TransactionIgnoreUrls ?? _mainConfiguration.TransactionIgnoreUrls; public IReadOnlyCollection TransactionNameGroups => - _dynamicConfiguration?.TransactionNameGroups ?? _mainConfiguration.TransactionNameGroups; + _dynamicConfiguration?.TransactionNameGroups ?? _mainConfiguration.TransactionNameGroups; public int TransactionMaxSpans => _dynamicConfiguration?.TransactionMaxSpans ?? _mainConfiguration.TransactionMaxSpans; diff --git a/src/Elastic.Apm/Helpers/WildcardMatcher.cs b/src/Elastic.Apm/Helpers/WildcardMatcher.cs index 3c9658ce3..2224d67d2 100644 --- a/src/Elastic.Apm/Helpers/WildcardMatcher.cs +++ b/src/Elastic.Apm/Helpers/WildcardMatcher.cs @@ -91,7 +91,7 @@ public static WildcardMatcher ValueOf(string wildcardString) /// The matchers which should be used to match the provided string /// The string to match against /// true, if any of the matchers match the provided string - public static bool IsAnyMatch(IReadOnlyList matchers, string s) => AnyMatch(matchers, s) != null; + public static bool IsAnyMatch(IReadOnlyCollection matchers, string s) => AnyMatch(matchers, s) != null; /// /// Returns the first that matches the provided string. @@ -99,7 +99,7 @@ public static WildcardMatcher ValueOf(string wildcardString) /// The matchers which should be used to match the provided string /// The string to match against /// The first matching , or null if none match. - internal static WildcardMatcher AnyMatch(IReadOnlyList matchers, string s) => s == null ? null : AnyMatch(matchers, s, null); + internal static WildcardMatcher AnyMatch(IReadOnlyCollection matchers, string s) => s == null ? null : AnyMatch(matchers, s, null); /// /// Returns the first that matches the provided partitioned string. @@ -113,10 +113,20 @@ internal static WildcardMatcher AnyMatch(IReadOnlyCollection ma if (matchers is null) return null; - foreach (var m in matchers) + if (matchers is IReadOnlyList list) { - if (m.Matches(firstPart, secondPart)) - return m; + for (var i = 0; i < list.Count; i++) + { + if (list[i].Matches(firstPart, secondPart)) + return list[i]; + } + return null; + } + + foreach (var matcher in matchers) + { + if (matcher.Matches(firstPart, secondPart)) + return matcher; } return null;