Repository navigation
Prevent leaks for SQL client instrumentation - #2799
Merged
Merged
Conversation
🤖 GitHub commentsJust comment with:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Orphan cleanup can become quadratic and substantially delay transaction completion under high SQL concurrency.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Prevents SQL instrumentation from retaining orphaned spans by adding bounded lifecycle tracking and safe abandonment.
Changes:
- Adds
PendingSpanStorewith expiration, capacity limits, and transaction cleanup. - Introduces thread-safe span abandonment and child-duration tracking.
- Adds comprehensive unit and integration coverage.
File summaries
| File | Description |
|---|---|
test/instrumentations/Elastic.Apm.SqlClient.Tests/SqlClientListenerTests.cs |
Tests timeout cleanup. |
test/instrumentations/Elastic.Apm.SqlClient.Tests/SqlClientDiagnosticListenerUnitTests.cs |
Tests SQL span lifecycle scenarios. |
test/Elastic.Apm.Tests/SpanTests.cs |
Tests abandonment and current-span behavior. |
test/Elastic.Apm.Tests/HelpersTests/PendingSpanStoreTests.cs |
Tests store eviction and concurrency. |
test/Elastic.Apm.Tests/ConstructorTests.cs |
Generalizes logger assertions. |
test/Elastic.Apm.Tests/ChildDurationTimerTests.cs |
Tests child-duration calculations. |
src/profiler/Elastic.Apm.Profiler.Managed/Integrations/AdoNet/DbSpanFactory.cs |
Uses static span creation. |
src/instrumentations/Elastic.Apm.EntityFrameworkCore/EfCoreDiagnosticListener.cs |
Updates database span creation. |
src/instrumentations/Elastic.Apm.EntityFramework6/Ef6Interceptor.cs |
Updates database span creation. |
src/Elastic.Apm/Model/Transaction.cs |
Adds transaction-ending callbacks. |
src/Elastic.Apm/Model/Span.cs |
Adds abandonment and revised duration tracking. |
src/Elastic.Apm/Model/ExecutionSegmentCommon.cs |
Supports non-current spans. |
src/Elastic.Apm/Model/DbSpanCommon.cs |
Adds static configurable span creation. |
src/Elastic.Apm/Instrumentations/SqlClient/SqlClientDiagnosticSubscriber.cs |
Owns listener/store disposal. |
src/Elastic.Apm/Instrumentations/SqlClient/SqlClientDiagnosticListener.cs |
Tracks and cleans pending SQL spans. |
src/Elastic.Apm/Helpers/PendingSpanStore.cs |
Implements bounded pending-span storage. |
Review details
- Files reviewed: 16/16 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.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core span/transaction lifecycle and timing bookkeeping (including concurrency-sensitive end/abandon semantics), which warrants careful human validation beyond automated review.
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 0 new
- Review effort level: Lite
trentm
approved these changes
Sep 1, 2026
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2787