Skip to content

Conversation

matt-hensley
Copy link
Contributor

Changes

Modifies SqlClient instrumentation to use shared handle implementation setup in #2970

Leaving in draft until #2970 lands, will rebase afterwards

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 comp:instrumentation.aspnet.telemetryhttpmodule Things related to OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule comp:instrumentation.aspnet Things related to OpenTelemetry.Instrumentation.AspNet comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient labels Aug 11, 2025
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.73%. Comparing base (8764c25) to head (3baac53).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2992      +/-   ##
==========================================
+ Coverage   69.60%   69.73%   +0.12%     
==========================================
  Files         413      413              
  Lines       16212    16201      -11     
==========================================
+ Hits        11285    11297      +12     
+ Misses       4927     4904      -23     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 87.36% <ø> (ø)
unittests-Exporter.Geneva 53.78% <ø> (+0.44%) ⬆️
unittests-Exporter.InfluxDB 95.14% <ø> (ø)
unittests-Exporter.Instana 74.86% <ø> (ø)
unittests-Exporter.OneCollector 94.61% <ø> (ø)
unittests-Extensions 90.65% <ø> (ø)
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Instrumentation.AWS 83.69% <ø> (ø)
unittests-Instrumentation.AspNet 74.93% <ø> (ø)
unittests-Instrumentation.AspNetCore 70.76% <ø> (ø)
unittests-Instrumentation.Cassandra 23.52% <ø> (ø)
unittests-Instrumentation.ConfluentKafka 14.10% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.12% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 80.00% <ø> (ø)
unittests-Instrumentation.EventCounters 76.36% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.42% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 79.61% <ø> (ø)
unittests-Instrumentation.Hangfire 84.61% <ø> (ø)
unittests-Instrumentation.Http 74.18% <ø> (ø)
unittests-Instrumentation.Owin 88.62% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 78.76% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 34.54% <ø> (ø)
unittests-Instrumentation.SqlClient 86.83% <100.00%> (-0.33%) ⬇️
unittests-Instrumentation.StackExchangeRedis 70.81% <ø> (ø)
unittests-Instrumentation.Wcf 78.95% <ø> (ø)
unittests-OpAmp.Client 61.08% <ø> (ø)
unittests-PersistentStorage 65.21% <ø> (ø)
unittests-Resources.AWS 75.00% <ø> (ø)
unittests-Resources.Azure 84.56% <ø> (ø)
unittests-Resources.Container 67.34% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)
unittests-Resources.Host 73.91% <ø> (ø)
unittests-Resources.OperatingSystem 76.98% <ø> (ø)
unittests-Resources.Process 100.00% <ø> (ø)
unittests-Resources.ProcessRuntime 79.59% <ø> (ø)
unittests-Sampler.AWS 88.25% <ø> (ø)

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

Files with missing lines Coverage Δ
...ient/Implementation/SqlClientDiagnosticListener.cs 88.67% <100.00%> (+0.07%) ⬆️
...ent/Implementation/SqlEventSourceListener.netfx.cs 81.25% <100.00%> (+0.51%) ⬆️
...trumentation.SqlClient/SqlClientInstrumentation.cs 88.46% <100.00%> (-4.23%) ⬇️
...lClient/SqlClientMeterProviderBuilderExtensions.cs 100.00% <100.00%> (ø)
...ation.SqlClient/TracerProviderBuilderExtensions.cs 100.00% <100.00%> (ø)

... and 2 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.

@Kielek
Copy link
Contributor

Kielek commented Aug 18, 2025

@matt-hensley, blocking PR merged, could you please rebase/resolve conflicts?

@github-actions github-actions bot removed the comp:instrumentation.aspnet.telemetryhttpmodule Things related to OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule label Aug 21, 2025
@github-actions github-actions bot removed the comp:instrumentation.aspnet Things related to OpenTelemetry.Instrumentation.AspNet label Aug 21, 2025
@matt-hensley matt-hensley marked this pull request as ready for review August 22, 2025 03:21
@matt-hensley matt-hensley requested a review from a team as a code owner August 22, 2025 03:21
Copy link
Contributor

Choose a reason for hiding this comment

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

I have applied following changes locally and execute:

.\build\scripts\test-aot-compatibility.ps1 net8.0 
.\build\scripts\test-aot-compatibility.ps1 net9.0 

both returned

Actual warning count is: 0
Executing test App...
./OpenTelemetry.AotCompatibility.TestApp.exe
Finished executing test App

I know that you have just extracted the code from internal class to shared, but what is the reason to do it, if there is no issues in aot tests?

Diff:

index 2048fffd..85d4f531 100644
--- a/src/Shared/InstrumentationHandleManager.cs
+++ b/src/Shared/InstrumentationHandleManager.cs
@@ -3,18 +3,8 @@

 namespace OpenTelemetry.Instrumentation;

-#if NET
-using System.Diagnostics.CodeAnalysis;
-#endif
-
-#if NET
-[RequiresUnreferencedCode(InstrumentationHandleManagerTrimmingUnsupportedMessage)]
-#endif
 internal sealed class InstrumentationHandleManager
 {
-#if NET
-    internal const string InstrumentationHandleManagerTrimmingUnsupportedMessage = "Trimming is not yet supported for InstrumentationHandleManager.";
-#endif
     private int metricHandles;
     private int tracingHandles;

@@ -40,9 +30,6 @@ internal sealed class InstrumentationHandleManager
     /// <returns>An IDisposable object.</returns>
     public IDisposable AddTracingHandle() => new TracingHandle(this);

-#if NET
-    [RequiresUnreferencedCode(InstrumentationHandleManagerTrimmingUnsupportedMessage)]
-#endif
     private sealed class MetricHandle : IDisposable
     {
         private readonly InstrumentationHandleManager manager;
@@ -64,9 +51,6 @@ internal sealed class InstrumentationHandleManager
         }
     }

-#if NET
-    [RequiresUnreferencedCode(InstrumentationHandleManagerTrimmingUnsupportedMessage)]
-#endif
     private sealed class TracingHandle : IDisposable
     {
         private readonly InstrumentationHandleManager manager;

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.

3 participants