Skip to content

Commit a8e6c9f

Browse files
[SqlClient] Rename Enrich property
Renames the `Enrich` property to `EnrichWithSqlCommand` and removes the custom event name parameter.
1 parent 86ac767 commit a8e6c9f

File tree

6 files changed

+14
-22
lines changed

6 files changed

+14
-22
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 & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public void ShouldEnrichWhenEnabled(bool shouldEnrich, bool error)
157157
{
158158
if (shouldEnrich)
159159
{
160-
opt.Enrich = ActivityEnrichment;
160+
opt.EnrichWithSqlCommand = ActivityEnrichment;
161161
}
162162
})
163163
.AddInMemoryExporter(activities)
@@ -219,19 +219,10 @@ public void ShouldNotCollectTelemetryAndShouldNotPropagateExceptionWhenFilterThr
219219
Assert.Empty(activities);
220220
}
221221

222-
private static void ActivityEnrichment(Activity activity, string method, object obj)
222+
private static void ActivityEnrichment(Activity activity, object obj)
223223
{
224224
activity.SetTag("enriched", "yes");
225-
226-
switch (method)
227-
{
228-
case "OnCustom":
229-
Assert.True(obj is SqlCommand);
230-
break;
231-
232-
default:
233-
break;
234-
}
225+
Assert.IsType<SqlCommand>(obj);
235226
}
236227

237228
private Activity[] RunCommandWithFilter(

0 commit comments

Comments
 (0)