Skip to content

Commit 52974c0

Browse files
committed
- Clarifying rules for db.namespace, db.collection.name and db.query.summary with examples
- Adding test for abortTransaction - Renaming transaction test to core_api
1 parent ae0d15e commit 52974c0

File tree

5 files changed

+281
-34
lines changed

5 files changed

+281
-34
lines changed

source/open-telemetry/open-telemetry.md

Lines changed: 71 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ the `withTransaction` span.
119119
The span name SHOULD be:
120120

121121
- `driver_operation_name db.collection_name` if the operation is executed on a collection (e.g.,
122-
`findOneAndDelete warehouse.users`).
122+
`collection.findOneAndDelete(filter)` will report `findAndModify warehouse_db.users_coll`).
123+
124+
**Note**: since the `findOneAndDelete` operation is implemented as a `findAndModify` command, the operation name in the
125+
span is `findAndModify`. This ensures consistency between drivers when naming operations. See the
126+
[covered operations](#covered-operations) table below for mapping of public API methods to operation names.
127+
123128
- `driver_operation_name db` if there is no specific collection for the operation (e.g., `runCommand warehouse`).
124129

125130
##### Operation Span Kind
@@ -143,14 +148,30 @@ requires an operation span to be available throughout the complete operation lif
143148

144149
###### db.namespace
145150

146-
This attribute SHOULD be set to current database name except for operations executing against admin db. This field is
147-
omitted for transaction (abort|commit), and client `bulkWrite` operations.
151+
This attribute SHOULD be set to current database name except for operations executing against admin db ex: (transaction,
152+
client `bulkWrite`) operations.
153+
154+
Examples:
155+
156+
- `find` on `test.users``test`
157+
- `runCommand` on `admin``admin`
158+
- `commitTransaction``admin`
159+
- `abortTransaction``admin`
160+
- client `bulkWrite``admin`
148161

149162
###### db.collection.name
150163

151164
This attribute should be set to the user's collection if the operation is executing against a collection, this field is
152165
omitted for commands running against `admin` database or commands that do not target a specific collection.
153166

167+
Examples:
168+
169+
- `find` on `test.users``users`
170+
- `runCommand` on `admin`*omitted*
171+
- `commitTransaction`*omitted*
172+
- `abortTransaction`*omitted*
173+
- client `bulkWrite`*omitted*
174+
154175
##### Exceptions
155176

156177
If the driver operation fails with an exception, drivers MUST record an exception to the current operation span. When
@@ -204,21 +225,38 @@ applicable to MongoDB.
204225

205226
###### db.namespace
206227

207-
This attribute SHOULD be set to current database name except for commands executing against admin db. This field is
208-
omitted for transaction (abort|commit).
228+
This attribute SHOULD be set to current database name except for operations executing against admin db ex: (transaction,
229+
client `bulkWrite`) operations.
230+
231+
Examples:
232+
233+
- `find` on `test.users``test`
234+
- `runCommand` on `admin``admin`
235+
- `commitTransaction``admin`
236+
- `abortTransaction``admin`
237+
- client `bulkWrite``admin`
209238

210239
###### db.collection.name
211240

212241
This attribute should be set to the user's collection if the operation is executing against a collection, this field is
213242
omitted for commands running against `admin` database or commands that do not target a specific collection.
214243

244+
Examples:
245+
246+
- `find` on `test.users``users`
247+
- `runCommand` on `admin`*omitted*
248+
- `commitTransaction`*omitted*
249+
- `abortTransaction`*omitted*
250+
- client `bulkWrite`*omitted*
251+
215252
###### db.query.summary
216253

217254
This attribute SHOULD contain:
218255

219256
- `command_name db.collection_name` if the command is executed on a collection.
220257
- `command_name db` if there is no specific collection for the command.
221-
- `command_name` in other cases (e.g., commands executed against `admin` database).
258+
- `command_name admin` in other cases (e.g., commands executed against `admin` database, transaction or client
259+
`bulkWrite`).
222260

223261
###### db.query.text
224262

@@ -269,32 +307,33 @@ See [OpenTelemetry Tests](tests/README.md) for the test plan.
269307

270308
The OpenTelemetry specification covers the following operations:
271309

272-
| Operation | Test |
273-
| :----------------------- | :----------------------------------------------------------------------------------- |
274-
| `aggregate` | [tests/transaction/aggregate.yml](tests/operation/aggregate.yml) |
275-
| `findAndModify` | [tests/transaction/find_one_and_update.yml](tests/operation/find_one_and_update.yml) |
276-
| `bulkWrite` | [tests/transaction/bulk_write.yml](tests/operation/bulk_write.yml) |
277-
| `commitTransaction` | [tests/transaction/transaction.yml](tests/transaction/transaction.yml) |
278-
| `abortTransaction` | [tests/transaction/transaction.yml](tests/transaction/transaction.yml) |
279-
| `createCollection` | [tests/transaction/create_collection.yml](tests/operation/create_collection.yml) |
280-
| `createIndexes` | [tests/transaction/create_indexes.yml](tests/operation/create_indexes.yml) |
281-
| `createView` | [tests/transaction/create_view.yml](tests/operation/create_view.yml) |
282-
| `distinct` | [tests/transaction/distinct.yml](tests/operation/distinct.yml) |
283-
| `dropCollection` | [tests/transaction/drop_collection.yml](tests/operation/drop_collection.yml) |
284-
| `dropIndexes` | [tests/transaction/drop_indexes.yml](tests/operation/drop_indexes.yml) |
285-
| `find` | [tests/transaction/find.yml](tests/operation/find.yml) |
286-
| `listCollections` | [tests/transaction/list_collections.yml](tests/operation/list_collections.yml) |
287-
| `listDatabases` | [tests/transaction/list_databases.yml](tests/operation/list_databases.yml) |
288-
| `listIndexes` | [tests/transaction/list_indexes.yml](tests/operation/list_indexes.yml) |
289-
| `mapReduce` | [tests/transaction/map_reduce.yml](tests/operation/map_reduce.yml) |
290-
| `estimatedDocumentCount` | [tests/transaction/count.yml](tests/operation/count.yml) |
291-
| `insert` | [tests/transaction/insert.yml](tests/operation/insert.yml) |
292-
| `delete` | [tests/transaction/delete.yml](tests/operation/delete.yml) |
293-
| `update` | [tests/transaction/update.yml](tests/operation/update.yml) |
294-
| `createSearchIndexes` | [tests/transaction/atlas_search.yml](tests/operation/atlas_search.yml) |
295-
| `dropSearchIndex` | [tests/transaction/atlas_search.yml](tests/operation/atlas_search.yml) |
296-
| `updateSearchIndex` | [tests/transaction/delete.yml](tests/operation/delete.yml) |
297-
| `delete` | [tests/transaction/atlas_search.yml](tests/operation/atlas_search.yml) |
310+
| Operation | Test |
311+
| :----------------------- | :----------------------------------------------------------------------------- |
312+
| `aggregate` | [tests/operation/aggregate.yml](tests/operation/aggregate.yml) |
313+
| `findAndModify` | [tests/operation/find_and_modify.yml](tests/operation/find_and_modify.yml) |
314+
| `bulkWrite` | [tests/operation/bulk_write.yml](tests/operation/bulk_write.yml) |
315+
| `commitTransaction` | [tests/transaction/core_api.yml](tests/transaction/core_api.yml) |
316+
| `abortTransaction` | [tests/transaction/core_api.yml](tests/transaction/core_api.yml) |
317+
| `withTransaction` | [tests/transaction/convenient.yml](tests/transaction/convenient.yml) |
318+
| `createCollection` | [tests/operation/create_collection.yml](tests/operation/create_collection.yml) |
319+
| `createIndexes` | [tests/operation/create_indexes.yml](tests/operation/create_indexes.yml) |
320+
| `createView` | [tests/operation/create_view.yml](tests/operation/create_view.yml) |
321+
| `distinct` | [tests/operation/distinct.yml](tests/operation/distinct.yml) |
322+
| `dropCollection` | [tests/operation/drop_collection.yml](tests/operation/drop_collection.yml) |
323+
| `dropIndexes` | [tests/operation/drop_indexes.yml](tests/operation/drop_indexes.yml) |
324+
| `find` | [tests/operation/find.yml](tests/operation/find.yml) |
325+
| `listCollections` | [tests/operation/list_collections.yml](tests/operation/list_collections.yml) |
326+
| `listDatabases` | [tests/operation/list_databases.yml](tests/operation/list_databases.yml) |
327+
| `listIndexes` | [tests/operation/list_indexes.yml](tests/operation/list_indexes.yml) |
328+
| `mapReduce` | [tests/operation/map_reduce.yml](tests/operation/map_reduce.yml) |
329+
| `estimatedDocumentCount` | [tests/operation/count.yml](tests/operation/count.yml) |
330+
| `insert` | [tests/operation/insert.yml](tests/operation/insert.yml) |
331+
| `delete` | [tests/operation/delete.yml](tests/operation/delete.yml) |
332+
| `update` | [tests/operation/update.yml](tests/operation/update.yml) |
333+
| `createSearchIndexes` | [tests/operation/atlas_search.yml](tests/operation/atlas_search.yml) |
334+
| `dropSearchIndex` | [tests/operation/atlas_search.yml](tests/operation/atlas_search.yml) |
335+
| `updateSearchIndex` | [tests/operation/delete.yml](tests/operation/delete.yml) |
336+
| `delete` | [tests/operation/atlas_search.yml](tests/operation/atlas_search.yml) |
298337

299338
## Backwards Compatibility
300339

File renamed without changes.
File renamed without changes.

source/open-telemetry/tests/transaction/transaction.json renamed to source/open-telemetry/tests/transaction/core_api.json

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
],
5757
"tests": [
5858
{
59-
"description": "observeTracingMessages around transaction",
59+
"description": "commit transaction",
6060
"operations": [
6161
{
6262
"object": "session0",
@@ -233,6 +233,138 @@
233233
]
234234
}
235235
]
236+
},
237+
{
238+
"description": "abort transaction",
239+
"operations": [
240+
{
241+
"object": "session0",
242+
"name": "startTransaction"
243+
},
244+
{
245+
"object": "collection0",
246+
"name": "insertOne",
247+
"arguments": {
248+
"session": "session0",
249+
"document": {
250+
"_id": 1
251+
}
252+
}
253+
},
254+
{
255+
"object": "session0",
256+
"name": "abortTransaction"
257+
}
258+
],
259+
"expectTracingMessages": [
260+
{
261+
"client": "client0",
262+
"ignoreExtraSpans": false,
263+
"spans": [
264+
{
265+
"name": "transaction",
266+
"attributes": {
267+
"db.system": "mongodb"
268+
},
269+
"nested": [
270+
{
271+
"name": "insert transaction-tests.test",
272+
"attributes": {
273+
"db.system": "mongodb",
274+
"db.namespace": "transaction-tests",
275+
"db.collection.name": "test",
276+
"db.operation.name": "insert",
277+
"db.operation.summary": "insert transaction-tests.test"
278+
},
279+
"nested": [
280+
{
281+
"name": "insert",
282+
"attributes": {
283+
"db.system": "mongodb",
284+
"db.namespace": "transaction-tests",
285+
"db.collection.name": "test",
286+
"server.address": {
287+
"$$type": "string"
288+
},
289+
"server.port": {
290+
"$$type": [
291+
"long",
292+
"string"
293+
]
294+
},
295+
"server.type": {
296+
"$$type": "string"
297+
},
298+
"db.query.summary": "insert transaction-tests.test",
299+
"db.query.text": {
300+
"$$matchAsDocument": {
301+
"$$matchAsRoot": {
302+
"insert": "test",
303+
"ordered": true,
304+
"txnNumber": 1,
305+
"startTransaction": true,
306+
"autocommit": false,
307+
"documents": [
308+
{
309+
"_id": 1
310+
}
311+
]
312+
}
313+
}
314+
},
315+
"db.mongodb.lsid": {
316+
"$$sessionLsid": "session0"
317+
}
318+
}
319+
}
320+
]
321+
},
322+
{
323+
"name": "abortTransaction admin",
324+
"attributes": {
325+
"db.system": "mongodb",
326+
"db.namespace": "admin",
327+
"db.collection.name": {
328+
"$$exists": false
329+
},
330+
"db.operation.name": "abortTransaction"
331+
},
332+
"nested": [
333+
{
334+
"name": "abortTransaction",
335+
"attributes": {
336+
"db.system": "mongodb",
337+
"db.namespace": "admin",
338+
"db.collection.name": {
339+
"$$exists": false
340+
},
341+
"db.query.summary": "abortTransaction admin",
342+
"db.command.name": "abortTransaction",
343+
"db.query.text": {
344+
"$$matchAsDocument": {
345+
"$$matchAsRoot": {
346+
"abortTransaction": 1,
347+
"txnNumber": 1,
348+
"autocommit": false
349+
}
350+
}
351+
}
352+
}
353+
}
354+
]
355+
}
356+
]
357+
}
358+
]
359+
}
360+
],
361+
"outcome": [
362+
{
363+
"collectionName": "test",
364+
"databaseName": "transaction-tests",
365+
"documents": []
366+
}
367+
]
236368
}
237369
]
238370
}

