From 3e25825fbe15ebfe984a9a199df2e56f15c1ea7f Mon Sep 17 00:00:00 2001 From: Furkan Date: Fri, 15 Nov 2024 21:10:38 +0300 Subject: [PATCH] feat: add labels to TimeSeries db in `DAQJobStoreRedis` --- src/daq/jobs/store/redis.py | 2 ++ src/tests/test_redis.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/daq/jobs/store/redis.py b/src/daq/jobs/store/redis.py index 66220b8..e9ad32c 100644 --- a/src/daq/jobs/store/redis.py +++ b/src/daq/jobs/store/redis.py @@ -115,6 +115,8 @@ def store_loop(self): self._ts.create( item_key, retention_msecs=retention_msecs, + labels={"key": msg.store_config.key} + | ({"prefix": msg.prefix} if msg.prefix else {}), ) if "timestamp" not in msg.data: self._logger.warning( diff --git a/src/tests/test_redis.py b/src/tests/test_redis.py index ff07569..fdf0294 100644 --- a/src/tests/test_redis.py +++ b/src/tests/test_redis.py @@ -89,7 +89,7 @@ def test_store_loop(self): RedisWriteQueueItem( store_config=DAQJobStoreConfigRedis( key="test_key_timeseries", - key_expiration_days=None, + key_expiration_days=1, use_timeseries=True, ), data={ @@ -127,6 +127,12 @@ def test_store_loop(self): ] ) + self.store._ts.create.assert_any_call( + "prefix.test_key_timeseries.header2", + retention_msecs=int(timedelta(days=1).total_seconds() * 1000), + labels={"key": "test_key_timeseries", "prefix": "prefix"}, + ) + self.store._ts.madd.assert_any_call( [ ("prefix.test_key_timeseries.header2", unix_ms, "row1_col2"),