Verified Commit b13ba03e authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Fix detect UTC offset for metriccollector.

parent bac371ed
Pipeline #37579 passed with stages
in 27 minutes and 35 seconds
......@@ -1006,6 +1006,20 @@ class Config(BaseConfig):
# Check quantiles is enabled
return getattr(self.perfomance, f"enable_{name}_quantiles", False)
@property
def tz_utc_offset(self) -> int:
"""
Return UTC offset for configured timezone
:return:
"""
import pytz
import datetime
if not hasattr(self, "_utcoffset"):
dt = datetime.datetime.now(tz=pytz.utc)
self._utcoffset = dt.astimezone(self.timezone).utcoffset()
return int(self._utcoffset.total_seconds())
config = Config()
config.load()
......
......@@ -189,7 +189,7 @@ class MetricsCollectorService(FastAPIService):
# Matched rule found
if map_item.ch_table not in out:
out[map_item.ch_table] = {
"ts": (item.ts.timestamp() + config.timezone._utcoffset.seconds) * NS,
"ts": (item.ts.timestamp() + config.tz_utc_offset) * NS,
"scope": map_item.ch_table,
"labels": item.labels,
"service": item.service,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment