Skip to content

Commit

Permalink
Add OTEL_RESOURCE_ATTRIBUTES conditionally if workload tracing is ena…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
mmkay committed Nov 13, 2024
1 parent 8727f91 commit a3b9a51
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ def _prometheus_layer(self) -> Layer:
a Pebble layer specification for the Prometheus workload container.
"""
logger.debug("Building pebble layer")
environment = {}
if self.workload_tracing.is_ready():
# tracing is ready to serve traffic, so we can add the topology.
environment["OTEL_RESOURCE_ATTRIBUTES"] = (
f"juju_application={self._topology.application},juju_model={self._topology.model},juju_model_uuid={self._topology.model_uuid},juju_unit={self._topology.unit},juju_charm={self._topology.charm_name}"
)
layer_config = {
"summary": "Prometheus layer",
"description": "Pebble layer configuration for Prometheus",
Expand All @@ -422,9 +428,7 @@ def _prometheus_layer(self) -> Layer:
"summary": "prometheus daemon",
"command": self._generate_command(),
"startup": "enabled",
"environment": {
"OTEL_RESOURCE_ATTRIBUTES": f"juju_application={self._topology.application},juju_model={self._topology.model},juju_model_uuid={self._topology.model_uuid},juju_unit={self._topology.unit},juju_charm={self._topology.charm_name}"
},
"environment": environment,
}
},
}
Expand Down

0 comments on commit a3b9a51

Please sign in to comment.