Skip to content
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, string!, object!>?
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.get -> System.Action<System.Diagnostics.Activity!, object!>?
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.set -> void
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object!, bool>?
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, string!, object!>?
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.get -> System.Action<System.Diagnostics.Activity!, object!>?
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnrichWithSqlCommand.set -> void
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object!, bool>?
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
been removed for .NET Framework where they were non-functional.
([#3079](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3079))

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

## 1.12.0-beta.2

Released 2025-Jul-15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.get_Enrich</Target>
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.get_EnrichWithSqlCommand</Target>
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
</Suppression>
Expand All @@ -20,7 +20,7 @@
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.set_Enrich(System.Action{System.Diagnostics.Activity,System.String,System.Object})</Target>
<Target>M:OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.set_EnrichWithSqlCommand(System.Action{System.Diagnostics.Activity,System.Object})</Target>
<Left>lib/netstandard2.0/OpenTelemetry.Instrumentation.SqlClient.dll</Left>
<Right>lib/net462/OpenTelemetry.Instrumentation.SqlClient.dll</Right>
</Suppression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public override void OnEventWritten(string name, object? payload)
#if !NETFRAMEWORK
try
{
options.Enrich?.Invoke(activity, "OnCustom", command);
options.EnrichWithSqlCommand?.Invoke(activity, command);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
/// The parameters passed to the enrich action are:
/// <list type="number">
/// <item>The <see cref="Activity"/> being enriched.</item>
/// <item>The name of the event. Currently only <c>"OnCustom"</c> is
/// used but more events may be added in the future.</item>
/// <item>The raw <c>SqlCommand</c> object from which additional
/// information can be extracted to enrich the <see
/// cref="Activity"/>.</item>
/// information can be extracted to enrich the <see cref="Activity"/>.</item>
/// </list>
/// </remarks>
public Action<Activity, string, object>? Enrich { get; set; }
public Action<Activity, object>? EnrichWithSqlCommand { get; set; }

/// <summary>
/// Gets or sets a filter function that determines whether or not to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void ShouldEnrichWhenEnabled(bool shouldEnrich, bool error)
{
if (shouldEnrich)
{
opt.Enrich = ActivityEnrichment;
opt.EnrichWithSqlCommand = ActivityEnrichment;
}
})
.AddInMemoryExporter(activities)
Expand Down Expand Up @@ -241,19 +241,10 @@ public void ShouldAssignSetDatabaseQueryParametersFromEnvironmentVariable(string
Assert.Equal(expected, options.SetDbQueryParameters);
}

private static void ActivityEnrichment(Activity activity, string method, object obj)
private static void ActivityEnrichment(Activity activity, object obj)
{
activity.SetTag("enriched", "yes");

switch (method)
{
case "OnCustom":
Assert.True(obj is SqlCommand);
break;

default:
break;
}
Assert.IsType<SqlCommand>(obj);
}

private Activity[] RunCommandWithFilter(
Expand Down
Loading