Skip to content

Commit c17702c

Browse files
authored
feat(otlp): Use OTel-friendly default Explore fields (#93736)
If the OTel-friendly UI flag is on, change the default fields for Explore to ID, Name, Duration, and Timestamp. We are moving away from OP and Description. Is waiting for #93725 to add backend support I added field definitions to `FieldKeys`, since this `name` and `kind` are `SpanV2` fields, that are EAP-specific an the most recent. I also updated the type of span definitions to `Record<string, FieldDefinition>` since span fields are set by the user, so we'll never have a complete listing to definitions.
1 parent ba6e414 commit c17702c

File tree

5 files changed

+72
-11
lines changed

5 files changed

+72
-11
lines changed

static/app/utils/fields/index.ts

Lines changed: 23 additions & 5 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 {SpanIndexedField} from 'sentry/views/insights/types';
4+
import {SpanFields, SpanIndexedField} 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 {
@@ -1896,11 +1896,29 @@ const SPAN_HTTP_FIELD_DEFINITIONS: Record<SpanHttpField, FieldDefinition> = {
18961896
valueType: FieldValueType.SIZE,
18971897
},
18981898
};
1899-
1900-
const SPAN_FIELD_DEFINITIONS: Record<AllEventFieldKeys, FieldDefinition> = {
1899+
const SPAN_FIELD_DEFINITIONS: Record<string, FieldDefinition> = {
19011900
...EVENT_FIELD_DEFINITIONS,
19021901
...SPAN_AGGREGATION_FIELDS,
19031902
...SPAN_HTTP_FIELD_DEFINITIONS,
1903+
[SpanFields.NAME]: {
1904+
desc: t(
1905+
'The span name. A short, human-readable identifier for the operation being performed by the span.'
1906+
),
1907+
kind: FieldKind.FIELD,
1908+
valueType: FieldValueType.STRING,
1909+
},
1910+
[SpanFields.KIND]: {
1911+
desc: t(
1912+
'The kind of span. Indicates the type of span such as server, client, internal, producer, or consumer.'
1913+
),
1914+
kind: FieldKind.FIELD,
1915+
valueType: FieldValueType.STRING,
1916+
},
1917+
[SpanFields.STATUS]: {
1918+
desc: t('Span status. Indicates whether the span operation was successful.'),
1919+
kind: FieldKind.FIELD,
1920+
valueType: FieldValueType.STRING,
1921+
},
19041922
};
19051923

19061924
const LOG_FIELD_DEFINITIONS: Record<string, FieldDefinition> = {};
@@ -2609,8 +2627,8 @@ export const getFieldDefinition = (
26092627
}
26102628
return null;
26112629
case 'span':
2612-
if (SPAN_FIELD_DEFINITIONS[key as keyof typeof SPAN_FIELD_DEFINITIONS]) {
2613-
return SPAN_FIELD_DEFINITIONS[key as keyof typeof SPAN_FIELD_DEFINITIONS];
2630+
if (SPAN_FIELD_DEFINITIONS[key]) {
2631+
return SPAN_FIELD_DEFINITIONS[key];
26142632
}
26152633

26162634
// In EAP we have numeric tags that can be passed as parameters to

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import type {Location} from 'history';
22

3+
import type {Organization} from 'sentry/types/organization';
34
import {defined} from 'sentry/utils';
45
import {decodeList} from 'sentry/utils/queryString';
6+
import {SpanFields} from 'sentry/views/insights/types';
7+
8+
export function defaultFields(organization?: Organization): string[] {
9+
if (organization?.features.includes('performance-otel-friendly-ui')) {
10+
return [
11+
SpanFields.ID,
12+
SpanFields.NAME,
13+
SpanFields.SPAN_DURATION,
14+
SpanFields.TIMESTAMP,
15+
];
16+
}
517

6-
export function defaultFields(): string[] {
718
return [
819
'id',
920
'span.op',
@@ -14,14 +25,17 @@ export function defaultFields(): string[] {
1425
];
1526
}
1627

17-
export function getFieldsFromLocation(location: Location): string[] {
28+
export function getFieldsFromLocation(
29+
location: Location,
30+
organization?: Organization
31+
): string[] {
1832
const fields = decodeList(location.query.field);
1933

2034
if (fields.length) {
2135
return fields;
2236
}
2337

24-
return defaultFields();
38+
return defaultFields(organization);
2539
}
2640

2741
export function updateLocationWithFields(

static/app/views/explore/contexts/pageParamsContext/index.spec.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {OrganizationFixture} from 'sentry-fixture/organization';
2+
13
import {act, render} from 'sentry-test/reactTestingLibrary';
24

35
import {DiscoverDatasets} from 'sentry/utils/discover/types';
@@ -742,4 +744,23 @@ describe('PageParamsProvider', function () {
742744
})
743745
);
744746
});
747+
748+
it('uses OTel-friendly default fields in OTel-friendly mode', function () {
749+
const organization = OrganizationFixture({
750+
features: ['performance-otel-friendly-ui'],
751+
});
752+
753+
render(
754+
<PageParamsProvider>
755+
<Component />
756+
</PageParamsProvider>,
757+
{organization}
758+
);
759+
760+
expect(pageParams).toEqual(
761+
expect.objectContaining({
762+
fields: ['id', 'span.name', 'span.duration', 'timestamp'],
763+
})
764+
);
765+
});
745766
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export function PageParamsProvider({children}: PageParamsProviderProps) {
178178
const pageParams: ReadablePageParams = useMemo(() => {
179179
const aggregateFields = getAggregateFieldsFromLocation(location, organization);
180180
const dataset = getDatasetFromLocation(location);
181-
const fields = getFieldsFromLocation(location);
181+
const fields = getFieldsFromLocation(location, organization);
182182
const mode = getModeFromLocation(location);
183183
const query = getQueryFromLocation(location);
184184
const groupBys = aggregateFields.filter(isGroupBy).map(groupBy => groupBy.groupBy);

static/app/views/insights/types.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ export enum SpanMetricsField {
7070
MOBILE_SLOW_FRAMES = 'mobile.slow_frames',
7171
}
7272

73-
// TODO: This will be the final field type for eap spans
73+
// TODO: This will be the final field type for EAP spans
7474
export enum SpanFields {
7575
TRANSACTION = 'transaction',
7676
IS_TRANSACTION = 'is_transaction',
7777
CACHE_HIT = 'cache.hit',
7878
IS_STARRED_TRANSACTION = 'is_starred_transaction',
79+
ID = 'id',
80+
TIMESTAMP = 'timestamp',
7981
SPAN_DURATION = 'span.duration',
8082
USER = 'user',
8183
MOBILE_FROZEN_FRAMES = 'mobile.frozen_frames',
@@ -90,6 +92,9 @@ export enum SpanFields {
9092
SPAN_DESCRIPTION = 'span.description',
9193
SPAN_GROUP = 'span.group',
9294
SPAN_OP = 'span.op',
95+
NAME = 'span.name',
96+
KIND = 'span.kind',
97+
STATUS = 'span.status',
9398
RELEASE = 'release',
9499
PROJECT_ID = 'project.id',
95100
RESPONSE_CODE = 'span.status_code',
@@ -140,7 +145,10 @@ type SpanNumberFields =
140145
type SpanStringFields =
141146
| SpanMetricsField.RESOURCE_RENDER_BLOCKING_STATUS
142147
| SpanFields.RAW_DOMAIN
143-
| 'id'
148+
| SpanFields.ID
149+
| SpanFields.NAME
150+
| SpanFields.KIND
151+
| SpanFields.STATUS
144152
| 'span_id'
145153
| 'span.op'
146154
| 'span.description'

0 commit comments

Comments
 (0)