elastic/rally

Configurable timezone for Rally logging

dliappis opened this issue · 4 comments

As discussed in https://discuss.elastic.co/t/how-to-set-other-time-zone-in-rallys-log/328683/2, right now the out of the box logging.json uses a UTC formatter without a possibility to change it.

We could support configuring the timezone in a user friendly manner e.g. via an additional timezone property. A primitive, insecure and naive implementation could be as simple as:

$ git diff
diff --git a/esrally/log.py b/esrally/log.py
index 189a1b8..9423b1a 100644
--- a/esrally/log.py
+++ b/esrally/log.py
@@ -32,7 +32,10 @@ def configure_utc_formatter(*args, **kwargs):
     timestamps across all deployments regardless of machine settings.
     """
     formatter = logging.Formatter(fmt=kwargs["format"], datefmt=kwargs["datefmt"])
-    formatter.converter = time.gmtime
+    if user_tz := kwargs.get("timezone"):
+        formatter.converter = getattr(time, user_tz)
+    else:
+        formatter.converter = time.gmtime
     return formatter

which would allow changing the logging config file to e.g.:

diff --git a/esrally/resources/logging.json b/esrally/resources/logging.json
index ba559e2..91cca4c 100644
--- a/esrally/resources/logging.json
+++ b/esrally/resources/logging.json
@@ -4,6 +4,7 @@
     "normal": {
       "format": "%(asctime)s,%(msecs)d %(actorAddress)s/PID:%(process)d %(name)s %(levelname)s %(message)s",
       "datefmt": "%Y-%m-%d %H:%M:%S",
+      "timezone": "localtime",
       "()": "esrally.log.configure_utc_formatter"
     },
     "profile": {

hi @dliappis, I would like to work on this issue. Please assign it to me.

Thank you @vaibhavsolanki1193 I've assigned it to you.

Hey there, is this issue still open?

b-deam commented

Thanks for your interest in Rally and for asking. #1727 should've closed this out, but it was obviously missed.

There are plenty of other issues labeled with good first issue that you can take a look at if you're interested in contributing.