diff --git a/CHANGELOG.md b/CHANGELOG.md index 57557e3daa4..b4e747a6d42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -212,6 +212,8 @@ release. [#3158](https://github.com/open-telemetry/opentelemetry-specification/pull/3158) - `http.route` SHOULD contain the "application root" if there is one. ([#3164](https://github.com/open-telemetry/opentelemetry-specification/pull/3164)) +- Change `db.statement` to only be collected if there is sanitization. + ([#3127](https://github.com/open-telemetry/opentelemetry-specification/pull/3127)) ### Compatibility diff --git a/semantic_conventions/trace/database.yaml b/semantic_conventions/trace/database.yaml index e89f5eadf3c..65cda87cf73 100644 --- a/semantic_conventions/trace/database.yaml +++ b/semantic_conventions/trace/database.yaml @@ -207,11 +207,10 @@ groups: tag: call-level type: string requirement_level: - conditionally_required: > - If applicable and not explicitly disabled via instrumentation configuration. + recommended: > + Should be collected by default only if there is sanitization that excludes sensitive information. brief: > The database statement being executed. - note: The value may be sanitized to exclude sensitive information. examples: ['SELECT * FROM wuser_table', 'SET mykey "WuValue"'] - id: operation tag: call-level diff --git a/specification/trace/semantic_conventions/database.md b/specification/trace/semantic_conventions/database.md index 22705196e3e..36bff3d5442 100644 --- a/specification/trace/semantic_conventions/database.md +++ b/specification/trace/semantic_conventions/database.md @@ -162,16 +162,14 @@ Usually only one `db.name` will be used per connection though. | Attribute | Type | Description | Examples | Requirement Level | |---|---|---|---|---| | `db.name` | string | This attribute is used to report the name of the database being accessed. For commands that switch the database, this should be set to the target database (even if the command fails). [1] | `customers`; `main` | Conditionally Required: If applicable. | -| `db.statement` | string | The database statement being executed. [2] | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | Conditionally Required: [3] | -| `db.operation` | string | The name of the operation being executed, e.g. the [MongoDB command name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as `findAndModify`, or the SQL keyword. [4] | `findAndModify`; `HMSET`; `SELECT` | Conditionally Required: If `db.statement` is not applicable. | +| `db.statement` | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | Recommended: [2] | +| `db.operation` | string | The name of the operation being executed, e.g. the [MongoDB command name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as `findAndModify`, or the SQL keyword. [3] | `findAndModify`; `HMSET`; `SELECT` | Conditionally Required: If `db.statement` is not applicable. | **[1]:** In some SQL databases, the database name to be used is called "schema name". In case there are multiple layers that could be considered for database name (e.g. Oracle instance name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema name). -**[2]:** The value may be sanitized to exclude sensitive information. +**[2]:** Should be collected by default only if there is sanitization that excludes sensitive information. -**[3]:** If applicable and not explicitly disabled via instrumentation configuration. - -**[4]:** When setting this to an SQL keyword, it is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if the operation name is provided by the library being instrumented. If the SQL statement has an ambiguous operation, or performs more than one operation, this value may be omitted. +**[3]:** When setting this to an SQL keyword, it is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if the operation name is provided by the library being instrumented. If the SQL statement has an ambiguous operation, or performs more than one operation, this value may be omitted. For **Redis**, the value provided for `db.statement` SHOULD correspond to the syntax of the Redis CLI.