Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
97d8a5b
added first tracing tests
nhachicha Jul 11, 2025
c82a6a2
using unsetOrMatches for txNumber, since it's not set for single topo…
nhachicha Jul 16, 2025
61270d6
updating tests
nhachicha Jul 20, 2025
581faa1
Tests and schema update for the upcoming Otel spec
nhachicha Aug 8, 2025
c447d10
Merge branch 'nh/tracing'
nhachicha Aug 8, 2025
3a578ee
Update generated files
nhachicha Aug 8, 2025
dbb1a9c
update schema to latest (1.26)
nhachicha Aug 8, 2025
29e25a1
update tests
nhachicha Aug 8, 2025
f801d78
DRIVERS-719 OpenTelementry specification
comandeo-mongo Jun 26, 2025
9d66a8a
Cursor operations
comandeo-mongo Aug 1, 2025
269221c
update doc
nhachicha Aug 9, 2025
452696d
moved tests under open-telemtry directroy
nhachicha Aug 9, 2025
9f05c59
Fixing formatting
nhachicha Aug 9, 2025
0523751
update formatting using pre-commit mdformat
nhachicha Aug 9, 2025
8466c1b
Adding Test README
nhachicha Aug 9, 2025
18ad723
Adding retries test, fixing duplicate exception tag
nhachicha Aug 13, 2025
04b947a
Update source/open-telemetry/open-telemetry.md
nhachicha Aug 14, 2025
88c7be0
Update source/open-telemetry/open-telemetry.md
nhachicha Aug 14, 2025
ced82eb
Update source/unified-test-format/tests/invalid/entity-client-observe…
nhachicha Aug 15, 2025
f1804c3
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
03d4e3c
Update source/unified-test-format/tests/invalid/entity-client-observe…
nhachicha Aug 15, 2025
3c69ed5
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
240d009
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
6a4d217
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
b596f05
Update generated files
nhachicha Aug 15, 2025
bbb075b
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
a5638da
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
56570a5
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
a4aa513
Update source/unified-test-format/tests/invalid/expectedTracingSpans-…
nhachicha Aug 15, 2025
cb74b54
Using YAML anchors and references
nhachicha Aug 14, 2025
3caa87f
PR feedback: Updating schema, adding more invalid tests
nhachicha Aug 15, 2025
7a68cbc
Fixing lint errors
nhachicha Aug 15, 2025
1c24759
Update source/open-telemetry/open-telemetry.md
comandeo-mongo Aug 18, 2025
a989a49
Update source/open-telemetry/open-telemetry.md
comandeo-mongo Aug 18, 2025
c84847c
adding more tests for operations
nhachicha Aug 20, 2025
a808992
update list of supported operations
nhachicha Aug 20, 2025
f78b541
Adjust spec format
comandeo-mongo Sep 2, 2025
67d4c90
Clarify cursor operation and transactions nesting
comandeo-mongo Sep 3, 2025
b478c9e
Fix bulkWrite test
comandeo-mongo Sep 3, 2025
0a1134d
Updating tests:
nhachicha Sep 8, 2025
7d0d83d
Merge remote-tracking branch 'origin/master' into DRIVERS-719
nhachicha Sep 9, 2025
0edc807
Fixing typo in test file
nhachicha Sep 9, 2025
3822daf
Fixing test
nhachicha Sep 9, 2025
9987dbf
Added convenient transaction test
nhachicha Sep 9, 2025
51fc929
Bring spec in accordance with the new tests
comandeo-mongo Sep 9, 2025
2841df3
db.response.status_code type is string per the OTel convention https:…
nhachicha Sep 9, 2025
5af87ec
Fix review remarks
comandeo-mongo Sep 9, 2025
46bc709
Fix review remarks
comandeo-mongo Sep 9, 2025
ae0d15e
Fix section names
comandeo-mongo Sep 10, 2025
52974c0
- Clarifying rules for db.namespace, db.collection.name and db.query.…
nhachicha Sep 10, 2025
00c1dc3
Update source/open-telemetry/open-telemetry.md
comandeo-mongo Sep 16, 2025
cafe19c
Respond to code review remarks
comandeo-mongo Sep 16, 2025
99f7ed3
Update source/open-telemetry/tests/operation/atlas_search.yml
comandeo-mongo Sep 16, 2025
50966dd
Tests formating
nhachicha Sep 17, 2025
1ca2881
Merge remote-tracking branch 'origin/master' into DRIVERS-719
nhachicha Sep 17, 2025
39863b0
Fix linting
nhachicha Sep 17, 2025
92bea10
Adding prose tests description
nhachicha Sep 18, 2025
e2d5ead
Folding find_reties test under find
nhachicha Sep 18, 2025
80ae25f
Clarify configuration options
comandeo-mongo Sep 18, 2025
682d6b8
Address code review remarks
comandeo-mongo Sep 18, 2025
5fa16fa
Add tests for client configuration
comandeo-mongo Sep 18, 2025
0895547
Remove non compliats tests
comandeo-mongo Sep 18, 2025
d8ecaf0
Fix typos
comandeo-mongo Sep 18, 2025
c9f1e94
Address code review remarks
comandeo-mongo Sep 19, 2025
b6e0eb9
Clarify query parametrization
comandeo-mongo Sep 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- [MongoDB Handshake](mongodb-handshake/handshake.md)
- [OCSP Support](ocsp-support/ocsp-support.md)
- [OP_MSG](message/OP_MSG.md)
- [OpenTelemetry](open-telemetry/open-telemetry.md)
- [Performance Benchmarking](benchmarking/benchmarking.md)
- [Polling SRV Records for mongos Discovery](polling-srv-records-for-mongos-discovery/polling-srv-records-for-mongos-discovery.md)
- [Read and Write Concern](read-write-concern/read-write-concern.md)
Expand Down
424 changes: 424 additions & 0 deletions source/open-telemetry/open-telemetry.md

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions source/open-telemetry/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# OpenTelemetry Tests

