Skip to main content

The charmlibs.interfaces.otlp package.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

charmlibs_interfaces_otlp-0.5.0.tar.gz (55.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

charmlibs_interfaces_otlp-0.5.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file charmlibs_interfaces_otlp-0.5.0.tar.gz.

File metadata

File hashes

Hashes for charmlibs_interfaces_otlp-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a2a963f32235afe8ffac17f04ad15e6da6dadd0f00aeaf687387214e33fde987
MD5 c190cf382aab7d876329cb83cfc93680
BLAKE2b-256 3f5242f01198ae391dfffbcd27cc4dc031e6189d2be299e37b18f56e16d237e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmlibs_interfaces_otlp-0.5.0.tar.gz:

Publisher: publish.yaml on canonical/charmlibs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file charmlibs_interfaces_otlp-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for charmlibs_interfaces_otlp-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9719475bd8cc8b1a7f9a14c8565686c77e8b9c643ca7759cb63ef8783d964e06
MD5 2be7372777ca234a35b1a3478d2d1e1f
BLAKE2b-256 aa4da2b6398e3072f452ee7e247e093a3bcc3483147a408e78c2f5d562df2a8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmlibs_interfaces_otlp-0.5.0-py3-none-any.whl:

Publisher: publish.yaml on canonical/charmlibs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page