PYTHON-6045 Add error.type OpenTelemetry command span attribute - #3000
Draft
blink1073 wants to merge 4 commits into
Draft
PYTHON-6045 Add error.type OpenTelemetry command span attribute#3000blink1073 wants to merge 4 commits into
blink1073 wants to merge 4 commits into
Conversation
This was referenced Aug 20, 2026
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
August 21, 2026 15:28
5583231 to
d161a7f
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
August 21, 2026 15:51
d161a7f to
3901b32
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
August 21, 2026 16:02
3901b32 to
8a91f4e
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
2 times, most recently
from
August 23, 2026 22:29
7020b94 to
e3b52c5
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
August 26, 2026 16:54
e3b52c5 to
5ecc46c
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
August 26, 2026 19:43
5ecc46c to
bf59e7f
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
September 1, 2026 10:27
bf59e7f to
1c28013
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
September 1, 2026 10:48
1c28013 to
19b45bc
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
September 1, 2026 11:01
19b45bc to
8451fa3
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
September 1, 2026 16:00
8451fa3 to
5a9f0aa
Compare
Emit error.type on command spans, mirroring db.response.status_code for server errors and falling back to the exception class name otherwise. Operation spans deliberately do not carry error.type, per the spec. Syncs the new open-telemetry error_type.json spec fixture (both the server-error and non-server-error cases).
Covers the two non-server-error paths where there is no server error code to mirror: a closed connection (ConnectionFailure) and a socket timeout (NetworkTimeout). Both assert error.type is the exception's qualified class name and that db.response.status_code is absent.
Cut each to the invariant a reader needs, dropping restatements of the code.
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
September 1, 2026 17:23
5a9f0aa to
1a0330d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PYTHON-6045
Fifth in the OpenTelemetry stack, on top of the four PRs splitting #2964. Base is
PYTHON-5947-otel-4-getmore.PYTHON-5947-otel-1-operationsPYTHON-5947-otel-2-transactionsPYTHON-5947-otel-3-unifiedPYTHON-5947-otel-4-getmorePYTHON-5947-otel-5-error-typeerror.typecommand span attribute (this PR)Implements
error.typeon command spans, specified by DRIVERS-3617 (mongodb/specifications#1974). OpenTelemetry backends group and alert on span attributes, so an error class carried only by the exception event cannot be queried at the span level.Changes in this PR
end_command_span_failuresetserror.typeto the server error code when the reply carries one, otherwise to the exception's qualified class name._set_exception_attributesreturns the computedexception.typeso the fallback reuses it.error.type, because an operation can succeed through a retry even when a command failed.error_type.jsonspec fixture.Test Plan
error_type.jsoncovers a server error, whereerror.typematchesdb.response.status_code, and a closed connection, where it falls back to the class name.ConnectionFailureandNetworkTimeout. Both fail if the fallback branch is removed.error.typemirrorsdb.response.status_code.just lintandjust typingare clean.otel-rhel8patch #10898 passed with 0 failed tasks.Checklist
Checklist for Author
Checklist for Reviewer