Skip to content

Commit 8409e20

Browse files
[SqlClient] Remove non-functional netfx properties (#3079)
1 parent 9d50b4b commit 8409e20

File tree

11 files changed

+85
-9
lines changed

11 files changed

+85
-9
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#nullable enable
2+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, string!, object!>?
3+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
4+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object!, bool>?
5+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
6+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool
7+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.set -> void
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#nullable enable
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#nullable enable
2+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, string!, object!>?
3+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
4+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object!, bool>?
5+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
6+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool
7+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.set -> void

src/OpenTelemetry.Instrumentation.SqlClient/.publicApi/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#nullable enable
22
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions
3-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, string!, object!>?
4-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
5-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object!, bool>?
6-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
7-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool
8-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.set -> void
93
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SqlClientTraceInstrumentationOptions() -> void
104
OpenTelemetry.Metrics.SqlClientMeterProviderBuilderExtensions
115
OpenTelemetry.Trace.TracerProviderBuilderExtensions

src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
Behaviors related to this option are now always enabled.
1717
([#3072](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3072))
1818

19+
* **Breaking change**: The `Enrich`, `Filter` and `RecordException` properties have
20+
been removed for .NET Framework where they were non-functional.
21+
([#3079](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3079))
22+
1923
## 1.12.0-beta.2
2024

2125
Released 2025-Jul-15
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<Suppression>
4+
<DiagnosticId>CP0002</DiagnosticId>
5+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.get_Enrich</Target>
6+
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
7+
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
8+
</Suppression>
9+
<Suppression>
10+
<DiagnosticId>CP0002</DiagnosticId>
11+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.get_Filter</Target>
12+
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
13+
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
14+
</Suppression>
15+
<Suppression>
16+
<DiagnosticId>CP0002</DiagnosticId>
17+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.get_RecordException</Target>
18+
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
19+
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
20+
</Suppression>
21+
<Suppression>
22+
<DiagnosticId>CP0002</DiagnosticId>
23+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.set_Enrich(System.Action{System.Diagnostics.Activity,System.String,System.Object})</Target>
24+
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
25+
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
26+
</Suppression>
27+
<Suppression>
28+
<DiagnosticId>CP0002</DiagnosticId>
29+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.set_Filter(System.Func{System.Object,System.Boolean})</Target>
30+
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
31+
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
32+
</Suppression>
33+
<Suppression>
34+
<DiagnosticId>CP0002</DiagnosticId>
35+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.set_RecordException(System.Boolean)</Target>
36+
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
37+
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
38+
</Suppression>
39+
</Suppressions>

src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,15 @@ public override void OnEventWritten(string name, object? payload)
127127
{
128128
try
129129
{
130+
#if !NETFRAMEWORK
130131
if (options.Filter?.Invoke(command) == false)
131132
{
132133
SqlClientInstrumentationEventSource.Log.CommandIsFilteredOut(activity.OperationName);
133134
activity.IsAllDataRequested = false;
134135
activity.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded;
135136
return;
136137
}
138+
#endif
137139
}
138140
catch (Exception ex)
139141
{
@@ -175,6 +177,7 @@ public override void OnEventWritten(string name, object? payload)
175177
}
176178
}
177179

180+
#if !NETFRAMEWORK
178181
try
179182
{
180183
options.Enrich?.Invoke(activity, "OnCustom", command);
@@ -183,6 +186,7 @@ public override void OnEventWritten(string name, object? payload)
183186
{
184187
SqlClientInstrumentationEventSource.Log.EnrichmentException(ex);
185188
}
189+
#endif
186190
}
187191
}
188192

@@ -261,10 +265,12 @@ public override void OnEventWritten(string name, object? payload)
261265

262266
activity.SetStatus(ActivityStatusCode.Error, exception.Message);
263267

268+
#if !NETFRAMEWORK
264269
if (options.RecordException)
265270
{
266271
activity.AddException(exception);
267272
}
273+
#endif
268274
}
269275
else
270276
{

src/OpenTelemetry.Instrumentation.SqlClient/SqlClientTraceInstrumentationOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#if !NETFRAMEWORK
45
using System.Diagnostics;
6+
#endif
57
using Microsoft.Extensions.Configuration;
68
#if NET
79
using OpenTelemetry.Instrumentation.SqlClient.Implementation;
@@ -56,6 +58,7 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
5658
#endif
5759
}
5860

61+
#if !NETFRAMEWORK
5962
/// <summary>
6063
/// Gets or sets an action to enrich an <see cref="Activity"/> with the
6164
/// raw <c>SqlCommand</c> object.
@@ -106,6 +109,7 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
106109
/// href="https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-spans.md"/>.</para>
107110
/// </remarks>
108111
public bool RecordException { get; set; }
112+
#endif
109113

110114
#if !NETFRAMEWORK
111115
/// <summary>

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientIntegrationTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ public void SuccessfulCommandTest(
5757
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
5858
.SetSampler(sampler)
5959
.AddInMemoryExporter(activities)
60-
.AddSqlClientInstrumentation(options => options.RecordException = recordException)
60+
.AddSqlClientInstrumentation(options =>
61+
{
62+
#if NET
63+
options.RecordException = recordException;
64+
#endif
65+
})
6166
.Build();
6267

6368
using var sqlConnection = new SqlConnection(this.GetConnectionString());

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ public void SpansAndMetricsGeneratedOnlyWhenEnabled(bool tracesEnabled, bool met
141141
if (tracesEnabled)
142142
{
143143
tracerProviderBuilder
144-
.AddSqlClientInstrumentation(options => options.RecordException = true)
144+
.AddSqlClientInstrumentation(options =>
145+
{
146+
#if NET
147+
options.RecordException = true;
148+
#endif
149+
})
145150
.AddInMemoryExporter(activities);
146151
}
147152

@@ -337,7 +342,9 @@ private void RunSqlClientTestCase(
337342
.SetSampler(sampler)
338343
.AddSqlClientInstrumentation(options =>
339344
{
345+
#if NET
340346
options.RecordException = true;
347+
#endif
341348
options.EmitOldAttributes = emitOldAttributes;
342349
options.EmitNewAttributes = emitNewAttributes;
343350
})

0 commit comments

Comments
 (0)