Skip to content

Commit

Permalink
stabilized output for _requested_receivers() (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroPasotti authored Nov 20, 2024
1 parent 6d15deb commit f113071
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/scenario/test_tracing_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit f113071

Please sign in to comment.