Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charm tracing fix #277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from charms.observability_libs.v1.cert_handler import CertHandler
from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider
from charms.tempo_k8s.v1.charm_tracing import trace_charm
from charms.tempo_k8s.v2.tracing import TracingEndpointRequirer
from charms.tempo_k8s.v2.tracing import TracingEndpointRequirer, charm_tracing_config
from charms.traefik_k8s.v2.ingress import IngressPerAppRequirer
from config_builder import ConfigBuilder, ConfigError
from ops.charm import ActionEvent, CharmBase
Expand All @@ -55,8 +55,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 @@ -159,6 +159,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 @@ -579,18 +582,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)
Loading