Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public ConfigurationKeyValue Lookup(ConfigurationOption option) =>
_dynamicConfiguration?.TransactionIgnoreUrls ?? _mainConfiguration.TransactionIgnoreUrls;

public IReadOnlyCollection<WildcardMatcher> TransactionNameGroups =>
_dynamicConfiguration?.TransactionNameGroups ?? _mainConfiguration.TransactionNameGroups;
_dynamicConfiguration?.TransactionNameGroups ?? _mainConfiguration.TransactionNameGroups;

public int TransactionMaxSpans => _dynamicConfiguration?.TransactionMaxSpans ?? _mainConfiguration.TransactionMaxSpans;

Expand Down
20 changes: 15 additions & 5 deletions src/Elastic.Apm/Helpers/WildcardMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public static WildcardMatcher ValueOf(string wildcardString)
/// <param name="matchers">The matchers which should be used to match the provided string</param>
/// <param name="s">The string to match against</param>
/// <returns><code>true</code>, if any of the matchers match the provided string</returns>
public static bool IsAnyMatch(IReadOnlyList<WildcardMatcher> matchers, string s) => AnyMatch(matchers, s) != null;
public static bool IsAnyMatch(IReadOnlyCollection<WildcardMatcher> matchers, string s) => AnyMatch(matchers, s) != null;

/// <summary>
/// Returns the first <see cref="WildcardMatcher" /> that matches the provided string.
/// </summary>
/// <param name="matchers"> The matchers which should be used to match the provided string</param>
/// <param name="s">The string to match against</param>
/// <returns>The first matching <see cref="WildcardMatcher" />, or <code>null</code> if none match.</returns>
internal static WildcardMatcher AnyMatch(IReadOnlyList<WildcardMatcher> matchers, string s) => s == null ? null : AnyMatch(matchers, s, null);
internal static WildcardMatcher AnyMatch(IReadOnlyCollection<WildcardMatcher> matchers, string s) => s == null ? null : AnyMatch(matchers, s, null);

/// <summary>
/// Returns the first <see cref="WildcardMatcher" /> that matches the provided partitioned string.
Expand All @@ -113,10 +113,20 @@ internal static WildcardMatcher AnyMatch(IReadOnlyCollection<WildcardMatcher> ma
if (matchers is null)
return null;

foreach (var m in matchers)
if (matchers is IReadOnlyList<WildcardMatcher> 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;
Expand Down
Loading