Skip to main content

charmlibs.interfaces.otlp

The otlp library.

OTLP integration library for Juju charms, providing OTLP endpoint information for communicating OTLP data and associated Loki and Prometheus rules.

Features

  • Provider/Requirer pattern: Enables charms to share OTLP endpoint information and rules content
  • Define endpoint support: Providers and requirers define what OTLP protocols and telemetries they support.
  • Rules interface: Add rules to a 'RuleStore' object and provide that to the requirer for publishing.
  • Automatic topology injection: Inject Juju topology labels into rule expressions and labels with metadata if the labels are not already labeled.

Getting started

To install, add charmlibs-interfaces-otlp to your Python dependencies. Then in your Python code, import as:

from charmlibs.interfaces.otlp import OtlpProvider, OtlpRequirer

Provider Side

from charmlibs.interfaces.otlp import OtlpProvider

class MyOtlpServer(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.framework.observe(self.on.ingress_ready, self._publish_endpoints)
        self.framework.observe(self.on.update_status, self._access_rules)

    def _publish_endpoints(self, event):
        OtlpProvider(self).add_endpoint(
            protocol="grpc",
            endpoint="https://my-app.ingress:4317",
            telemetries=["logs", "metrics"],
        ).add_endpoint(
            protocol="http",
            endpoint="https://my-app.ingress:4318",
            telemetries=["traces"],
        ).publish()

    def _access_rules(self, event):
        for relation_id, rule_store in OtlpProvider(self).rules.items():
            pass  # do something with rule_store.logql and/or rule_store.promql

Requirer Side

from charmlibs.interfaces.otlp import OtlpRequirer, RulesStore

class MyOtlpSender(CharmBase):
    def __init__(self, framework: ops.Framework):
        super().__init__(framework)
        self.framework.observe(self.on.update_status, self._access_endpoints)
        self.framework.observe(self.on.update_status, self._publish_rules)

    def _publish_rules(self, _: ops.EventBase):
        rules = (
            RuleStore(JujuTopology.from_charm(self))
            .add_logql(SINGLE_LOGQL_ALERT, group_name='test_logql_alert')
            .add_promql(SINGLE_PROMQL_RECORD, group_name='test_promql_record')
            .add_logql(OFFICIAL_LOGQL_RULES)
        )
        OtlpRequirer(self, rules=rules).publish()

    def _access_endpoints(self, _: ops.EventBase):
        OtlpRequirer(
            self,
            protocols=["grpc", "http"],
            telemetries=["logs", "metrics", "traces"],
        ).endpoints

Documentation

For complete documentation, see the charmlibs documentation.

Contributing

See CONTRIBUTING.md in the repository root.

Metadata

Release files for charmlibs-interfaces-otlp 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for charmlibs-interfaces-otlp 0.6.0
File Size Uploaded Provenance Actions
charmlibs_interfaces_otlp-0.6.0.tar.gz 56.4 kB With provenance Details for charmlibs_interfaces_otlp-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for charmlibs-interfaces-otlp 0.6.0
File Interpreter ABI Platform Actions
charmlibs_interfaces_otlp-0.6.0-py3-none-any.whl Python 3 none any Details for charmlibs_interfaces_otlp-0.6.0-py3-none-any.whl

Total release size: 69.1 kB

Release files / charmlibs_interfaces_otlp-0.6.0.tar.gz

Download URL charmlibs_interfaces_otlp-0.6.0.tar.gz
Size 56.4 kB
Tags Source
SHA-256 checksum
How to use checksums
17622c234c69ca1f30de2a2c829de58a72eaef2c312c8f3bc55c6cad7c274fb4
BLAKE2b-256 checksum
How to use checksums
66508847288a594c4d01de0f0e8e5f53209eab7ce64c6ce0180d758325b1a4b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / charmlibs_interfaces_otlp-0.6.0-py3-none-any.whl

Download URL charmlibs_interfaces_otlp-0.6.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74f02ec74356c79812bba1c86974ff582bb860c3f055568f1683482f9b28c33b
BLAKE2b-256 checksum
How to use checksums
7faf5939ebed6950f9f24ac391d0103b49f29688cdf4476a34a40cefb79488d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for charmlibs-interfaces-otlp 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for charmlibs_interfaces_otlp-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page