PYTHON-6045 Add error.type OpenTelemetry command span attribute - #2999
Closed
blink1073 wants to merge 2 commits into
Closed
PYTHON-6045 Add error.type OpenTelemetry command span attribute#2999blink1073 wants to merge 2 commits into
blink1073 wants to merge 2 commits into
Conversation
4 tasks
blink1073
force-pushed
the
PYTHON-5947-otel-4-getmore
branch
from
August 20, 2026 02:11
1c2cd2b to
dba0bf0
Compare
Implements DRIVERS-3617: 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.
blink1073
force-pushed
the
PYTHON-5947-otel-5-error-type
branch
from
August 20, 2026 11:10
6805066 to
5583231
Compare
Member
Author
|
Superseded by #3000, which has its head branch on this repo rather than my fork so it can join the stack in GitHub's UI (fork PRs cannot be stacked). Same commits, same base. |
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 the
error.typecommand span attribute specified by DRIVERS-3617 (mongodb/specifications#1974).error.typeis the span-level dimension OpenTelemetry backends group and alert on; carried only as the exception event'sexception.type, error class cannot be aggregated on.Changes in this PR
end_command_span_failuresetserror.typeon command spans: the server error code when one is present (mirroringdb.response.status_code), otherwise the exception's qualified class name._set_exception_attributesreturns the computedexception.typeso the fallback reuses it.error.type, per the spec: an operation can succeed via retry even when an underlying command failed.error_type.jsonspec fixture.Test Plan
test/open_telemetry/operation/error_type.json: server error (error.typematchesdb.response.status_code) and closed connection (db.response.status_codeabsent,error.typeis the class name). Both assert the operation span has noerror.type.ConnectionFailureandNetworkTimeout. Verified both fail if the fallback branch is removed.error.typemirrorsdb.response.status_code.just lintandjust typingclean.otel-rhel8: #10898 — success, 0 failed tasks.Checklist
Checklist for Author
Checklist for Reviewer