Skip to content

Commit 45ce4b3

Browse files
[SqlClient] Remove non-functional netfx properties
Remove members from the public API that no nothing on .NET Framework.
1 parent 3f072fa commit 45ce4b3

File tree

12 files changed

+46
-8
lines changed

12 files changed

+46
-8
lines changed

build/Common.prod.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<!-- Note: This resolves all the PublicApiAnalyzers files which are actually used by the analyzer -->
8787
<AdditionalFiles Include=".publicApi\PublicAPI.*.txt" />
8888
<AdditionalFiles Include=".publicApi\$(TargetFramework)\PublicAPI.*.txt" />
89+
<AdditionalFiles Include=".publicApi\$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)'))\PublicAPI.*.txt" />
8990
</ItemGroup>
9091
</Target>
9192

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.SetDbQueryParameters.get -> bool
104
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SetDbQueryParameters.set -> void
115
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SqlClientTraceInstrumentationOptions() -> void

src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md

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

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

1923
Released 2025-Jul-15

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;
@@ -47,6 +49,7 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
4749
#endif
4850
}
4951

52+
#if !NETFRAMEWORK
5053
/// <summary>
5154
/// Gets or sets an action to enrich an <see cref="Activity"/> with the
5255
/// raw <c>SqlCommand</c> object.
@@ -97,6 +100,7 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
97100
/// href="https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-spans.md"/>.</para>
98101
/// </remarks>
99102
public bool RecordException { get; set; }
103+
#endif
100104

101105
/// <summary>
102106
/// Gets or sets a value indicating whether or not the <see cref="SqlClientInstrumentation"/>

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());

0 commit comments

Comments
 (0)