From fb6c164b31356d9fa5cff414c3a69d92e5029254 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Thu, 21 Aug 2025 16:57:42 +0100 Subject: [PATCH] Update TestMetrics.swift TestMetrics hashing is unstable due to different possible ordering of the metric dimensions. This change sorts the dimensions to at least reduce the instability, I'm not sure if the dimensions are enforced to be unique given they are of type `[(String, String)]` --- Sources/MetricsTestKit/TestMetrics.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MetricsTestKit/TestMetrics.swift b/Sources/MetricsTestKit/TestMetrics.swift index 1acb675..09daa05 100644 --- a/Sources/MetricsTestKit/TestMetrics.swift +++ b/Sources/MetricsTestKit/TestMetrics.swift @@ -148,7 +148,7 @@ public final class TestMetrics: MetricsFactory { extension TestMetrics.FullKey: Hashable { public func hash(into hasher: inout Hasher) { self.label.hash(into: &hasher) - for dim in self.dimensions { + for dim in self.dimensions.sorted(by: { $0.0 < $1.0 }) { dim.0.hash(into: &hasher) dim.1.hash(into: &hasher) }