|
@@ -23,7 +23,7 @@ import {IconProfiling} from 'sentry/icons';
|
|
|
import {t} from 'sentry/locale';
|
|
|
import {space} from 'sentry/styles/space';
|
|
|
import type {DateString, PageFilters} from 'sentry/types/core';
|
|
|
-import type {MRI, ParsedMRI} from 'sentry/types/metrics';
|
|
|
+import type {MetricAggregation, MRI, ParsedMRI} from 'sentry/types/metrics';
|
|
|
import {defined} from 'sentry/utils';
|
|
|
import {trackAnalytics} from 'sentry/utils/analytics';
|
|
|
import {Container, FieldDateTime, NumberContainer} from 'sentry/utils/discover/styles';
|
|
@@ -33,7 +33,7 @@ import {formatMetricUsingUnit} from 'sentry/utils/metrics/formatters';
|
|
|
import {parseMRI} from 'sentry/utils/metrics/mri';
|
|
|
import {
|
|
|
type Field as SelectedField,
|
|
|
- getSummaryValueForOp,
|
|
|
+ getSummaryValueForAggregation,
|
|
|
type MetricsSamplesResults,
|
|
|
type ResultField,
|
|
|
type Summary,
|
|
@@ -68,11 +68,11 @@ const fields: SelectedField[] = [
|
|
|
export type Field = (typeof fields)[number];
|
|
|
|
|
|
interface MetricsSamplesTableProps {
|
|
|
+ aggregation?: MetricAggregation;
|
|
|
focusArea?: SelectionRange;
|
|
|
hasPerformance?: boolean;
|
|
|
mri?: MRI;
|
|
|
onRowHover?: (sampleId?: string) => void;
|
|
|
- op?: string;
|
|
|
query?: string;
|
|
|
setMetricsSamples?: React.Dispatch<
|
|
|
React.SetStateAction<MetricsSamplesResults<Field>['data'] | undefined>
|
|
@@ -148,7 +148,7 @@ export function MetricSamplesTable({
|
|
|
focusArea,
|
|
|
mri,
|
|
|
onRowHover,
|
|
|
- op,
|
|
|
+ aggregation,
|
|
|
query,
|
|
|
setMetricsSamples,
|
|
|
sortKey = 'sort',
|
|
@@ -212,7 +212,7 @@ export function MetricSamplesTable({
|
|
|
max: focusArea?.max,
|
|
|
min: focusArea?.min,
|
|
|
mri,
|
|
|
- op,
|
|
|
+ aggregation,
|
|
|
query,
|
|
|
referrer: 'api.organization.metrics-samples',
|
|
|
enabled,
|
|
@@ -288,8 +288,8 @@ export function MetricSamplesTable({
|
|
|
}, [currentSort, location]);
|
|
|
|
|
|
const _renderBodyCell = useMemo(
|
|
|
- () => renderBodyCell(op, parsedMRI?.unit),
|
|
|
- [op, parsedMRI?.unit]
|
|
|
+ () => renderBodyCell(aggregation, parsedMRI?.unit),
|
|
|
+ [aggregation, parsedMRI?.unit]
|
|
|
);
|
|
|
|
|
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
@@ -409,7 +409,7 @@ function renderHeadCell(
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-function renderBodyCell(op?: string, unit?: string) {
|
|
|
+function renderBodyCell(aggregation?: MetricAggregation, unit?: string) {
|
|
|
return function (
|
|
|
col: GridColumnOrder<ResultField>,
|
|
|
dataRow: MetricsSamplesResults<SelectedField>['data'][number]
|
|
@@ -443,7 +443,13 @@ function renderBodyCell(op?: string, unit?: string) {
|
|
|
}
|
|
|
|
|
|
if (col.key === 'summary') {
|
|
|
- return <SummaryRenderer summary={dataRow.summary} op={op} unit={unit} />;
|
|
|
+ return (
|
|
|
+ <SummaryRenderer
|
|
|
+ summary={dataRow.summary}
|
|
|
+ aggregation={aggregation}
|
|
|
+ unit={unit}
|
|
|
+ />
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
if (col.key === 'timestamp') {
|
|
@@ -638,17 +644,17 @@ function DurationRenderer({duration}: {duration: number}) {
|
|
|
|
|
|
function SummaryRenderer({
|
|
|
summary,
|
|
|
- op,
|
|
|
+ aggregation,
|
|
|
unit,
|
|
|
}: {
|
|
|
summary: Summary;
|
|
|
- op?: string;
|
|
|
+ aggregation?: MetricAggregation;
|
|
|
unit?: string;
|
|
|
}) {
|
|
|
- const value = getSummaryValueForOp(summary, op);
|
|
|
+ const value = getSummaryValueForAggregation(summary, aggregation);
|
|
|
|
|
|
// if the op is `count`, then the unit does not apply
|
|
|
- unit = op === 'count' ? '' : unit;
|
|
|
+ unit = aggregation === 'count' ? '' : unit;
|
|
|
|
|
|
return (
|
|
|
<NumberContainer>{formatMetricUsingUnit(value ?? null, unit ?? '')}</NumberContainer>
|