Skip to content

Commit e37778b

Browse files
committed
ref(insights): Make SpanFields.SPAN_GROUP nullable
Move SPAN_GROUP from NonNullableStringFields to NullableStringFields, reflecting the reality that OpenTelemetry-ingested spans can have null span.group values. This makes SpanResponse['span.group'] resolve to string | null, letting TypeScript catch unsafe usages. Fix all surfaced type errors by updating prop types to accept null and adding null coalescing where values are passed to MutableSearch.
1 parent 8aabafc commit e37778b

File tree

7 files changed

+12
-10
lines changed

7 files changed

+12
-10
lines changed

static/app/components/events/eventStatisticalDetector/eventRegressionTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {formatPercentage} from 'sentry/utils/number/formatPercentage';
1818
import {unreachable} from 'sentry/utils/unreachable';
1919

2020
export interface EventRegressionTableRow {
21-
group: string;
21+
group: string | null;
2222
operation: string;
2323
percentageChange: number;
2424
description?: string;

static/app/views/dashboards/widgets/detailsWidget/detailsWidgetVisualization.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function DetailsWidgetVisualization(props: DetailsWidgetVisualizationProp
6161
(spanDescription.split('?')[0] ?? '').split('.').pop()?.toLowerCase() ?? ''
6262
);
6363

64-
if (isImage) {
64+
if (isImage && spanGroup) {
6565
const projectId = span[SpanFields.PROJECT_ID]
6666
? Number(span[SpanFields.PROJECT_ID])
6767
: undefined;

static/app/views/insights/common/components/fullSpanDescription.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const formatter = new SQLishFormatter();
2121
interface Props {
2222
moduleName: ModuleName;
2323
filters?: Record<string, string>;
24-
group?: string;
24+
group?: string | null;
2525
shortDescription?: string;
2626
}
2727

@@ -33,7 +33,10 @@ export function FullSpanDescription({
3333
}: Props) {
3434
const {data: indexedSpans, isFetching: areIndexedSpansLoading} = useSpans(
3535
{
36-
search: MutableSearch.fromQueryObject({'span.group': group, ...filters}),
36+
search: MutableSearch.fromQueryObject({
37+
'span.group': group ?? undefined,
38+
...filters,
39+
}),
3740
limit: 1,
3841
fields: [
3942
SpanFields.PROJECT_ID,
@@ -104,7 +107,7 @@ export function FullSpanDescription({
104107

105108
type TruncatedQueryClipBoxProps = {
106109
children: ReactNode;
107-
group: string | undefined;
110+
group: string | null | undefined;
108111
};
109112

110113
function QueryClippedBox({group, children}: TruncatedQueryClipBoxProps) {

static/app/views/insights/common/components/spanDescription.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function DatabaseSpanDescription({
4949

5050
const {data: indexedSpans, isFetching: areIndexedSpansLoading} = useSpans(
5151
{
52-
search: MutableSearch.fromQueryObject({'span.group': groupId}),
52+
search: MutableSearch.fromQueryObject({'span.group': groupId ?? undefined}),
5353
limit: 1,
5454
fields: [
5555
SpanFields.PROJECT_ID,

static/app/views/insights/common/components/spanGroupDetailsLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface Props {
1717
moduleName: ModuleName.DB | ModuleName.RESOURCE;
1818
projectId: number;
1919
extraLinkQueryParams?: Record<string, string>;
20-
group?: string;
20+
group?: string | null;
2121
spanOp?: string;
2222
}
2323

static/app/views/insights/common/components/tableCells/spanDescriptionCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface Props {
1919
moduleName: ModuleName.DB | ModuleName.RESOURCE;
2020
projectId: number;
2121
extraLinkQueryParams?: Record<string, string>;
22-
group?: string;
22+
group?: string | null;
2323
spanAction?: string;
2424
spanOp?: string;
2525
system?: string;

static/app/views/insights/types.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ export type NonNullableStringFields =
314314
| SpanFields.FILE_EXTENSION
315315
| SpanFields.SPAN_OP
316316
| SpanFields.SPAN_DESCRIPTION
317-
| SpanFields.SPAN_GROUP
318317
| SpanFields.SPAN_CATEGORY
319318
| SpanFields.SPAN_SYSTEM
320319
| SpanFields.TIMESTAMP
@@ -331,7 +330,7 @@ export type NonNullableStringFields =
331330
| SpanFields.USER_DISPLAY
332331
| SpanFields.SENTRY_ORIGIN;
333332

334-
type NullableStringFields = SpanFields.NORMALIZED_DESCRIPTION;
333+
type NullableStringFields = SpanFields.NORMALIZED_DESCRIPTION | SpanFields.SPAN_GROUP;
335334

336335
export type SpanStringFields = NullableStringFields | NonNullableStringFields;
337336

0 commit comments

Comments
 (0)