From 2b8913ff2b1cb5fdd16aea973278c21c27af5154 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <post@soeren-henning.de>
Date: Sat, 28 Mar 2020 18:54:01 +0100
Subject: [PATCH] Let prometheus query consider time diff

---
 execution/lag_analysis.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/execution/lag_analysis.py b/execution/lag_analysis.py
index fa30e0e2f..a810a088a 100644
--- a/execution/lag_analysis.py
+++ b/execution/lag_analysis.py
@@ -1,4 +1,5 @@
 import sys
+import os
 import requests
 from datetime import datetime, timedelta, timezone
 import pandas as pd
@@ -10,10 +11,14 @@ exp_id =  sys.argv[1]
 benchmark = sys.argv[2]
 dim_value = sys.argv[3]
 instances = sys.argv[4]
+time_diff_ms = int(os.getenv('CLOCK_DIFF_MS', 0))
 
 #http://localhost:9090/api/v1/query_range?query=sum%20by(job,topic)(kafka_consumer_consumer_fetch_manager_metrics_records_lag)&start=2015-07-01T20:10:30.781Z&end=2020-07-01T20:11:00.781Z&step=15s
 
-now = datetime.utcnow().replace(tzinfo=timezone.utc).replace(microsecond=0)
+now_local = datetime.utcnow().replace(tzinfo=timezone.utc).replace(microsecond=0)
+now = now_local - timedelta(milliseconds=time_diff_ms)
+print(f"Now Local: {now_local}")
+print(f"Now Used: {now}")
 
 end = now
 start = now - timedelta(minutes=5)
-- 
GitLab