caikit.runtime.trace

The trace module holds utilities for tracing runtime requests.

Attributes

log

error

_TRACE_MODULE

_PROPAGATE_MODULE

_CONTEXT_TRACER_ATTR

Classes

_NoOpProxy

This dummy class is infinitely callable and will return itself on any

Functions

configure()

Configure all tracing based on config and installed packages

get_tracer(→ Union[_NoOpProxy, opentelemetry.trace.Tracer])

Get a tracer that can be called with the opentelemetry API. If not

get_trace_context(→ Optional[opentelemetry.Context])

Extract the trace context from the runtime request context

set_tracer(runtime_context, tracer)

Helper to decorate a runtime context with a tracer if enabled

start_child_span(...)

Context manager that wraps start_as_current_span if enabled and tries to

_load_tls_secret(→ bytes)

If the config value points at a file, load it, otherwise assume it's an

Module Contents

caikit.runtime.trace.log[source]
caikit.runtime.trace.error
caikit.runtime.trace._TRACE_MODULE = None
caikit.runtime.trace._PROPAGATE_MODULE = None
caikit.runtime.trace.configure()[source]

Configure all tracing based on config and installed packages

caikit.runtime.trace.get_tracer(name: str) _NoOpProxy | opentelemetry.trace.Tracer[source]

Get a tracer that can be called with the opentelemetry API. If not configured, this will be a No-Op Proxy.

caikit.runtime.trace.get_trace_context(runtime_context: caikit.core.data_model.runtime_context.RuntimeServerContextType) opentelemetry.Context | None[source]

Extract the trace context from the runtime request context

caikit.runtime.trace.set_tracer(runtime_context: caikit.core.data_model.runtime_context.RuntimeServerContextType, tracer: opentelemetry.trace.Tracer)[source]

Helper to decorate a runtime context with a tracer if enabled

caikit.runtime.trace.start_child_span(runtime_context: caikit.core.data_model.runtime_context.RuntimeServerContextType, span_name: str) Iterable[opentelemetry.trace.Span | _NoOpProxy][source]

Context manager that wraps start_as_current_span if enabled and tries to fetch a parent span from the runtime context

caikit.runtime.trace._CONTEXT_TRACER_ATTR = '__tracer__'
caikit.runtime.trace._load_tls_secret(tls_config_val: str) bytes[source]

If the config value points at a file, load it, otherwise assume it’s an inline string

class caikit.runtime.trace._NoOpProxy[source]

This dummy class is infinitely callable and will return itself on any getattr call or context enter/exit. It can be used to provide a no-op stand-in for all of the classes in the opentelemetry ecosystem when they are either not configured or not available.

__getattr__(*_, **__)[source]
__call__(*_, **__) _NoOpProxy[source]
__enter__(*_, **__) _NoOpProxy[source]
__exit__(*_, **__)[source]