---
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/tempo_api
---

# 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/tempo_api#drawer)

## charms.tempo\_coordinator\_k8s.v0.tempo\_api

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

    Fetch library

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

    [Download tempo\_api.py](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api/download)
  + *Last updated* 25 Aug 2025
  + *Revision* Library version 0.4

tempo\_api.

This library implements endpoint wrappers for the tempo-api interface. The tempo-api interface is used to
transfer information about an instance of Tempo, such as how to access and uniquely identify it. Typically, this is
useful for charms that operate a Tempo instance to give other applications access to
[Tempo's HTTP API](https://grafana.com/docs/tempo/latest/api_docs/).

##### Usage

###### Requirer

TempoApiRequirer is a wrapper for pulling data from the tempo-api interface. To use it in your charm:

* observe the relation-changed event for this relation wherever your charm needs to use this data (this endpoint wrapper
  DOES NOT automatically observe any events)
* wherever you need access to the data, call `TempoApiRequirer(...).get_data()`

An example implementation is:

```
class FooCharm(CharmBase):
    def __init__(self, framework):
        super().__init__(framework)

        tempo_api = TempoApiRequirer(self.model.relations, "tempo-api")

        self.framework.observe(
            self.on["tempo-api"].relation_changed, self._on_tempo_api_changed
        )

    def do_something_with_metadata(self):
        data = tempo_api.get_data()
        ...
```

Where you also add relation to your `charmcraft.yaml` or `metadata.yaml` (note that TempoApiRequirer is designed for
relating to a single application and must be used with limit=1 as shown below):

```
requires:
  tempo-api:
    limit: 1
    interface: tempo_api
```

###### Provider

TempoApiProvider is a wrapper for publishing data to charms related using the tempo-api interface. Note that
`TempoApiProvider` *does not* manage any events, but instead provides a `publish` method for sending data to
all related applications. Triggering `publish` appropriately is left to the charm author, although generally you want
to do this at least during the `relation_joined` and `leader_elected` events. An example implementation is:

```
class FooCharm(CharmBase):
    def __init__(self, framework):
        super().__init__(framework)
        self.tempo_api = TempoApiProvider(
            relations=self.model.relations,
            relation_name="tempo-api",
            app=self.app,
        )

        self.framework.observe(self.on.leader_elected, self.do_something_to_publish)
        self.framework.observe(
            self._charm.on["tempo-api"].relation_joined, self.do_something_to_publish
        )
        self.framework.observe(
            self.on.some_event_that_changes_tempos_url, self.do_something_to_publish
        )

    def do_something_to_publish(self, e):
        self.tempo_api.publish(...)
```

Where you also add the following to your `charmcraft.yaml` or `metadata.yaml`:

```
provides:
  tempo-api:
    interface: tempo_api
```

---

Index

* [class TempoApiUrls](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapiurls)
* [class TempoApiAppData](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapiappdata)
* [class TempoApiRequirer](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapirequirer)
* + [def \_\_init\_\_(
    self,
    relation\_mapping,
    relation\_name)](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapirequirer-__init__)
* + [def relations(
    self)](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapirequirer-relations)
* + [def get\_data(
    self)](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapirequirer-get_data)
* [class TempoApiProvider](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapiprovider)
* + [def \_\_init\_\_(
    self,
    relation\_mapping,
    relation\_name,
    app)](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapiprovider-__init__)
* + [def relations(
    self)](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapiprovider-relations)
* + [def publish(
    self,
    direct\_url\_http,
    direct\_url\_grpc,
    ingress\_url\_http,
    ingress\_url\_grpc)](https://charmhub.io/tempo-coordinator-k8s/libraries/tempo_api#tempoapiprovider-publish)

#### class TempoApiUrls

Description

Data model for urls Tempo offers for query access, for a given protocol. None

#### class TempoApiAppData

Description

Data model for the tempo-api interface. None

#### class TempoApiRequirer

Description

Endpoint wrapper for the requirer side of the tempo-api relation. None

Methods

TempoApiRequirer.
\_\_init\_\_(

*self*

,
relation\_mapping: RelationMapping

,
relation\_name: str
)

Initialize the TempoApiRequirer object.

Arguments

relation\_mapping

The RelationMapping of a charm (typically `self.model.relations` from within a charm
object).

relation\_name

The name of the wrapped relation.

Description

This object is for accessing data from relations that use the tempo-api interface. It **does not**
autonomously handle the events associated with that relation. It is up to the charm using this object to
observe those events as they see fit. Typically, that charm should observe this relation's relation-changed
event.

This object requires the relation has limit=1 set in charmcraft.yaml, otherwise it will raise a ValueError
exception.

TempoApiRequirer.
relations(

*self*
)

Description

Return the relation instances for applications related to us on the monitored relation. None

TempoApiRequirer.
get\_data(

*self*
)

Return data from the relation.

Description

Returns None if no data is available, either because no applications are related to us, or because the related
application has not sent data. To distinguish between these cases, check if
len(tempo\_api\_requirer.relations)==0.

#### class TempoApiProvider

Description

The provider side of the tempo-api relation. None

Methods

TempoApiProvider.
\_\_init\_\_(

*self*

,
relation\_mapping: RelationMapping

,
relation\_name: str

,
app: Application
)

Initialize the TempoApiProvider object.

Arguments

relation\_mapping

The RelationMapping of a charm (typically `self.model.relations` from within a charm
object).

app

This application.

relation\_name

The name of the wrapped relation.

Description

This object is for serializing and sending data to a relation that uses the tempo-api interface - it does
not automatically observe any events for that relation. It is up to the charm using this to call publish when
it is appropriate to do so, typically on at least the charm's leader\_elected event and this relation's
relation\_joined event.

TempoApiProvider.
relations(

*self*
)

Description

Return the applications related to us under the monitored relation. None

TempoApiProvider.
publish(

*self*

,
direct\_url\_http

,
direct\_url\_grpc

,
ingress\_url\_http

,
ingress\_url\_grpc
)

Post tempo-api to all related applications.

Arguments

direct\_url\_http

The cluster-internal URL at which this application can be reached for an http connection.
Typically, this is a Kubernetes FQDN like name.namespace.svc.cluster.local for
connecting to the tempo http api from inside the cluster, with scheme and maybe port.

direct\_url\_grpc

The cluster-internal URL at which this application can be reached for a grpc connection.
Typically, this is a Kubernetes FQDN like name.namespace.svc.cluster.local for
connecting to the tempo grpc api from inside the cluster, with scheme.

ingress\_url\_http

The non-internal URL at which this application can be reached for an http connection.
Typically, this is an ingress URL.

ingress\_url\_grpc

The non-internal URL at which this application can be reached for a grpc connection.
Typically, this is an ingress URL.

Description

This method writes to the relation's app data bag, and thus should never be called by a unit that is not the
leader otherwise ops will raise an exception.