source/open-telemetry/tests/transaction/transaction.yml renamed to source/open-telemetry/tests/transaction/core_api.yml

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ initialData:
3030
databaseName: transaction-tests
3131
documents: []
3232
tests:
33-
- description: observeTracingMessages around transaction
33+
- description: commit transaction
3434
operations:
3535
- object: *session0
3636
name: startTransaction
@@ -125,3 +125,79 @@ tests:
125125
databaseName: transaction-tests
126126
documents:
127127
- _id: 1
128+
129+
- description: abort transaction
130+
operations:
131+
- object: *session0
132+
name: startTransaction
133+
- object: *collection0
134+
name: insertOne
135+
arguments:
136+
session: *session0
137+
document:
138+
_id: 1
139+
- object: *session0
140+
name: abortTransaction
141+
142+
expectTracingMessages:
143+
- client: *client0
144+
ignoreExtraSpans: false
145+
spans:
146+
- name: transaction
147+
attributes:
148+
db.system: mongodb
149+
nested:
150+
- name: insert transaction-tests.test
151+
attributes:
152+
db.system: mongodb
153+
db.namespace: transaction-tests
154+
db.collection.name: test
155+
db.operation.name: insert
156+
db.operation.summary: insert transaction-tests.test
157+
nested:
158+
- name: insert
159+
attributes:
160+
db.system: mongodb
161+
db.namespace: transaction-tests
162+
db.collection.name: test
163+
server.address: { $$type: string }
164+
server.port: { $$type: ['long', 'string'] }
165+
server.type: { $$type: string }
166+
db.query.summary: insert transaction-tests.test
167+
db.query.text:
168+
$$matchAsDocument:
169+
$$matchAsRoot:
170+
insert: test
171+
ordered: true
172+
txnNumber: 1
173+
startTransaction: true
174+
autocommit: false
175+
documents:
176+
- _id: 1
177+
db.mongodb.lsid: { $$sessionLsid: *session0 }
178+
- name: abortTransaction admin
179+
attributes:
180+
db.system: mongodb
181+
db.namespace: admin
182+
db.collection.name: { $$exists: false }
183+
db.operation.name: abortTransaction
184+
nested:
185+
- name: abortTransaction
186+
attributes:
187+
db.system: mongodb
188+
db.namespace: admin
189+
db.collection.name: { $$exists: false }
190+
db.query.summary: abortTransaction admin
191+
db.command.name: abortTransaction
192+
db.query.text:
193+
$$matchAsDocument:
194+
$$matchAsRoot:
195+
abortTransaction: 1
196+
txnNumber: 1
197+
autocommit: false
198+
199+
outcome:
200+
- collectionName: test
201+
databaseName: transaction-tests
202+
documents: []
203+

0 commit comments

Comments
 (0)