Skip to content

Commit

Permalink
Add workload tracing to Mimir (#84)
Browse files Browse the repository at this point in the history
* workload traces

* fix syntax

* remove git

* better desc
  • Loading branch information
michaeldmitry authored Nov 14, 2024
1 parent d70c313 commit 6e9841c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
10 changes: 8 additions & 2 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,17 @@ requires:
description: |
Certificate and key files for securing Mimir communications with TLS.
tracing:
charm-tracing:
interface: tracing
limit: 1
description: |
Enables sending traces to the tracing backend.
Enables sending charm traces to a distributed tracing backend such as Tempo.
workload-tracing:
interface: tracing
limit: 1
description: |
Enables sending workload traces to a distributed tracing backend such as Tempo.
provides:
mimir-cluster:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ops
cosl
cosl>=0.0.43
pydantic
# crossplane is a package from nginxinc to interact with the Nginx config
crossplane
Expand Down
28 changes: 11 additions & 17 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import os
import shutil
import socket
from typing import Any, Optional
from typing import Any
from urllib.parse import urlparse

import cosl.coordinated_workers.nginx
import ops
from charms.grafana_k8s.v0.grafana_source import GrafanaSourceProvider
from charms.prometheus_k8s.v1.prometheus_remote_write import PrometheusRemoteWriteProvider
from charms.tempo_coordinator_k8s.v0.charm_tracing import trace_charm
from charms.tempo_coordinator_k8s.v0.tracing import charm_tracing_config
from charms.traefik_k8s.v2.ingress import IngressPerAppReadyEvent, IngressPerAppRequirer
from cosl.coordinated_workers.coordinator import Coordinator
from ops.model import ModelError
Expand All @@ -39,8 +40,8 @@


@trace_charm(
tracing_endpoint="tempo_endpoint",
server_cert="server_cert_path",
tracing_endpoint="charm_tracing_endpoint",
server_cert="server_ca_cert",
extra_types=[
Coordinator,
],
Expand Down Expand Up @@ -71,11 +72,17 @@ def __init__(self, *args: Any):
"grafana-dashboards": "grafana-dashboards-provider",
"logging": "logging-consumer",
"metrics": "self-metrics-endpoint",
"tracing": "tracing",
"charm-tracing": "charm-tracing",
"workload-tracing": "workload-tracing",
"s3": "s3",
},
nginx_config=NginxConfig().config,
workers_config=MimirConfig().config,
workload_tracing_protocols=["jaeger_thrift_http"],
)

self.charm_tracing_endpoint, self.server_ca_cert = charm_tracing_config(
self.coordinator.charm_tracing, cosl.coordinated_workers.nginx.CA_CERT_PATH
)

if port := urlparse(self.internal_url).port:
Expand Down Expand Up @@ -134,19 +141,6 @@ def hostname(self) -> str:
"""Unit's hostname."""
return socket.getfqdn()

@property
def tempo_endpoint(self) -> Optional[str]:
"""Tempo endpoint for charm tracing."""
if self.coordinator.tracing.is_ready():
return self.coordinator.tracing.get_endpoint(protocol="otlp_http")
else:
return None

@property
def server_cert_path(self) -> Optional[str]:
"""Server certificate path for tls tracing."""
return cosl.coordinated_workers.nginx.CERT_PATH

@property
def internal_url(self) -> str:
"""Returns workload's FQDN. Used for ingress."""
Expand Down

0 comments on commit 6e9841c

Please sign in to comment.