Skip to content

Commit

Permalink
charm tracing fix (#277)
Browse files Browse the repository at this point in the history
* charm tracing fix

* import
  • Loading branch information
PietroPasotti authored Jan 15, 2025
1 parent 54c6860 commit 5a4cec2
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

0 comments on commit 5a4cec2

Please sign in to comment.