Skip to content

Add Java MongoDB database conformance - #136

Draft
trask wants to merge 3 commits into
mainfrom
trask-add-mongodb-database-domain
Draft

trask wants to merge 3 commits into
mainfrom
trask-add-mongodb-database-domain

Conversation

@trask

@trask trask commented Aug 29, 2026

Copy link
Copy Markdown
Member

Adds Java MongoDB conformance for the current synchronous and Reactive Streams drivers and the final legacy async driver release, each through the Java agent and published opentelemetry-mongo-3.1 library.

  • Runs deterministic find, update, delete, and aggregate workloads against a digest-pinned MongoDB 8.0 container.
  • Checks exact stable database attributes and sanitized command text, including the endSessions lifecycle command.
  • Adds MongoDB backend dispatch, lifecycle/error coverage, db.mongodb.client classification, generated coverage snapshots, docs, and Renovate tracking.

The legacy async API is intentionally pinned to 3.12.14 because that line is unmaintained and was replaced by Reactive Streams. MongoDB instrumentation currently does not emit db.query.summary; expectations assert that gap explicitly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Java MongoDB conformance across synchronous, legacy async, and Reactive Streams drivers using both Java agent and library instrumentation.

Changes:

  • Adds a pinned MongoDB backend with deterministic fixtures and tests.
  • Adds shared Java workloads and launchers for three driver APIs.
  • Adds conformance expectations, coverage snapshots, documentation, and Renovate support.

Reviewed changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/database/runner/tests/test_database_session.py Tests MongoDB cleanup on failure.
tools/database/runner/tests/test_database_model.py Verifies registry classification.
tools/database/runner/tests/test_database_coverage.py Tests MongoDB span refinement.
tools/database/runner/tests/test_database_backends.py Tests backend lifecycle and packaging.
tools/database/runner/src/database_conformance/mongodb.js Creates deterministic MongoDB fixtures.
tools/database/runner/src/database_conformance/_mongodb.py Defines the MongoDB container backend.
tools/database/runner/src/database_conformance/_coverage.py Adds MongoDB span classification.
tools/database/runner/src/database_conformance/__init__.py Registers the MongoDB backend.
tools/database/runner/README.md Documents MongoDB runner support.
scenarios/database/README.md Documents MongoDB scenarios.
scenarios/database/java/shared/mongodb/sync/scenarios/src/main/java/io/opentelemetry/conformance/database/mongodb/sync/MongoSyncScenario.java Implements synchronous workloads.
scenarios/database/java/shared/mongodb/sync/scenarios/build.gradle.kts Configures the sync workload.
scenarios/database/java/shared/mongodb/sync/opentelemetry-library/src/main/java/MongoSyncLibraryScenario.java Launches sync library instrumentation.
scenarios/database/java/shared/mongodb/sync/opentelemetry-library/build.gradle.kts Adds sync library dependencies.
scenarios/database/java/shared/mongodb/sync/opentelemetry-javaagent/src/main/java/MongoSyncJavaagentScenario.java Launches sync agent instrumentation.
scenarios/database/java/shared/mongodb/sync/opentelemetry-javaagent/build.gradle.kts Configures the sync agent.
scenarios/database/java/shared/mongodb/support/src/main/java/io/opentelemetry/conformance/database/mongodb/MongoContract.java Defines shared connection and fixture values.
scenarios/database/java/shared/mongodb/support/build.gradle.kts Configures shared MongoDB support.
scenarios/database/java/shared/mongodb/reactive/scenarios/src/main/java/io/opentelemetry/conformance/database/mongodb/reactive/MongoReactiveScenario.java Implements reactive workloads.
scenarios/database/java/shared/mongodb/reactive/scenarios/build.gradle.kts Configures the reactive workload.
scenarios/database/java/shared/mongodb/reactive/opentelemetry-library/src/main/java/MongoReactiveLibraryScenario.java Launches reactive library instrumentation.
scenarios/database/java/shared/mongodb/reactive/opentelemetry-library/build.gradle.kts Adds reactive library dependencies.
scenarios/database/java/shared/mongodb/reactive/opentelemetry-javaagent/src/main/java/MongoReactiveJavaagentScenario.java Launches reactive agent instrumentation.
scenarios/database/java/shared/mongodb/reactive/opentelemetry-javaagent/build.gradle.kts Configures the reactive agent.
scenarios/database/java/shared/mongodb/async/scenarios/src/main/java/io/opentelemetry/conformance/database/mongodb/async/MongoAsyncScenario.java Implements legacy async workloads.
scenarios/database/java/shared/mongodb/async/scenarios/build.gradle.kts Configures the async workload.
scenarios/database/java/shared/mongodb/async/opentelemetry-library/src/main/java/MongoAsyncLibraryScenario.java Launches async library instrumentation.
scenarios/database/java/shared/mongodb/async/opentelemetry-library/build.gradle.kts Adds async library dependencies.
scenarios/database/java/shared/mongodb/async/opentelemetry-javaagent/src/main/java/MongoAsyncJavaagentScenario.java Launches async agent instrumentation.
scenarios/database/java/shared/mongodb/async/opentelemetry-javaagent/build.gradle.kts Configures the async agent.
scenarios/database/java/settings.gradle.kts Registers MongoDB Gradle projects.
scenarios/database/java/README.md Documents Java MongoDB coverage.
scenarios/database/java/mongodb/sync/opentelemetry-library/database.yaml Selects the MongoDB backend.
scenarios/database/java/mongodb/sync/opentelemetry-library/data.json Records sync library coverage.
scenarios/database/java/mongodb/sync/opentelemetry-library/conformance.yaml Defines sync library expectations.
scenarios/database/java/mongodb/sync/opentelemetry-javaagent/database.yaml Selects the MongoDB backend.
scenarios/database/java/mongodb/sync/opentelemetry-javaagent/data.json Records sync agent coverage.
scenarios/database/java/mongodb/sync/opentelemetry-javaagent/conformance.yaml Defines sync agent expectations.
scenarios/database/java/mongodb/reactive/opentelemetry-library/database.yaml Selects the MongoDB backend.
scenarios/database/java/mongodb/reactive/opentelemetry-library/data.json Records reactive library coverage.
scenarios/database/java/mongodb/reactive/opentelemetry-library/conformance.yaml Defines reactive library expectations.
scenarios/database/java/mongodb/reactive/opentelemetry-javaagent/database.yaml Selects the MongoDB backend.
scenarios/database/java/mongodb/reactive/opentelemetry-javaagent/data.json Records reactive agent coverage.
scenarios/database/java/mongodb/reactive/opentelemetry-javaagent/conformance.yaml Defines reactive agent expectations.
scenarios/database/java/mongodb/async/opentelemetry-library/database.yaml Selects the MongoDB backend.
scenarios/database/java/mongodb/async/opentelemetry-library/data.json Records async library coverage.
scenarios/database/java/mongodb/async/opentelemetry-library/conformance.yaml Defines async library expectations.
scenarios/database/java/mongodb/async/opentelemetry-javaagent/database.yaml Selects the MongoDB backend.
scenarios/database/java/mongodb/async/opentelemetry-javaagent/data.json Records async agent coverage.
scenarios/database/java/mongodb/async/opentelemetry-javaagent/conformance.yaml Defines async agent expectations.
scenarios/database/java/gradle/libs.versions.toml Adds MongoDB dependencies and versions.
.github/renovate.json5 Enables MongoDB image updates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Base automatically changed from trask-add-jdbc-database-domain to main August 30, 2026 22:01
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@trask
trask force-pushed the trask-add-mongodb-database-domain branch from 5b76b11 to f24eeb4 Compare August 30, 2026 22:47
@trask
trask requested a balanced review from Copilot August 31, 2026 00:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 47 changed files in this pull request and generated no new comments.

