Skip to content

Conversation

nhachicha
Copy link

@nhachicha nhachicha commented Aug 8, 2025

DRIVERS-719

  • Update schema to 1.26
  • Added invalid test to unified test runner
  • Added nominal valid tests for the 3 tracing grouping (Operation, Cursor and Transaction)
  • Update description of the new field observeTracingMessages and expectTracingMessages
  • Merge back the draft spec into this

@nhachicha nhachicha self-assigned this Aug 8, 2025
@nhachicha nhachicha changed the title OpenTelemetry DRIVERS-719 OpenTelementry specification Aug 8, 2025
- `enableCommandPayload`: Optional boolean. When set to `true`, enables capturing of command payload details in
tracing spans.
- If `true`, the test runner SHOULD capture detailed command payload information in tracing spans.
- If `false` or omitted, the test runner SHOULD exclude command payload details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this impacts the test runner, but should it also refer to configuring the MongoClient to enable tracing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This point is similar to #1826 (comment) ?
This option is both configured via the test runner and should be available to toggle on/off via MongoClient. This should be covered by a prose test 👍

nhachicha and others added 8 commits August 14, 2025 17:48
…TracingMessages-additionalProperties.yml

Co-authored-by: Jeremy Mikola <[email protected]>
…spanMalformedTagsMustBeObject.yml

Co-authored-by: Jeremy Mikola <[email protected]>
…TracingMessages-additionalPropertyType.yml

Co-authored-by: Jeremy Mikola <[email protected]>
…missingPropertySpans.yml

Co-authored-by: Jeremy Mikola <[email protected]>
…spanMalformedMissingName.yml

Co-authored-by: Jeremy Mikola <[email protected]>
…spanMalformedTagsMustBeObject.yml

Co-authored-by: Jeremy Mikola <[email protected]>
comandeo-mongo and others added 6 commits September 2, 2025 17:42
- error.type is dropped in favour of using https://opentelemetry.io/docs/specs/semconv/exceptions/exceptions-spans/
- db.response.status_code is set in case of an error
- namespace and collection names are reported as following:
    - 1: If the operation/command operates at the user collection level, then these fields should be set
    - 2: If the operation/command operates at the admin db, then only db.namespace should be set
    - 3: For bulkWrite collection name is not reported (db name is admin)
    - 4: For [abort|commit]Transaction no db name or collection reported
@nhachicha nhachicha marked this pull request as ready for review September 10, 2025 12:24
@nhachicha nhachicha requested review from a team as code owners September 10, 2025 12:24
@nhachicha nhachicha requested review from alcaeus, jmikola, GromNaN and blink1073 and removed request for a team and blink1073 September 10, 2025 12:24
…summary with examples

- Adding test for abortTransaction
- Renaming transaction test to core_api
- **MongoClient Level**: Drivers SHOULD provide a configuration option for `MongoClient`'s Configuration/Settings that
enables or disables tracing for operations and commands executed with this client. This option MUST override
settings on higher levels. This configuration can be implemented with a `MongoClient` option, for example,
`tracing.enabled`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We usually call out if an option should be URI, MongoClient settings, or both. Like for versioned api:
https://github.com/mongodb/specifications/blob/master/source/versioned-api/versioned-api.md#no-uri-options

Also can you clarify how tracing.enabled is supposed to be translated into code? Is it MongoClient(tracing=True), MongoClient(tracing="enabled"), or something else?


#### Tracer Attributes

If a driver creates a Tracer using OpenTelemetry API, drivers MUST use the following attributes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say "When a driver"? Is creating a Tracer optional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. In the Ruby driver I implemented tracing attribute as a Hash, so the code should be like Mongo::Client.new('mongodb://...', tracing: { enabled: true }). Do you think we should specify the syntax here?
  2. As mentioned above, some driver may decide not to use OpenTelemetry API. In this case they do not have a Tracer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using a Hash, do you anticipate there will be a need for additional options beyond enabled? My first impression is that such a design conflicts with the Defy Augury mantra for our specs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java uses MongoClientSettings builder to pass in the tracer instance (interface abstracting the underlying collector) . Drivers should be free to define this in their idiomatic way.


A common complaint from our support team is that they don't know how to easily get debugging information from drivers.
Some drivers provide debug logging, but others do not. For drivers that do provide it, the log messages produced and the
mechanisms for enabling debug logging are inconsistent.
Copy link
Member

@ShaneHarvey ShaneHarvey Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this the motivation for standardized logging? Could this section reference Standardized Logging and explain why OTel is a better (or necessary) alternative?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShaneHarvey I updated the motivation based on the scope, please let me know if you think it looks better now.


## Covered operations

