-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Conversation
Pinging @elastic/apm-ui (Team:apm) |
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.
I think there's a bug.
|
||
const onToggleLegend = (series: Serie[]) => { | ||
if (!isEmpty(series)) { | ||
setMaxY(getMaxY(series as TimeSeries[])); |
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.
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:
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
.
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.
@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.
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. |
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.
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.
@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. |
x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
Show resolved
Hide resolved
x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
Outdated
Show resolved
Hide resolved
Are you sure you pulled the last changes? can you paste the URL, please? |
@elasticmachine merge upstream |
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). Maybe we can research how other products does this. Are there any white papers around this? Perhaps Elastic Charts have some insights. |
@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. |
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. 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). |
@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$. |
@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, |
@sqren actually that's interesting, the table shows a |
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. |
@elasticmachine merge upstream |
x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
Outdated
Show resolved
Hide resolved
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. 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 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. |
a904331
to
ee533a2
Compare
x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/ml_header.tsx
Outdated
Show resolved
Hide resolved
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
History
To update your PR or re-run it, just comment with: |
…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
…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>
… (#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>
Works well in all browsers 👍 |
closes #74830