trask and others added 2 commits August 30, 2026 17:27
Review finding:

The new MongoDB parameter row brings a seeding bootstrap under the shared assertion `assert b"INSERT INTO" not in schema` on line 166, which exists to prove that a packaged schema seeds no data. The MongoDB bootstrap does seed data: mongodb.js calls insertMany with four documents, and this same PR documents that in tools/database/runner/README.md ("recreates the `items` collection with deterministic documents") and in scenarios/database/README.md. For the MongoDB parameter the assertion can never fail and checks nothing, so the test now asserts a property the MongoDB bootstrap does not have. Fix: make the seeding claim per-backend, for example by removing the INSERT INTO assertion from this lifecycle test and asserting that postgres.sql and mariadb.sql contain no INSERT INTO inside test_the_schema_is_packaged_with_the_runner, which already reads each packaged file.

Analysis: "seeds no rows" is a property of an individual packaged schema, not of the shared container lifecycle, so it belongs with the per-file assertions in test_the_schema_is_packaged_with_the_runner rather than in the parametrized lifecycle test. Keeping it in the lifecycle test forced one claim onto every backend, and the MongoDB bootstrap seeds four documents on purpose, so the claim silently became a substring check that no JavaScript bootstrap can ever trip. Moving it to postgres.sql and mariadb.sql states it exactly where it holds, next to the assertions that already describe what each relational schema creates. The lifecycle test keeps schema_marker, which is what proves the right file reached the container.

Upsides: every assertion now checks the file it is written about; the relational no-rows contract is stated once per schema instead of once for all backends; a future backend that seeds data no longer inherits a claim that contradicts it.

Downsides: the no-rows check now lives in a different test from the transfer it constrains, so a reader of the lifecycle test has to look at test_the_schema_is_packaged_with_the_runner to see what each schema may contain.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Review finding:

This line replaced the sentence "`runner_config` must contain only `backend`, set to `postgresql` or `mariadb`." The replacement keeps the list of supported backends but drops the "must contain only `backend`" constraint. The code still enforces that constraint: _backend_name in tools/database/runner/src/database_conformance/__init__.py raises a SpecError saying runner_config "must contain exactly one string key named 'backend'" for an extra or differently named key, and test_database_session_rejects_invalid_backend_configuration still covers it. No other sentence in this README states the constraint, so after this PR a reader cannot learn from the docs that runner_config rejects any key besides backend. Fix: restore the constraint in the new sentence, for example "runner_config must contain only `backend`, whose supported values are `postgresql`, `mariadb`, and `mongodb`."

Analysis: `_backend_name` rejects a `runner_config` whose key set is anything other than `{"backend"}`, so a package that adds a second key fails to load rather than having the key ignored. That is the kind of rule a reader needs before writing the block, and the README's example shows only the valid shape, which on its own does not say whether more keys are allowed. Folding the constraint back into the same sentence that lists the backends keeps the paragraph at one idea per sentence and adds no new section.

Upsides: the documented contract matches what the loader enforces and what test_database_session_rejects_invalid_backend_configuration covers; a package author learns the rule before hitting the SpecError.

Downsides: the sentence carries two facts, the exact-key rule and the list of backends, so a future backend edits a slightly longer line.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@trask
trask requested a balanced review from Copilot August 31, 2026 00:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 47 changed files in this pull request and generated no new comments.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-09-17 06:53 UTC

Move out of draft to request review.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

This branch has not been deployed

No deployments
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.

2 participants