The OpenTelemetry specification covers the following operations:
Copy link
Member

@ShaneHarvey ShaneHarvey Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say something like "covers all driver operations including but not limited to"? My understanding is that every driver api should produce OTel info, even non-spec driver specific helpers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say something like "including but not limited to

Agree, in this iteration, we tried to include all the operations supported by the unified test runner. Example AFAIK there's no dropDatabase test in the UTR but the operation is reported in OTel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks. Updated accordingly.

| `abortTransaction` | [tests/transaction/transaction.yml](tests/transaction/transaction.yml) |
| `createCollection` | [tests/transaction/create_collection.yml](tests/operation/create_collection.yml) |
| `createIndexes` | [tests/transaction/create_indexes.yml](tests/operation/create_indexes.yml) |
| `createView` | [tests/transaction/create_view.yml](tests/operation/create_view.yml) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createView is not a spec method. I don't think it should be included here or in the unified tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a fair point, my understanding is that some operations predate the spec ex createView defined in https://jira.mongodb.org/browse/DRIVERS-309 or createCollection only defined in unified tests. To your point in #1826 (comment) We should aim to cover the majority of operations that will help the developer trace and troubleshoot their application

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are we going to remove createView here? Or mention that it's not standard?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Tracer is responsible for creating spans, and using a tracer is the only way to create a span. A Tracer is not
responsible for configuration; this should be the responsibility of the TracerProvider instead.

**OpenTelemetry API and SDK**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this section intended to be under ### Terms? It definitely doesn't look like it belongs under #### Tracer.

It seems relevant to the paragraph under #### External Dependencies below, so perhaps drop the title here and just move the following paragraph to that section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely removed the Tracer section, and moved the API and SDK to the External Dependencies.


OpenTelemetry SHOULD be disabled by default.

Drivers SHOULD support configuring OpenTelemetry on multiple levels.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nhachicha @comandeo-mongo: Feel free to resolve this if the question is no longer relevant. Otherwise, respond and I'll resolve after reading.

- **MongoClient Level**: Drivers SHOULD provide a configuration option for `MongoClient`'s Configuration/Settings that
enables or disables tracing for operations and commands executed with this client. This option MUST override
settings on higher levels. This configuration can be implemented with a `MongoClient` option, for example,
`tracing.enabled`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShaneHarvey: thanks for bringing up the typing. If this really is just a boolean type, I think tracing or enableTracing (more active language than tracingEnabled) with a default value of false would be most consistent with other driver option names in PHP. But since these aren't URI options there should be more naming flexibility available for drivers.

It looks like @comandeo-mongo is talking about this in a comment below, too: https://github.com/mongodb/specifications/pull/1826/files#r2339648026


#### Tracer Attributes

If a driver creates a Tracer using OpenTelemetry API, drivers MUST use the following attributes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using a Hash, do you anticipate there will be a need for additional options beyond enabled? My first impression is that such a design conflicts with the Defy Augury mantra for our specs.


This attribute contains the full database command executed serialized to extended JSON. If not truncated, the content of
this attribute SHOULD be equivalent to the `document` field of the CommandStartedEvent of the command monitoring
excluding the following fields: `lsid`, `$db`, `$clusterTime`, `signature`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PHP team was recently discussing query shapes and how one might remove dynamic values (e.g. 5 in { x: { $gt: 5 }}) to yield a parameterized query for purposes of logging or query aggregation. In the case of CSFLE, the query might already have BSON binary values (with the encrypted subtype) by the time the query is sent along for logging, which can also be considered a form of parameterization. In that case, a driver could easily replace those binary values with placeholders (assuming the encrypted blobs are irrelevant for logging).

There's may also be some overlap here with making security redactions for other, sensitive commands.

With regard to this spec, I'd suggest mentioning query parameterization as a potential todo item in a "Future Work" section (as is found in other specs).

cc: @GromNaN @paulinevos @alcaeus

@@ -0,0 +1,129 @@
description: cursor retrieval
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not too much work, I'd advocate for making these descriptions consistent with the base filename (sans .yml extension). So if "cursor retrieval" is the logical name to group tests in this file, I'd suggest using cursor-retrieval here and naming the file cursor-retrieval.yml.

exception.type: { $$exists: false }
exception.stacktrace: { $$exists: false }
server.address: { $$type: string }
server.port: { $$type: ['int', 'long'] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed you don't quote single values for $$type above, so consider using [int, long] here in the interest of consistency and keeping the tests as concise as possible (without sacrificing readability and introducing ambiguity in YAML parsing).

- name: aggregate
object: *collection0
arguments:
pipeline: &pipeline1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: was this test originally taken from a larger file? I would have expected &pipeline0 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants