From 0e0db9003fec04056c6744793008a6cd8e9d26c2 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 23 Jun 2023 16:42:17 -0700 Subject: [PATCH] sharder: Fix completed metric emission Related-Change: Ie2a8e4eced6688e5a98aa37c3c7b0c13fd2ddeee Change-Id: Ic19964f1fc4e99f586364aefa1033800dd9bf143 --- swift/container/sharder.py | 2 +- test/unit/container/test_sharder.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/swift/container/sharder.py b/swift/container/sharder.py index adff1df977..b24adbad73 100644 --- a/swift/container/sharder.py +++ b/swift/container/sharder.py @@ -2396,7 +2396,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator): 'state') self.logger.timing_since( 'sharder.sharding.completed', - broker.get_own_shard_range().epoch) + float(broker.get_own_shard_range().epoch)) else: self.info(broker, 'Completed cleaving, DB remaining in ' 'sharding state') diff --git a/test/unit/container/test_sharder.py b/test/unit/container/test_sharder.py index 76387d1379..e809858ddc 100644 --- a/test/unit/container/test_sharder.py +++ b/test/unit/container/test_sharder.py @@ -2476,6 +2476,9 @@ class TestSharder(BaseTestSharder): self.assertEqual('sharder.sharding.cleave', self.logger.log_dict['timing_since'][-1][0][0]) self.assertGreater(self.logger.log_dict['timing_since'][-1][0][1], 0) + for call in self.logger.log_dict['timing_since']: + self.assertNotIsInstance(call[0][1], Timestamp) + self.assertIsInstance(call[0][1], float) lines = sharder.logger.get_lines_for_level('info') self.assertEqual( ["Kick off container cleaving, own shard range in state " @@ -2534,6 +2537,9 @@ class TestSharder(BaseTestSharder): self.assertEqual('sharder.sharding.send_sr', self.logger.log_dict['timing_since'][-1][0][0]) self.assertGreater(self.logger.log_dict['timing_since'][-1][0][1], 0) + for call in self.logger.log_dict['timing_since']: + self.assertNotIsInstance(call[0][1], Timestamp) + self.assertIsInstance(call[0][1], float) def test_cleave_timing_metrics(self): broker = self._make_broker()