---
title: Charmhub | Deploy Tempo Coordinator K8s using Charmhub - The Open Operator
  Collection
description: Deploy the latest version of Tempo Coordinator K8s as a Kubernetes Operator
  on any cloud.
url: https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing
---

# Tempo Coordinator K8s

[Canonical Observability](https://charmhub.io/publisher/observability "View all packages from Canonical Observability")

* [Canonical Observability](https://charmhub.io/publisher/observability "View all packages from Canonical Observability")

Platform:

2.10/stable 162

```
juju deploy tempo-coordinator-k8s --channel 2.10/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#drawer)

## charms.tempo\_coordinator\_k8s.v0.charm\_tracing

* [*Docstrings*Docstrings](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing)
  [*Code*Source code](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.tempo_coordinator_k8s.v0.charm_tracing
    ```

    [Download charm\_tracing.py](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing/download)
  + *Last updated* 24 Jun 2026
  + *Revision* Library version 0.14

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

---

Index

* [def is\_enabled(
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#is_enabled)
* [def charm\_tracing\_disabled(
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#charm_tracing_disabled)
* [def get\_current\_span(
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#get_current_span)
* [class TracingError](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#tracingerror)
* [class UntraceableObjectError](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#untraceableobjecterror)
* [def trace\_charm(
  tracing\_endpoint,
  server\_cert,
  service\_name,
  extra\_types,
  buffer\_max\_events,
  buffer\_max\_size\_mib,
  buffer\_path
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#trace_charm)
* [def trace\_type(
  cls
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#trace_type)
* [def trace\_method(
  method,
  name
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#trace_method)
* [def trace\_function(
  function,
  name
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#trace_function)
* [def trace(
  obj
  )](https://charmhub.io/tempo-coordinator-k8s/libraries/charm_tracing#trace)

#### 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`.
