You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DB: fix how operation and collection names are recorded for complex queries (opt-in db.query.text on metrics, new db.query.summary recommended attribute) (#1482)
Copy file name to clipboardExpand all lines: docs/database/cassandra.md
+46-16Lines changed: 46 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,30 +34,52 @@ The Semantic Conventions for [Cassandra](https://cassandra.apache.org/) extend a
34
34
|[`db.cassandra.page_size`](/docs/attributes-registry/db.md)| int | The fetch size used for paging, i.e. how many rows will be returned at once. |`5000`|`Recommended`||
35
35
|[`db.cassandra.speculative_execution_count`](/docs/attributes-registry/db.md)| int | The number of times a query was speculatively executed. Not set or `0` if the query was not executed speculatively. |`0`; `2`|`Recommended`||
36
36
|[`db.operation.batch.size`](/docs/attributes-registry/db.md)| int | The number of queries included in a batch operation. [11]|`2`; `3`; `4`|`Recommended`||
37
-
|[`db.query.text`](/docs/attributes-registry/db.md)| string | The database query being executed. [12]|`SELECT * FROM wuser_table where username = ?`; `SET mykey "WuValue"`|`Recommended`[13]||
38
-
|[`network.peer.address`](/docs/attributes-registry/network.md)| string | Peer address of the database node where the operation was performed. [14]|`10.1.2.80`; `/tmp/my.sock`|`Recommended`||
37
+
|[`db.query.summary`](/docs/attributes-registry/db.md)| string | Low cardinality representation of a database query text. [12]|`SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id`|`Recommended`[13]||
38
+
|[`db.query.text`](/docs/attributes-registry/db.md)| string | The database query being executed. [14]|`SELECT * FROM wuser_table where username = ?`; `SET mykey ?`|`Recommended`[15]||
39
+
|[`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`||
39
40
|[`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. ||
40
-
|[`server.address`](/docs/attributes-registry/server.md)| string | Name of the database host. [15]|`example.com`; `10.1.2.80`; `/tmp/my.sock`|`Recommended`||
41
-
|[`db.query.parameter.<key>`](/docs/attributes-registry/db.md)| string | A query parameter used in `db.query.text`, with `<key>` being the parameter name, and the attribute value being a string representation of the parameter value. [16]|`someval`; `55`|`Opt-In`||
41
+
|[`server.address`](/docs/attributes-registry/server.md)| string | Name of the database host. [17]|`example.com`; `10.1.2.80`; `/tmp/my.sock`|`Recommended`||
42
+
|[`db.query.parameter.<key>`](/docs/attributes-registry/db.md)| string | A query parameter used in `db.query.text`, with `<key>` being the parameter name, and the attribute value being a string representation of the parameter value. [18]|`someval`; `55`|`Opt-In`||
42
43
43
44
**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
44
-
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.
45
-
For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used, otherwise `db.collection.name` SHOULD NOT be captured.
45
+
46
+
A single database query may involve multiple collections.
47
+
48
+
If the collection name is parsed from the query text, it SHOULD only be captured for queries that
49
+
contain a single collection and it SHOULD match the value provided in
50
+
the query text including any schema and database name prefix.
51
+
52
+
For batch operations, if the individual operations are known to have the same collection name
53
+
then that collection name SHOULD be used.
54
+
55
+
If the operation or query involves multiple collections, `db.collection.name`
56
+
SHOULD NOT be captured.
57
+
46
58
This attribute has stability level RELEASE CANDIDATE.
47
59
48
-
**[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.
60
+
**[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.
49
61
50
62
**[3]:** 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.
51
63
Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system.
52
64
It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
53
65
This attribute has stability level RELEASE CANDIDATE.
54
66
55
-
**[4]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
56
-
If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query.
57
-
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.
67
+
**[4]:** It is RECOMMENDED to capture the value as provided by the application
68
+
without attempting to do any case normalization.
69
+
70
+
A single database query may involve multiple operations. If the operation
71
+
name is parsed from the query text, it SHOULD only be captured for queries that
72
+
contain a single operation or when the operation name describing the
73
+
whole query is available by other means.
74
+
75
+
For batch operations, if the individual operations are known to have the same operation name
76
+
then that operation name SHOULD be used prepended by `BATCH `,
77
+
otherwise `db.operation.name` SHOULD be `BATCH` or some other database
78
+
system specific term if more applicable.
79
+
58
80
This attribute has stability level RELEASE CANDIDATE.
59
81
60
-
**[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.
82
+
**[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.
61
83
62
84
**[6]:** 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.
63
85
Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system.
@@ -76,18 +98,25 @@ Instrumentations SHOULD document how `error.type` is populated.
76
98
**[11]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`.
77
99
This attribute has stability level RELEASE CANDIDATE.
78
100
79
-
**[12]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext).
101
+
**[12]:**`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.
102
+
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.
103
+
This attribute has stability level RELEASE CANDIDATE.
104
+
105
+
**[13]:** if readily available or if instrumentation supports query summarization.
106
+
107
+
**[14]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext).
80
108
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.
81
109
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.
82
110
This attribute has stability level RELEASE CANDIDATE.
83
111
84
-
**[13]:** SHOULD be collected by default only if there is sanitization that excludes sensitive information. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext).
112
+
**[15]:** 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).
113
+
Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.<key>`](../../docs/attributes-registry/db.md)).
85
114
86
-
**[14]:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used.
115
+
**[16]:** If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used.
87
116
88
-
**[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.
117
+
**[17]:** 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.
89
118
90
-
**[16]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders.
119
+
**[18]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders.
91
120
If a parameter has no name and instead is referenced only by index, then `<key>` SHOULD be the 0-based index.
92
121
This attribute has stability level RELEASE CANDIDATE.
93
122
@@ -97,6 +126,7 @@ and SHOULD be provided **at span creation time** (if provided at all):
0 commit comments