feat: send/receive relations for forwarding OTLP metrics #131
Merged
MichaelThamm merged 27 commits intomainfrom Feb 12, 2026
Merged
feat: send/receive relations for forwarding OTLP metrics #131MichaelThamm merged 27 commits intomainfrom
MichaelThamm merged 27 commits intomainfrom
Conversation
MichaelThamm
commented
Jan 30, 2026
MichaelThamm
commented
Jan 30, 2026
3 tasks
sed-i
reviewed
Jan 31, 2026
c590828 to
0839d50
Compare
Merged
3 tasks
MichaelThamm
commented
Feb 5, 2026
MichaelThamm
commented
Feb 6, 2026
sed-i
reviewed
Feb 6, 2026
sed-i
approved these changes
Feb 6, 2026
Contributor
Author
|
@copilot leave the functionality intact, but improve the code |
|
@MichaelThamm I've opened a new pull request, #189, to work on those changes. Once the pull request is ready, I'll request review from you. |
3 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
dev/betaand let IS test itIssue
Being able to send metrics cross-model is currently not possible and a feature was attempted in:
However, we dropped this since OTLP can achieve the same thing and is collector-native.
Tandem ingress loadbalancing issue:
Solution
Tandem PR:
Since the workloads are handling the serving and receiving of the OTLP data, the databag only needs to communicate a few things:
It is the charm’s responsibility to handle the endpoint information accordingly. For example, writing the OTLP endpoint to config file. A concrete example is the
opentelemetry-collector-k8scharm needs to enable receivers, exporters, and pipelines in its config based on OTLP requirements.Note
Not all OTLP servers can handle all telemetries and all protocols, e.g. Loki only supports logs via HTTP.
We can encapsulate all information with 2 endpoints:
Otelcol-k8s charm will use the k8s service address when providing endpoints to load balance across all pipelines.
Important
The VM charm cannot do this so it must provide each unit address since it has no "service" address like in k8s, unless ingressed. This is a future TODO for when we implement the
receive-otlpendpoint for the VM charm.Databags
The provider offers in app data:
{ "grpc": { "endpoint": "http://provider-0.endpoint:4317", "telemetries": ["logs", "metrics"], }, "http": {"endpoint": "http://provider-0.endpoint:4318", "telemetries": ["logs"]}, }and the consumer does not offer anything:
{}The consumer aggregates all the OtlpEndpoints from all relations in this format:
{ 123: { "grpc": { "endpoint": "http://provider-0.endpoint:4317", "telemetries": ["logs", "metrics"], }, "http": {"endpoint": "http://provider-0.endpoint:4318", "telemetries": ["logs"]}, }, 456: {...}, }Pydantic models
The models validate that only supported protocols and telemetries are defined in the databag.
PR Scope
This feature PR for OTLP is incomplete because it enables forwarding only
metricstelemetry data between 2 otel-collector charms. Other telemetries can easily be added by updating the provider usage:The
otlp.pyfile is local to otelcol and is not a published lib. The plan is to eventually move this tocharmlibs. This means that, for now, only two otel-collector charms can communicate OTLP.Ingress
I added a test that we can access the OTLP HTTP receiver through ingress. Since the Traefik charm can not handle gRPC, otel-collector will currently only support OTLP over HTTP.
TLS
We have an existing config builder feature which adds TLS to all receivers. OTLP exporter offers a
tls:insecureconfig. We toggle this config based on the state of the scheme (httpvs.https) of the provider/server address.We could support mTLS in the future:
Context
Testing Instructions
I added integration tests for:
test_ingress.py::test_push_otlp_logs_through_ingresstest_otlp.py::test_otlp_forwarding_insecuretest_otlp.py::test_otlp_forwarding_secureI added unit tests for:
test_config_manager.py::test_add_otlp_forwardingtest_ingress.py::test_otlp_url_in_databag(ingress)test_otlp.py::test_provider_app_data_raises_validation_errortest_otlp.py::test_send_otlp_multiple_relations_and_unitstest_otlp.py::test_send_otlp_invalidtest_otlp.py::test_receive_otlptest_otlp.py::test_cyclic_relationsManual
Testing for OTLP forwarding between VM to K8s otelcol is documented in:
Upgrade Notes