Skip to content

Commit

Permalink
fix: convert timestamp to UTC in Cloud Monitoring MQL backend (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvaylet committed Mar 15, 2023
1 parent 2afdc28 commit b7d3c05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions slo_generator/backends/cloud_monitoring_mql.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import typing
import warnings
from collections import OrderedDict
from datetime import datetime
from datetime import datetime, timezone
from typing import List, Optional, Tuple

from google.api.distribution_pb2 import Distribution
Expand Down Expand Up @@ -240,7 +240,7 @@ def enrich_query_with_time_horizon_and_period(
# epoch, in UTC, with decimal part representing nanoseconds.
# MQL expects dates formatted like "%Y/%m/%d %H:%M:%S" or "%Y/%m/%d-%H:%M:%S".
# Reference: https://cloud.google.com/monitoring/mql/reference#lexical-elements
end_time_str: str = datetime.fromtimestamp(timestamp).strftime(
end_time_str: str = datetime.fromtimestamp(timestamp, tz=timezone.utc).strftime(
"%Y/%m/%d %H:%M:%S"
)
query_with_time_horizon_and_period: str = (
Expand Down

0 comments on commit b7d3c05

Please sign in to comment.