Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldmitry committed Dec 12, 2024
1 parent dc68cac commit 993d943
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,23 @@ def __init__(self, *args):
self.framework.observe(self.alertmanager_consumer.on.cluster_changed, self._configure)
self.framework.observe(self.resources_patch.on.patch_failed, self._on_k8s_patch_failed)
self.framework.observe(self.on.validate_configuration_action, self._on_validate_config)
self.framework.observe(self.on.send_datasource_relation_changed, self._configure)
self.framework.observe(self.on.send_datasource_relation_departed, self._configure)
self.framework.observe(self.on.grafana_source_relation_changed, self._configure)
self.framework.observe(self.on.grafana_source_relation_departed, self._configure)
self.framework.observe(
self.on.send_datasource_relation_changed, self._on_grafana_source_changed
)
self.framework.observe(
self.on.send_datasource_relation_departed, self._on_grafana_source_changed
)
self.framework.observe(
self.on.grafana_source_relation_changed, self._on_grafana_source_changed
)
self.framework.observe(
self.on.grafana_source_relation_departed, self._on_grafana_source_changed
)
self.framework.observe(self.on.collect_unit_status, self._on_collect_unit_status)

def _on_grafana_source_changed(self, _):
self._update_datasource_exchange()

def _on_collect_unit_status(self, event: CollectStatusEvent):
# "Pull" statuses
retention_time = self.model.config.get("metrics_retention_time", "")
Expand Down Expand Up @@ -586,7 +597,6 @@ def _configure(self, _):
)
self.remote_write_provider.update_endpoint()
self.catalogue.update_item(item=self._catalogue_item)
self._update_datasource_exchange()

try:
# Need to reload if config or alerts changed.
Expand Down Expand Up @@ -1122,6 +1132,10 @@ def _update_datasource_exchange(self) -> None:
if not self.unit.is_leader():
return

# we might have multiple grafana-source relations, this method collects them all and returns a mapping from
# the `grafana_uid` to the contents of the `datasource_uids` field
# for simplicity, we assume that we're sending the same data to different grafanas.
# read more in https://discourse.charmhub.io/t/tempo-ha-docs-correlating-traces-metrics-logs/16116
grafana_uids_to_units_to_uids = self.grafana_source_provider.get_source_uids()
raw_datasources: List[DatasourceDict] = []

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ async def deploy_tempo_cluster(ops_test: OpsTest):
status="active",
timeout=2000,
idle_period=30,
# TODO: intermittent issue where tempo momentarily goes into error state
# TODO: remove when https://github.com/canonical/tempo-coordinator-k8s-operator/issues/90 is fixed
raise_on_error=False,
)

Expand Down

0 comments on commit 993d943

Please sign in to comment.