Skip to content

use charm-tracing-config #585

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

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
18 changes: 11 additions & 7 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider
from charms.rolling_ops.v0.rollingops import RollingOpsManager
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 ops import EventBase, RelationBrokenEvent, RelationCreatedEvent
from ops.charm import RelationChangedEvent, UpdateStatusEvent
from ops.model import (
Expand Down Expand Up @@ -89,6 +89,7 @@
SERVER_CONFIG_USERNAME,
TRACING_PROTOCOL,
TRACING_RELATION_NAME,
CHARM_CA_CERT_PATH,
)
from k8s_helpers import KubernetesHelpers
from log_rotate_manager import LogRotateManager
Expand All @@ -104,7 +105,8 @@


@trace_charm(
tracing_endpoint="tracing_endpoint",
tracing_endpoint="charm_tracing_endpoint",
server_cert="charm_tracing_server_cert",
extra_types=(
GrafanaDashboardProvider,
KubernetesHelpers,
Expand Down Expand Up @@ -197,11 +199,13 @@ def __init__(self, *args):
self, protocols=[TRACING_PROTOCOL], relation_name=TRACING_RELATION_NAME
)

@property
def tracing_endpoint(self) -> Optional[str]:
"""Otlp http endpoint for charm instrumentation."""
if self.tracing.is_ready():
return self.tracing.get_endpoint(TRACING_PROTOCOL)
self.charm_tracing_endpoint, self.charm_tracing_server_cert = charm_tracing_config(
self.tracing,
# Fixme: this None here means that if Tempo is related to a tls certificate provider,
# and mysql is getting an https endpoint from tempo, you will get a big fat warning
# and tracing will be disabled as tempo will reject non-https connections.
# https://github.com/canonical/mysql-k8s-operator/issues/586
None)

@property
def _mysql(self) -> MySQL:
Expand Down
Loading