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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file charmlibs_interfaces_otlp-0.4.0.tar.gz.
File metadata
- Download URL: charmlibs_interfaces_otlp-0.4.0.tar.gz
- Upload date:
- Size: 54.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c96863b06f3c36421366b92de6c7c42925648cf0bf4151c01cf053203e4f712
|
|
| MD5 |
4aab84241bd1d9fcc6d06f34425f9db3
|
|
| BLAKE2b-256 |
6c8eab06cdd353244b3787a5aac2b3a7e8911ce6a3f79dd63d31bfb691eee069
|
Provenance
The following attestation bundles were made for charmlibs_interfaces_otlp-0.4.0.tar.gz:
Publisher:
publish.yaml on canonical/charmlibs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
charmlibs_interfaces_otlp-0.4.0.tar.gz -
Subject digest:
0c96863b06f3c36421366b92de6c7c42925648cf0bf4151c01cf053203e4f712 - Sigstore transparency entry: 1203559104
- Sigstore integration time:
-
Permalink:
canonical/charmlibs@1503ba41c93f94853cec8f9fda45281ef032df07 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1503ba41c93f94853cec8f9fda45281ef032df07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file charmlibs_interfaces_otlp-0.4.0-py3-none-any.whl.
File metadata
- Download URL: charmlibs_interfaces_otlp-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c116ddacf8f66269d9b3e9fecf8daa2d8a95e90e9489e9fc4fc305fd3d7f17cf
|
|
| MD5 |
891ab00fd51c37118bb66f0e6f62fa3c
|
|
| BLAKE2b-256 |
4f29f3dd30821137adf1f421bfd06cd92feae0ffcfe5cad20fa8db4046c331e8
|
Provenance
The following attestation bundles were made for charmlibs_interfaces_otlp-0.4.0-py3-none-any.whl:
Publisher:
publish.yaml on canonical/charmlibs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
charmlibs_interfaces_otlp-0.4.0-py3-none-any.whl -
Subject digest:
c116ddacf8f66269d9b3e9fecf8daa2d8a95e90e9489e9fc4fc305fd3d7f17cf - Sigstore transparency entry: 1203559107
- Sigstore integration time:
-
Permalink:
canonical/charmlibs@1503ba41c93f94853cec8f9fda45281ef032df07 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1503ba41c93f94853cec8f9fda45281ef032df07 -
Trigger Event:
push
-
Statement type: