-
Notifications
You must be signed in to change notification settings - Fork 356
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
Container dashboard charts: send datapoints as full timestamps #3696
Container dashboard charts: send datapoints as full timestamps #3696
Conversation
fa16216
to
56b5d14
Compare
@@ -233,7 +233,7 @@ def hourly_image_metrics | |||
def daily_image_metrics | |||
daily_image_metrics = Hash.new(0) | |||
daily_metrics.each do |m| | |||
day = m.timestamp.strftime("%Y-%m-%d") | |||
day = m.timestamp |
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.
This looks problematic.
It gives me "Sat, 15 Jul 2017 22:29:00 UTC +00:00" .. which is not guaranteed to be parseable in javascript IIRC
Should this be m.timestamp.strftime("%Y-%m-%dT%H:%M:%S%z")
?
EDIT: never mind..
> m.timestamp
=> Sat, 15 Jul 2017 22:29:00 UTC +00:00
> m.timestamp.to_s
=> "2017-07-15 22:29:00 UTC"
@mzazrivec Looks like we will have to fix this differently. The problem is that previously, all data points from one day were summed, so you'd get
but now, you'll get data more like:
which is not summed by day. Also... before: after: |
@mzazrivec Maybe we can do the same thing we do for hours?
so, something like |
Using this diff instead: diff --git a/app/services/container_dashboard_service.rb b/app/services/container_dashboard_service.rb
index d4bf6ac6c..2a95bf09b 100644
--- a/app/services/container_dashboard_service.rb
+++ b/app/services/container_dashboard_service.rb
@@ -233,7 +233,7 @@ class ContainerDashboardService < DashboardService
def daily_image_metrics
daily_image_metrics = Hash.new(0)
daily_metrics.each do |m|
- day = m.timestamp.strftime("%Y-%m-%d")
+ day = m.timestamp.beginning_of_day.utc
daily_image_metrics[day] +=
m.stat_container_image_registration_rate if m.stat_container_image_registration_rate.present?
end
diff --git a/app/services/container_service_mixin.rb b/app/services/container_service_mixin.rb
index 8ee70b172..d9012e2e6 100644
--- a/app/services/container_service_mixin.rb
+++ b/app/services/container_service_mixin.rb
@@ -10,7 +10,7 @@ module ContainerServiceMixin
daily_pod_delete_trend = Hash.new(0)
daily_metrics.each do |m|
- date = m.timestamp.strftime("%Y-%m-%d")
+ date = m.timestamp.beginning_of_day.utc
fill_pod_metrics(m, date, daily_pod_create_trend, daily_pod_delete_trend)
end
@@ -122,7 +122,7 @@ module ContainerServiceMixin
def daily_network_metrics
daily_network_metrics = Hash.new(0)
daily_metrics.each do |m|
- day = m.timestamp.strftime("%Y-%m-%d")
+ day = m.timestamp.beginning_of_day.utc
daily_network_metrics[day] += m.net_usage_rate_average if m.net_usage_rate_average.present?
end
@@ -179,7 +179,7 @@ module ContainerServiceMixin
total_mem = Hash.new(0)
daily_metrics.each do |metric|
- date = metric.timestamp.strftime("%Y-%m-%d")
+ date = metric.timestamp.beginning_of_day.utc
fill_utilization(metric, date, used_cpu, used_mem, total_cpu, total_mem)
end
(but not yet sure this still fixes the BZ...) (seems it does, at least the screenshot is the same for |
c17420a
to
4cd0fae
Compare
@himdel fixed as suggested. |
@@ -233,7 +233,7 @@ def hourly_image_metrics | |||
def daily_image_metrics | |||
daily_image_metrics = Hash.new(0) | |||
daily_metrics.each do |m| | |||
day = m.timestamp.strftime("%Y-%m-%d") | |||
day = m.timestamp.timestamp.beginning_of_day.utc |
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.
double timestamp ;)
(otherwise, 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.
fixed
We need to send chart datapoints as complete timestamps (including timezone info) so that the patternfly component would correctly convert them to Date() objects and avoid ugly side-effects when viewing the charts in browsers located in different timezones. https://bugzilla.redhat.com/show_bug.cgi?id=1542720
4cd0fae
to
35f2268
Compare
Checked commits mzazrivec/manageiq-ui-classic@044b120~...35f2268 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
…ashboard_charts Container dashboard charts: send datapoints as full timestamps (cherry picked from commit 43e6773) https://bugzilla.redhat.com/show_bug.cgi?id=1565156
Gaprindashvili backport details:
|
…ashboard_charts Container dashboard charts: send datapoints as full timestamps (cherry picked from commit 43e6773) https://bugzilla.redhat.com/show_bug.cgi?id=1565157
Fine backport details:
|
We need to send chart datapoints as complete timestamps (including timezone info) so that the patternfly component would correctly convert them to
Date()
objects and avoid ugly side-effects when viewing the charts in browsers located in different timezones.How to reproduce:
$ TZ='America/New_York' firefox
You'll notince the datapoints in the EST timezone are shifted by one day back.
Previously, we were sending the datapoints to the angular component as
2018-03-23
strings. The patternfly component would then convert them toDate()
objects. Now we'll be sending the full timestamp as2018-03-23T00:00:00.0000-04:00
.https://bugzilla.redhat.com/show_bug.cgi?id=1542720
@himdel review please?