Skip to content

Commit 4c43c8f

Browse files
traskCopilot
andauthored
Clarify DB batch operation and collection notes (open-telemetry#3876)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9282dd69-337c-44f5-8854-ab7f30dc2ef0
1 parent f651517 commit 4c43c8f

16 files changed

Lines changed: 161 additions & 118 deletions

docs/db/cassandra.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Spans representing calls to a Cassandra database adhere to the general [Semantic
6464
**[2] `db.collection.name`:** It is RECOMMENDED to capture the value as provided by the application
6565
without attempting to do any case normalization.
6666

67-
For batch operations, if the individual operations are known to have the same collection name
67+
For batch operations, if the individual operations would all have the same
68+
`db.collection.name` when executed as non-batch operations,
6869
then that collection name SHOULD be used.
6970

7071
**[3] `db.namespace`:** If a database system has multiple namespace components, they SHOULD be concatenated from the most general to the most specific namespace component, using `|` as a separator between the components. Any missing components (and their associated separators) SHOULD be omitted.
@@ -83,9 +84,10 @@ in non-batch operations.
8384
If spaces can occur in the operation name, multiple consecutive spaces
8485
SHOULD be normalized to a single space.
8586

86-
For batch operations, if the individual operations are known to have the same operation name
87-
then that operation name SHOULD be used prepended by `BATCH `,
88-
otherwise `db.operation.name` SHOULD be `BATCH` or some other database
87+
For batch operations, if the individual operations would all have the same
88+
`db.operation.name` when executed as non-batch operations,
89+
then that operation name SHOULD be used prepended by `BATCH `.
90+
Otherwise, `db.operation.name` SHOULD be `BATCH` or some other database
8991
system specific term if more applicable.
9092

9193
**[6] `db.response.status_code`:** If the operation failed and status code is available.
@@ -135,16 +137,17 @@ that support query parsing SHOULD generate a summary following
135137
[Generating query summary](/docs/db/database-spans.md#generating-a-summary-of-the-query)
136138
section.
137139

138-
For batch operations, if the individual operations are known to have the same query summary
139-
then that query summary SHOULD be used prepended by `BATCH `,
140-
otherwise `db.query.summary` SHOULD be `BATCH` or some other database
140+
For batch operations, if the individual operations would all have the same
141+
`db.query.summary` when executed as non-batch operations,
142+
then that query summary SHOULD be used prepended by `BATCH `.
143+
Otherwise, `db.query.summary` SHOULD be `BATCH` or some other database
141144
system specific term if more applicable.
142145

143146
**[14] `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/db/database-spans.md#sanitization-of-dbquerytext).
144147
Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.<key>`](/docs/registry/attributes/db.md)).
145148

146149
**[15] `db.query.text`:** For sanitization see [Sanitization of `db.query.text`](/docs/db/database-spans.md#sanitization-of-dbquerytext).
147-
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.
150+
For batch operations, if the individual operations would all have the same `db.query.text` when executed as non-batch operations, 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.
148151
Parameterized query text SHOULD NOT be sanitized. 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.
149152

150153
**[16] `db.response.returned_rows`:** The number of rows returned by the database operation as observed

docs/db/cosmosdb.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,17 @@ A request to execute a batch operation with no operations SHOULD also be treated
233233
as a batch operation, and `db.operation.batch.size` SHOULD be set to `0`.
234234

235235
**[10] `db.query.text`:** For sanitization see [Sanitization of `db.query.text`](/docs/db/database-spans.md#sanitization-of-dbquerytext).
236-
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.
236+
For batch operations, if the individual operations would all have the same `db.query.text` when executed as non-batch operations, 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.
237237
Parameterized query text SHOULD NOT be sanitized. 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.
238238

239239
**[11] `db.stored_procedure.name`:** If operation applies to a specific stored procedure.
240240

241241
**[12] `db.stored_procedure.name`:** It is RECOMMENDED to capture the value as provided by the application
242242
without attempting to do any case normalization.
243243

244-
For batch operations, if the individual operations are known to have the same
245-
stored procedure name then that stored procedure name SHOULD be used.
244+
For batch operations, if the individual operations would all have the same
245+
`db.stored_procedure.name` when executed as non-batch operations,
246+
then that stored procedure name SHOULD be used.
246247

247248
**[13] `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.
248249

@@ -403,9 +404,10 @@ in non-batch operations.
403404
If spaces can occur in the operation name, multiple consecutive spaces
404405
SHOULD be normalized to a single space.
405406

406-
For batch operations, if the individual operations are known to have the same operation name
407-
then that operation name SHOULD be used prepended by `BATCH `,
408-
otherwise `db.operation.name` SHOULD be `BATCH` or some other database
407+
For batch operations, if the individual operations would all have the same
408+
`db.operation.name` when executed as non-batch operations,
409+
then that operation name SHOULD be used prepended by `BATCH `.
410+
Otherwise, `db.operation.name` SHOULD be `BATCH` or some other database
409411
system specific term if more applicable.
410412

411413
**[2] `db.collection.name`:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.

docs/db/database-metrics.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ The collection name SHOULD NOT be extracted from `db.query.text`,
104104
when the database system supports query text with multiple collections
105105
in non-batch operations.
106106

107-
For batch operations, if the individual operations are known to have the same
108-
collection name then that collection name SHOULD be used.
107+
For batch operations, if the individual operations would all have the same
108+
`db.collection.name` when executed as non-batch operations,
109+
then that collection name SHOULD be used.
109110

110111
**[4] `db.namespace`:** If a database system has multiple namespace components, they SHOULD be concatenated from the most general to the most specific namespace component, using `|` as a separator between the components. Any missing components (and their associated separators) SHOULD be omitted.
111112
Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system.
@@ -123,9 +124,10 @@ in non-batch operations.
123124
If spaces can occur in the operation name, multiple consecutive spaces
124125
SHOULD be normalized to a single space.
125126

126-
For batch operations, if the individual operations are known to have the same operation name
127-
then that operation name SHOULD be used prepended by `BATCH `,
128-
otherwise `db.operation.name` SHOULD be `BATCH` or some other database
127+
For batch operations, if the individual operations would all have the same
128+
`db.operation.name` when executed as non-batch operations,
129+
then that operation name SHOULD be used prepended by `BATCH `.
130+
Otherwise, `db.operation.name` SHOULD be `BATCH` or some other database
129131
system specific term if more applicable.
130132

131133
**[7] `db.response.status_code`:** If the operation failed and status code is available.
@@ -153,26 +155,28 @@ that support query parsing SHOULD generate a summary following
153155
[Generating query summary](/docs/db/database-spans.md#generating-a-summary-of-the-query)
154156
section.
155157

156-
For batch operations, if the individual operations are known to have the same query summary
157-
then that query summary SHOULD be used prepended by `BATCH `,
158-
otherwise `db.query.summary` SHOULD be `BATCH` or some other database
158+
For batch operations, if the individual operations would all have the same
159+
`db.query.summary` when executed as non-batch operations,
160+
then that query summary SHOULD be used prepended by `BATCH `.
161+
Otherwise, `db.query.summary` SHOULD be `BATCH` or some other database
159162
system specific term if more applicable.
160163

161164
**[14] `db.stored_procedure.name`:** If operation applies to a specific stored procedure.
162165

163166
**[15] `db.stored_procedure.name`:** It is RECOMMENDED to capture the value as provided by the application
164167
without attempting to do any case normalization.
165168

166-
For batch operations, if the individual operations are known to have the same
167-
stored procedure name then that stored procedure name SHOULD be used.
169+
For batch operations, if the individual operations would all have the same
170+
`db.stored_procedure.name` when executed as non-batch operations,
171+
then that stored procedure name SHOULD be used.
168172

169173
**[16] `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.
170174
If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used.
171175

172176
**[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.
173177

174178
**[18] `db.query.text`:** For sanitization see [Sanitization of `db.query.text`](/docs/db/database-spans.md#sanitization-of-dbquerytext).
175-
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.
179+
For batch operations, if the individual operations would all have the same `db.query.text` when executed as non-batch operations, 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.
176180
Parameterized query text SHOULD NOT be sanitized. 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.
177181

178182
---
@@ -293,8 +297,9 @@ The collection name SHOULD NOT be extracted from `db.query.text`,
293297
when the database system supports query text with multiple collections
294298
in non-batch operations.
295299

296-
For batch operations, if the individual operations are known to have the same
297-
collection name then that collection name SHOULD be used.
300+
For batch operations, if the individual operations would all have the same
301+
`db.collection.name` when executed as non-batch operations,
302+
then that collection name SHOULD be used.
298303

299304
**[4] `db.namespace`:** If a database system has multiple namespace components, they SHOULD be concatenated from the most general to the most specific namespace component, using `|` as a separator between the components. Any missing components (and their associated separators) SHOULD be omitted.
300305
Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system.
@@ -312,9 +317,10 @@ in non-batch operations.
312317
If spaces can occur in the operation name, multiple consecutive spaces
313318
SHOULD be normalized to a single space.
314319

315-
For batch operations, if the individual operations are known to have the same operation name
316-
then that operation name SHOULD be used prepended by `BATCH `,
317-
otherwise `db.operation.name` SHOULD be `BATCH` or some other database
320+
For batch operations, if the individual operations would all have the same
321+
`db.operation.name` when executed as non-batch operations,
322+
then that operation name SHOULD be used prepended by `BATCH `.
323+
Otherwise, `db.operation.name` SHOULD be `BATCH` or some other database
318324
system specific term if more applicable.
319325

320326
**[7] `db.response.status_code`:** If the operation failed and status code is available.
@@ -342,9 +348,10 @@ that support query parsing SHOULD generate a summary following
342348
[Generating query summary](/docs/db/database-spans.md#generating-a-summary-of-the-query)
343349
section.
344350

345-
For batch operations, if the individual operations are known to have the same query summary
346-
then that query summary SHOULD be used prepended by `BATCH `,
347-
otherwise `db.query.summary` SHOULD be `BATCH` or some other database
351+
For batch operations, if the individual operations would all have the same
352+
`db.query.summary` when executed as non-batch operations,
353+
then that query summary SHOULD be used prepended by `BATCH `.
354+
Otherwise, `db.query.summary` SHOULD be `BATCH` or some other database
348355
system specific term if more applicable.
349356

350357
**[14] `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.
@@ -353,7 +360,7 @@ If a database operation involved multiple network calls (for example retries), t
353360
**[15] `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.
354361

355362
**[16] `db.query.text`:** For sanitization see [Sanitization of `db.query.text`](/docs/db/database-spans.md#sanitization-of-dbquerytext).
356-
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.
363+
For batch operations, if the individual operations would all have the same `db.query.text` when executed as non-batch operations, 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.
357364
Parameterized query text SHOULD NOT be sanitized. 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.
358365

359366
---

0 commit comments

Comments
 (0)