Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sqlclient] Enable collecting server.* attributes by default #2249

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
for the same information. Note that `server.address` is only included when
the `EnableConnectionLevelAttributes` option is enabled.
([#2229](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2229))
* When `EnableConnectionLevelAttributes` is enabled, the `server.port` attribute
will now be written as an integer to be compliant with the
[semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/attributes-registry/server.md).
* **Breaking change**: When `EnableConnectionLevelAttributes` is enabled, the
`server.port` attribute will now be written as an integer to be compliant with
the [semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/attributes-registry/server.md).
Previously, it was written as a string.
([#2233](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2233))
* The `EnableConnectionLevelAttributes` option is now enabled by default.
([#2249](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2249))

## 1.9.0-beta.1

Expand Down
6 changes: 3 additions & 3 deletions src/OpenTelemetry.Instrumentation.SqlClient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ command text will be captured.
> [!NOTE]
> EnableConnectionLevelAttributes is supported on all runtimes.

By default, `EnabledConnectionLevelAttributes` is disabled.
If `EnabledConnectionLevelAttributes` is enabled,
By default, `EnabledConnectionLevelAttributes` is enabled.
When `EnabledConnectionLevelAttributes` is enabled,
the [`DataSource`](https://docs.microsoft.com/dotnet/api/system.data.common.dbconnection.datasource)
will be parsed and the server name or IP address will be sent as
the `server.address` attribute, the instance name will be sent as
the `db.mssql.instance_name` attribute, and the port will be sent as the
`net.peer.port` attribute if it is not 1433 (the default port).
`server.port` attribute if it is not 1433 (the default port).

The following example shows how to use `EnableConnectionLevelAttributes`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,20 @@ internal SqlClientTraceInstrumentationOptions(IConfiguration configuration)
/// cref="SqlClientInstrumentation"/> should parse the DataSource on a
/// SqlConnection into server name, instance name, and/or port
/// connection-level attribute tags. Default value: <see
/// langword="false"/>.
/// langword="true"/>.
/// </summary>
/// <remarks>
/// <para>
/// <b>EnableConnectionLevelAttributes is supported on all runtimes.</b>
/// </para>
/// <para>
/// The default behavior is to set the SqlConnection DataSource as the <see cref="SemanticConventions.AttributePeerService"/> tag.
/// If enabled, SqlConnection DataSource will be parsed and the server name will be sent as the
/// <see cref="SemanticConventions.AttributeServerAddress"/> or <see cref="SemanticConventions.AttributeServerSocketAddress"/> tag,
/// <see cref="SemanticConventions.AttributeServerAddress"/> tag,
/// the instance name will be sent as the <see cref="SemanticConventions.AttributeDbMsSqlInstanceName"/> tag,
/// and the port will be sent as the <see cref="SemanticConventions.AttributeServerPort"/> tag if it is not 1433 (the default port).
/// </para>
/// </remarks>
public bool EnableConnectionLevelAttributes { get; set; }
public bool EnableConnectionLevelAttributes { get; set; } = true;

/// <summary>
/// Gets or sets an action to enrich an <see cref="Activity"/> with the
Expand Down
Loading