Open
Conversation
|
|
||
| def _set_error_on_span(span, exception): | ||
| if isinstance(exception, issues.Error) and exception.status is not None: | ||
| error_type = exception.status.name |
There was a problem hiding this comment.
error_type мы проставляем здесь как transport или ydb_error
Это можно определить по status code исключения.
"error.type", ydbException.Code
is StatusCode.ClientTransportUnknown
or StatusCode.ClientTransportUnavailable
or StatusCode.ClientTransportTimeout
or StatusCode.ClientTransportResourceExhausted
or StatusCode.ClientTransportUnimplemented
? "transport_error"
: "ydb_error"
vgvoleg
requested changes
Mar 27, 2026
| options={"bdist_wheel": {"universal": True}}, | ||
| extras_require={ | ||
| "yc": ["yandexcloud", ], | ||
| "tracing": ["opentelemetry-api>=1.0.0", "opentelemetry-sdk>=1.0.0"], |
Collaborator
There was a problem hiding this comment.
let's rename it to opentelemetry, we already have a tracing module and ydb[tracing] looks confusing
|
|
||
| with ydb.QuerySessionPool(driver) as pool: | ||
| with tracer.start_as_current_span("sync-example"): | ||
| pool.execute_with_retries("SELECT 1") |
Collaborator
There was a problem hiding this comment.
we should add a dedicated page to our docs (docs folder) that describes how it works
| if _enabled: | ||
| return | ||
|
|
||
| _tracer = trace.get_tracer("ydb.sdk") |
Collaborator
There was a problem hiding this comment.
is it a good idea? what do you think about an ability to pass already existed tracer to this method?
There was a problem hiding this comment.
I think that tracer is optional parameter
enable_tracing(tracer = null)
tracer ?? trace.get_tracer("ydb.sdk")
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.
Pull request type
What is the current behavior?
The YDB Python SDK does not provide built-in OpenTelemetry tracing support. There is legacy integration with OpenTracing API which uses the deprecated standard.
Issue Number: N/A
What is the new behavior?
Adds OpenTelemetry tracing support to the YDB Python SDK. When enabled via enable_tracing(), the SDK automatically creates spans for key operations:
Each span includes standard attributes: db.system.name, db.namespace, server.address, server.port, ydb.session.id, ydb.node.id, ydb.tx.id.
W3C Trace Context (traceparent) is automatically propagated in gRPC metadata, enabling end-to-end distributed tracing between client and YDB server. Execute spans cover the full operation lifecycle, including streaming result iteration — not just the initial gRPC call. Errors are recorded on spans with error.type, db.response.status_code, and exception events.
Tracing is opt-in (pip install ydb[tracing] + enable_tracing()). Without it, the SDK behavior is unchanged — all tracing code paths are no-op.
Other information