From 74a04c78c6c9dd514317a51e797ee4afd30a307f Mon Sep 17 00:00:00 2001 From: Panos Paparrigopoulos Date: Thu, 19 Oct 2023 09:57:12 +0200 Subject: [PATCH 1/2] enables metadata.timestamp overwrite from the messages in amq sender --- src/python/CMSMonitoring/amq_sender.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/python/CMSMonitoring/amq_sender.py b/src/python/CMSMonitoring/amq_sender.py index 0652ac18..23105721 100644 --- a/src/python/CMSMonitoring/amq_sender.py +++ b/src/python/CMSMonitoring/amq_sender.py @@ -25,7 +25,7 @@ def to_chunks(data, samples=1000): yield data[i : i + samples] -def send_to_amq(data, confs, batch_size, topic=None, doc_type=None): +def send_to_amq(data, confs, batch_size, topic=None, doc_type=None, overwrite_meta_ts=False): """Sends list of dictionary in chunks""" wait_seconds = 0.001 if confs: @@ -54,8 +54,9 @@ def send_to_amq(data, confs, batch_size, topic=None, doc_type=None): ) messages = [] for msg in chunk: + ts = None if not overwrite_meta_ts else msg.get('timestamp', None) notif, _, _ = stomp_amq.make_notification( - payload=msg, doc_type=doc_type, producer=producer + payload=msg, doc_type=doc_type, producer=producer, ts=ts ) messages.append(notif) if messages: From 4ce894f092c1e8c012a62cde148e05a177d75b17 Mon Sep 17 00:00:00 2001 From: Nikodemas Tuckus Date: Thu, 19 Oct 2023 17:34:46 +0200 Subject: [PATCH 2/2] delete one None --- src/python/CMSMonitoring/amq_sender.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/CMSMonitoring/amq_sender.py b/src/python/CMSMonitoring/amq_sender.py index 23105721..250c1f31 100644 --- a/src/python/CMSMonitoring/amq_sender.py +++ b/src/python/CMSMonitoring/amq_sender.py @@ -54,7 +54,7 @@ def send_to_amq(data, confs, batch_size, topic=None, doc_type=None, overwrite_me ) messages = [] for msg in chunk: - ts = None if not overwrite_meta_ts else msg.get('timestamp', None) + ts = None if not overwrite_meta_ts else msg.get("timestamp") notif, _, _ = stomp_amq.make_notification( payload=msg, doc_type=doc_type, producer=producer, ts=ts )