Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Introduce `ydb.observability` — vendor-neutral tracing entrypoint with a `TracingProvider` interface; `enable_tracing(provider)` accepts any implementation (custom or OpenTelemetry) and replaces the previously installed one. The SDK core no longer imports `opentelemetry`, so tracing can be enabled without the OpenTelemetry packages by supplying a custom provider

## 3.30.0 ##
* Query session attach stream handles `NodeShutdown` and `SessionShutdown` session hints: on `NodeShutdown` the session's node connection is pessimized and the session is retired, on `SessionShutdown` the session is retired without touching the node
* Honor the `max_bytes` parameter in topic reader `receive_batch`/`receive_batch_with_tx` (previously accepted but silently ignored); add `max_bytes` to the async reader as well
Expand Down
42 changes: 40 additions & 2 deletions docs/opentelemetry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,46 @@ and **before** creating a ``Driver``:
``enable_tracing()`` accepts an optional ``tracer`` argument. If omitted, the SDK
obtains a tracer named ``"ydb.sdk"`` from the global tracer provider.

Repeated calls to ``enable_tracing()`` do nothing until you call ``disable_tracing()``,
which removes hooks so you can reconfigure or turn instrumentation off.
Repeated calls to ``enable_tracing()`` replace the previously installed provider, so
it is safe to reconfigure at any time. Call ``disable_tracing()`` to remove the hooks
entirely and return the SDK to its no-op default.


Custom Providers (Vendor-Neutral API)
-------------------------------------

OpenTelemetry is only one possible backend. The SDK exposes a small tracing
interface in :mod:`ydb.observability` that any custom implementation can satisfy.
This is how ``ydb.opentelemetry.enable_tracing`` is implemented — it constructs an
:class:`~ydb.opentelemetry.plugin.OtelTracingProvider` and hands it to
:func:`ydb.observability.enable_tracing`.

.. code-block:: python

from ydb.observability import (
NoopSpan,
Span,
TracingProvider,
enable_tracing,
disable_tracing,
)

class MyProvider:
def create_span(self, name, attributes=None, kind=None) -> Span:
# return your own Span implementation
return NoopSpan()

def get_trace_metadata(self):
# (key, value) pairs to attach to outgoing gRPC calls
return ()

enable_tracing(MyProvider())
# ... use the SDK ...
disable_tracing()

``enable_tracing(provider)`` replaces whichever provider was installed before
(OpenTelemetry, another custom one, or the built-in Noop). Passing ``None`` is
equivalent to ``disable_tracing()``.


What Is Instrumented
Expand Down
Loading
Loading