Skip to content

DRIVERS-3617 Specify error.type on OpenTelemetry command spans - #1974

Draft
blink1073 wants to merge 7 commits into
mongodb:masterfrom
blink1073:DRIVERS-3617
Draft

DRIVERS-3617 Specify error.type on OpenTelemetry command spans#1974
blink1073 wants to merge 7 commits into
mongodb:masterfrom
blink1073:DRIVERS-3617

Conversation

@blink1073

@blink1073 blink1073 commented Aug 19, 2026

Copy link
Copy Markdown
Member

Please complete the following before merging:

  • Is the relevant DRIVERS ticket in the PR title?
  • Update changelog.
  • Test changes in at least one language driver. mongodb/mongo-python-driver#3000 (PYTHON-6045)
  • Test these changes against all server versions and topologies (including standalone, replica set, and sharded clusters). Evergreen patch #10898 — 0 failed tasks across standalone, replica set, and sharded cluster on server versions 4.2 through 9.0.

Summary

The OpenTelemetry command span spec already defines db.response.status_code but was missing error.type, which the technical design lists alongside it. error.type is a span-level attribute (distinct from exception.type, carried on the exception event), and tracing backends query and alert on span attributes rather than event attributes — without it, drivers have no shared definition for the dimension backends actually group failures by.

Changes

  • Add error.type to the Command Span Attributes table as a required-if-an-error-happens string attribute.
  • Specify that error.type SHOULD match db.response.status_code for server errors, and otherwise SHOULD be the exception class name; MUST NOT be set on success; SHOULD have low cardinality.
  • Document that error.type deliberately duplicates exception.type and why (span- vs event-level querying).
  • State that operation spans MUST NOT carry error.type, since an operation can succeed overall (e.g. via retry) even when an underlying command failed.
  • Add a unified test format fixture (error_type.yml/.json) with two cases: a server error, where error.type matches db.response.status_code; and a non-server error (connection closed before a response), where db.response.status_code is absent and error.type falls back to the exception class name. Both cases also assert the operation span has no error.type.
  • Add a dated changelog entry to open-telemetry.md.

Testing

  • make -C source (YAML → JSON generation, confirmed no diff after regeneration)
  • pre-commit run --all-files (mdformat, markdown-link-check, codespell, etc.) — clean
  • mkdocs build --strict — clean
  • Validated the new fixture's generated JSON against schema-1.27.json with ajv-cli — valid

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.

1 participant