______________________________________________________________________

## Testing

### Automated Tests

The YAML and JSON files in this directory are platform-independent tests meant to exercise a driver's implementation of
the OpenTelemetry specification. These tests utilize the
[Unified Test Format](../../unified-test-format/unified-test-format.md).

For each test, create a MongoClient, configure it to enable tracing.

```yaml
createEntities:
- client:
id: client0
observeTracingMessages:
enableCommandPayload: true
```

These tests require the ability to collect tracing [spans](../open-telemetry.md) data in a structured form as described
in the
[Unified Test Format specification.expectTracingMessages](../../unified-test-format/unified-test-format.md#expectTracingMessages).
For example the Java driver uses [Micrometer](https://jira.mongodb.org/browse/JAVA-5732) to collect tracing spans.

```yaml
expectTracingMessages:
client: client0
ignoreExtraSpans: false
spans:
...
```

### Prose Tests

*Test 1: Tracing Enable/Disable via Environment Variable*

1. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED` to `false`.
2. Create a `MongoClient` without explicitly enabling tracing.
3. Perform a database operation (e.g., `find()` on a test collection).
4. Assert that no OpenTelemetry tracing spans are emitted for the operation.
5. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED` to `true`.
6. Create a new `MongoClient` without explicitly enabling tracing.
7. Perform the same database operation.
8. Assert that OpenTelemetry tracing spans are emitted for the operation.

*Test 2: Command Payload Emission via Environment Variable*

1. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED` to `true`.
2. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH` to a positive integer
(e.g., 1024).
3. Create a `MongoClient` without explicitly enabling command payload emission.
4. Perform a database operation (e.g., `find()`).
5. Assert that the emitted tracing span includes the `db.query.text` attribute.
6. Unset the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH`.
7. Create a new `MongoClient`.
8. Perform the same database operation.
9. Assert that the emitted tracing span does not include the `db.query.text` attribute.
130 changes: 130 additions & 0 deletions source/open-telemetry/tests/operation/aggregate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"description": "operation aggregate",
"schemaVersion": "1.27",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": false,
"observeTracingMessages": {
"enableCommandPayload": true
}
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "operation-aggregate"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "test"
}
}
],
"tests": [
{
"description": "aggregation",
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"_id": 1
}
}
]
}
}
],
"expectTracingMessages": [
{
"client": "client0",
"ignoreExtraSpans": false,
"spans": [
{
"name": "aggregate operation-aggregate.test",
"attributes": {
"db.system": "mongodb",
"db.namespace": "operation-aggregate",
"db.collection.name": "test",
"db.operation.name": "aggregate",
"db.operation.summary": "aggregate operation-aggregate.test"
},
"nested": [
{
"name": "aggregate",
"attributes": {
"db.system": "mongodb",
"db.namespace": "operation-aggregate",
"db.collection.name": "test",
"db.command.name": "aggregate",
"network.transport": "tcp",
"db.mongodb.cursor_id": {
"$$exists": false
},
"db.response.status_code": {
"$$exists": false
},
"exception.message": {
"$$exists": false
},
"exception.type": {
"$$exists": false
},
"exception.stacktrace": {
"$$exists": false
},
"server.address": {
"$$type": "string"
},
"server.port": {
"$$type": [
"int",
"long"
]
},
"db.query.summary": "aggregate operation-aggregate.test",
"db.query.text": {
"$$matchAsDocument": {
"$$matchAsRoot": {
"aggregate": "test",
"pipeline": [
{
"$match": {
"_id": 1
}
}
]
}
}
},
"db.mongodb.server_connection_id": {
"$$type": [
"int",
"long"
]
},
"db.mongodb.driver_connection_id": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
}
]
}
]
}
62 changes: 62 additions & 0 deletions source/open-telemetry/tests/operation/aggregate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
description: operation aggregate
schemaVersion: '1.27'
createEntities:
- client:
id: &client0 client0
useMultipleMongoses: false
observeTracingMessages:
enableCommandPayload: true
- database:
id: &database0 database0
client: *client0
databaseName: operation-aggregate
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collectionName0 test

tests:
- description: aggregation
operations:
- name: aggregate
object: *collection0
arguments:
pipeline: &pipeline0
- $match: { _id: 1 }

expectTracingMessages:
- client: *client0
ignoreExtraSpans: false
spans:
- name: aggregate operation-aggregate.test
attributes:
db.system: mongodb
db.namespace: operation-aggregate
db.collection.name: test
db.operation.name: aggregate
db.operation.summary: aggregate operation-aggregate.test
nested:
- name: aggregate
attributes:
db.system: mongodb
db.namespace: operation-aggregate
db.collection.name: *collectionName0
db.command.name: aggregate
network.transport: tcp
db.mongodb.cursor_id: { $$exists: false }
db.response.status_code: { $$exists: false }
exception.message: { $$exists: false }
exception.type: { $$exists: false }
exception.stacktrace: { $$exists: false }
server.address: { $$type: string }
server.port: { $$type: [int, long] }
db.query.summary: aggregate operation-aggregate.test
db.query.text:
$$matchAsDocument:
$$matchAsRoot:
aggregate: test
pipeline: *pipeline0
db.mongodb.server_connection_id:
$$type: [ int, long ]
db.mongodb.driver_connection_id:
$$type: [ int, long ]
Loading
Loading