diff --git a/src/charm.py b/src/charm.py index af11cae..c30ac8f 100755 --- a/src/charm.py +++ b/src/charm.py @@ -302,7 +302,9 @@ def _requested_receivers(self) -> Tuple[ReceiverProtocol, ...]: requested_protocols.update(self.enabled_receivers) # and publish only those we support requested_receivers = requested_protocols.intersection(set(self.tempo.receiver_ports)) - return tuple(requested_receivers) + # sorting for stable output to prevent remote units from receiving + # spurious relation-changed events + return tuple(sorted(requested_receivers)) @property def _trace_retention_period_hours(self) -> int: diff --git a/tests/scenario/test_tracing_provider.py b/tests/scenario/test_tracing_provider.py index 66866e7..6ab599a 100644 --- a/tests/scenario/test_tracing_provider.py +++ b/tests/scenario/test_tracing_provider.py @@ -32,7 +32,7 @@ def test_receivers_removed_on_relation_broken( with charm_tracing_disabled(): with context(context.on.relation_broken(tracing_grpc), state) as mgr: charm = mgr.charm - assert set(charm._requested_receivers()) == {"otlp_http", "jaeger_thrift_http"} + assert charm._requested_receivers() == ("jaeger_thrift_http", "otlp_http") state_out = mgr.run() r_out = [r for r in state_out.relations if r.id == tracing_http.id][0]