Skip to content

Commit d2f9d05

Browse files
authored
Rename SqlClientInstrumentationOptions to SqlClientTraceInstrumentationOptions (#5285)
1 parent 8ca81d4 commit d2f9d05

11 files changed

+48
-45
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions
2-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.EnableConnectionLevelAttributes.get -> bool
3-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.EnableConnectionLevelAttributes.set -> void
4-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity, string, object>
5-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.Enrich.set -> void
6-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.Filter.get -> System.Func<object, bool>
7-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.Filter.set -> void
8-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.RecordException.get -> bool
9-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.RecordException.set -> void
10-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.SetDbStatementForStoredProcedure.get -> bool
11-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.SetDbStatementForStoredProcedure.set -> void
12-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.SetDbStatementForText.get -> bool
13-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.SetDbStatementForText.set -> void
14-
OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions.SqlClientInstrumentationOptions() -> void
1+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions
2+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnableConnectionLevelAttributes.get -> bool
3+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.EnableConnectionLevelAttributes.set -> void
4+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity, string, object>
5+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Enrich.set -> void
6+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.get -> System.Func<object, bool>
7+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.Filter.set -> void
8+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.get -> bool
9+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.RecordException.set -> void
10+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SetDbStatementForStoredProcedure.get -> bool
11+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SetDbStatementForStoredProcedure.set -> void
12+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SetDbStatementForText.get -> bool
13+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SetDbStatementForText.set -> void
14+
OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions.SqlClientTraceInstrumentationOptions() -> void
1515
OpenTelemetry.Trace.TracerProviderBuilderExtensions
1616
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddSqlClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder
17-
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddSqlClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action<OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions> configureSqlClientInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
18-
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddSqlClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.SqlClient.SqlClientInstrumentationOptions> configureSqlClientInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
17+
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddSqlClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action<OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions> configureSqlClientTraceInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
18+
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddSqlClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions> configureSqlClientTraceInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder

src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
Now that this suite of attributes are stable, this instrumentation will only
99
emit the new attributes.
1010
([#5270](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5270))
11+
* **Breaking Change**: Renamed `SqlClientInstrumentationOptions` to
12+
`SqlClientTraceInstrumentationOptions`.
13+
([#5285](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5285))
1114

1215
## 1.6.0-beta.3
1316

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ internal sealed class SqlClientDiagnosticListener : ListenerHandler
3232
private readonly PropertyFetcher<CommandType> commandTypeFetcher = new("CommandType");
3333
private readonly PropertyFetcher<object> commandTextFetcher = new("CommandText");
3434
private readonly PropertyFetcher<Exception> exceptionFetcher = new("Exception");
35-
private readonly SqlClientInstrumentationOptions options;
35+
private readonly SqlClientTraceInstrumentationOptions options;
3636

37-
public SqlClientDiagnosticListener(string sourceName, SqlClientInstrumentationOptions options)
37+
public SqlClientDiagnosticListener(string sourceName, SqlClientTraceInstrumentationOptions options)
3838
: base(sourceName)
3939
{
40-
this.options = options ?? new SqlClientInstrumentationOptions();
40+
this.options = options ?? new SqlClientTraceInstrumentationOptions();
4141
}
4242

4343
public override bool SupportsNullActivity => true;

src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlEventSourceListener.netfx.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ internal sealed class SqlEventSourceListener : EventListener
2929
internal const int BeginExecuteEventId = 1;
3030
internal const int EndExecuteEventId = 2;
3131

32-
private readonly SqlClientInstrumentationOptions options;
32+
private readonly SqlClientTraceInstrumentationOptions options;
3333
private EventSource adoNetEventSource;
3434
private EventSource mdsEventSource;
3535

36-
public SqlEventSourceListener(SqlClientInstrumentationOptions options = null)
36+
public SqlEventSourceListener(SqlClientTraceInstrumentationOptions options = null)
3737
{
38-
this.options = options ?? new SqlClientInstrumentationOptions();
38+
this.options = options ?? new SqlClientTraceInstrumentationOptions();
3939
}
4040

4141
public override void Dispose()

src/OpenTelemetry.Instrumentation.SqlClient/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ For an ASP.NET application, adding instrumentation is typically done in the
7575
## Advanced configuration
7676

7777
This instrumentation can be configured to change the default behavior by using
78-
`SqlClientInstrumentationOptions`.
78+
`SqlClientTraceInstrumentationOptions`.
7979

8080
### Capturing database statements
8181

82-
The `SqlClientInstrumentationOptions` class exposes two properties that can be
83-
used to configure how the
82+
The `SqlClientTraceInstrumentationOptions` class exposes two properties that can
83+
be used to configure how the
8484
[`db.statement`](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-spans.md#call-level-attributes)
8585
attribute is captured upon execution of a query but the behavior depends on the
8686
runtime used.

src/OpenTelemetry.Instrumentation.SqlClient/SqlClientInstrumentation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal sealed class SqlClientInstrumentation : IDisposable
4444
[RequiresUnreferencedCode(SqlClientTrimmingUnsupportedMessage)]
4545
#endif
4646
public SqlClientInstrumentation(
47-
SqlClientInstrumentationOptions options = null)
47+
SqlClientTraceInstrumentationOptions options = null)
4848
{
4949
#if NETFRAMEWORK
5050
this.sqlEventSourceListener = new SqlEventSourceListener(options);

src/OpenTelemetry.Instrumentation.SqlClient/SqlClientInstrumentationOptions.cs renamed to src/OpenTelemetry.Instrumentation.SqlClient/SqlClientTraceInstrumentationOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace OpenTelemetry.Instrumentation.SqlClient;
1515
/// <remarks>
1616
/// For help and examples see: <a href="https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Instrumentation.SqlClient/README.md#advanced-configuration" />.
1717
/// </remarks>
18-
public class SqlClientInstrumentationOptions
18+
public class SqlClientTraceInstrumentationOptions
1919
{
2020
/*
2121
* Match...

src/OpenTelemetry.Instrumentation.SqlClient/TracerProviderBuilderExtensions.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ public static class TracerProviderBuilderExtensions
2626
[RequiresUnreferencedCode(SqlClientInstrumentation.SqlClientTrimmingUnsupportedMessage)]
2727
#endif
2828
public static TracerProviderBuilder AddSqlClientInstrumentation(this TracerProviderBuilder builder)
29-
=> AddSqlClientInstrumentation(builder, name: null, configureSqlClientInstrumentationOptions: null);
29+
=> AddSqlClientInstrumentation(builder, name: null, configureSqlClientTraceInstrumentationOptions: null);
3030

3131
/// <summary>
3232
/// Enables SqlClient instrumentation.
3333
/// </summary>
3434
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
35-
/// <param name="configureSqlClientInstrumentationOptions">Callback action for configuring <see cref="SqlClientInstrumentationOptions"/>.</param>
35+
/// <param name="configureSqlClientTraceInstrumentationOptions">Callback action for configuring <see cref="SqlClientTraceInstrumentationOptions"/>.</param>
3636
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
3737
#if NET6_0_OR_GREATER
3838
[RequiresUnreferencedCode(SqlClientInstrumentation.SqlClientTrimmingUnsupportedMessage)]
3939
#endif
4040
public static TracerProviderBuilder AddSqlClientInstrumentation(
4141
this TracerProviderBuilder builder,
42-
Action<SqlClientInstrumentationOptions> configureSqlClientInstrumentationOptions)
43-
=> AddSqlClientInstrumentation(builder, name: null, configureSqlClientInstrumentationOptions);
42+
Action<SqlClientTraceInstrumentationOptions> configureSqlClientTraceInstrumentationOptions)
43+
=> AddSqlClientInstrumentation(builder, name: null, configureSqlClientTraceInstrumentationOptions);
4444

4545
/// <summary>
4646
/// Enables SqlClient instrumentation.
4747
/// </summary>
4848
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
4949
/// <param name="name">Name which is used when retrieving options.</param>
50-
/// <param name="configureSqlClientInstrumentationOptions">Callback action for configuring <see cref="SqlClientInstrumentationOptions"/>.</param>
50+
/// <param name="configureSqlClientTraceInstrumentationOptions">Callback action for configuring <see cref="SqlClientTraceInstrumentationOptions"/>.</param>
5151
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
5252
#if NET6_0_OR_GREATER
5353
[RequiresUnreferencedCode(SqlClientInstrumentation.SqlClientTrimmingUnsupportedMessage)]
@@ -56,20 +56,20 @@ public static TracerProviderBuilder AddSqlClientInstrumentation(
5656
public static TracerProviderBuilder AddSqlClientInstrumentation(
5757
this TracerProviderBuilder builder,
5858
string name,
59-
Action<SqlClientInstrumentationOptions> configureSqlClientInstrumentationOptions)
59+
Action<SqlClientTraceInstrumentationOptions> configureSqlClientTraceInstrumentationOptions)
6060
{
6161
Guard.ThrowIfNull(builder);
6262

6363
name ??= Options.DefaultName;
6464

65-
if (configureSqlClientInstrumentationOptions != null)
65+
if (configureSqlClientTraceInstrumentationOptions != null)
6666
{
67-
builder.ConfigureServices(services => services.Configure(name, configureSqlClientInstrumentationOptions));
67+
builder.ConfigureServices(services => services.Configure(name, configureSqlClientTraceInstrumentationOptions));
6868
}
6969

7070
builder.AddInstrumentation(sp =>
7171
{
72-
var sqlOptions = sp.GetRequiredService<IOptionsMonitor<SqlClientInstrumentationOptions>>().Get(name);
72+
var sqlOptions = sp.GetRequiredService<IOptionsMonitor<SqlClientTraceInstrumentationOptions>>().Get(name);
7373

7474
return new SqlClientInstrumentation(sqlOptions);
7575
});

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public void SqlClient_NamedOptions()
4747
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
4848
.ConfigureServices(services =>
4949
{
50-
services.Configure<SqlClientInstrumentationOptions>(o => defaultExporterOptionsConfigureOptionsInvocations++);
50+
services.Configure<SqlClientTraceInstrumentationOptions>(o => defaultExporterOptionsConfigureOptionsInvocations++);
5151

52-
services.Configure<SqlClientInstrumentationOptions>("Instrumentation2", o => namedExporterOptionsConfigureOptionsInvocations++);
52+
services.Configure<SqlClientTraceInstrumentationOptions>("Instrumentation2", o => namedExporterOptionsConfigureOptionsInvocations++);
5353
})
5454
.AddSqlClientInstrumentation()
55-
.AddSqlClientInstrumentation("Instrumentation2", configureSqlClientInstrumentationOptions: null)
55+
.AddSqlClientInstrumentation("Instrumentation2", configureSqlClientTraceInstrumentationOptions: null)
5656
.Build();
5757

5858
Assert.Equal(1, defaultExporterOptionsConfigureOptionsInvocations);

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientInstrumentationOptionsTests.cs renamed to test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTraceInstrumentationOptionsTests.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace OpenTelemetry.Instrumentation.SqlClient.Tests;
99

10-
public class SqlClientInstrumentationOptionsTests
10+
public class SqlClientTraceInstrumentationOptionsTests
1111
{
12-
static SqlClientInstrumentationOptionsTests()
12+
static SqlClientTraceInstrumentationOptionsTests()
1313
{
1414
Activity.DefaultIdFormat = ActivityIdFormat.W3C;
1515
Activity.ForceDefaultIdFormat = true;
@@ -45,7 +45,7 @@ public void ParseDataSourceTests(
4545
string expectedInstanceName,
4646
string expectedPort)
4747
{
48-
var sqlConnectionDetails = SqlClientInstrumentationOptions.ParseDataSource(dataSource);
48+
var sqlConnectionDetails = SqlClientTraceInstrumentationOptions.ParseDataSource(dataSource);
4949

5050
Assert.NotNull(sqlConnectionDetails);
5151
Assert.Equal(expectedServerHostName, sqlConnectionDetails.ServerHostName);
@@ -60,7 +60,7 @@ public void ParseDataSourceTests(
6060
[InlineData(true, "127.0.0.1,1434", null, "127.0.0.1", null, "1434")]
6161
[InlineData(true, "127.0.0.1\\instanceName, 1818", null, "127.0.0.1", "instanceName", "1818")]
6262
[InlineData(false, "localhost", "localhost", null, null, null)]
63-
public void SqlClientInstrumentationOptions_EnableConnectionLevelAttributes(
63+
public void SqlClientTraceInstrumentationOptions_EnableConnectionLevelAttributes(
6464
bool enableConnectionLevelAttributes,
6565
string dataSource,
6666
string expectedServerHostName,
@@ -70,7 +70,7 @@ public void SqlClientInstrumentationOptions_EnableConnectionLevelAttributes(
7070
{
7171
var source = new ActivitySource("sql-client-instrumentation");
7272
var activity = source.StartActivity("Test Sql Activity");
73-
var options = new SqlClientInstrumentationOptions()
73+
var options = new SqlClientTraceInstrumentationOptions()
7474
{
7575
EnableConnectionLevelAttributes = enableConnectionLevelAttributes,
7676
};

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private static void VerifyActivityData(
222222
}
223223
else
224224
{
225-
var connectionDetails = SqlClientInstrumentationOptions.ParseDataSource(dataSource);
225+
var connectionDetails = SqlClientTraceInstrumentationOptions.ParseDataSource(dataSource);
226226

227227
if (!string.IsNullOrEmpty(connectionDetails.ServerHostName))
228228
{

0 commit comments

Comments
 (0)