Rename `db.statement` to `db.query.text` and introduce `db.query.parameter.<key>` (#866)
This commit is contained in:
parent
c65428b52e
commit
b5b2409b52
|
|
@ -0,0 +1,4 @@
|
|||
change_type: breaking
|
||||
component: db
|
||||
note: Rename `db.statement` to `db.query.text` and introduce `db.query.parameter.<key>`
|
||||
issues: [ 716 ]
|
||||
|
|
@ -25,11 +25,15 @@
|
|||
| `db.instance.id` | string | An identifier (address, unique name, or any other identifier) of the database instance that is executing queries or mutations on the current connection. This is useful in cases where the database is running in a clustered environment and the instrumentation is able to record the node executing the query. The client may obtain this value in databases like MySQL using queries like `select @@hostname`. | `mysql-e26b99z.example.com` |  |
|
||||
| `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` |  |
|
||||
| `db.operation.name` | string | The name of the operation or command being executed. | `findAndModify`; `HMSET`; `SELECT` |  |
|
||||
| `db.statement` | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` |  |
|
||||
| `db.query.parameter.<key>` | string | The query parameters used in `db.query.text`, with `<key>` being the parameter name, and the attribute value being the parameter value. [2] | `someval`; `55` |  |
|
||||
| `db.query.text` | string | The database query being executed. | `SELECT * FROM wuser_table where username = ?`; `SET mykey "WuValue"` |  |
|
||||
| `db.system` | string | An identifier for the database management system (DBMS) product being used. See below for a list of well-known identifiers. | `other_sql` |  |
|
||||
|
||||
**[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]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders.
|
||||
If a parameter has no name and instead is referenced only by index, then `<key>` SHOULD be the 0-based index.
|
||||
|
||||
`db.system` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
|
||||
|
||||
| Value | Description | Stability |
|
||||
|
|
@ -101,7 +105,7 @@
|
|||
| `db.cassandra.speculative_execution_count` | int | The number of times a query was speculatively executed. Not set or `0` if the query was not executed speculatively. | `0`; `2` |  |
|
||||
| `db.cassandra.table` | string | The name of the primary Cassandra table that the operation is acting upon, including the keyspace name (if applicable). [1] | `mytable` |  |
|
||||
|
||||
**[1]:** This mirrors the db.sql.table attribute but references cassandra rather than sql. It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
**[1]:** This mirrors the db.sql.table attribute but references cassandra rather than sql. It is not recommended to attempt any client-side parsing of `db.query.text` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
|
||||
`db.cassandra.consistency_level` MUST be one of the following:
|
||||
|
||||
|
|
@ -206,7 +210,7 @@
|
|||
|---|---|---|---|---|
|
||||
| `db.sql.table` | string | The name of the primary table that the operation is acting upon, including the database name (if applicable). [1] | `public.users`; `customers` |  |
|
||||
|
||||
**[1]:** It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
**[1]:** It is not recommended to attempt any client-side parsing of `db.query.text` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
<!-- endsemconv -->
|
||||
|
||||
## Deprecated DB Attributes
|
||||
|
|
@ -218,5 +222,6 @@
|
|||
| `db.elasticsearch.node.name` | string | Deprecated, use `db.instance.id` instead. | `instance-0000000001` | <br>Replaced by `db.instance.id`. |
|
||||
| `db.jdbc.driver_classname` | string | Removed, no replacement at this time. | `org.postgresql.Driver`; `com.microsoft.sqlserver.jdbc.SQLServerDriver` | <br>Removed as not used. |
|
||||
| `db.operation` | string | Deprecated, use `db.operation.name` instead. | `findAndModify`; `HMSET`; `SELECT` | <br>Replaced by `db.operation.name`. |
|
||||
| `db.statement` | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | <br>Replaced by `db.query.text`. |
|
||||
| `db.user` | string | Deprecated, no replacement at this time. | `readonly_user`; `reporting_user` | <br>No replacement at this time. |
|
||||
<!-- endsemconv -->
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ described on this page.
|
|||
|
||||
**[1]:** For Cassandra the `db.name` should be set to the Cassandra keyspace name.
|
||||
|
||||
**[2]:** This mirrors the db.sql.table attribute but references cassandra rather than sql. It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
**[2]:** This mirrors the db.sql.table attribute but references cassandra rather than sql. It is not recommended to attempt any client-side parsing of `db.query.text` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
|
||||
**[3]:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used.
|
||||
|
||||
|
|
|
|||
|
|
@ -77,10 +77,11 @@ These attributes will usually be the same for all operations performed over the
|
|||
| [`db.operation.name`](../attributes-registry/db.md) | string | The name of the operation or command being executed. | `findAndModify`; `HMSET`; `SELECT` | `Conditionally Required` [2] |  |
|
||||
| [`server.port`](../attributes-registry/server.md) | int | Server port number. [3] | `80`; `8080`; `443` | `Conditionally Required` [4] |  |
|
||||
| [`db.instance.id`](../attributes-registry/db.md) | string | An identifier (address, unique name, or any other identifier) of the database instance that is executing queries or mutations on the current connection. This is useful in cases where the database is running in a clustered environment and the instrumentation is able to record the node executing the query. The client may obtain this value in databases like MySQL using queries like `select @@hostname`. | `mysql-e26b99z.example.com` | `Recommended` If different from the `server.address` |  |
|
||||
| [`db.statement`](../attributes-registry/db.md) | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | `Recommended` [5] |  |
|
||||
| [`db.query.text`](../attributes-registry/db.md) | string | The database query being executed. | `SELECT * FROM wuser_table where username = ?`; `SET mykey "WuValue"` | `Recommended` [5] |  |
|
||||
| [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [6] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` If applicable for this database system. |  |
|
||||
| [`network.peer.port`](../attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` if and only if `network.peer.address` is set. |  |
|
||||
| [`server.address`](../attributes-registry/server.md) | string | Name of the database host. [7] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` |  |
|
||||
| [`db.query.parameter.<key>`](../attributes-registry/db.md) | string | The query parameters used in `db.query.text`, with `<key>` being the parameter name, and the attribute value being the parameter value. [8] | `someval`; `55` | `Opt-In` |  |
|
||||
|
||||
**[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).
|
||||
|
||||
|
|
@ -97,6 +98,9 @@ If a database operation involved multiple network calls (for example retries), t
|
|||
|
||||
**[7]:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available.
|
||||
|
||||
**[8]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders.
|
||||
If a parameter has no name and instead is referenced only by index, then `<key>` SHOULD be the 0-based index.
|
||||
|
||||
`db.system` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
|
||||
|
||||
| Value | Description | Stability |
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ If the endpoint id is not available, the span name SHOULD be the `http.request.m
|
|||
| [`server.port`](../attributes-registry/server.md) | int | Server port number. [5] | `80`; `8080`; `443` | `Conditionally Required` [6] |  |
|
||||
| [`db.elasticsearch.cluster.name`](../attributes-registry/db.md) | string | Represents the identifier of an Elasticsearch cluster. | `e9106fc68e3044f0b1475b04bf4ffd5f` | `Recommended` [7] |  |
|
||||
| [`db.instance.id`](../attributes-registry/db.md) | string | An identifier (address, unique name, or any other identifier) of the database instance that is executing queries or mutations on the current connection. This is useful in cases where the database is running in a clustered environment and the instrumentation is able to record the node executing the query. The client may obtain this value in databases like MySQL using queries like `select @@hostname`. | `mysql-e26b99z.example.com` | `Recommended` [8] |  |
|
||||
| [`db.statement`](../attributes-registry/db.md) | string | The request body for a [search-type query](https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html), as a json string. | `"{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}"` | `Recommended` [9] |  |
|
||||
| [`db.query.text`](../attributes-registry/db.md) | string | The request body for a [search-type query](https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html), as a json string. | `"{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}"` | `Recommended` [9] |  |
|
||||
| [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [10] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` |  |
|
||||
| [`network.peer.port`](../attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` if and only if `network.peer.address` is set. |  |
|
||||
| [`server.address`](../attributes-registry/server.md) | string | Name of the database host. [11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` |  |
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ In the case of `EXEC`, this SHOULD be the stored procedure name that is being ex
|
|||
|
||||
**[3]:** If setting a `db.mssql.instance_name`, `server.port` is no longer required (but still recommended if non-standard).
|
||||
|
||||
**[4]:** It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
**[4]:** It is not recommended to attempt any client-side parsing of `db.query.text` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
<!-- endsemconv -->
|
||||
|
||||
[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.31.0/specification/document-status.md
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ described on this page.
|
|||
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|
||||
|---|---|---|---|---|---|
|
||||
| [`db.redis.database_index`](../attributes-registry/db.md) | int | The index of the database being accessed as used in the [`SELECT` command](https://redis.io/commands/select), provided as an integer. To be used instead of the generic `db.name` attribute. | `0`; `1`; `15` | `Conditionally Required` If other than the default database (`0`). |  |
|
||||
| [`db.statement`](../attributes-registry/db.md) | string | The full syntax of the Redis CLI command. [1] | `HMSET myhash field1 'Hello' field2 'World'` | `Recommended` [2] |  |
|
||||
| [`db.query.text`](../attributes-registry/db.md) | string | The full syntax of the Redis CLI command. [1] | `HMSET myhash field1 'Hello' field2 'World'` | `Recommended` [2] |  |
|
||||
| [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [3] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` |  |
|
||||
| [`network.peer.port`](../attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` if and only if `network.peer.address` is set. |  |
|
||||
|
||||
**[1]:** For **Redis**, the value provided for `db.statement` SHOULD correspond to the syntax of the Redis CLI. If, for example, the [`HMSET` command](https://redis.io/commands/hmset) is invoked, `"HMSET myhash field1 'Hello' field2 'World'"` would be a suitable value for `db.statement`.
|
||||
**[1]:** For **Redis**, the value provided for `db.query.text` SHOULD correspond to the syntax of the Redis CLI. If, for example, the [`HMSET` command](https://redis.io/commands/hmset) is invoked, `"HMSET myhash field1 'Hello' field2 'World'"` would be a suitable value for `db.query.text`.
|
||||
|
||||
**[2]:** Should be collected by default only if there is sanitization that excludes sensitive information.
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ In the case of `EXEC`, this SHOULD be the stored procedure name that is being ex
|
|||
|
||||
**[2]:** If readily available. Otherwise, if the instrumentation library parses `db.statement` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query.
|
||||
|
||||
**[3]:** It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
**[3]:** It is not recommended to attempt any client-side parsing of `db.query.text` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.
|
||||
<!-- endsemconv -->
|
||||
|
||||
## Example
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ groups:
|
|||
note: >
|
||||
This mirrors the db.sql.table attribute but references cassandra rather than sql.
|
||||
It is not recommended to attempt any client-side parsing of
|
||||
`db.statement` just to get this property, but it should be set if
|
||||
`db.query.text` just to get this property, but it should be set if
|
||||
it is provided by the library being instrumented.
|
||||
If the operation is acting upon an anonymous table, or more than one table, this
|
||||
value MUST NOT be set.
|
||||
|
|
@ -266,18 +266,31 @@ groups:
|
|||
brief: The name of the primary table that the operation is acting upon, including the database name (if applicable).
|
||||
note: >
|
||||
It is not recommended to attempt any client-side parsing of
|
||||
`db.statement` just to get this property, but it should be set if
|
||||
`db.query.text` just to get this property, but it should be set if
|
||||
it is provided by the library being instrumented.
|
||||
If the operation is acting upon an anonymous table, or more than one table, this
|
||||
value MUST NOT be set.
|
||||
examples: ['public.users', 'customers']
|
||||
tag: tech-specific-sql
|
||||
- id: statement
|
||||
- id: query.text
|
||||
type: string
|
||||
stability: experimental
|
||||
brief: >
|
||||
The database statement being executed.
|
||||
examples: ['SELECT * FROM wuser_table', 'SET mykey "WuValue"']
|
||||
The database query being executed.
|
||||
examples: ['SELECT * FROM wuser_table where username = ?', 'SET mykey "WuValue"']
|
||||
tag: db-generic
|
||||
- id: query.parameter
|
||||
type: template[string]
|
||||
stability: experimental
|
||||
brief: >
|
||||
The query parameters used in `db.query.text`, with `<key>` being the parameter name,
|
||||
and the attribute value being the parameter value.
|
||||
note: >
|
||||
Query parameters should only be captured when `db.query.text` is parameterized with placeholders.
|
||||
|
||||
If a parameter has no name and instead is referenced only by index,
|
||||
then `<key>` SHOULD be the 0-based index.
|
||||
examples: ['someval', '55']
|
||||
tag: db-generic
|
||||
- id: system
|
||||
brief: An identifier for the database management system (DBMS) product being used. See below for a list of well-known identifiers.
|
||||
|
|
|
|||
|
|
@ -36,3 +36,9 @@ groups:
|
|||
deprecated: "No replacement at this time."
|
||||
stability: experimental
|
||||
examples: ['readonly_user', 'reporting_user']
|
||||
- id: statement
|
||||
type: string
|
||||
brief: The database statement being executed.
|
||||
deprecated: "Replaced by `db.query.text`."
|
||||
stability: experimental
|
||||
examples: ['SELECT * FROM wuser_table', 'SET mykey "WuValue"']
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ groups:
|
|||
- ref: db.name
|
||||
requirement_level:
|
||||
conditionally_required: If applicable.
|
||||
- ref: db.statement
|
||||
- ref: db.query.text
|
||||
requirement_level:
|
||||
recommended: >
|
||||
Should be collected by default only if there is sanitization that excludes sensitive information.
|
||||
- ref: db.query.parameter
|
||||
requirement_level: opt_in
|
||||
- ref: db.operation.name
|
||||
requirement_level:
|
||||
conditionally_required: >
|
||||
|
|
@ -136,14 +138,14 @@ groups:
|
|||
requirement_level:
|
||||
conditionally_required: If other than the default database (`0`).
|
||||
tag: tech-specific
|
||||
- ref: db.statement
|
||||
- ref: db.query.text
|
||||
tag: tech-specific
|
||||
brief: >
|
||||
The full syntax of the Redis CLI command.
|
||||
examples: ["HMSET myhash field1 'Hello' field2 'World'"]
|
||||
note: >
|
||||
For **Redis**, the value provided for `db.statement` SHOULD correspond to the syntax of the Redis CLI.
|
||||
If, for example, the [`HMSET` command](https://redis.io/commands/hmset) is invoked, `"HMSET myhash field1 'Hello' field2 'World'"` would be a suitable value for `db.statement`.
|
||||
For **Redis**, the value provided for `db.query.text` SHOULD correspond to the syntax of the Redis CLI.
|
||||
If, for example, the [`HMSET` command](https://redis.io/commands/hmset) is invoked, `"HMSET myhash field1 'Hello' field2 'World'"` would be a suitable value for `db.query.text`.
|
||||
|
||||
- id: db.mongodb
|
||||
type: span
|
||||
|
|
@ -180,7 +182,7 @@ groups:
|
|||
requirement_level: required
|
||||
examples: [ 'https://localhost:9200/index/_search?q=user.id:kimchy' ]
|
||||
tag: tech-specific
|
||||
- ref: db.statement
|
||||
- ref: db.query.text
|
||||
requirement_level:
|
||||
recommended: >
|
||||
Should be collected by default for search-type queries and only if there is sanitization that excludes
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ versions:
|
|||
- rename_attributes:
|
||||
attribute_map:
|
||||
db.operation: db.operation.name
|
||||
# https://github.com/open-telemetry/semantic-conventions/pull/866
|
||||
- rename_attributes:
|
||||
attribute_map:
|
||||
db.statement: db.query.text
|
||||
metrics:
|
||||
changes:
|
||||
# https://github.com/open-telemetry/semantic-conventions/pull/484
|
||||
|
|
|
|||
Loading…
Reference in New Issue