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

[8.16] [APM] Time spent by span type chart rendering problems (#202755) #203075

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { flatten, orderBy, last } from 'lodash';
import { flatten, orderBy, last, clamp, round } from 'lodash';
import { rangeQuery, kqlQuery } from '@kbn/observability-plugin/server';
import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { asPercent } from '../../../../common/utils/formatters';
Expand Down Expand Up @@ -145,9 +145,15 @@ export async function getTransactionBreakdown({
const type = bucket.key as string;

return bucket.subtypes.buckets.map((subBucket) => {
const percentageRaw =
(subBucket.total_self_time_per_subtype.value || 0) / sumAllSelfTimes;
// limit percentage from 0% to 100% and
// round to 8 decimal points (results in 6 decimal points after converting to percentages) to prevent displaying scientific notation in charts
const percentage = round(clamp(percentageRaw, 0, 1), 8);

return {
name: (subBucket.key as string) || type,
percentage: (subBucket.total_self_time_per_subtype.value || 0) / sumAllSelfTimes,
percentage,
};
});
})
Expand Down
Loading
Loading