Skip to content

Commit a7204f9

Browse files
authored
ref(insights): replace spanIndexedFields with spanFields (#95664)
1 parent d616e5b commit a7204f9

File tree

64 files changed

+546
-755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+546
-755
lines changed

static/app/components/performance/spanSearchQueryBuilder.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
import {useTraceItemTags} from 'sentry/views/explore/contexts/spanTagsContext';
2828
import {TraceItemDataset} from 'sentry/views/explore/types';
2929
import {SPANS_FILTER_KEY_SECTIONS} from 'sentry/views/insights/constants';
30-
import {SpanIndexedField} from 'sentry/views/insights/types';
30+
import {SpanFields} from 'sentry/views/insights/types';
3131
import {
3232
useSpanFieldCustomTags,
3333
useSpanFieldSupportedTags,
@@ -218,7 +218,7 @@ export function useEAPSpanSearchQueryBuilderProps(props: EAPSpanSearchQueryBuild
218218

219219
const numberAttributes = numberTags;
220220
const stringAttributes = useMemo(() => {
221-
if (stringTags.hasOwnProperty(SpanIndexedField.RELEASE)) {
221+
if (stringTags.hasOwnProperty(SpanFields.RELEASE)) {
222222
return {
223223
...stringTags,
224224
...STATIC_SEMVER_TAGS,

static/app/utils/fields/index.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {t} from 'sentry/locale';
22
import type {TagCollection} from 'sentry/types/group';
33
import {CONDITIONS_ARGUMENTS, WEB_VITALS_QUALITY} from 'sentry/utils/discover/types';
4-
import {SpanFields, SpanIndexedField} from 'sentry/views/insights/types';
4+
import {SpanFields} from 'sentry/views/insights/types';
55
// Don't forget to update https://docs.sentry.io/product/sentry-basics/search/searchable-properties/ for any changes made here
66

77
export enum FieldKind {
@@ -826,9 +826,9 @@ export const AGGREGATION_FIELDS: Record<AggregationKey, FieldDefinition> = {
826826
};
827827

828828
// TODO: Extend the two lists below with more options upon backend support
829-
export const ALLOWED_EXPLORE_VISUALIZE_FIELDS: SpanIndexedField[] = [
830-
SpanIndexedField.SPAN_DURATION, // DO NOT RE-ORDER: the first element is used as the default
831-
SpanIndexedField.SPAN_SELF_TIME,
829+
export const ALLOWED_EXPLORE_VISUALIZE_FIELDS: SpanFields[] = [
830+
SpanFields.SPAN_DURATION, // DO NOT RE-ORDER: the first element is used as the default
831+
SpanFields.SPAN_SELF_TIME,
832832
];
833833

834834
export const ALLOWED_EXPLORE_VISUALIZE_AGGREGATES: AggregationKey[] = [
@@ -859,7 +859,7 @@ const SPAN_AGGREGATION_FIELDS: Record<AggregationKey, FieldDefinition> = {
859859
kind: 'column',
860860
columnTypes: function ({key, valueType}) {
861861
return (
862-
key === SpanIndexedField.SPAN_DURATION &&
862+
key === SpanFields.SPAN_DURATION &&
863863
(valueType === FieldValueType.DURATION || valueType === FieldValueType.NUMBER)
864864
);
865865
},
@@ -1192,92 +1192,92 @@ const SPAN_OP_FIELDS: Record<SpanOpBreakdown, FieldDefinition> = {
11921192
};
11931193

11941194
type TraceFields =
1195-
| SpanIndexedField.IS_TRANSACTION
1196-
| SpanIndexedField.SPAN_ACTION
1197-
| SpanIndexedField.SPAN_DESCRIPTION
1198-
| SpanIndexedField.SPAN_DOMAIN
1199-
| SpanIndexedField.SPAN_DURATION
1200-
| SpanIndexedField.SPAN_GROUP
1201-
| SpanIndexedField.SPAN_CATEGORY
1202-
| SpanIndexedField.SPAN_OP
1203-
| SpanIndexedField.NORMALIZED_DESCRIPTION
1195+
| SpanFields.IS_TRANSACTION
1196+
| SpanFields.SPAN_ACTION
1197+
| SpanFields.SPAN_DESCRIPTION
1198+
| SpanFields.SPAN_DOMAIN
1199+
| SpanFields.SPAN_DURATION
1200+
| SpanFields.SPAN_GROUP
1201+
| SpanFields.SPAN_CATEGORY
1202+
| SpanFields.SPAN_OP
1203+
| SpanFields.NORMALIZED_DESCRIPTION
12041204
// TODO: Remove self time field when it is deprecated
1205-
| SpanIndexedField.SPAN_SELF_TIME
1206-
| SpanIndexedField.SPAN_STATUS
1207-
| SpanIndexedField.RESPONSE_CODE
1208-
| SpanIndexedField.CACHE_HIT;
1205+
| SpanFields.SPAN_SELF_TIME
1206+
| SpanFields.SPAN_STATUS
1207+
| SpanFields.SPAN_STATUS_CODE
1208+
| SpanFields.CACHE_HIT;
12091209

12101210
const TRACE_FIELD_DEFINITIONS: Record<TraceFields, FieldDefinition> = {
12111211
/** Indexed Fields */
1212-
[SpanIndexedField.SPAN_ACTION]: {
1212+
[SpanFields.SPAN_ACTION]: {
12131213
desc: t(
12141214
'The Sentry Insights span action, e.g `SELECT` for a SQL span or `POST` for an HTTP client span'
12151215
),
12161216
kind: FieldKind.FIELD,
12171217
valueType: FieldValueType.STRING,
12181218
},
1219-
[SpanIndexedField.SPAN_DESCRIPTION]: {
1219+
[SpanFields.SPAN_DESCRIPTION]: {
12201220
desc: t('Description of the span’s operation'),
12211221
kind: FieldKind.FIELD,
12221222
valueType: FieldValueType.STRING,
12231223
},
1224-
[SpanIndexedField.NORMALIZED_DESCRIPTION]: {
1224+
[SpanFields.NORMALIZED_DESCRIPTION]: {
12251225
desc: t(
12261226
'Parameterized and normalized description of the span, commonly used for grouping within insights'
12271227
),
12281228
kind: FieldKind.FIELD,
12291229
valueType: FieldValueType.STRING,
12301230
},
1231-
[SpanIndexedField.SPAN_DOMAIN]: {
1231+
[SpanFields.SPAN_DOMAIN]: {
12321232
desc: t(
12331233
'General scope of the span’s action, i.e. the tables involved in a `db` span or the host name in an `http` span'
12341234
),
12351235
kind: FieldKind.FIELD,
12361236
valueType: FieldValueType.STRING,
12371237
},
1238-
[SpanIndexedField.SPAN_DURATION]: {
1238+
[SpanFields.SPAN_DURATION]: {
12391239
desc: t('The total time taken by the span'),
12401240
kind: FieldKind.METRICS,
12411241
valueType: FieldValueType.DURATION,
12421242
},
1243-
[SpanIndexedField.SPAN_GROUP]: {
1243+
[SpanFields.SPAN_GROUP]: {
12441244
desc: t('Unique hash of the span’s description'),
12451245
kind: FieldKind.FIELD,
12461246
valueType: FieldValueType.STRING,
12471247
},
1248-
[SpanIndexedField.SPAN_CATEGORY]: {
1248+
[SpanFields.SPAN_CATEGORY]: {
12491249
desc: t(
12501250
'The prefix of the span operation, e.g if `span.op` is `http.client`, then `span.category` is `http`'
12511251
),
12521252
kind: FieldKind.FIELD,
12531253
valueType: FieldValueType.STRING,
12541254
},
1255-
[SpanIndexedField.SPAN_OP]: {
1255+
[SpanFields.SPAN_OP]: {
12561256
desc: t('The operation of the span, e.g `http.client`, `middleware`'),
12571257
kind: FieldKind.FIELD,
12581258
valueType: FieldValueType.STRING,
12591259
},
1260-
[SpanIndexedField.SPAN_SELF_TIME]: {
1260+
[SpanFields.SPAN_SELF_TIME]: {
12611261
desc: t('The duration of the span excluding the duration of its child spans'),
12621262
kind: FieldKind.METRICS,
12631263
valueType: FieldValueType.DURATION,
12641264
},
1265-
[SpanIndexedField.SPAN_STATUS]: {
1265+
[SpanFields.SPAN_STATUS]: {
12661266
desc: t('Status of the operation the span represents'),
12671267
kind: FieldKind.FIELD,
12681268
valueType: FieldValueType.STRING,
12691269
},
1270-
[SpanIndexedField.RESPONSE_CODE]: {
1270+
[SpanFields.SPAN_STATUS_CODE]: {
12711271
desc: t('The HTTP response status code'),
12721272
kind: FieldKind.FIELD,
12731273
valueType: FieldValueType.STRING,
12741274
},
1275-
[SpanIndexedField.IS_TRANSACTION]: {
1275+
[SpanFields.IS_TRANSACTION]: {
12761276
desc: t('The span is also a transaction'),
12771277
kind: FieldKind.FIELD,
12781278
valueType: FieldValueType.BOOLEAN,
12791279
},
1280-
[SpanIndexedField.CACHE_HIT]: {
1280+
[SpanFields.CACHE_HIT]: {
12811281
desc: t('`true` if the cache was hit, `false` otherwise'),
12821282
kind: FieldKind.FIELD,
12831283
valueType: FieldValueType.BOOLEAN,
@@ -1928,7 +1928,7 @@ const SPAN_FIELD_DEFINITIONS: Record<string, FieldDefinition> = {
19281928
kind: FieldKind.FIELD,
19291929
valueType: FieldValueType.STRING,
19301930
},
1931-
[SpanFields.STATUS]: {
1931+
[SpanFields.SPAN_STATUS]: {
19321932
desc: t('Span status. Indicates whether the span operation was successful.'),
19331933
kind: FieldKind.FIELD,
19341934
valueType: FieldValueType.STRING,

static/app/views/dashboards/widgets/common/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export type TabularMeta<TFields extends string = string> = {
7171

7272
export type TabularRow<TFields extends string = string> = Record<
7373
TFields,
74-
number | string | string[] | null
74+
number | string | string[] | boolean | null
7575
>;
7676

7777
export type TabularData<TFields extends string = string> = {

static/app/views/explore/components/schemaHints/schemaHintsList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
} from 'sentry/views/explore/contexts/logs/logsPageParams';
4141
import {LOGS_FILTER_KEY_SECTIONS} from 'sentry/views/explore/logs/constants';
4242
import {SPANS_FILTER_KEY_SECTIONS} from 'sentry/views/insights/constants';
43-
import {SpanIndexedField} from 'sentry/views/insights/types';
43+
import {SpanFields} from 'sentry/views/insights/types';
4444

4545
const SCHEMA_HINTS_DRAWER_WIDTH = '350px';
4646

@@ -75,9 +75,9 @@ function getTagsFromKeys(keys: string[], tags: TagCollection): Tag[] {
7575
.map(key => {
7676
if (key === USER_IDENTIFIER_KEY) {
7777
return (
78-
tags[SpanIndexedField.USER_EMAIL] ||
79-
tags[SpanIndexedField.USER_USERNAME] ||
80-
tags[SpanIndexedField.USER_ID]
78+
tags[SpanFields.USER_EMAIL] ||
79+
tags[SpanFields.USER_USERNAME] ||
80+
tags[SpanFields.USER_ID]
8181
);
8282
}
8383
return tags[key];

static/app/views/explore/components/schemaHints/schemaHintsUtils.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import type {TagCollection} from 'sentry/types/group';
22
import {FieldKey} from 'sentry/utils/fields';
33
import {OurLogKnownFieldKey} from 'sentry/views/explore/logs/types';
4-
import {SpanIndexedField} from 'sentry/views/insights/types';
4+
import {SpanFields} from 'sentry/views/insights/types';
55

66
export const USER_IDENTIFIER_KEY = 'user.key';
77

8-
const FRONTEND_HINT_KEYS = [SpanIndexedField.BROWSER_NAME, USER_IDENTIFIER_KEY];
8+
const FRONTEND_HINT_KEYS = [SpanFields.BROWSER_NAME, USER_IDENTIFIER_KEY];
99

1010
const MOBILE_HINT_KEYS = [FieldKey.OS_NAME, FieldKey.DEVICE_FAMILY, USER_IDENTIFIER_KEY];
1111

1212
const COMMON_HINT_KEYS = [
13-
SpanIndexedField.IS_TRANSACTION,
14-
SpanIndexedField.SPAN_OP,
15-
SpanIndexedField.SPAN_DESCRIPTION,
16-
SpanIndexedField.SPAN_DURATION,
17-
SpanIndexedField.TRANSACTION,
13+
SpanFields.IS_TRANSACTION,
14+
SpanFields.SPAN_OP,
15+
SpanFields.SPAN_DESCRIPTION,
16+
SpanFields.SPAN_DURATION,
17+
SpanFields.TRANSACTION,
1818
FieldKey.HTTP_STATUS_CODE,
19-
SpanIndexedField.RELEASE,
19+
SpanFields.RELEASE,
2020
'url',
2121
];
2222

static/app/views/explore/constants.tsx

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
import {OurLogKnownFieldKey} from 'sentry/views/explore/logs/types';
2-
import {SpanFields, SpanIndexedField} from 'sentry/views/insights/types';
2+
import {SpanFields} from 'sentry/views/insights/types';
33

44
export const SENTRY_SEARCHABLE_SPAN_STRING_TAGS: string[] = [
55
// NOTE: intentionally choose to not expose transaction id
66
// as we're moving toward span ids
77

88
'id', // SpanIndexedField.SPAN_ID is actually `span_id`
99
'profile.id', // SpanIndexedField.PROFILE_ID is actually `profile_id`
10-
SpanIndexedField.BROWSER_NAME,
11-
SpanIndexedField.ENVIRONMENT,
12-
SpanIndexedField.ORIGIN_TRANSACTION,
13-
SpanIndexedField.PROJECT,
14-
SpanIndexedField.RAW_DOMAIN,
15-
SpanIndexedField.RELEASE,
16-
SpanIndexedField.SDK_NAME,
17-
SpanIndexedField.SDK_VERSION,
18-
SpanIndexedField.SPAN_ACTION,
19-
SpanIndexedField.SPAN_CATEGORY,
20-
SpanIndexedField.SPAN_DESCRIPTION,
21-
SpanIndexedField.SPAN_DOMAIN,
22-
SpanIndexedField.SPAN_GROUP,
23-
SpanIndexedField.SPAN_OP,
24-
SpanIndexedField.SPAN_STATUS,
25-
SpanIndexedField.TIMESTAMP,
26-
SpanIndexedField.TRACE,
27-
SpanIndexedField.TRANSACTION,
28-
SpanIndexedField.TRANSACTION_METHOD,
29-
SpanIndexedField.TRANSACTION_OP,
30-
SpanIndexedField.USER,
31-
SpanIndexedField.USER_EMAIL,
32-
SpanIndexedField.USER_GEO_SUBREGION,
33-
SpanIndexedField.USER_ID,
34-
SpanIndexedField.USER_IP,
35-
SpanIndexedField.USER_USERNAME,
36-
SpanIndexedField.IS_TRANSACTION, // boolean field but we can expose it as a string
37-
SpanIndexedField.NORMALIZED_DESCRIPTION,
38-
SpanIndexedField.CACHE_HIT,
10+
SpanFields.BROWSER_NAME,
11+
SpanFields.ENVIRONMENT,
12+
SpanFields.ORIGIN_TRANSACTION,
13+
SpanFields.PROJECT,
14+
SpanFields.RAW_DOMAIN,
15+
SpanFields.RELEASE,
16+
SpanFields.SDK_NAME,
17+
SpanFields.SDK_VERSION,
18+
SpanFields.SPAN_ACTION,
19+
SpanFields.SPAN_CATEGORY,
20+
SpanFields.SPAN_DESCRIPTION,
21+
SpanFields.SPAN_DOMAIN,
22+
SpanFields.SPAN_GROUP,
23+
SpanFields.SPAN_OP,
24+
SpanFields.SPAN_STATUS,
25+
SpanFields.TIMESTAMP,
26+
SpanFields.TRACE,
27+
SpanFields.TRANSACTION,
28+
SpanFields.TRANSACTION_METHOD,
29+
SpanFields.TRANSACTION_OP,
30+
SpanFields.USER,
31+
SpanFields.USER_EMAIL,
32+
SpanFields.USER_GEO_SUBREGION,
33+
SpanFields.USER_ID,
34+
SpanFields.USER_IP,
35+
SpanFields.USER_USERNAME,
36+
SpanFields.IS_TRANSACTION, // boolean field but we can expose it as a string
37+
SpanFields.NORMALIZED_DESCRIPTION,
38+
SpanFields.CACHE_HIT,
3939
];
4040

4141
export const SENTRY_SEARCHABLE_SPAN_NUMBER_TAGS: string[] = [
42-
SpanIndexedField.SPAN_DURATION,
43-
SpanIndexedField.SPAN_SELF_TIME,
42+
SpanFields.SPAN_DURATION,
43+
SpanFields.SPAN_SELF_TIME,
4444
];
4545

4646
export const SENTRY_SPAN_STRING_TAGS: string[] = [
4747
'id', // SpanIndexedField.SPAN_ID is actually `span_id`
48-
SpanIndexedField.PROJECT,
49-
SpanIndexedField.SPAN_DESCRIPTION,
50-
SpanIndexedField.SPAN_OP,
51-
SpanIndexedField.TIMESTAMP,
52-
SpanIndexedField.TRANSACTION,
53-
SpanIndexedField.TRACE,
54-
SpanIndexedField.IS_TRANSACTION, // boolean field but we can expose it as a string
55-
SpanIndexedField.NORMALIZED_DESCRIPTION,
56-
SpanIndexedField.RELEASE, // temporary as orgs with >1k keys still want releases
48+
SpanFields.PROJECT,
49+
SpanFields.SPAN_DESCRIPTION,
50+
SpanFields.SPAN_OP,
51+
SpanFields.TIMESTAMP,
52+
SpanFields.TRANSACTION,
53+
SpanFields.TRACE,
54+
SpanFields.IS_TRANSACTION, // boolean field but we can expose it as a string
55+
SpanFields.NORMALIZED_DESCRIPTION,
56+
SpanFields.RELEASE, // temporary as orgs with >1k keys still want releases
5757
SpanFields.PROJECT_ID,
5858
SpanFields.SPAN_SYSTEM,
5959
SpanFields.SPAN_CATEGORY,

static/app/views/explore/contexts/pageParamsContext/visualizes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from 'sentry/utils/fields';
1717
import {decodeList} from 'sentry/utils/queryString';
1818
import {ChartType} from 'sentry/views/insights/common/components/chart';
19-
import {SpanIndexedField} from 'sentry/views/insights/types';
19+
import {SpanFields} from 'sentry/views/insights/types';
2020

2121
export const MAX_VISUALIZES = 4;
2222

@@ -168,7 +168,7 @@ export function updateVisualizeAggregate({
168168
// and carry the argument if it's the same type, reset to a default
169169
// if it's not the same type. Just hard coding it for now for simplicity
170170
// as `count_unique` is the only aggregate that takes a string.
171-
return `${newAggregate}(${SpanIndexedField.SPAN_OP})`;
171+
return `${newAggregate}(${SpanFields.SPAN_OP})`;
172172
}
173173

174174
if (NO_ARGUMENT_SPAN_AGGREGATES.includes(newAggregate as AggregationKey)) {

static/app/views/explore/hooks/useVisualizeFields.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from 'sentry/utils/fields';
1414
import {AttributeDetails} from 'sentry/views/explore/components/attributeDetails';
1515
import {TypeBadge} from 'sentry/views/explore/components/typeBadge';
16-
import {SpanIndexedField} from 'sentry/views/insights/types';
16+
import {SpanFields} from 'sentry/views/insights/types';
1717

1818
interface UseVisualizeFieldsProps {
1919
numberTags: TagCollection;
@@ -29,9 +29,9 @@ export function useVisualizeFields({
2929
const [kind, tags]: [FieldKind, TagCollection] = useMemo(() => {
3030
if (parsedFunction?.name === AggregationKey.COUNT) {
3131
const countTags: TagCollection = {
32-
[SpanIndexedField.SPAN_DURATION]: {
32+
[SpanFields.SPAN_DURATION]: {
3333
name: t('spans'),
34-
key: SpanIndexedField.SPAN_DURATION,
34+
key: SpanFields.SPAN_DURATION,
3535
},
3636
};
3737
return [FieldKind.MEASUREMENT, countTags];

static/app/views/explore/tables/tracesTable/fieldRenderers.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import useProjects from 'sentry/utils/useProjects';
2323
import type {TraceResult} from 'sentry/views/explore/hooks/useTraces';
2424
import {BREAKDOWN_SLICES} from 'sentry/views/explore/hooks/useTraces';
2525
import type {SpanResult} from 'sentry/views/explore/hooks/useTraceSpans';
26-
import type {SpanIndexedField, SpanIndexedResponse} from 'sentry/views/insights/types';
26+
import type {EAPSpanResponse, SpanFields} from 'sentry/views/insights/types';
2727
import {TraceViewSources} from 'sentry/views/performance/newTraceDetails/traceHeader/breadcrumbs';
2828
import {getTraceDetailsUrl} from 'sentry/views/performance/traceDetails/utils';
2929

@@ -482,7 +482,7 @@ export function SpanTimeRenderer({
482482
);
483483
}
484484

485-
type SpanStatus = SpanIndexedResponse[SpanIndexedField.SPAN_STATUS];
485+
type SpanStatus = EAPSpanResponse[SpanFields.SPAN_STATUS];
486486

487487
const STATUS_TO_TAG_TYPE: Record<SpanStatus, keyof Theme['tag']> = {
488488
ok: 'success',

0 commit comments

Comments
 (0)