Must add UTC time offset to Query
s in order to get any results
#11096
Labels
api: monitoring
Issues related to the Cloud Monitoring API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Environment details
google-cloud-monitoring
version: 2.9.1Steps to reproduce
Querying metrics, I have to add at least 4 hours (the time offset to UTC from EDT) in order to get any results. Here's the code I ran into it with
This will only return anything if minutes>=241 (or the equivalent w/ other units of time) and the subscription exists.
This is of course very confusing and for the longest time I couldn't figure out why on my local machine I couldn't see some metrics data but my server on UTC time could using the exact same code.
I'm guessing this has to do with some naive vs non-naive UTC time.
Additional notes from my own debugging
I think there might be something up at the stage where
TimeInterval
converts the end_time/start_time into aDatetimeWithSeconds
.I executed these within a minute of each other:
I confirmed the above lines on another person's Macbook (though using py3.8). I'm wondering if there's some kind of misunderstanding on my part or something not documented since I would expect that this bug would come up for a lot of people.
Possible Fix: A fix that works for both my UTC machine and my EDT machine is to use
end_time=datetime.now(tz=timezone.utc)
(which is what's recommended in the docs for utcnow).The text was updated successfully, but these errors were encountered: