From 5a4cec2b384ba948d835017f9d14200e0a17e757 Mon Sep 17 00:00:00 2001 From: PietroPasotti Date: Wed, 15 Jan 2025 14:21:21 +0100 Subject: [PATCH] charm tracing fix (#277) * charm tracing fix * import --- src/charm.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/charm.py b/src/charm.py index e1ed666..7d7e311 100755 --- a/src/charm.py +++ b/src/charm.py @@ -30,7 +30,7 @@ from charms.observability_libs.v1.cert_handler import CertHandler from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider from charms.tempo_coordinator_k8s.v0.charm_tracing import trace_charm -from charms.tempo_coordinator_k8s.v0.tracing import TracingEndpointRequirer +from charms.tempo_coordinator_k8s.v0.tracing import TracingEndpointRequirer, charm_tracing_config from charms.traefik_k8s.v2.ingress import IngressPerAppRequirer from ops.charm import ActionEvent, CharmBase from ops.main import main @@ -56,8 +56,8 @@ @trace_charm( - tracing_endpoint="tracing_endpoint", - server_cert="server_ca_cert_path", + tracing_endpoint="_charm_tracing_endpoint", + server_cert="_charm_tracing_ca_cert", extra_types=( AlertmanagerProvider, CertHandler, @@ -161,6 +161,9 @@ def __init__(self, *args): ], ) self._tracing = TracingEndpointRequirer(self, protocols=["otlp_http"]) + self._charm_tracing_endpoint, self._charm_tracing_ca_cert = charm_tracing_config( + self._tracing, self._ca_cert_path + ) self.catalog = CatalogueConsumer(charm=self, item=self._catalogue_item) @@ -604,18 +607,6 @@ def _external_url(self) -> str: def _scheme(self) -> str: return "https" if self._is_tls_ready() else "http" - @property - def tracing_endpoint(self) -> Optional[str]: - """Otlp http endpoint for charm instrumentation.""" - if self._tracing.is_ready(): - return self._tracing.get_endpoint("otlp_http") - return None - - @property - def server_ca_cert_path(self) -> Optional[str]: - """Server CA certificate path for tls tracing.""" - return self._ca_cert_path if self.server_cert.enabled else None - if __name__ == "__main__": main(AlertmanagerCharm)