Skip to content

Commit 3abc4e5

Browse files
[SqlClient] Rename Enrich property
Renames the `Enrich` property to `EnrichWithSqlCommand` and removes the custom event name parameter.
1 parent d41d46e commit 3abc4e5

File tree

6 files changed

+14
-24
lines changed

6 files changed

+14
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#nullable enable
2-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, string!, object!>?
3-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
2+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.get -> System.Action<System.Diagnostics.Activity!, object!>?
3+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.set -> void
44
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object!, bool>?
55
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
66
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#nullable enable
2-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, string!, object!>?
3-
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
2+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.get -> System.Action<System.Diagnostics.Activity!, object!>?
3+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.set -> void
44
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object!, bool>?
55
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
66
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool

src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
been removed for .NET Framework where they were non-functional.
1919
([#3079](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3079))
2020

21+
* **Breaking change**: The `Enrich` property has been renamed to
22+
`EnrichWithSqlCommand` and no longer passes an event name to the delegate.
23+
([#TODO](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/TODO))
24+
2125
## 1.12.0-beta.2
2226

2327
Released 2025-Jul-15

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public override void OnEventWritten(string name, object? payload)
180180
#if !NETFRAMEWORK
181181
try
182182
{
183-
options.Enrich?.Invoke(activity, "OnCustom", command);
183+
options.EnrichWithSqlCommand?.Invoke(activity, command);
184184
}
185185
catch (Exception ex)
186186
{

src/OpenTelemetry.Instrumentation.SqlClient/SqlClientTraceInstrumentationOptions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,11 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
5959
/// The parameters passed to the enrich action are:
6060
/// <list type="number">
6161
/// <item>The <see cref="Activity"/> being enriched.</item>
62-
/// <item>The name of the event. Currently only <c>"OnCustom"</c> is
63-
/// used but more events may be added in the future.</item>
6462
/// <item>The raw <c>SqlCommand</c> object from which additional
65-
/// information can be extracted to enrich the <see
66-
/// cref="Activity"/>.</item>
63+
/// information can be extracted to enrich the <see cref="Activity"/>.</item>
6764
/// </list>
6865
/// </remarks>
69-
public Action<Activity, string, object>? Enrich { get; set; }
66+
public Action<Activity, object>? EnrichWithSqlCommand { get; set; }
7067

7168
/// <summary>
7269
/// Gets or sets a filter function that determines whether or not to

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void ShouldEnrichWhenEnabled(bool shouldEnrich, bool error)
155155
{
156156
if (shouldEnrich)
157157
{
158-
opt.Enrich = ActivityEnrichment;
158+
opt.EnrichWithSqlCommand = ActivityEnrichment;
159159
}
160160
})
161161
.AddInMemoryExporter(activities)
@@ -216,24 +216,13 @@ public void ShouldNotCollectTelemetryAndShouldNotPropagateExceptionWhenFilterThr
216216

217217
Assert.Empty(activities);
218218
}
219-
#endif
220219

221-
private static void ActivityEnrichment(Activity activity, string method, object obj)
220+
private static void ActivityEnrichment(Activity activity, object obj)
222221
{
223222
activity.SetTag("enriched", "yes");
224-
225-
switch (method)
226-
{
227-
case "OnCustom":
228-
Assert.True(obj is SqlCommand);
229-
break;
230-
231-
default:
232-
break;
233-
}
223+
Assert.IsType<SqlCommand>(obj);
234224
}
235225

236-
#if NET
237226
private Activity[] RunCommandWithFilter(
238227
string commandText,
239228
Func<object, bool> filter)

0 commit comments

Comments
 (0)