Skip to content

Eliminate enumerator boxing in TransactionNameGroups - #2800

Closed
stevejgordon wants to merge 1 commit into
mainfrom
transactionnamegroups-optimisation
Closed

stevejgordon wants to merge 1 commit into
mainfrom
transactionnamegroups-optimisation

Conversation

@stevejgordon

Copy link
Copy Markdown
Contributor

Follow-up to #2791, which introduced a for loop in AnyMatch but left the parameter typed as IReadOnlyCollection<WildcardMatcher>. Because the compiler must call IEnumerable<T>.GetEnumerator() through the interface, it boxes the underlying struct enumerator into a heap allocation on every invocation.

This change widens TransactionNameGroups from IReadOnlyCollection to IReadOnlyList (consistent with SanitizeFieldNames, TransactionIgnoreUrls, and IgnoreMessageQueues). ReadOnlyCollection<T> already implements IReadOnlyList<T>, so all existing implementations and call sites are unaffected.

@cla-checker-service

cla-checker-service Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

💚 CLA has been signed

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The optimization introduces a source- and binary-breaking change to the public configuration interface.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Optimizes transaction-name grouping by enabling indexed matcher access to avoid enumerator boxing.

Changes:

  • Changes transaction-name-group collections to IReadOnlyList.
  • Replaces matcher enumeration with indexed iteration.
File summaries
File Description
test/Elastic.Apm.Tests/ConstructorTests.cs Updates test configuration signature.
test/Elastic.Apm.Feature.Tests/TestConfiguration.cs Updates feature-test configuration signature.
src/Elastic.Apm/Helpers/WildcardMatcher.cs Uses indexed matching.
src/Elastic.Apm/Config/IConfigurationReader.cs Changes the public configuration contract.
src/Elastic.Apm/Config/FallbackToEnvironmentConfigurationBase.cs Updates stored collection type.
src/Elastic.Apm/Config/ConfigConsts.cs Updates the default value type.
src/Elastic.Apm/Config/AbstractConfigurationReader.cs Updates parser return type.
src/Elastic.Apm/BackendComm/CentralConfig/RuntimeConfigurationSnapshot.cs Updates snapshot property type.
src/Elastic.Apm/BackendComm/CentralConfig/CentralConfiguration.cs Updates central configuration type.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

/// </para>
/// </remarks>
IReadOnlyCollection<WildcardMatcher> TransactionNameGroups { get; }
IReadOnlyList<WildcardMatcher> TransactionNameGroups { get; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants