Просмотр исходного кода

fix(starfish): use span.self_time instead of span.duration (#51051)

Dominik Buszowiecki 1 год назад
Родитель
Сommit
8d7c60b2b7

+ 3 - 0
static/app/views/starfish/components/chart.tsx

@@ -48,6 +48,9 @@ export const STARFISH_FIELDS: Record<string, {outputType: AggregationOutputType}
   [SpanMetricsFields.SPAN_DURATION]: {
     outputType: 'duration',
   },
+  [SpanMetricsFields.SPAN_SELF_TIME]: {
+    outputType: 'duration',
+  },
 };
 
 type Props = {

+ 3 - 3
static/app/views/starfish/components/samplesTable/spanSamplesTable.tsx

@@ -33,8 +33,8 @@ const COLUMN_ORDER: TableColumnHeader[] = [
 
 type SpanTableRow = {
   description: string;
-  duration: number;
   op: string;
+  'span.self_time': number;
   span_id: string;
   timestamp: string;
   transaction: {
@@ -82,14 +82,14 @@ export function SpanSamplesTable({isLoading, data, p95}: Props) {
       return (
         <SpanDurationBar
           spanOp={row.op}
-          spanDuration={row.duration}
+          spanDuration={row['span.self_time']}
           transactionDuration={row.transaction['transaction.duration']}
         />
       );
     }
 
     if (column.key === 'p95_comparison') {
-      return <DurationComparisonCell duration={row.duration} p95={p95} />;
+      return <DurationComparisonCell duration={row['span.self_time']} p95={p95} />;
     }
 
     if (column.key === 'timestamp') {

+ 1 - 1
static/app/views/starfish/queries/types.tsx

@@ -12,10 +12,10 @@ export type IndexedSpan = {
   action: string;
   description: string;
   domain: string;
-  duration: number;
   group: string;
   module: string;
   op: string;
+  'span.self_time': number;
   span_id: string;
   timestamp: string;
   transaction_id: string;

+ 8 - 7
static/app/views/starfish/queries/useSpanList.tsx

@@ -5,22 +5,23 @@ import {defined} from 'sentry/utils';
 import EventView from 'sentry/utils/discover/eventView';
 import {DiscoverDatasets} from 'sentry/utils/discover/types';
 import {useLocation} from 'sentry/utils/useLocation';
-import {ModuleName} from 'sentry/views/starfish/types';
+import {ModuleName, SpanMetricsFields} from 'sentry/views/starfish/types';
 import {useSpansQuery} from 'sentry/views/starfish/utils/useSpansQuery';
 import {NULL_SPAN_CATEGORY} from 'sentry/views/starfish/views/webServiceView/spanGroupBreakdownContainer';
 
+const {SPAN_SELF_TIME} = SpanMetricsFields;
 const SPAN_FILTER_KEYS = ['span.op', 'span.domain', 'span.action'];
 
 export type SpanMetrics = {
-  'p95(span.duration)': number;
-  'percentile_percent_change(span.duration, 0.95)': number;
+  'p95(span.self_time)': number;
+  'percentile_percent_change(span.self_time, 0.95)': number;
   'span.description': string;
   'span.domain': string;
   'span.group': string;
   'span.op': string;
   'sps()': number;
   'sps_percent_change()': number;
-  'sum(span.duration)': number;
+  'sum(span.self_time)': number;
   'time_spent_percentage()': number;
 };
 
@@ -77,10 +78,10 @@ function getEventView(
         'span.domain',
         'sps()',
         'sps_percent_change()',
-        'sum(span.duration)',
-        'p95(span.duration)',
+        `sum(${SPAN_SELF_TIME})`,
+        `p95(${SPAN_SELF_TIME})`,
         'time_spent_percentage()',
-        'percentile_percent_change(span.duration, 0.95)',
+        `percentile_percent_change(${SPAN_SELF_TIME}, 0.95)`,
       ],
       orderby: orderBy,
       dataset: DiscoverDatasets.SPANS_METRICS,

+ 2 - 2
static/app/views/starfish/queries/useSpanMetricsSeries.tsx

@@ -13,9 +13,9 @@ import {useSpansQuery} from 'sentry/views/starfish/utils/useSpansQuery';
 
 export type SpanMetrics = {
   interval: number;
-  'p95(span.duration)': number;
+  'p95(span.self_time)': number;
   'sps()': number;
-  'sum(span.duration)': number;
+  'sum(span.self_time)': number;
   'time_spent_percentage()': number;
 };
 

+ 2 - 1
static/app/views/starfish/queries/useSpanSamples.tsx

@@ -4,6 +4,7 @@ import {DiscoverDatasets} from 'sentry/utils/discover/types';
 import {useLocation} from 'sentry/utils/useLocation';
 import useOrganization from 'sentry/utils/useOrganization';
 import type {IndexedSpan} from 'sentry/views/starfish/queries/types';
+import {SpanIndexedFields} from 'sentry/views/starfish/types';
 
 const DEFAULT_LIMIT = 10;
 const DEFAULT_ORDER_BY = '-duration';
@@ -31,7 +32,7 @@ export function useSpanSamples(
         'description',
         'domain',
         'module',
-        'duration',
+        SpanIndexedFields.SPAN_SELF_TIME,
         'op',
         'transaction_id',
         'timestamp',

+ 9 - 6
static/app/views/starfish/queries/useSpanTransactionMetrics.tsx

@@ -4,12 +4,15 @@ import EventView from 'sentry/utils/discover/eventView';
 import {DiscoverDatasets} from 'sentry/utils/discover/types';
 import {useLocation} from 'sentry/utils/useLocation';
 import type {IndexedSpan} from 'sentry/views/starfish/queries/types';
+import {SpanMetricsFields} from 'sentry/views/starfish/types';
 import {useSpansQuery} from 'sentry/views/starfish/utils/useSpansQuery';
 
+const {SPAN_SELF_TIME} = SpanMetricsFields;
+
 export type SpanTransactionMetrics = {
-  'p50(span.duration)': number;
-  'p95(span.duration)': number;
-  'percentile_percent_change(span.duration, 0.95)': number;
+  'p50(span.self_time)': number;
+  'p95(span.self_time)': number;
+  'percentile_percent_change(span.self_time, 0.95)': number;
   'sps()': number;
   'sps_percent_change()': number;
   'sum(span.self_time)': number;
@@ -48,9 +51,9 @@ function getEventView(span: {group: string}, location: Location, transactions: s
         'transaction',
         'sps()',
         'sps_percent_change()',
-        'sum(span.duration)',
-        'p95(span.duration)',
-        'percentile_percent_change(span.duration, 0.95)',
+        `sum(${SPAN_SELF_TIME})`,
+        `p95(${SPAN_SELF_TIME})`,
+        `percentile_percent_change(${SPAN_SELF_TIME}, 0.95)`,
         'time_spent_percentage(local)',
       ],
       orderby: '-time_spent_percentage_local',

+ 12 - 0
static/app/views/starfish/types.tsx

@@ -1,3 +1,5 @@
+import {DiscoverDatasets} from 'sentry/utils/discover/types';
+
 export enum ModuleName {
   HTTP = 'http',
   DB = 'db',
@@ -11,4 +13,14 @@ export enum SpanMetricsFields {
   SPAN_ACTION = 'span.action',
   SPAN_DOMAIN = 'span.domain',
   SPAN_DURATION = 'span.duration',
+  SPAN_SELF_TIME = 'span.self_time',
+}
+
+export enum SpanIndexedFields {
+  SPAN_SELF_TIME = 'span.self_time',
 }
+
+export const StarfishDatasetFields = {
+  [DiscoverDatasets.SPANS_METRICS]: SpanIndexedFields,
+  [DiscoverDatasets.SPANS_INDEXED]: SpanIndexedFields,
+};

+ 15 - 5
static/app/views/starfish/views/spanSummaryPage/index.tsx

@@ -24,11 +24,14 @@ import {TimeSpentCell} from 'sentry/views/starfish/components/tableCells/timeSpe
 import {useSpanMeta} from 'sentry/views/starfish/queries/useSpanMeta';
 import {useSpanMetrics} from 'sentry/views/starfish/queries/useSpanMetrics';
 import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useSpanMetricsSeries';
+import {SpanMetricsFields} from 'sentry/views/starfish/types';
 import formatThroughput from 'sentry/views/starfish/utils/chartValueFormatters/formatThroughput';
 import {DataTitles} from 'sentry/views/starfish/views/spans/types';
 import {SampleList} from 'sentry/views/starfish/views/spanSummaryPage/sampleList';
 import {SpanTransactionsTable} from 'sentry/views/starfish/views/spanSummaryPage/spanTransactionsTable';
 
+const {SPAN_SELF_TIME} = SpanMetricsFields;
+
 type Props = {
   location: Location;
 } & RouteComponentProps<{groupId: string}, {transaction: string}>;
@@ -55,7 +58,12 @@ function SpanSummaryPage({params, location}: Props) {
   const {data: spanMetrics} = useSpanMetrics(
     {group: groupId},
     queryFilter,
-    ['sps()', 'sum(span.duration)', 'p95(span.duration)', 'time_spent_percentage()'],
+    [
+      'sps()',
+      `sum(${SPAN_SELF_TIME})`,
+      `p95(${SPAN_SELF_TIME})`,
+      'time_spent_percentage()',
+    ],
     'span-summary-page-metrics'
   );
 
@@ -63,7 +71,7 @@ function SpanSummaryPage({params, location}: Props) {
     useSpanMetricsSeries(
       {group: groupId},
       queryFilter,
-      ['p95(span.duration)', 'sps()'],
+      [`p95(${SPAN_SELF_TIME})`, 'sps()'],
       'sidebar-span-metrics'
     );
 
@@ -94,7 +102,9 @@ function SpanSummaryPage({params, location}: Props) {
                     <ThroughputCell throughputPerSecond={spanMetrics?.['sps()']} />
                   </Block>
                   <Block title={t('Duration')} description={t('Time spent in this span')}>
-                    <DurationCell milliseconds={spanMetrics?.['p95(span.duration)']} />
+                    <DurationCell
+                      milliseconds={spanMetrics?.[`p95(${SPAN_SELF_TIME})`]}
+                    />
                   </Block>
                   <Block
                     title={t('Time Spent')}
@@ -104,7 +114,7 @@ function SpanSummaryPage({params, location}: Props) {
                   >
                     <TimeSpentCell
                       timeSpentPercentage={spanMetrics?.['time_spent_percentage()']}
-                      totalSpanTime={spanMetrics?.['sum(span.duration)']}
+                      totalSpanTime={spanMetrics?.[`p95(${SPAN_SELF_TIME})`]}
                     />
                   </Block>
                 </BlockContainer>
@@ -147,7 +157,7 @@ function SpanSummaryPage({params, location}: Props) {
                       <Chart
                         statsPeriod="24h"
                         height={140}
-                        data={[spanMetricsSeriesData?.['p95(span.duration)']]}
+                        data={[spanMetricsSeriesData?.[`p95(${SPAN_SELF_TIME})`]]}
                         start=""
                         end=""
                         loading={areSpanMetricsSeriesLoading}

+ 6 - 3
static/app/views/starfish/views/spanSummaryPage/sampleList/durationChart/index.tsx

@@ -7,8 +7,11 @@ import {P95_COLOR} from 'sentry/views/starfish/colours';
 import Chart from 'sentry/views/starfish/components/chart';
 import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useSpanMetricsSeries';
 import {useSpanSamples} from 'sentry/views/starfish/queries/useSpanSamples';
+import {SpanMetricsFields} from 'sentry/views/starfish/types';
 import {DataTitles} from 'sentry/views/starfish/views/spans/types';
 
+const {SPAN_SELF_TIME} = SpanMetricsFields;
+
 type Props = {
   groupId: string;
   transactionName: string;
@@ -21,7 +24,7 @@ function DurationChart({groupId, transactionName}: Props) {
   const {isLoading, data: spanMetricsSeriesData} = useSpanMetricsSeries(
     {group: groupId},
     {transactionName},
-    ['p95(span.duration)'],
+    [`p95(${SPAN_SELF_TIME})`],
     'sidebar-span-metrics'
   );
 
@@ -34,7 +37,7 @@ function DurationChart({groupId, transactionName}: Props) {
   );
 
   const sampledSpanDataSeries: Series[] = spans.map(
-    ({timestamp, duration, transaction_id}) => ({
+    ({timestamp, 'span.self_time': duration, transaction_id}) => ({
       data: [
         {
           name: moment(timestamp).unix(),
@@ -54,7 +57,7 @@ function DurationChart({groupId, transactionName}: Props) {
       <Chart
         statsPeriod="24h"
         height={140}
-        data={[spanMetricsSeriesData?.['p95(span.duration)']]}
+        data={[spanMetricsSeriesData?.[`p95(${SPAN_SELF_TIME})`]]}
         start=""
         end=""
         loading={isLoading}

Некоторые файлы не были показаны из-за большого количества измененных файлов