Skip to content

Conversation

@martincostello
Copy link
Member

@martincostello martincostello commented Aug 28, 2025

Fixes #3033

Changes

Ensure any current activity is stopped if only metrics is enabled but a global activity listener is registered.

I've manually verified the original issue is resolved and that .NET isn't affected by the same issue.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added the comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient label Aug 28, 2025
@codecov
Copy link

codecov bot commented Aug 28, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.89%. Comparing base (7adf24a) to head (fc92d32).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ent/Implementation/SqlEventSourceListener.netfx.cs 80.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3041      +/-   ##
==========================================
+ Coverage   69.78%   69.89%   +0.11%     
==========================================
  Files         420      410      -10     
  Lines       16294    16242      -52     
==========================================
- Hits        11371    11353      -18     
+ Misses       4923     4889      -34     
Flag Coverage Δ
unittests-Instrumentation.Cassandra ?
unittests-Instrumentation.SqlClient 86.92% <80.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ent/Implementation/SqlEventSourceListener.netfx.cs 81.08% <80.00%> (-0.17%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello marked this pull request as ready for review August 29, 2025 09:47
Copilot AI review requested due to automatic review settings August 29, 2025 09:47
@martincostello martincostello requested a review from a team as a code owner August 29, 2025 09:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where SQL activities were not being properly stopped on .NET Framework when using a global activity listener with metrics-only configuration. The change ensures that any current SQL activity is stopped regardless of whether tracing or metrics are being collected.

  • Separates activity stopping logic from activity modification logic in the event handler
  • Adds comprehensive test coverage for the metrics-only scenario with global activity listener
  • Updates changelog to document the bug fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
SqlEventSourceListener.netfx.cs Refactors OnEndExecute method to ensure SQL activities are stopped even when only metrics are enabled
SqlClientIntegrationTests.cs Adds test to verify activities are properly stopped in metrics-only scenarios and minor code cleanup
CHANGELOG.md Documents the bug fix for activity stopping issue

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Ensure any current activity is stopped if only metrics is enabled but a global activity listener is registered.

Resolves open-telemetry#3033.
Add PR number and fix lint warning.
Only stop if it's out activity.
Refactor method to only have one point of return.
- Add integration test for open-telemetry#3033.
- Add missing assertion.
- Use expression bodied method.
Fix entries being added to previous release.
martincostello and others added 2 commits September 2, 2025 09:44
This was referenced Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Memory leak and wrong operation duration metric

2 participants