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] Chart units don't update when toggling the chart legends #74931

Merged
merged 12 commits into from
Aug 31, 2020

Conversation

cauemarcondes
Copy link
Contributor

@cauemarcondes cauemarcondes commented Aug 13, 2020

closes #74830

Screenshot 2020-08-26 at 13 09 43

Screenshot 2020-08-26 at 13 09 51

@cauemarcondes cauemarcondes marked this pull request as ready for review August 13, 2020 11:37
@cauemarcondes cauemarcondes requested a review from a team as a code owner August 13, 2020 11:37
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Aug 13, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

Copy link
Member

@dgieselaar dgieselaar left a comment

Choose a reason for hiding this comment

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

I think there's a bug.


const onToggleLegend = (series: Serie[]) => {
if (!isEmpty(series)) {
setMaxY(getMaxY(series as TimeSeries[]));
Copy link
Member

Choose a reason for hiding this comment

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

I have some concerns here, mostly around us having to maintain state about CustomPlot in TransactionCharts, which could easily get out of sync. For instance, this happens when I enter a filter into the query bar that gives no results, and then go back:

image

The axis unit is not updated. Of course we can probably fix this even with this implementation, but it might be better to consider having state only one place (for instance, the consumers of CustomPlot.

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 I've rethought the solution to this problem. I removed the state (a04aaba#diff-da514a7cc4e8210906a22c7f824eaea9L170-L184) and I use asDuration to calculate what will be the unit shown in the y-axis based on the value passed by the CustomPlot. This fixes the issue of this ticket and also the bug you reported.

@formgeist
Copy link
Contributor

We had this up for discussion in our weekly sync, and we agreed to pursue changing the tooltip values to display their individual units appropriate for the value shown.

Copy link
Contributor

@formgeist formgeist left a comment

Choose a reason for hiding this comment

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

LGTM - I think it takes some getting used to, but in the end, I think this is the right approach and most detailed for our users.

@dgieselaar
Copy link
Member

@cauemarcondes I'm not sure why in this case durations above 60000ms are not formatted in minutes. The y-axis does use minutes in this case. In this case I would have expected the value above 6000ms to be formatted as minutes.

image

@cauemarcondes
Copy link
Contributor Author

I'm not sure why in this case durations above 60000ms are not formatted in minutes. The y-axis does use minutes in this case. In this case I would have expected the value above 6000ms to be formatted as minutes.

Are you sure you pulled the last changes? can you paste the URL, please?

@cauemarcondes
Copy link
Contributor Author

@elasticmachine merge upstream

@sorenlouv
Copy link
Member

sorenlouv commented Aug 24, 2020

I'm not sure this is the right approach. Mainly I don't think we should mix different units (ms, sec, min) in the same visualisation. It's especially confusing when the unit in the tooltip changes for the same metric (eg. 99th is sometimes in minutes and other times in ms).
I agree that the current approach is not great (where the unit is determined from the max value which is always 99th series). Perhaps we should base the unit on the avg series - or the overall average or median value? And then use that unit everywhere (on axis, in tooltips etc). WDYT?

Maybe we can research how other products does this. Are there any white papers around this? Perhaps Elastic Charts have some insights.

@dgieselaar
Copy link
Member

@sqren That came up, but IMHO that creates edge cases that feel like they are worse than the problem they are solving (of having different units). Like, a very low avg but a very high 95th percentile becomes unreadable. I'd also consider the implementation cost to be higher because the code has to be aware of an "avg" series vs other series. It also might not necessarily translate well to other charts.

@sorenlouv
Copy link
Member

sorenlouv commented Aug 26, 2020

I'd also consider the implementation cost to be higher because the code has to be aware of an "avg" series vs other series. It also might not necessarily translate well to other charts.

This would be solved if we use the overall avg/median, right?

I think what we have today have worked reasonably well (we haven't gotten any issues from users afaik) which is why I'm hesitant to making this change.
From #74830 it looks like the specific problem is that we select minutes as unit instead of seconds.

If we make the following simple change, would that perhaps alleviate the problem for now?

function getDurationUnitKey(max: number): DurationTimeUnit {
-  if (max > toMicroseconds(1, 'hours')) {
+  if (max > toMicroseconds(10, 'hours')) {
    return 'hours';
  }
-  if (max > toMicroseconds(1, 'minutes')) {
+  if (max > toMicroseconds(10, 'minutes')) {
    return 'minutes';
  }
  if (max > toMicroseconds(10, 'seconds')) {
    return 'seconds';
  }
  if (max > toMicroseconds(1, 'milliseconds')) {
    return 'milliseconds';
  }
  return 'microseconds';
}

Explanation: Above change will only use hours as unit if the value is higher than 10 hours, and minutes if the values is larger than 10 minutes

This change will also align the formatting a little more (we still have a preference for milliseconds over microseconds though).
I get that this won't fix extreme cases where 99th is a lot higher than avg. But again: that's always been the case and as long as we don't receive complaints from user's I'd rather leaving it mostly as-is (with minor tweaks).

@dgieselaar
Copy link
Member

dgieselaar commented Aug 26, 2020

@sqren I feel like "base the displayed unit on the displayed value" is easy to grasp. All the other solutions have edge cases. The fact that, in some cases (not most), different units will be displayed in the tooltip, doesn't outweigh that cost to me. In general, I feel like every improvement we made to how values are formatted opens up new edge cases. But I've been looking at it from a distance ofc. Anyway, just my 0.02$.

@formgeist
Copy link
Contributor

@sqren I think I agree with your suggestion to change the thresholds for the hours and minutes. We've resolved the initial problem of not updating the y-axis unit labels to fit with the data, this already helps the user in exploring the data appropriately. IMO we got stuck optimizing for a weird edge-case we're seeing in our test data, rather than thinking about the common cases. I wouldn't think to see this large range between average and 95p in a relatively controlled environment. And if that's the case, your suggestion to move the top thresholds for hours and minutes will help as well. I say we move forward with this and see if we get any feedback (we haven't so far).

Thanks,

@dgieselaar
Copy link
Member

@sqren actually that's interesting, the table shows a < if the value is lower than 0.1. Maybe that will help here too. But yeah, more logic :) (and the values are sortable in the table which maybe makes it more important to have the same units).

@formgeist
Copy link
Contributor

I think our users are looking for ways to compare the data, especially in the duration chart but also in the tables. I don't find myself looking for a specific number, but rather compare it to other values in the table. Having a "per number unit formatting" will make it cognitively very difficult to keep track and compare. Tbh the examples we're looking at are edge-cases. In the example of this duration chart, a user is moreover looking to compare the percentiles to the average, and keeping to the same unit support this. We already have fixed a problem that enables the user to disable a disruptive 99p to see what the avg. looks like compared to the 95p. If someone wants to investigate other unit improvements, feel free to open an issue, but I don't think this discussion should block this PR for merging.

@cauemarcondes
Copy link
Contributor Author

@elasticmachine merge upstream

@MartinKolarik
Copy link

Adding my two cents here since I'm also frequently affected by this and I see there are several possible solutions discussed. Our usual transaction length is about 1 second, but occasionally, there are spikes up to a few minutes. Currently, that produces completely unhelpful tooltips if there's any such spike in the selected interval. Even for cases where the values are not all displayed as zero, showing them in minutes is way too imprecise.

image

However, the current solution doesn't work well even if the 99th value is just slightly above 1 minute, because it switches everything to minutes and dealing with numbers like 0.1 minute, 0.2 minute and 1.1 minutes is harder than 3 seconds, 10 seconds, 64 seconds when you are used to everything being in seconds most of the time.

I think switching the units based on currently displayed values makes sense, but ideally, the tooltip would be more useful in the cases I described without manually switching off the 99th percentile line. The solution proposed in #74931 (comment) is something that would help in that regard and something I thought of myself before I found this PR.

@dgieselaar dgieselaar dismissed their stale review August 31, 2020 06:59

Søren is now reviewing this

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
apm 948 +3 945

async chunks size

id value diff baseline
apm 4.7MB -1.8KB 4.7MB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@cauemarcondes cauemarcondes merged commit 647f397 into elastic:master Aug 31, 2020
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 31, 2020
…s-for-710

* 'master' of github.com:elastic/kibana: (43 commits)
  [APM] Chart units don't update when toggling the chart legends (elastic#74931)
  [ILM] Add support for frozen phase in UI (elastic#75968)
  Hides advanced json for count metric (elastic#74636)
  add client-side feature usage API (elastic#75486)
  [Maps] add drilldown support map embeddable (elastic#75598)
  [Enterprise Search] Request handler refactors/enhancements + update existing routes to use shared handler (elastic#76106)
  [Resolver] model `location.search` in redux (elastic#76140)
  [APM] Prevent imports of public in server code (elastic#75979)
  fix eslint issue
  skip flaky suite (elastic#76223)
  [APM] Transaction duration anomaly alerting integration (elastic#75719)
  [Transforms] Avoid using "Are you sure" (elastic#75932)
  [Security Solution][Exceptions] - Fix bug of alerts not updating after closure from exceptions modal (elastic#76145)
  [plugin-helpers] improve 3rd party KP plugin support (elastic#75019)
  [docs/getting-started] link to yarn v1 specifically (elastic#76169)
  [Security_Solution][Resolver] Resolver loading and error state (elastic#75600)
  Fixes App Search documentation links (elastic#76133)
  Fix alerts unable to create / update when the name has trailing whitepace(s) (elastic#76079)
  [Resolver] Fix useSelector usage (elastic#76129)
  [Enterprise Search] Migrate util and components from ent-search (elastic#76051)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/node_allocation.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/types.ts
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/warm_phase.ts
@cauemarcondes cauemarcondes deleted the apm-chart-unt branch August 31, 2020 10:23
cauemarcondes added a commit to cauemarcondes/kibana that referenced this pull request Aug 31, 2020
…ic#74931)

* changing unit when legend is disabled

* changing unit when legend is disabled

* show individual units in the tooltip

* addressing PR comment

* increasing duration threshold

* change formatter based on available legends

* addressing PR comment

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
cauemarcondes added a commit that referenced this pull request Aug 31, 2020
… (#76273)

* changing unit when legend is disabled

* changing unit when legend is disabled

* show individual units in the tooltip

* addressing PR comment

* increasing duration threshold

* change formatter based on available legends

* addressing PR comment

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@dgieselaar dgieselaar self-assigned this Oct 12, 2020
@dgieselaar
Copy link
Member

Works well in all browsers 👍

@dgieselaar dgieselaar added the apm:test-plan-done Pull request that was successfully tested during the test plan label Oct 16, 2020
@dgieselaar dgieselaar removed their assignment Oct 16, 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 Team:APM All issues that need APM UI Team support v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Chart units don't update when toggling the chart legends
7 participants