tempo-coordinator-k8s

Tempo Coordinator K8s

Channel Revision Published Runs on
2/stable 134 13 Nov 2025
Ubuntu 24.04
2/candidate 134 13 Nov 2025
Ubuntu 24.04
2/edge 135 13 Nov 2025
Ubuntu 24.04
dev/edge 140 16 Feb 2026
Ubuntu 24.04
1/stable 79 16 May 2025
Ubuntu 22.04
1/candidate 79 16 May 2025
Ubuntu 22.04
1/beta 79 16 May 2025
Ubuntu 22.04
1/edge 79 08 May 2025
Ubuntu 22.04
juju deploy tempo-coordinator-k8s --channel 2/stable
Show information

Platform:

charms.tempo_coordinator_k8s.v0.charm_tracing

This charm library contains utilities to instrument your Charm with opentelemetry tracing data collection.

WARNING this library is deprecated and will be discontinued in 27.04. Instead, please use the new ops[tracing] library.

See this migration guide: https://discourse.charmhub.io/t/18076 See this deprecation announcement: https://discourse.charmhub.io/t/19669


def is_enabled()

Description

Whether charm tracing is enabled. None

def charm_tracing_disabled()

Contextmanager to temporarily disable charm tracing.

Description

For usage in tests.

def get_current_span()

Return the currently active Span, if there is one, else None.

Description

If you'd rather keep your logic unconditional, you can use opentelemetry.trace.get_current_span, which will return an object that behaves like a span but records no data.

class TracingError

Description

Base class for errors raised by this module. None

class UntraceableObjectError

Description

Raised when an object you're attempting to instrument cannot be autoinstrumented. None

def trace_charm(
    tracing_endpoint: str,
    server_cert,
    service_name,
    extra_types,
    buffer_max_events: int,
    buffer_max_size_mib: int,
    buffer_path
)

Autoinstrument the decorated charm with tracing telemetry.

Arguments

tracing_endpoint

name of a method, property or attribute on the charm type that returns an optional (fully resolvable) tempo url to which the charm traces will be pushed. If None, tracing will be effectively disabled.

server_cert

name of a method, property or attribute on the charm type that returns an optional absolute path to a CA certificate file to be used when sending traces to a remote server. If it returns None, an insecure connection will be used. To avoid errors in transient situations where the endpoint is already https but there is no certificate on disk yet, it is recommended to disable tracing (by returning None from the tracing_endpoint) altogether until the cert has been written to disk.

service_name

service name tag to attach to all traces generated by this charm. Defaults to the juju application name this charm is deployed under.

extra_types

pass any number of types that you also wish to autoinstrument. For example, charm libs, relation endpoint wrappers, workload abstractions, ...

buffer_max_events

max number of events to save in the buffer. Set to 0 to disable buffering.

buffer_max_size_mib

max size of the buffer file. When exceeded, spans will be dropped. Minimum 10MiB.

buffer_path

path to buffer file to use for saving buffered spans.

Description

Use this function to get out-of-the-box traces for all events emitted on this charm and all method calls on instances of this class.

Usage:

from charms.tempo_coordinator_k8s.v0.charm_tracing import trace_charm from charms.tempo_coordinator_k8s.v0.tracing import TracingEndpointRequirer from ops import CharmBase

@trace_charm( tracing_endpoint="tempo_otlp_http_endpoint", ) class MyCharm(CharmBase):

def __init__(self, framework: Framework):
    ...
    self.tracing = TracingEndpointRequirer(self)

@property
def tempo_otlp_http_endpoint(self) -> Optional[str]:
    if self.tracing.is_ready():
        return self.tracing.otlp_http_endpoint()
    else:
        return None

Methods

def trace_type(cls: _T)

Set up tracing on this class.

Description

Use this decorator to get out-of-the-box traces for all method calls on instances of this class. It assumes that this class is only instantiated after a charm type decorated with @trace_charm has been instantiated.

def trace_method(
    method: _F,
    name
)

Trace this method.

Description

A span will be opened when this method is called and closed when it returns.

def trace_function(
    function: _F,
    name
)

Trace this function.

Description

A span will be opened when this function is called and closed when it returns.

def trace(obj)

Trace this object and send the resulting spans to Tempo.

Description

It will dispatch to trace_type if the decorated object is a class, otherwise trace_function.