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

Add ability to submit time deltas to database query utility #5524

Merged
merged 2 commits into from
Jan 22, 2020
Merged

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Jan 21, 2020

Motivation

Many integrations do that

@codecov
Copy link

codecov bot commented Jan 21, 2020

Codecov Report

Merging #5524 into master will increase coverage by 1.65%.
The diff coverage is 100%.

Impacted Files Coverage Δ
..._checks_base/datadog_checks/base/utils/db/utils.py 100% <100%> (ø) ⬆️
...cks_base/datadog_checks/base/utils/db/transform.py 100% <100%> (ø) ⬆️
datadog_checks_base/tests/test_db.py 100% <100%> (ø) ⬆️
http_check/datadog_checks/http_check/__init__.py 100% <0%> (ø) ⬆️
http_check/tests/test_unit.py 100% <0%> (ø) ⬆️
...datanode/datadog_checks/hdfs_datanode/__about__.py 100% <0%> (ø) ⬆️
dns_check/datadog_checks/dns_check/__about__.py 100% <0%> (ø) ⬆️
...ks/dev/tooling/configuration/consumers/__init__.py 100% <0%> (ø) ⬆️
http_check/datadog_checks/http_check/config.py 94.73% <0%> (ø) ⬆️
dns_check/datadog_checks/dns_check/__init__.py 100% <0%> (ø) ⬆️
... and 879 more

# Prevent naive datetime objects
if dt.tzinfo is None:
# The stdlib datetime.timezone.utc doesn't work properly on Windows
dt = dt.replace(tzinfo=pytz.utc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are assuming that since this is coming from a database, its most likely UTC which makes sense.

There are occasions if we have a naive timestamp that we should normalize to local timezone instead, maybe an opportunity for a future PR timeutils module.

An implementation I have used in the past which has been quite handy: https://github.com/riverbed/steelscript/blob/af4405c63f378db5466397fd566beb8226edf647/steelscript/common/timeutils.py#L52

datadog_checks_base/tests/test_db.py Outdated Show resolved Hide resolved
Copy link
Member

@mgarabed mgarabed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Strange CI errors though .. 🤔

@ofek ofek merged commit 6ef75e0 into master Jan 22, 2020
@ofek ofek deleted the ofek/qt branch January 22, 2020 21:06
AlexandreYang pushed a commit that referenced this pull request Jan 30, 2020
* Add ability to submit time deltas to database query utility

* address
@ofek ofek mentioned this pull request Mar 19, 2020
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants