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

[APM] Correct timezone formatting #48355

Merged
merged 2 commits into from
Oct 22, 2019
Merged

[APM] Correct timezone formatting #48355

merged 2 commits into from
Oct 22, 2019

Conversation

smith
Copy link
Contributor

@smith smith commented Oct 16, 2019

  • Don't set the timezone anywhere in APM since it's already set in autoload

For the chart X-axes:

  • Create nice ticks for the configured timezone (ie at 1w, 1d, 12hrs interval) by offsetting the xMin/xMax
  • Explicitly pass those tick values to the x-axis
  • When formatting, use scaleUtc to format everything as UTC, and offset the time again with the configured timezone.

Fixes #47832
Fixes #48355

@smith smith requested a review from a team as a code owner October 16, 2019 03:02
@elasticmachine
Copy link
Contributor

💔 Build Failed

* This produces the same results as the built-in formatter from D3, which is
* what react-vis uses, but shifts the timezone.
*/
tickFormatX = value => {
Copy link
Member

Choose a reason for hiding this comment

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

Should this perhaps be named something like tickFormatXTime to indicate it's not a generic formatter but one specifically for formatting time values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in b78868ae249.

.parse(value);

value.setTime(
value.getTime() + (configuredZoneOffset - guessedZoneOffset) * 60000
Copy link
Member

Choose a reason for hiding this comment

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

Nice idea with just shifting the time, instead of re-implementing the date logic. Is it possible to add a test for this somehow?

Copy link
Member

Choose a reason for hiding this comment

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

How will this deal with DST etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dgieselaar since the offsets are calculated based on the time input, those offset values should include/exclude DST as needed and be correct.

Copy link
Member

Choose a reason for hiding this comment

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

Oh right, this formats per-value. So that should be fine. We might be missing something though, seems like the native time formatter is a little smarter about how to format. For instance, this is what it looks like with 7 days selected. All labels show '06 AM'.

image

This is what it previously looked like:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm thanks for spotting this. I think it might have something to do with the domain/range being provided to the scale. Will look into it.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@smith smith force-pushed the nls/47959/tz branch 2 times, most recently from e11e0cc to 772a48b Compare October 17, 2019 21:58
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

smith added a commit to smith/kibana that referenced this pull request Oct 18, 2019
* Don't set the timezone anywhere in APM since it's already set in autoload
* Always use the local timezone for the chart tooltip

This makes the timezone handling consitently use the users set preference _except_ in the charts where the local time is always used.

In the charts we have to go through react-vis and d3-scale and nothing I tried to modify the scale on the x-axis ever really worked. We could revisit this later.

Fixes elastic#47832
Fixes elastic#48355
@elasticmachine
Copy link
Contributor

💔 Build Failed

* Don't set the timezone anywhere in APM since it's already set in autoload

For the chart X-axes:

* Create nice ticks for the configured timezone (ie at 1w, 1d, 12hrs interval) by offsetting the xMin/xMax
* Explicitly pass those tick values to the x-axis
* When formatting, use scaleUtc to format everything as UTC, and offset the time again with the configured timezone.

Fixes elastic#47832
Fixes elastic#48355
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@smith
Copy link
Contributor Author

smith commented Oct 21, 2019

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💔 Build Failed

@smith
Copy link
Contributor Author

smith commented Oct 21, 2019

@elasticmachine test this please

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

Nice work! 👍

@sorenlouv
Copy link
Member

I'm a little reluctant about backporting this to 7.5. Might be safer to backport to 7.x and wait for 7.6. That'll give us ample time to discover any adverse side-effects.

@smith smith added v7.6.0 and removed v7.5.0 labels Oct 22, 2019
@smith smith merged commit e14dcb2 into elastic:master Oct 22, 2019
@smith smith deleted the nls/47959/tz branch October 22, 2019 15:01
smith added a commit to smith/kibana that referenced this pull request Oct 22, 2019
* Don't set the timezone anywhere in APM since it's already set in autoload

For the chart X-axes:

* Create nice ticks for the configured timezone (ie at 1w, 1d, 12hrs interval) by offsetting the xMin/xMax
* Explicitly pass those tick values to the x-axis
* When formatting, use scaleUtc to format everything as UTC, and offset the time again with the configured timezone.

Fixes elastic#47832
Fixes elastic#48355
smith added a commit that referenced this pull request Oct 22, 2019
* Don't set the timezone anywhere in APM since it's already set in autoload

For the chart X-axes:

* Create nice ticks for the configured timezone (ie at 1w, 1d, 12hrs interval) by offsetting the xMin/xMax
* Explicitly pass those tick values to the x-axis
* When formatting, use scaleUtc to format everything as UTC, and offset the time again with the configured timezone.

Fixes #47832
Fixes #48355
@cauemarcondes cauemarcondes self-assigned this Jan 22, 2020
@cauemarcondes
Copy link
Contributor

Test:
IE:✅
Firefox:✅
Chrome:✅
Safari:✅
Related issue: #55534

@cauemarcondes cauemarcondes added the apm:test-plan-done Pull request that was successfully tested during the test plan label Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:test-plan-done Pull request that was successfully tested during the test plan release_note:fix v7.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Time on x-axis doesn't align with time in tooltip
6 participants