Skip to content

Commit

Permalink
Change db.statement to only be collected if there is sanitization (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
avzis authored Apr 6, 2023
1 parent b124b1c commit 10f79bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions semantic_conventions/trace/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions specification/trace/semantic_conventions/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<!-- endsemconv -->

For **Redis**, the value provided for `db.statement` SHOULD correspond to the syntax of the Redis CLI.
Expand Down

0 comments on commit 10f79bd

Please sign in to comment.