-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Update datetime method to clean up noisy log #99542
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
Conversation
ee2e096 to
051c182
Compare
|
✅ All tests passed |
051c182 to
f5fa84d
Compare
f5fa84d to
7216c73
Compare
7216c73 to
6004b97
Compare
| # Need to support timezone-aware and naive datetimes since | ||
| # Snuba API only deals in naive UTC | ||
| now = datetime.now(UTC) if start.tzinfo else datetime.utcnow() | ||
| now = datetime.now(UTC) if start.tzinfo else datetime.now(UTC).replace(tzinfo=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, wouldn't replacing the tzinfo with None remove the UTC?
In other words: in the existing definition:
datetime.now(UTC) if start.tzinfo else datetime.utcnow()
How are datetime.now(UTC) and datetime.utcnow() different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, digging in I see that replace does leave the time alone, so this shouldn't be a problem. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe yeah I was confused by this too
While looking through GCP logs, I see this noisy log showing up a ton: ``` /usr/src/sentry/src/sentry/utils/dates.py:193: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). ``` lets address it
While looking through GCP logs, I see this noisy log showing up a ton: ``` /usr/src/sentry/src/sentry/utils/dates.py:193: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). ``` lets address it
While looking through GCP logs, I see this noisy log showing up a ton:
lets address it