Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: convert timestamps to UTC in Cloud Monitoring MQL backend #331

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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