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

PMM-13254 Api migration fixes #1635

Merged
merged 3 commits into from
Oct 24, 2024
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 @@ -4,14 +4,16 @@ import { LineMetadata } from './Metadata.types';
export const showMetadata = (metadata: string[]): LineMetadata[] => {
const metadataToShow: LineMetadata[] = [];

Object.entries(metadata).forEach(([k, v]) => {
const line: LineMetadata = ({
name: metadataNames[k] ? metadataNames[k].name : k,
value: v,
});
Object.entries(metadata)
.filter(([, v]) => !!v)
.forEach(([k, v]) => {
const line: LineMetadata = {
name: metadataNames[k] ? metadataNames[k].name : k,
value: v,
};

metadataToShow.push(line);
});
metadataToShow.push(line);
});

metadataToShow.sort((a, b) => a.name.localeCompare(b.name));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const Metrics: FC<MetricsProps> = ({
? humanize.transform(item.metric.avg, item.pipeTypes.perQueryStatsPipe)
: (+item.metric.sum / +item.queryCount).toFixed(2) || '0'}
</span>
{item.isLatencyChart && <Latency {...latencyChartProps} />}
{!!item.isLatencyChart && <Latency {...latencyChartProps} />}
</div>
);
};
Expand Down
17 changes: 6 additions & 11 deletions pmm-app/src/shared/components/helpers/processMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,18 @@ const sortDetails = (a, b) => {
return indA < indB ? -1 : 1;
};

const metricHasData = ([, value]: [string, unknown]) => Object
.values(value as Record<string, number>)
.some((value) => value !== 0);

export const processMetrics = (metricsCatalogue, metrics) => {
const data = metrics.metrics ? metrics.metrics : metrics.totals;
const data = Object.keys(metrics.metrics).length ? metrics.metrics : metrics.totals;

return Object.entries(data)
.filter(
(metricData) => Object.keys(metricData[1] as any[]).length,
)
.filter(
(metricData) => {
const metricStorage = metricData[1] as any;
const notZeroCount = metricStorage.cnt !== 0;
const notSum = metricStorage.sum === undefined;

return !(notZeroCount && notSum);
},

)
.filter(metricHasData)
.sort(sortDetails)
.map((metricData) => {
const [metricName] = metricData;
Expand Down
Loading