Skip to content

Commit e758269

Browse files
[SqlClient] Rename Enrich property (#3080)
1 parent 8409e20 commit e758269

File tree

7 files changed

+16
-24
lines changed

7 files changed

+16
-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
@@ -20,6 +20,10 @@
2020
been removed for .NET Framework where they were non-functional.
2121
([#3079](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3079))
2222

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

2529
Released 2025-Jul-15

src/OpenTelemetry.Instrumentation.SqlClient/CompatibilitySuppressions.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<Suppression>
44
<DiagnosticId>CP0002</DiagnosticId>
5-
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.get_Enrich</Target>
5+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.get_EnrichWithSqlCommand</Target>
66
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
77
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
88
</Suppression>
@@ -20,7 +20,7 @@
2020
</Suppression>
2121
<Suppression>
2222
<DiagnosticId>CP0002</DiagnosticId>
23-
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.set_Enrich(System.Action{System.Diagnostics.Activity,System.String,System.Object})</Target>
23+
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.set_EnrichWithSqlCommand(System.Action{System.Diagnostics.Activity,System.Object})</Target>
2424
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
2525
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
2626
</Suppression>

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
@@ -68,14 +68,11 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
6868
/// The parameters passed to the enrich action are:
6969
/// <list type="number">
7070
/// <item>The <see cref="Activity"/> being enriched.</item>
71-
/// <item>The name of the event. Currently only <c>"OnCustom"</c> is
72-
/// used but more events may be added in the future.</item>
7371
/// <item>The raw <c>SqlCommand</c> object from which additional
74-
/// information can be extracted to enrich the <see
75-
/// cref="Activity"/>.</item>
72+
/// information can be extracted to enrich the <see cref="Activity"/>.</item>
7673
/// </list>
7774
/// </remarks>
78-
public Action<Activity, string, object>? Enrich { get; set; }
75+
public Action<Activity, object>? EnrichWithSqlCommand { get; set; }
7976

8077
/// <summary>
8178
/// 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)
@@ -241,19 +241,10 @@ public void ShouldAssignSetDatabaseQueryParametersFromEnvironmentVariable(string
241241
Assert.Equal(expected, options.SetDbQueryParameters);
242242
}
243243

244-
private static void ActivityEnrichment(Activity activity, string method, object obj)
244+
private static void ActivityEnrichment(Activity activity, object obj)
245245
{
246246
activity.SetTag("enriched", "yes");
247-
248-
switch (method)
249-
{
250-
case "OnCustom":
251-
Assert.True(obj is SqlCommand);
252-
break;
253-
254-
default:
255-
break;
256-
}
247+
Assert.IsType<SqlCommand>(obj);
257248
}
258249

259250
private Activity[] RunCommandWithFilter(

0 commit comments

Comments
 (0)