From 514e388afcbeee12391726e5d7da0dc38af698ca Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 14:02:34 -0800 Subject: [PATCH 1/7] Refine db.operation.name and db.collection.name --- .chloggen/1566.yaml | 22 ++++++++++ docs/attributes-registry/db.md | 17 +++----- docs/database/cassandra.md | 17 +++----- docs/database/cosmosdb.md | 41 +++++++----------- docs/database/database-metrics.md | 34 +++++---------- docs/database/database-spans.md | 17 +++----- docs/database/hbase.md | 6 +-- docs/database/mariadb.md | 69 ++++++++++--------------------- docs/database/mongodb.md | 11 ++--- docs/database/mssql.md | 69 ++++++++++--------------------- docs/database/mysql.md | 69 ++++++++++--------------------- docs/database/postgresql.md | 69 ++++++++++--------------------- docs/database/redis.md | 68 ++++++++++++++---------------- docs/database/sql.md | 69 ++++++++++--------------------- model/database/common.yaml | 33 ++++++++------- model/database/registry.yaml | 17 +++----- model/database/spans.yaml | 43 +++++++++++++------ 17 files changed, 260 insertions(+), 411 deletions(-) create mode 100644 .chloggen/1566.yaml diff --git a/.chloggen/1566.yaml b/.chloggen/1566.yaml new file mode 100644 index 0000000000..5b82a55e2a --- /dev/null +++ b/.chloggen/1566.yaml @@ -0,0 +1,22 @@ +# Use this changelog template to create an entry for release notes. +# +# If your change doesn't affect end users you should instead start +# your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db) +component: db + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Don't capture `db.operation.name` and `db.collection.name` from query formats that support multiples. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +# The values here must be integers. +issues: [ 1566 ] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/docs/attributes-registry/db.md b/docs/attributes-registry/db.md index bc6f42e7f4..087608fb9c 100644 --- a/docs/attributes-registry/db.md +++ b/docs/attributes-registry/db.md @@ -34,18 +34,13 @@ This group defines the attributes used to describe telemetry in the context of d **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. +The collection name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single collection name present +and the collection name is known to always be under the captured `db.namespace`. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - This attribute has stability level RELEASE CANDIDATE. **[2]:** If a database system has multiple namespace components, they SHOULD be concatenated (potentially using database system specific conventions) from most general to most specific namespace component, and more specific namespaces SHOULD NOT be captured without the more general namespaces, to ensure that "startswith" queries for the more general namespaces will be valid. @@ -59,10 +54,8 @@ This attribute has stability level RELEASE CANDIDATE. **[4]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. For batch operations, if the individual operations are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `, diff --git a/docs/database/cassandra.md b/docs/database/cassandra.md index ccfa8ad091..40ec3639ef 100644 --- a/docs/database/cassandra.md +++ b/docs/database/cassandra.md @@ -44,18 +44,13 @@ The Semantic Conventions for [Cassandra](https://cassandra.apache.org/) extend a **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. +The collection name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single collection name present +and the collection name is known to always be under the captured `db.namespace`. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - This attribute has stability level RELEASE CANDIDATE. **[2]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. @@ -68,10 +63,8 @@ This attribute has stability level RELEASE CANDIDATE. **[4]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. For batch operations, if the individual operations are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `, diff --git a/docs/database/cosmosdb.md b/docs/database/cosmosdb.md index 3b75b969ae..6194a859b1 100644 --- a/docs/database/cosmosdb.md +++ b/docs/database/cosmosdb.md @@ -336,50 +336,41 @@ Explaining bucket configuration: | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| -| [`db.collection.name`](/docs/attributes-registry/db.md) | string | Cosmos DB container name. [1] | `public.users`; `customers` | `Conditionally Required` If available | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.collection.name`](/docs/attributes-registry/db.md) | string | Cosmos DB container name. [1] | `public.users`; `customers` | `Conditionally Required` If available. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.cosmosdb.consistency_level`](/docs/attributes-registry/db.md) | string | Account or request [consistency level](https://learn.microsoft.com/azure/cosmos-db/consistency-levels). | `Eventual`; `ConsistentPrefix`; `BoundedStaleness`; `Strong`; `Session` | `Conditionally Required` If available. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.cosmosdb.sub_status_code`](/docs/attributes-registry/db.md) | int | Cosmos DB sub status code. | `1000`; `1002` | `Conditionally Required` when response was received and contained sub-code. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.namespace`](/docs/attributes-registry/db.md) | string | The name of the database, fully qualified within the server address and port. | `customers`; `test.users` | `Conditionally Required` If available. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [2] | `findAndModify`; `HMSET`; `SELECT` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | Database response status code. [4] | `102`; `ORA-17002`; `08P01`; `404` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [6] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [7] | `80`; `8080`; `443` | `Conditionally Required` [8] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [9] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | Database response status code. [2] | `102`; `ORA-17002`; `08P01`; `404` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [5] | `80`; `8080`; `443` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [7] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -**[2]:** It is RECOMMENDED to capture the value as provided by the application -without attempting to do any case normalization. - -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +The collection name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single collection name present +and the collection name is known to always be under the captured `db.namespace`. -For batch operations, if the individual operations are known to have the same operation name -then that operation name SHOULD be used prepended by `BATCH `, -otherwise `db.operation.name` SHOULD be `BATCH` or some other database -system specific term if more applicable. +For batch operations, if the individual operations are known to have the same collection name +then that collection name SHOULD be used. This attribute has stability level RELEASE CANDIDATE. -**[3]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. - -**[4]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. +**[2]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system. This attribute has stability level RELEASE CANDIDATE. -**[5]:** If the operation failed and status code is available. +**[3]:** If the operation failed and status code is available. -**[6]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +**[4]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how `error.type` is populated. -**[7]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +**[5]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[8]:** If using a port other than the default port for this DBMS and if `server.address` is set. +**[6]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[9]:** 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. +**[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. The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): diff --git a/docs/database/database-metrics.md b/docs/database/database-metrics.md index a82e7ccbd8..f3d6825809 100644 --- a/docs/database/database-metrics.md +++ b/docs/database/database-metrics.md @@ -101,18 +101,13 @@ This attribute has stability level RELEASE CANDIDATE. **[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. +The collection name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single collection name present +and the collection name is known to always be under the captured `db.namespace`. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - This attribute has stability level RELEASE CANDIDATE. **[3]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. @@ -125,10 +120,8 @@ This attribute has stability level RELEASE CANDIDATE. **[5]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. For batch operations, if the individual operations are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `, @@ -291,18 +284,13 @@ This attribute has stability level RELEASE CANDIDATE. **[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. +The collection name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single collection name present +and the collection name is known to always be under the captured `db.namespace`. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - This attribute has stability level RELEASE CANDIDATE. **[3]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. @@ -315,10 +303,8 @@ This attribute has stability level RELEASE CANDIDATE. **[5]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. For batch operations, if the individual operations are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `, diff --git a/docs/database/database-spans.md b/docs/database/database-spans.md index 06c08b0597..ab5d11e954 100644 --- a/docs/database/database-spans.md +++ b/docs/database/database-spans.md @@ -119,18 +119,13 @@ This attribute has stability level RELEASE CANDIDATE. **[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. +The collection name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single collection name present +and the collection name is known to always be under the captured `db.namespace`. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - This attribute has stability level RELEASE CANDIDATE. **[3]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. @@ -143,10 +138,8 @@ This attribute has stability level RELEASE CANDIDATE. **[5]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. For batch operations, if the individual operations are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `, diff --git a/docs/database/hbase.md b/docs/database/hbase.md index e7a9f5921a..5563ddfc6b 100644 --- a/docs/database/hbase.md +++ b/docs/database/hbase.md @@ -40,10 +40,8 @@ This attribute has stability level RELEASE CANDIDATE. **[3]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. For batch operations, if the individual operations are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `, diff --git a/docs/database/mariadb.md b/docs/database/mariadb.md index 99aced8daf..fa93682cd1 100644 --- a/docs/database/mariadb.md +++ b/docs/database/mariadb.md @@ -21,38 +21,18 @@ The Semantic Conventions for *MariaDB* extend and override the [Database Semanti | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| -| [`db.collection.name`](/docs/attributes-registry/db.md) | string | The name of the SQL table that the operation is acting upon. [1] | `users`; `dbo.products` | `Conditionally Required` [2] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection. [3] | `products`; `customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [4] | `SELECT`; `INSERT`; `UPDATE`; `DELETE`; `CREATE`; `mystoredproc` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [Maria DB error code](https://mariadb.com/kb/en/mariadb-error-code-reference/) represented as a string. [6] | `1008`; `3058` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [7] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [8] | `80`; `8080`; `443` | `Conditionally Required` [9] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [10] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [11] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [12] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [13] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [14] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection. [1] | `products`; `customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [Maria DB error code](https://mariadb.com/kb/en/mariadb-error-code-reference/) represented as a string. [2] | `1008`; `3058` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [4] | `80`; `8080`; `443` | `Conditionally Required` [5] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [6] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [7] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [8] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [9] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [10] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.response.returned_rows`](/docs/attributes-registry/db.md) | int | Number of rows returned by the operation. | `10`; `30`; `1000` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [15] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [16] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [12] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. - -For batch operations, if the individual operations are known to have the same collection name -then that collection name SHOULD be used. - -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - -This attribute has stability level RELEASE CANDIDATE. - -**[2]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. - -**[3]:** A connection's currently associated database may change during its lifetime, e.g. from executing `USE `. +**[1]:** A connection's currently associated database may change during its lifetime, e.g. from executing `USE `. If instrumentation is unable to capture the connection's currently associated database on each query without triggering an additional query to be executed (e.g. `SELECT DATABASE()`), @@ -62,12 +42,7 @@ Instrumentation SHOULD document if `db.namespace` reflects the database provided It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -**[4]:** This SHOULD be the SQL command such as `SELECT`, `INSERT`, `UPDATE`, `CREATE`, `DROP`. -In the case of `EXEC`, this SHOULD be the stored procedure name that is being executed. - -**[5]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. - -**[6]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database +**[2]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database return code which is adopted by some database systems like PostgreSQL. See [PostgreSQL error codes](https://www.postgresql.org/docs/current/errcodes-appendix.html) for the details. @@ -103,43 +78,41 @@ For example, generic DB instrumentation that detected an error and has SQLSTATE `"42000"` and vendor-specific `1071` should set `db.response.status_code` to `"42000/1071"`." -**[7]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +**[3]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how `error.type` is populated. -**[8]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +**[4]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[9]:** If using a port other than the default port for this DBMS and if `server.address` is set. +**[5]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[10]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. +**[6]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. This attribute has stability level RELEASE CANDIDATE. -**[11]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. +**[7]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not available, instrumentations that support query parsing SHOULD generate a summary following [Generating query summary](../../docs/database/database-spans.md#generating-a-summary-of-the-quey-text) section. This attribute has stability level RELEASE CANDIDATE. -**[12]:** if readily available or if instrumentation supports query summarization. +**[8]:** if readily available or if instrumentation supports query summarization. -**[13]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[9]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). For batch operations, if the individual operations are known to have the same query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD be concatenated with separator `; ` or some other database system specific separator if more applicable. Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk. This attribute has stability level RELEASE CANDIDATE. -**[14]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[10]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). -**[15]:** 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. +**[11]:** 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. -**[16]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders. +**[12]:** 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 `` SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): -* [`db.collection.name`](/docs/attributes-registry/db.md) * [`db.namespace`](/docs/attributes-registry/db.md) -* [`db.operation.name`](/docs/attributes-registry/db.md) * [`db.query.summary`](/docs/attributes-registry/db.md) * [`db.query.text`](/docs/attributes-registry/db.md) * [`server.address`](/docs/attributes-registry/server.md) diff --git a/docs/database/mongodb.md b/docs/database/mongodb.md index 05939fca5b..84d43bf276 100644 --- a/docs/database/mongodb.md +++ b/docs/database/mongodb.md @@ -32,18 +32,13 @@ The Semantic Conventions for [MongoDB](https://www.mongodb.com/) extend and over **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. +The collection name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single collection name present +and the collection name is known to always be under the captured `db.namespace`. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - This attribute has stability level RELEASE CANDIDATE. **[2]:** See [MongoDB database commands](https://www.mongodb.com/docs/manual/reference/command/). diff --git a/docs/database/mssql.md b/docs/database/mssql.md index 35519e5fd6..ac3bb5f290 100644 --- a/docs/database/mssql.md +++ b/docs/database/mssql.md @@ -21,38 +21,18 @@ The Semantic Conventions for the *Microsoft SQL Server* extend and override the | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| -| [`db.collection.name`](/docs/attributes-registry/db.md) | string | The name of the SQL table that the operation is acting upon. [1] | `users`; `dbo.products` | `Conditionally Required` [2] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection, qualified by the instance name. [3] | `instance1.products`; `customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [4] | `SELECT`; `INSERT`; `UPDATE`; `DELETE`; `CREATE`; `mystoredproc` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [Microsoft SQL Server error](https://learn.microsoft.com/sql/relational-databases/errors-events/database-engine-events-and-errors) number represented as a string. [6] | `102`; `40020` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [7] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [8] | `80`; `8080`; `443` | `Conditionally Required` [9] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [10] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [11] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [12] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [13] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [14] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection, qualified by the instance name. [1] | `instance1.products`; `customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [Microsoft SQL Server error](https://learn.microsoft.com/sql/relational-databases/errors-events/database-engine-events-and-errors) number represented as a string. [2] | `102`; `40020` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [4] | `80`; `8080`; `443` | `Conditionally Required` [5] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [6] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [7] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [8] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [9] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [10] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.response.returned_rows`](/docs/attributes-registry/db.md) | int | Number of rows returned by the operation. | `10`; `30`; `1000` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [15] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [16] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [12] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. - -For batch operations, if the individual operations are known to have the same collection name -then that collection name SHOULD be used. - -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - -This attribute has stability level RELEASE CANDIDATE. - -**[2]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. - -**[3]:** When connected to a default instance, `db.namespace` SHOULD be set to the name of +**[1]:** When connected to a default instance, `db.namespace` SHOULD be set to the name of the database. When connected to a [named instance](https://learn.microsoft.com/sql/connect/jdbc/building-the-connection-url#named-and-multiple-sql-server-instances), `db.namespace` SHOULD be set to the combination of instance and database name following the `{instance_name}.{database_name}` pattern. @@ -66,50 +46,43 @@ Instrumentation SHOULD document if `db.namespace` reflects the database provided It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -**[4]:** This SHOULD be the SQL command such as `SELECT`, `INSERT`, `UPDATE`, `CREATE`, `DROP`. -In the case of `EXEC`, this SHOULD be the stored procedure name that is being executed. - -**[5]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. - -**[6]:** Microsoft SQL Server does not report SQLSTATE. +**[2]:** Microsoft SQL Server does not report SQLSTATE. -**[7]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +**[3]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how `error.type` is populated. -**[8]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +**[4]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[9]:** If using a port other than the default port for this DBMS and if `server.address` is set. +**[5]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[10]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. +**[6]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. This attribute has stability level RELEASE CANDIDATE. -**[11]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. +**[7]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not available, instrumentations that support query parsing SHOULD generate a summary following [Generating query summary](../../docs/database/database-spans.md#generating-a-summary-of-the-quey-text) section. This attribute has stability level RELEASE CANDIDATE. -**[12]:** if readily available or if instrumentation supports query summarization. +**[8]:** if readily available or if instrumentation supports query summarization. -**[13]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[9]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). For batch operations, if the individual operations are known to have the same query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD be concatenated with separator `; ` or some other database system specific separator if more applicable. Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk. This attribute has stability level RELEASE CANDIDATE. -**[14]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[10]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). -**[15]:** 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. +**[11]:** 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. -**[16]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders. +**[12]:** 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 `` SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): -* [`db.collection.name`](/docs/attributes-registry/db.md) * [`db.namespace`](/docs/attributes-registry/db.md) -* [`db.operation.name`](/docs/attributes-registry/db.md) * [`db.query.summary`](/docs/attributes-registry/db.md) * [`db.query.text`](/docs/attributes-registry/db.md) * [`server.address`](/docs/attributes-registry/server.md) diff --git a/docs/database/mysql.md b/docs/database/mysql.md index 65e273688a..271b2ce699 100644 --- a/docs/database/mysql.md +++ b/docs/database/mysql.md @@ -21,38 +21,18 @@ The Semantic Conventions for *MySQL* extend and override the [Database Semantic | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| -| [`db.collection.name`](/docs/attributes-registry/db.md) | string | The name of the SQL table that the operation is acting upon. [1] | `users`; `dbo.products` | `Conditionally Required` [2] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection. [3] | `products`; `customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [4] | `SELECT`; `INSERT`; `UPDATE`; `DELETE`; `CREATE`; `mystoredproc` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [MySQL error number](https://dev.mysql.com/doc/mysql-errors/9.0/en/error-reference-introduction.html). [6] | `1005`; `MY-010016` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [7] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [8] | `80`; `8080`; `443` | `Conditionally Required` [9] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [10] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [11] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [12] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [13] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [14] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection. [1] | `products`; `customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [MySQL error number](https://dev.mysql.com/doc/mysql-errors/9.0/en/error-reference-introduction.html). [2] | `1005`; `MY-010016` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [4] | `80`; `8080`; `443` | `Conditionally Required` [5] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [6] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [7] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [8] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [9] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [10] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.response.returned_rows`](/docs/attributes-registry/db.md) | int | Number of rows returned by the operation. | `10`; `30`; `1000` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [15] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [16] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [12] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. - -For batch operations, if the individual operations are known to have the same collection name -then that collection name SHOULD be used. - -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - -This attribute has stability level RELEASE CANDIDATE. - -**[2]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. - -**[3]:** A connection's currently associated database may change during its lifetime, e.g. from executing `USE `. +**[1]:** A connection's currently associated database may change during its lifetime, e.g. from executing `USE `. If instrumentation is unable to capture the connection's currently associated database on each query without triggering an additional query to be executed (e.g. `SELECT DATABASE()`), @@ -62,12 +42,7 @@ Instrumentation SHOULD document if `db.namespace` reflects the database provided It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -**[4]:** This SHOULD be the SQL command such as `SELECT`, `INSERT`, `UPDATE`, `CREATE`, `DROP`. -In the case of `EXEC`, this SHOULD be the stored procedure name that is being executed. - -**[5]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. - -**[6]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database +**[2]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database return code which is adopted by some database systems like PostgreSQL. See [PostgreSQL error codes](https://www.postgresql.org/docs/current/errcodes-appendix.html) for the details. @@ -103,43 +78,41 @@ For example, generic DB instrumentation that detected an error and has SQLSTATE `"42000"` and vendor-specific `1071` should set `db.response.status_code` to `"42000/1071"`." -**[7]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +**[3]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how `error.type` is populated. -**[8]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +**[4]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[9]:** If using a port other than the default port for this DBMS and if `server.address` is set. +**[5]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[10]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. +**[6]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. This attribute has stability level RELEASE CANDIDATE. -**[11]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. +**[7]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not available, instrumentations that support query parsing SHOULD generate a summary following [Generating query summary](../../docs/database/database-spans.md#generating-a-summary-of-the-quey-text) section. This attribute has stability level RELEASE CANDIDATE. -**[12]:** if readily available or if instrumentation supports query summarization. +**[8]:** if readily available or if instrumentation supports query summarization. -**[13]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[9]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). For batch operations, if the individual operations are known to have the same query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD be concatenated with separator `; ` or some other database system specific separator if more applicable. Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk. This attribute has stability level RELEASE CANDIDATE. -**[14]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[10]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). -**[15]:** 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. +**[11]:** 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. -**[16]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders. +**[12]:** 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 `` SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): -* [`db.collection.name`](/docs/attributes-registry/db.md) * [`db.namespace`](/docs/attributes-registry/db.md) -* [`db.operation.name`](/docs/attributes-registry/db.md) * [`db.query.summary`](/docs/attributes-registry/db.md) * [`db.query.text`](/docs/attributes-registry/db.md) * [`server.address`](/docs/attributes-registry/server.md) diff --git a/docs/database/postgresql.md b/docs/database/postgresql.md index 23950fbe41..11976a51a9 100644 --- a/docs/database/postgresql.md +++ b/docs/database/postgresql.md @@ -21,38 +21,18 @@ The Semantic Conventions for *PostgreSQL* extend and override the [Database Sema | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| -| [`db.collection.name`](/docs/attributes-registry/db.md) | string | The name of the SQL table that the operation is acting upon. [1] | `users`; `dbo.products` | `Conditionally Required` [2] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.namespace`](/docs/attributes-registry/db.md) | string | The schema associated with the connection, qualified by the database name. [3] | `mydatabase.products`; `mydatabase.customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [4] | `SELECT`; `INSERT`; `UPDATE`; `DELETE`; `CREATE`; `mystoredproc` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [PostgreSQL error code](https://www.postgresql.org/docs/current/errcodes-appendix.html). [6] | `08000`; `08P01` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [7] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [8] | `80`; `8080`; `443` | `Conditionally Required` [9] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [10] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [11] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [12] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [13] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [14] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.namespace`](/docs/attributes-registry/db.md) | string | The schema associated with the connection, qualified by the database name. [1] | `mydatabase.products`; `mydatabase.customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [PostgreSQL error code](https://www.postgresql.org/docs/current/errcodes-appendix.html). [2] | `08000`; `08P01` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [4] | `80`; `8080`; `443` | `Conditionally Required` [5] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [6] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [7] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [8] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [9] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [10] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.response.returned_rows`](/docs/attributes-registry/db.md) | int | Number of rows returned by the operation. | `10`; `30`; `1000` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [15] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [16] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [12] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. - -For batch operations, if the individual operations are known to have the same collection name -then that collection name SHOULD be used. - -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - -This attribute has stability level RELEASE CANDIDATE. - -**[2]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. - -**[3]:** `db.namespace` SHOULD be set to the combination of database and schema name following the `{database}.{schema}` pattern. +**[1]:** `db.namespace` SHOULD be set to the combination of database and schema name following the `{database}.{schema}` pattern. A connection's currently associated database may change during its lifetime, e.g. from executing `SET search_path TO `. If the search path has multiple schemas, the first schema in the search path SHOULD be used. @@ -69,12 +49,7 @@ Instrumentation SHOULD document if `db.namespace` reflects the user provided whe It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -**[4]:** This SHOULD be the SQL command such as `SELECT`, `INSERT`, `UPDATE`, `CREATE`, `DROP`. -In the case of `EXEC`, this SHOULD be the stored procedure name that is being executed. - -**[5]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. - -**[6]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database +**[2]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database return code which is adopted by some database systems like PostgreSQL. See [PostgreSQL error codes](https://www.postgresql.org/docs/current/errcodes-appendix.html) for the details. @@ -110,43 +85,41 @@ For example, generic DB instrumentation that detected an error and has SQLSTATE `"42000"` and vendor-specific `1071` should set `db.response.status_code` to `"42000/1071"`." -**[7]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +**[3]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how `error.type` is populated. -**[8]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +**[4]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[9]:** If using a port other than the default port for this DBMS and if `server.address` is set. +**[5]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[10]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. +**[6]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. This attribute has stability level RELEASE CANDIDATE. -**[11]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. +**[7]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not available, instrumentations that support query parsing SHOULD generate a summary following [Generating query summary](../../docs/database/database-spans.md#generating-a-summary-of-the-quey-text) section. This attribute has stability level RELEASE CANDIDATE. -**[12]:** if readily available or if instrumentation supports query summarization. +**[8]:** if readily available or if instrumentation supports query summarization. -**[13]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[9]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). For batch operations, if the individual operations are known to have the same query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD be concatenated with separator `; ` or some other database system specific separator if more applicable. Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk. This attribute has stability level RELEASE CANDIDATE. -**[14]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[10]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). -**[15]:** 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. +**[11]:** 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. -**[16]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders. +**[12]:** 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 `` SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): -* [`db.collection.name`](/docs/attributes-registry/db.md) * [`db.namespace`](/docs/attributes-registry/db.md) -* [`db.operation.name`](/docs/attributes-registry/db.md) * [`db.query.summary`](/docs/attributes-registry/db.md) * [`db.query.text`](/docs/attributes-registry/db.md) * [`server.address`](/docs/attributes-registry/server.md) diff --git a/docs/database/redis.md b/docs/database/redis.md index cc09b36948..04dfa86aae 100644 --- a/docs/database/redis.md +++ b/docs/database/redis.md @@ -22,16 +22,16 @@ The Semantic Conventions for [Redis](https://redis.com/) extend and override the | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| | [`db.namespace`](/docs/attributes-registry/db.md) | string | The [database index] associated with the connection, represented as a string. [1] | `0`; `1`; `15` | `Conditionally Required` If and only if it can be captured reliably. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [2] | `findAndModify`; `HMSET`; `SELECT` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | The Redis [simple error](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-errors) prefix. [4] | `ERR`; `WRONGTYPE`; `CLUSTERDOWN` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [6] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [7] | `80`; `8080`; `443` | `Conditionally Required` [8] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [9] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.text`](/docs/attributes-registry/db.md) | string | The full syntax of the Redis CLI command. [10] | `HMSET myhash field1 'Hello' field2 'World'` | `Recommended` [11] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`network.peer.address`](/docs/attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [12] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | The Redis [simple error](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-errors) prefix. [2] | `ERR`; `WRONGTYPE`; `CLUSTERDOWN` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [5] | `80`; `8080`; `443` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [7] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [8] | `findAndModify`; `HMSET`; `SELECT` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.text`](/docs/attributes-registry/db.md) | string | The full syntax of the Redis CLI command. [9] | `HMSET myhash field1 'Hello' field2 'World'` | `Recommended` [10] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`network.peer.address`](/docs/attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [11] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`network.peer.port`](/docs/attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` if and only if `network.peer.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [13] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [14] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [12] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [13] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1]:** A connection's currently associated database index may change during its lifetime, e.g. from executing `SELECT `. @@ -41,51 +41,47 @@ then it is RECOMMENDED to fallback and use the database index provided when the Instrumentation SHOULD document if `db.namespace` reflects the database index provided when the connection was established. -**[2]:** It is RECOMMENDED to capture the value as provided by the application -without attempting to do any case normalization. +**[2]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. +Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system. +This attribute has stability level RELEASE CANDIDATE. -A single database query may involve multiple operations. If the operation -name is parsed from the query text, it SHOULD only be captured for queries that -contain a single operation or when the operation name describing the -whole query is available by other means. +**[3]:** If the operation failed and status code is available. -For batch operations, if the individual operations are known to have the same operation name -then that operation name SHOULD be used prepended by `BATCH `, -otherwise `db.operation.name` SHOULD be `BATCH` or some other database -system specific term if more applicable. +**[4]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. +Instrumentations SHOULD document how `error.type` is populated. -This attribute has stability level RELEASE CANDIDATE. +**[5]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[3]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. +**[6]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[4]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. -Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system. +**[7]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. This attribute has stability level RELEASE CANDIDATE. -**[5]:** If the operation failed and status code is available. - -**[6]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. -When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. -Instrumentations SHOULD document how `error.type` is populated. +**[8]:** It is RECOMMENDED to capture the value as provided by the application +without attempting to do any case normalization. -**[7]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. -**[8]:** If using a port other than the default port for this DBMS and if `server.address` is set. +For batch operations, if the individual operations are known to have the same operation name +then that operation name SHOULD be used prepended by `BATCH `, +otherwise `db.operation.name` SHOULD be `BATCH` or some other database +system specific term if more applicable. -**[9]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. This attribute has stability level RELEASE CANDIDATE. -**[10]:** 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`. +**[9]:** 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`. -**[11]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. +**[10]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). -**[12]:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used. +**[11]:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used. -**[13]:** 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. +**[12]:** 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. -**[14]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders. +**[13]:** 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 `` SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. diff --git a/docs/database/sql.md b/docs/database/sql.md index 66773c90bd..57f6f504e7 100644 --- a/docs/database/sql.md +++ b/docs/database/sql.md @@ -45,38 +45,18 @@ Instrumentations applied to generic SQL drivers SHOULD adhere to SQL semantic co | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| -| [`db.collection.name`](/docs/attributes-registry/db.md) | string | The name of the SQL table that the operation is acting upon. [1] | `users`; `dbo.products` | `Conditionally Required` [2] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection, fully qualified within the server address and port. [3] | `customers`; `test.users` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [4] | `SELECT`; `INSERT`; `UPDATE`; `DELETE`; `CREATE`; `mystoredproc` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | Database response code recorded as string. [6] | `ORA-17027`; `1052`; `2201B` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [7] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [8] | `80`; `8080`; `443` | `Conditionally Required` [9] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [10] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [11] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [12] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [13] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [14] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection, fully qualified within the server address and port. [1] | `customers`; `test.users` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | Database response code recorded as string. [2] | `ORA-17027`; `1052`; `2201B` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [4] | `80`; `8080`; `443` | `Conditionally Required` [5] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [6] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [7] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [8] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [9] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [10] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.response.returned_rows`](/docs/attributes-registry/db.md) | int | Number of rows returned by the operation. | `10`; `30`; `1000` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [15] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [16] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [12] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - -A single database query may involve multiple collections. - -If the collection name is parsed from the query text, it SHOULD only be captured for queries that -contain a single collection and it SHOULD match the value provided in -the query text including any schema and database name prefix. - -For batch operations, if the individual operations are known to have the same collection name -then that collection name SHOULD be used. - -If the operation or query involves multiple collections, `db.collection.name` -SHOULD NOT be captured. - -This attribute has stability level RELEASE CANDIDATE. - -**[2]:** If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, in which case it SHOULD be the single collection name in the query. - -**[3]:** If a database system has multiple namespace components (e.g. schema name and database name), they SHOULD be concatenated +**[1]:** If a database system has multiple namespace components (e.g. schema name and database name), they SHOULD be concatenated (potentially using database system specific conventions) from most general to most specific namespace component, and more specific namespaces SHOULD NOT be captured without the more general namespaces, to ensure that "startswith" queries for the more general namespaces will be valid. @@ -94,12 +74,7 @@ Instrumentation SHOULD document if `db.namespace` reflects the database provided It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. -**[4]:** This SHOULD be the SQL command such as `SELECT`, `INSERT`, `UPDATE`, `CREATE`, `DROP`. -In the case of `EXEC`, this SHOULD be the stored procedure name that is being executed. - -**[5]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. - -**[6]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database +**[2]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database return code which is adopted by some database systems like PostgreSQL. See [PostgreSQL error codes](https://www.postgresql.org/docs/current/errcodes-appendix.html) for the details. @@ -135,42 +110,40 @@ For example, generic DB instrumentation that detected an error and has SQLSTATE `"42000"` and vendor-specific `1071` should set `db.response.status_code` to `"42000/1071"`." -**[7]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +**[3]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how `error.type` is populated. -**[8]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +**[4]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[9]:** If using a port other than the default port for this DBMS and if `server.address` is set. +**[5]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[10]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. +**[6]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. This attribute has stability level RELEASE CANDIDATE. -**[11]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. +**[7]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries. Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not available, instrumentations that support query parsing SHOULD generate a summary following [Generating query summary](../../docs/database/database-spans.md#generating-a-summary-of-the-quey-text) section. This attribute has stability level RELEASE CANDIDATE. -**[12]:** if readily available or if instrumentation supports query summarization. +**[8]:** if readily available or if instrumentation supports query summarization. -**[13]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[9]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). For batch operations, if the individual operations are known to have the same query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD be concatenated with separator `; ` or some other database system specific separator if more applicable. Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk. This attribute has stability level RELEASE CANDIDATE. -**[14]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). +**[10]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). -**[15]:** 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. +**[11]:** 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. -**[16]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders. +**[12]:** 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 `` SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): -* [`db.collection.name`](/docs/attributes-registry/db.md) -* [`db.operation.name`](/docs/attributes-registry/db.md) * [`db.query.summary`](/docs/attributes-registry/db.md) * [`db.query.text`](/docs/attributes-registry/db.md) * [`server.address`](/docs/attributes-registry/server.md) diff --git a/model/database/common.yaml b/model/database/common.yaml index 5d776a2f28..c4660d766b 100644 --- a/model/database/common.yaml +++ b/model/database/common.yaml @@ -4,12 +4,6 @@ groups: brief: 'Database Client attributes' stability: experimental attributes: - - ref: db.operation.name - requirement_level: - conditionally_required: > - If readily available and if there is a single operation name that describes the - database call. The operation name MAY be parsed from the query text, - in which case it SHOULD be the single operation name found in the query. - ref: server.address brief: > Name of the database host. @@ -43,12 +37,9 @@ groups: # requirement_level: # conditionally_required: if available - ref: db.collection.name - brief: > - Cosmos DB container name. - note: > - It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. + brief: Cosmos DB container name. requirement_level: - conditionally_required: If available + conditionally_required: If available. - ref: db.namespace sampling_relevant: true requirement_level: @@ -61,20 +52,34 @@ groups: requirement_level: conditionally_required: If available. - - id: attributes.db.client.with_query_and_collection + - id: attributes.db.client.with_query extends: attributes.db.client.minimal type: attribute_group stability: experimental brief: This group defines the attributes describing database operations that - have query and collection name. + may have queries. attributes: - ref: db.query.text - ref: db.query.summary requirement_level: recommended: if readily available or if instrumentation supports query summarization. + + - id: attributes.db.client.with_query_and_collection + extends: attributes.db.client.with_query + type: attribute_group + stability: experimental + brief: This group defines the attributes describing database operations that + have operation name, collection name and query. + attributes: + - ref: db.operation.name + requirement_level: # TODO (trask) simplify + conditionally_required: > + If readily available and if there is a single operation name that describes the + database call. The operation name MAY be parsed from the query text, + in which case it SHOULD be the single operation name found in the query. - ref: db.collection.name sampling_relevant: true - requirement_level: + requirement_level: # TODO (trask) simplify conditionally_required: > If readily available and if a database call is performed on a single collection. The collection name MAY be parsed from the query text, diff --git a/model/database/registry.yaml b/model/database/registry.yaml index c67c035cc2..35ab782549 100644 --- a/model/database/registry.yaml +++ b/model/database/registry.yaml @@ -12,18 +12,13 @@ groups: note: | It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - A single database query may involve multiple collections. - - If the collection name is parsed from the query text, it SHOULD only be captured for queries that - contain a single collection and it SHOULD match the value provided in - the query text including any schema and database name prefix. + The collection name SHOULD NOT be extracted from `db.query.text`, + unless the query format is known to only ever have a single collection name present + and the collection name is known to always be under the captured `db.namespace`. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. - If the operation or query involves multiple collections, `db.collection.name` - SHOULD NOT be captured. - This attribute has stability level RELEASE CANDIDATE. examples: ["public.users", "customers"] - id: db.namespace @@ -53,10 +48,8 @@ groups: It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - A single database query may involve multiple operations. If the operation - name is parsed from the query text, it SHOULD only be captured for queries that - contain a single operation or when the operation name describing the - whole query is available by other means. + The operation name SHOULD NOT be extracted from `db.query.text`, + unless the query format is known to only ever have a single operation name present. For batch operations, if the individual operations are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `, diff --git a/model/database/spans.yaml b/model/database/spans.yaml index 551b12bed6..0dbe0a4e46 100644 --- a/model/database/spans.yaml +++ b/model/database/spans.yaml @@ -16,12 +16,18 @@ groups: - ref: server.port sampling_relevant: true - - id: trace.db.common.query_and_collection - extends: attributes.db.client.with_query_and_collection + - id: trace.db.common.query + extends: attributes.db.client.with_query type: attribute_group stability: experimental brief: This group defines the attributes used to perform database client calls. attributes: + - ref: server.address + sampling_relevant: true + - ref: server.port + sampling_relevant: true + - ref: db.operation.batch.size + - ref: db.response.returned_rows - ref: db.query.text sampling_relevant: true requirement_level: @@ -37,6 +43,13 @@ groups: sampling_relevant: true - ref: db.query.parameter requirement_level: opt_in + + - id: trace.db.common.query_and_collection + extends: attributes.db.client.with_query_and_collection + type: attribute_group + stability: experimental + brief: This group defines the attributes used to perform database client calls. + attributes: - ref: db.collection.name sampling_relevant: true - ref: db.operation.name @@ -47,6 +60,21 @@ groups: - ref: server.port sampling_relevant: true - ref: db.response.returned_rows + - ref: db.query.text + sampling_relevant: true + requirement_level: + recommended: > + Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes + sensitive data, e.g. by redacting all literal values present in the query text. + See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). + + Parameterized query text SHOULD be collected by default + (the query parameter values themselves are opt-in, + see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). + - ref: db.query.summary + sampling_relevant: true + - ref: db.query.parameter + requirement_level: opt_in - id: trace.db.common.full type: attribute_group @@ -451,19 +479,10 @@ groups: - id: db.sql type: span stability: experimental - extends: trace.db.common.query_and_collection + extends: trace.db.common.query brief: > Attributes for SQL databases attributes: - - ref: db.operation.name - note: > - This SHOULD be the SQL command such as `SELECT`, `INSERT`, `UPDATE`, `CREATE`, `DROP`. - - In the case of `EXEC`, this SHOULD be the stored procedure name that is being executed. - examples: ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'CREATE', 'mystoredproc'] - - ref: db.collection.name - brief: The name of the SQL table that the operation is acting upon. - examples: ['users', 'dbo.products'] - ref: db.namespace brief: > The database associated with the connection, From e7cd106ff2be72dfcf3cc165eb5aa86019b89fed Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 15:07:52 -0800 Subject: [PATCH 2/7] less changes --- model/database/spans.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/model/database/spans.yaml b/model/database/spans.yaml index 0dbe0a4e46..807d0bd8f6 100644 --- a/model/database/spans.yaml +++ b/model/database/spans.yaml @@ -10,6 +10,11 @@ groups: # sampling_relevant: true - ref: db.operation.name sampling_relevant: true + requirement_level: # TODO (trask) simplify + conditionally_required: > + If readily available and if there is a single operation name that describes the + database call. The operation name MAY be parsed from the query text, + in which case it SHOULD be the single operation name found in the query. - ref: db.operation.batch.size - ref: server.address sampling_relevant: true From a0eb54cc5a3f20a22ecaf947bab807749887422a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 15:09:49 -0800 Subject: [PATCH 3/7] less changes --- docs/database/redis.md | 66 ++++++++++++++++++++------------------- model/database/spans.yaml | 2 +- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/docs/database/redis.md b/docs/database/redis.md index 04dfa86aae..cb2a30bdd8 100644 --- a/docs/database/redis.md +++ b/docs/database/redis.md @@ -22,16 +22,16 @@ The Semantic Conventions for [Redis](https://redis.com/) extend and override the | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | |---|---|---|---|---|---| | [`db.namespace`](/docs/attributes-registry/db.md) | string | The [database index] associated with the connection, represented as a string. [1] | `0`; `1`; `15` | `Conditionally Required` If and only if it can be captured reliably. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | The Redis [simple error](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-errors) prefix. [2] | `ERR`; `WRONGTYPE`; `CLUSTERDOWN` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [5] | `80`; `8080`; `443` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [7] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [8] | `findAndModify`; `HMSET`; `SELECT` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.query.text`](/docs/attributes-registry/db.md) | string | The full syntax of the Redis CLI command. [9] | `HMSET myhash field1 'Hello' field2 'World'` | `Recommended` [10] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`network.peer.address`](/docs/attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [11] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [2] | `findAndModify`; `HMSET`; `SELECT` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | The Redis [simple error](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-errors) prefix. [4] | `ERR`; `WRONGTYPE`; `CLUSTERDOWN` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [6] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [7] | `80`; `8080`; `443` | `Conditionally Required` [8] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [9] | `2`; `3`; `4` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.query.text`](/docs/attributes-registry/db.md) | string | The full syntax of the Redis CLI command. [10] | `HMSET myhash field1 'Hello' field2 'World'` | `Recommended` [11] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`network.peer.address`](/docs/attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [12] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`network.peer.port`](/docs/attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` if and only if `network.peer.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [12] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [13] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [13] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [14] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1]:** A connection's currently associated database index may change during its lifetime, e.g. from executing `SELECT `. @@ -41,24 +41,7 @@ then it is RECOMMENDED to fallback and use the database index provided when the Instrumentation SHOULD document if `db.namespace` reflects the database index provided when the connection was established. -**[2]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. -Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system. -This attribute has stability level RELEASE CANDIDATE. - -**[3]:** If the operation failed and status code is available. - -**[4]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. -When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. -Instrumentations SHOULD document how `error.type` is populated. - -**[5]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. - -**[6]:** If using a port other than the default port for this DBMS and if `server.address` is set. - -**[7]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. -This attribute has stability level RELEASE CANDIDATE. - -**[8]:** It is RECOMMENDED to capture the value as provided by the application +**[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The operation name SHOULD NOT be extracted from `db.query.text`, @@ -71,17 +54,36 @@ system specific term if more applicable. This attribute has stability level RELEASE CANDIDATE. -**[9]:** 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`. +**[3]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. + +**[4]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. +Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system. +This attribute has stability level RELEASE CANDIDATE. + +**[5]:** If the operation failed and status code is available. + +**[6]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. +Instrumentations SHOULD document how `error.type` is populated. + +**[7]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. + +**[8]:** If using a port other than the default port for this DBMS and if `server.address` is set. + +**[9]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`. +This attribute has stability level RELEASE CANDIDATE. + +**[10]:** 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`. -**[10]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. +**[11]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). -**[11]:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used. +**[12]:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used. -**[12]:** 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. +**[13]:** 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. -**[13]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders. +**[14]:** 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 `` SHOULD be the 0-based index. This attribute has stability level RELEASE CANDIDATE. diff --git a/model/database/spans.yaml b/model/database/spans.yaml index 807d0bd8f6..055332a8d2 100644 --- a/model/database/spans.yaml +++ b/model/database/spans.yaml @@ -332,7 +332,7 @@ groups: - id: db.redis type: span stability: experimental - extends: attributes.db.client.minimal + extends: trace.db.common.minimal brief: > Attributes for Redis attributes: From c4db43af1abff1526188f248cdcd56324dfc9b75 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 10 Nov 2024 15:12:35 -0800 Subject: [PATCH 4/7] less changes --- docs/database/cosmosdb.md | 36 ++++++++++++++++++++++++++---------- model/database/common.yaml | 6 ++++++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/docs/database/cosmosdb.md b/docs/database/cosmosdb.md index 6194a859b1..d42823c441 100644 --- a/docs/database/cosmosdb.md +++ b/docs/database/cosmosdb.md @@ -340,10 +340,11 @@ Explaining bucket configuration: | [`db.cosmosdb.consistency_level`](/docs/attributes-registry/db.md) | string | Account or request [consistency level](https://learn.microsoft.com/azure/cosmos-db/consistency-levels). | `Eventual`; `ConsistentPrefix`; `BoundedStaleness`; `Strong`; `Session` | `Conditionally Required` If available. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.cosmosdb.sub_status_code`](/docs/attributes-registry/db.md) | int | Cosmos DB sub status code. | `1000`; `1002` | `Conditionally Required` when response was received and contained sub-code. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`db.namespace`](/docs/attributes-registry/db.md) | string | The name of the database, fully qualified within the server address and port. | `customers`; `test.users` | `Conditionally Required` If available. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | Database response status code. [2] | `102`; `ORA-17002`; `08P01`; `404` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [4] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [5] | `80`; `8080`; `443` | `Conditionally Required` [6] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [7] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [2] | `findAndModify`; `HMSET`; `SELECT` | `Conditionally Required` [3] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | Database response status code. [4] | `102`; `ORA-17002`; `08P01`; `404` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [6] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [7] | `80`; `8080`; `443` | `Conditionally Required` [8] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [9] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. @@ -356,21 +357,36 @@ then that collection name SHOULD be used. This attribute has stability level RELEASE CANDIDATE. -**[2]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. +**[2]:** It is RECOMMENDED to capture the value as provided by the application +without attempting to do any case normalization. + +The operation name SHOULD NOT be extracted from `db.query.text`, +unless the query format is known to only ever have a single operation name present. + +For batch operations, if the individual operations are known to have the same operation name +then that operation name SHOULD be used prepended by `BATCH `, +otherwise `db.operation.name` SHOULD be `BATCH` or some other database +system specific term if more applicable. + +This attribute has stability level RELEASE CANDIDATE. + +**[3]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query. + +**[4]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes. Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system. This attribute has stability level RELEASE CANDIDATE. -**[3]:** If the operation failed and status code is available. +**[5]:** If the operation failed and status code is available. -**[4]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. +**[6]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how `error.type` is populated. -**[5]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +**[7]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[6]:** If using a port other than the default port for this DBMS and if `server.address` is set. +**[8]:** If using a port other than the default port for this DBMS and if `server.address` is set. -**[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. +**[9]:** 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. The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): diff --git a/model/database/common.yaml b/model/database/common.yaml index c4660d766b..b536f73173 100644 --- a/model/database/common.yaml +++ b/model/database/common.yaml @@ -36,6 +36,12 @@ groups: # - ref: db.system # requirement_level: # conditionally_required: if available + - ref: db.operation.name + requirement_level: # TODO (trask) simplify + conditionally_required: > + If readily available and if there is a single operation name that describes the + database call. The operation name MAY be parsed from the query text, + in which case it SHOULD be the single operation name found in the query. - ref: db.collection.name brief: Cosmos DB container name. requirement_level: From 36e3cf91103aeb7418104b3134fbe5622cd275bc Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 11 Nov 2024 09:44:33 -0800 Subject: [PATCH 5/7] Revert a bit --- docs/attributes-registry/db.md | 3 +-- docs/database/cassandra.md | 3 +-- docs/database/cosmosdb.md | 3 +-- docs/database/database-metrics.md | 6 ++---- docs/database/database-spans.md | 3 +-- docs/database/mongodb.md | 3 +-- model/database/registry.yaml | 3 +-- 7 files changed, 8 insertions(+), 16 deletions(-) diff --git a/docs/attributes-registry/db.md b/docs/attributes-registry/db.md index 087608fb9c..675a50a0a8 100644 --- a/docs/attributes-registry/db.md +++ b/docs/attributes-registry/db.md @@ -35,8 +35,7 @@ This group defines the attributes used to describe telemetry in the context of d **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, -unless the query format is known to only ever have a single collection name present -and the collection name is known to always be under the captured `db.namespace`. +unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. diff --git a/docs/database/cassandra.md b/docs/database/cassandra.md index 6ddc5eceac..f9b461cb52 100644 --- a/docs/database/cassandra.md +++ b/docs/database/cassandra.md @@ -45,8 +45,7 @@ The Semantic Conventions for [Cassandra](https://cassandra.apache.org/) extend a **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, -unless the query format is known to only ever have a single collection name present -and the collection name is known to always be under the captured `db.namespace`. +unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. diff --git a/docs/database/cosmosdb.md b/docs/database/cosmosdb.md index 38ad3fb12d..6f50665b21 100644 --- a/docs/database/cosmosdb.md +++ b/docs/database/cosmosdb.md @@ -349,8 +349,7 @@ Explaining bucket configuration: **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, -unless the query format is known to only ever have a single collection name present -and the collection name is known to always be under the captured `db.namespace`. +unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. diff --git a/docs/database/database-metrics.md b/docs/database/database-metrics.md index f3d6825809..20907e852e 100644 --- a/docs/database/database-metrics.md +++ b/docs/database/database-metrics.md @@ -102,8 +102,7 @@ This attribute has stability level RELEASE CANDIDATE. **[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, -unless the query format is known to only ever have a single collection name present -and the collection name is known to always be under the captured `db.namespace`. +unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. @@ -285,8 +284,7 @@ This attribute has stability level RELEASE CANDIDATE. **[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, -unless the query format is known to only ever have a single collection name present -and the collection name is known to always be under the captured `db.namespace`. +unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. diff --git a/docs/database/database-spans.md b/docs/database/database-spans.md index 3116fb3102..fa86dcfc18 100644 --- a/docs/database/database-spans.md +++ b/docs/database/database-spans.md @@ -120,8 +120,7 @@ This attribute has stability level RELEASE CANDIDATE. **[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, -unless the query format is known to only ever have a single collection name present -and the collection name is known to always be under the captured `db.namespace`. +unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. diff --git a/docs/database/mongodb.md b/docs/database/mongodb.md index 312364aa10..40dd7bcec9 100644 --- a/docs/database/mongodb.md +++ b/docs/database/mongodb.md @@ -33,8 +33,7 @@ The Semantic Conventions for [MongoDB](https://www.mongodb.com/) extend and over **[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, -unless the query format is known to only ever have a single collection name present -and the collection name is known to always be under the captured `db.namespace`. +unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. diff --git a/model/database/registry.yaml b/model/database/registry.yaml index 35ab782549..7448c0cda2 100644 --- a/model/database/registry.yaml +++ b/model/database/registry.yaml @@ -13,8 +13,7 @@ groups: It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. The collection name SHOULD NOT be extracted from `db.query.text`, - unless the query format is known to only ever have a single collection name present - and the collection name is known to always be under the captured `db.namespace`. + unless the query format is known to only ever have a single collection name present. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used. From 18980b348447942900d70518e7230cbb75f7b7f3 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 12 Nov 2024 19:40:23 -0700 Subject: [PATCH 6/7] fix sql example --- docs/database/sql.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/database/sql.md b/docs/database/sql.md index 2160126354..40baf19d5b 100644 --- a/docs/database/sql.md +++ b/docs/database/sql.md @@ -167,12 +167,10 @@ This is an example of attributes for a MySQL database span: | Key | Value | |:-----------------------| :----------------------------------------------------------- | | Span name | `"SELECT orders"` | -| `db.collection.name` | `"orders"` | | `db.namespace` | `"ShopDb"` | | `db.system` | `"mysql"` | | `server.address` | `"shopdb.example.com"` | | `server.port` | `3306` | | `db.query.text` | `"SELECT * FROM orders WHERE order_id = 'o4711'"` | -| `db.operation.name` | `"SELECT"` | [DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status From 61e9f355bea950c1ef9254f2be0c505dd61ac9ca Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 19 Nov 2024 12:19:37 -0800 Subject: [PATCH 7/7] update in other places --- docs/database/cassandra.md | 8 ++++++-- docs/database/cosmosdb.md | 8 ++++++-- docs/database/database-spans.md | 8 ++++++-- model/database/spans.yaml | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/database/cassandra.md b/docs/database/cassandra.md index 7ceca51951..1f09ac0651 100644 --- a/docs/database/cassandra.md +++ b/docs/database/cassandra.md @@ -40,7 +40,7 @@ The Semantic Conventions for [Cassandra](https://cassandra.apache.org/) extend a | [`network.peer.address`](/docs/attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [16] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`network.peer.port`](/docs/attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` if and only if `network.peer.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [17] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. | `someval`; `55` | `Opt-In` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)
Replaced by `db.operation.parameter`. | +| [`db.operation.parameter.`](/docs/attributes-registry/db.md) | string | A database operation parameter, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [18] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1] `db.collection.name`:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. @@ -103,12 +103,16 @@ Even though parameterized query text can potentially have sensitive data, by usi This attribute has stability level RELEASE CANDIDATE. **[15] `db.query.text`:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). -Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). +Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.operation.parameter.`](../../docs/attributes-registry/db.md)). **[16] `network.peer.address`:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used. **[17] `server.address`:** 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. +**[18] `db.operation.parameter`:** If a parameter has no name and instead is referenced only by index, then `` SHOULD be the 0-based index. +If `db.query.text` is also captured, then `db.operation.parameter.` SHOULD match up with the parameterized placeholders present in `db.query.text`. +This attribute has stability level RELEASE CANDIDATE. + The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): diff --git a/docs/database/cosmosdb.md b/docs/database/cosmosdb.md index ae7ed018e0..380f7af770 100644 --- a/docs/database/cosmosdb.md +++ b/docs/database/cosmosdb.md @@ -58,7 +58,7 @@ Cosmos DB instrumentation includes call-level (public API) surface spans and net | [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [12] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [13] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [14] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`user_agent.original`](/docs/attributes-registry/user-agent.md) | string | Full user-agent string is generated by Cosmos DB SDK [15] | `cosmos-netstandard-sdk/3.23.0\|3.23.1\|1\|X64\|Linux 5.4.0-1098-azure 104 18\|.NET Core 3.1.32\|S\|` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. | `someval`; `55` | `Opt-In` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)
Replaced by `db.operation.parameter`. | +| [`db.operation.parameter.`](/docs/attributes-registry/db.md) | string | A database operation parameter, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [16] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1] `db.collection.name`:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. @@ -217,7 +217,7 @@ Even though parameterized query text can potentially have sensitive data, by usi This attribute has stability level RELEASE CANDIDATE. **[13] `db.query.text`:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). -Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). +Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.operation.parameter.`](../../docs/attributes-registry/db.md)). **[14] `server.address`:** 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. @@ -225,6 +225,10 @@ Parameterized query text SHOULD be collected by default (the query parameter val Format Reg-{D (Disabled discovery)}-S(application region)|L(List of preferred regions)|N(None, user did not configure it). Default value is "NS". +**[16] `db.operation.parameter`:** If a parameter has no name and instead is referenced only by index, then `` SHOULD be the 0-based index. +If `db.query.text` is also captured, then `db.operation.parameter.` SHOULD match up with the parameterized placeholders present in `db.query.text`. +This attribute has stability level RELEASE CANDIDATE. + The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): diff --git a/docs/database/database-spans.md b/docs/database/database-spans.md index 11c4d483b5..eb2797eac4 100644 --- a/docs/database/database-spans.md +++ b/docs/database/database-spans.md @@ -112,7 +112,7 @@ These attributes will usually be the same for all operations performed over the | [`network.peer.address`](/docs/attributes-registry/network.md) | string | Peer address of the database node where the operation was performed. [17] | `10.1.2.80`; `/tmp/my.sock` | `Recommended` If applicable for this database system. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`network.peer.port`](/docs/attributes-registry/network.md) | int | Peer port number of the network connection. | `65123` | `Recommended` if and only if `network.peer.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [18] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`db.query.parameter.`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `` being the parameter name, and the attribute value being a string representation of the parameter value. | `someval`; `55` | `Opt-In` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)
Replaced by `db.operation.parameter`. | +| [`db.operation.parameter.`](/docs/attributes-registry/db.md) | string | A database operation parameter, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [19] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | **[1] `db.system`:** The actual DBMS may differ from the one identified by the client. For example, when using PostgreSQL client libraries to connect to a CockroachDB, the `db.system` is set to `postgresql` based on the instrumentation's best knowledge. This attribute has stability level RELEASE CANDIDATE. @@ -178,13 +178,17 @@ Even though parameterized query text can potentially have sensitive data, by usi This attribute has stability level RELEASE CANDIDATE. **[16] `db.query.text`:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). -Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). +Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.operation.parameter.`](../../docs/attributes-registry/db.md)). **[17] `network.peer.address`:** Semantic conventions for individual database systems SHOULD document whether `network.peer.*` attributes are applicable. Network peer address and port are useful when the application interacts with individual database nodes directly. If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used. **[18] `server.address`:** 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. +**[19] `db.operation.parameter`:** If a parameter has no name and instead is referenced only by index, then `` SHOULD be the 0-based index. +If `db.query.text` is also captured, then `db.operation.parameter.` SHOULD match up with the parameterized placeholders present in `db.query.text`. +This attribute has stability level RELEASE CANDIDATE. + The following attributes can be important for making sampling decisions and SHOULD be provided **at span creation time** (if provided at all): diff --git a/model/database/spans.yaml b/model/database/spans.yaml index a17fc2b67a..365e83600a 100644 --- a/model/database/spans.yaml +++ b/model/database/spans.yaml @@ -75,10 +75,10 @@ groups: Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, - see [`db.query.parameter.`](../../docs/attributes-registry/db.md)). + see [`db.operation.parameter.`](../../docs/attributes-registry/db.md)). - ref: db.query.summary sampling_relevant: true - - ref: db.query.parameter + - ref: db.operation.parameter requirement_level: opt_in - id: trace.db.common.full