diff --git a/.chloggen/1070.yaml b/.chloggen/1070.yaml new file mode 100644 index 000000000..bdab30dad --- /dev/null +++ b/.chloggen/1070.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: enhancement + +# 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: Mention how to capture collection and operation names from query text in the registry + +# 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: [ 1070 ] + +# (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 9c4834bbf..b04d6bed2 100644 --- a/docs/attributes-registry/db.md +++ b/docs/attributes-registry/db.md @@ -28,14 +28,15 @@ This group defines the attributes used to describe telemetry in the context of d | `db.query.text` | string | The database query being executed. | `SELECT * FROM wuser_table where username = ?`; `SET mykey "WuValue"` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | `db.system` | string | The database management system (DBMS) product as identified by the client instrumentation. [5] | `other_sql`; `adabas`; `cache` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. **[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. Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system. It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. **[3]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. **[4]:** 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. diff --git a/docs/database/cassandra.md b/docs/database/cassandra.md index f16a17317..3074faf11 100644 --- a/docs/database/cassandra.md +++ b/docs/database/cassandra.md @@ -40,16 +40,17 @@ described on this page. | [`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 | The query parameters used in `db.query.text`, with `` being the parameter name, and the attribute value being the parameter value. [12] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. -**[2]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.collection.name`, then it SHOULD be the first collection name found in the query. +**[2]:** If readily available. The collection name MAY be parsed from the query text, in which case it SHOULD be the first collection name found in the query. **[3]:** For commands that switch the keyspace, this SHOULD be set to the target keyspace (even if the command fails). **[4]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. -**[5]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[5]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[6]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/cosmosdb.md b/docs/database/cosmosdb.md index 76ad96edb..d48769a0b 100644 --- a/docs/database/cosmosdb.md +++ b/docs/database/cosmosdb.md @@ -43,14 +43,15 @@ Cosmos DB instrumentation includes call-level (public API) surface spans and net | [`user_agent.original`](/docs/attributes-registry/user-agent.md) | string | Full user-agent string is generated by Cosmos DB SDK [10] | `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 | The query parameters used in `db.query.text`, with `` being the parameter name, and the attribute value being the parameter value. [11] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. **[2]:** **[3]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. -**[4]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[4]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[5]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/couchdb.md b/docs/database/couchdb.md index 40039a35b..1b897b80a 100644 --- a/docs/database/couchdb.md +++ b/docs/database/couchdb.md @@ -33,7 +33,7 @@ described on this page. **[2]:** In **CouchDB**, `db.operation.name` should be set to the HTTP method + the target REST route according to the API reference documentation. For example, when retrieving a document, `db.operation.name` would be set to (literally, i.e., without replacing the placeholders with concrete values): [`GET /{db}/{docid}`](https://docs.couchdb.org/en/stable/api/document/common.html#get--db-docid). -**[3]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[3]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[4]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/database-metrics.md b/docs/database/database-metrics.md index 77b3cf51d..667c11e5a 100644 --- a/docs/database/database-metrics.md +++ b/docs/database/database-metrics.md @@ -108,18 +108,19 @@ of `[ 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10 ]`. **[1]:** 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. -**[2]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -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. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. -**[3]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.collection.name`, then it SHOULD be the first collection name found in the query. +**[3]:** If readily available. The collection name MAY be parsed from the query text, in which case it SHOULD be the first collection name in the query. **[4]:** 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. Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system. It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. **[5]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. -**[6]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[6]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[7]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/database-spans.md b/docs/database/database-spans.md index 53f2156bc..d5f7a3400 100644 --- a/docs/database/database-spans.md +++ b/docs/database/database-spans.md @@ -103,18 +103,19 @@ These attributes will usually be the same for all operations performed over the **[1]:** 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. -**[2]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -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. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. -**[3]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.collection.name`, then it SHOULD be the first collection name found in the query. +**[3]:** If readily available. The collection name MAY be parsed from the query text, in which case it SHOULD be the first collection name found in the query. **[4]:** 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. Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system. It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. **[5]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. -**[6]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[6]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[7]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/hbase.md b/docs/database/hbase.md index 91a42579f..3e83f1a6e 100644 --- a/docs/database/hbase.md +++ b/docs/database/hbase.md @@ -35,8 +35,9 @@ described on this page. **[2]:** When performing table-related operations, the instrumentations SHOULD extract the namespace from the table name according to the [HBase table naming conventions](https://hbase.apache.org/book.html#namespace_creation). If namespace is not provided, instrumentation SHOULD set `db.namespace` value to `default`. **[3]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. -**[4]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[4]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[5]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/mongodb.md b/docs/database/mongodb.md index 592ed984e..7424e675c 100644 --- a/docs/database/mongodb.md +++ b/docs/database/mongodb.md @@ -30,14 +30,14 @@ described on this page. | [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [6] | `80`; `8080`; `443` | `Conditionally Required` [7] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -**[1]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. **[2]:** **[3]:** See [MongoDB database commands](https://www.mongodb.com/docs/manual/reference/command/). -**[4]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[4]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[5]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/mssql.md b/docs/database/mssql.md index ec7e8e56a..faae65a4c 100644 --- a/docs/database/mssql.md +++ b/docs/database/mssql.md @@ -32,10 +32,10 @@ described on this page. | [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [10] | `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 | The query parameters used in `db.query.text`, with `` being the parameter name, and the attribute value being the parameter value. [11] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. -**[2]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.collection.name`, then it SHOULD be the first collection name found in the query. +**[2]:** If readily available. The collection name MAY be parsed from the query text, in which case it SHOULD be the first collection name found in the query. **[3]:** When connecting to a default instance, `db.namespace` SHOULD be set to the name of the database. When connecting 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. For commands that switch the database, this SHOULD be set to the target database (even if the command fails). @@ -43,7 +43,7 @@ For commands that switch the database, this SHOULD be set to the target database **[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. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[5]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[6]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/redis.md b/docs/database/redis.md index c5f5772b4..696d248c6 100644 --- a/docs/database/redis.md +++ b/docs/database/redis.md @@ -38,8 +38,9 @@ Instrumentations SHOULD NOT set this attribute if capturing it would require add For commands that switch the database, this SHOULD be set to the target database (even if the command fails). **[2]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. -**[3]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[3]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[4]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/docs/database/sql.md b/docs/database/sql.md index 7b5473a5b..d9b9d42e0 100644 --- a/docs/database/sql.md +++ b/docs/database/sql.md @@ -30,10 +30,10 @@ described on this page. | [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [10] | `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 | The query parameters used in `db.query.text`, with `` being the parameter name, and the attribute value being the parameter value. [11] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | -**[1]:** If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. -It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. -**[2]:** If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.collection.name`, then it SHOULD be the first collection name found in the query. +**[2]:** If readily available. The collection name MAY be parsed from the query text, in which case it SHOULD be the first collection name found in the query. **[3]:** If a database system has multiple namespace components, they SHOULD be concatenated (potentially using database system specific conventions) from most general to most @@ -58,7 +58,7 @@ If instrumentation cannot reliably determine the current database name, it SHOUL **[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. Otherwise, if the instrumentation library parses `db.query.text` to capture `db.operation.name`, then it SHOULD be the first operation name found in the query. +**[5]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. **[6]:** The `error.type` SHOULD match the error code returned by the database or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. diff --git a/model/db-common.yaml b/model/db-common.yaml index cccfe64cb..3dfc31af1 100644 --- a/model/db-common.yaml +++ b/model/db-common.yaml @@ -6,8 +6,8 @@ groups: - ref: db.operation.name requirement_level: conditionally_required: > - If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture - `db.operation.name`, then it SHOULD be the first operation name found in the query. + If readily available. The operation name MAY be parsed from the query text, + in which case it SHOULD be the first operation name found in the query. - ref: server.address brief: > Name of the database host. diff --git a/model/metrics/database-metrics.yaml b/model/metrics/database-metrics.yaml index 0b0823406..969c47a0d 100644 --- a/model/metrics/database-metrics.yaml +++ b/model/metrics/database-metrics.yaml @@ -11,8 +11,8 @@ groups: - ref: db.collection.name requirement_level: conditionally_required: > - If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture - `db.collection.name`, then it SHOULD be the first collection name found in the query. + If readily available. The collection name MAY be parsed from the query text, + in which case it SHOULD be the first collection name in the query. - ref: db.system # TODO: Not adding to the minimal because of https://github.com/open-telemetry/build-tools/issues/192 requirement_level: required diff --git a/model/registry/db.yaml b/model/registry/db.yaml index f23c9ed5e..18d12f736 100644 --- a/model/registry/db.yaml +++ b/model/registry/db.yaml @@ -10,10 +10,10 @@ groups: stability: experimental brief: The name of a collection (table, container) within the database. note: > - If the collection name is parsed from the query, it SHOULD match the value provided - in the query and may be qualified with the schema and database name. + It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. - It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. + If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query + and it SHOULD match the value provided in the query text including any schema and database name prefix. examples: ['public.users', 'customers'] - id: namespace type: string @@ -38,6 +38,8 @@ groups: The name of the operation or command being executed. note: > It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. + + If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. examples: ['findAndModify', 'HMSET', 'SELECT'] - id: query.text type: string diff --git a/model/trace/database.yaml b/model/trace/database.yaml index 102ce2968..ece87e3db 100644 --- a/model/trace/database.yaml +++ b/model/trace/database.yaml @@ -34,9 +34,8 @@ groups: - ref: db.collection.name requirement_level: conditionally_required: > - If readily available. Otherwise, if the instrumentation library parses `db.query.text` to capture - `db.collection.name`, then it SHOULD be the first collection name found in the query. - + If readily available. The collection name MAY be parsed from the query text, + in which case it SHOULD be the first collection name found in the query. - id: trace.db.common.full type: attribute_group