Skip to content

Commit 811bebd

Browse files
committed
refactoring, fix tests
1 parent 3ba8b9c commit 811bebd

File tree

6 files changed

+42
-46
lines changed

6 files changed

+42
-46
lines changed

static/app/utils/discover/fieldRenderers.tsx

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import {
4747
SPAN_OP_BREAKDOWN_FIELDS,
4848
SPAN_OP_RELATIVE_BREAKDOWN_FIELD,
4949
} from 'sentry/utils/discover/fields';
50-
import {generateLinkToEventInTraceView} from 'sentry/utils/discover/urls';
5150
import ViewReplayLink from 'sentry/utils/discover/viewReplayLink';
5251
import {getShortEventId} from 'sentry/utils/events';
5352
import {formatRate} from 'sentry/utils/formatters';
@@ -68,7 +67,6 @@ import {SpanDescriptionCell} from 'sentry/views/insights/common/components/table
6867
import {StarredSegmentCell} from 'sentry/views/insights/common/components/tableCells/starredSegmentCell';
6968
import {TimeSpentCell} from 'sentry/views/insights/common/components/tableCells/timeSpentCell';
7069
import {ModuleName, SpanFields, SpanMetricsField} from 'sentry/views/insights/types';
71-
import {getTraceDetailsUrl} from 'sentry/views/performance/traceDetails/utils';
7270
import {
7371
filterToLocationQuery,
7472
SpanOperationBreakdownFilter,
@@ -143,7 +141,9 @@ const EmptyValueContainer = styled('span')`
143141
color: ${p => p.theme.subText};
144142
`;
145143
const emptyValue = <EmptyValueContainer>{t('(no value)')}</EmptyValueContainer>;
146-
const emptyStringValue = <EmptyValueContainer>{t('(empty string)')}</EmptyValueContainer>;
144+
export const emptyStringValue = (
145+
<EmptyValueContainer>{t('(empty string)')}</EmptyValueContainer>
146+
);
147147
const missingUserMisery = tct(
148148
'We were unable to calculate User Misery. A likely cause of this is that the user was not set. [link:Read the docs]',
149149
{
@@ -476,30 +476,12 @@ const SPECIAL_FIELDS: Record<string, SpecialField> = {
476476
},
477477
id: {
478478
sortField: 'id',
479-
renderFunc: (data, {organization, location}) => {
479+
renderFunc: data => {
480480
const id: string | unknown = data?.id;
481481
if (typeof id !== 'string') {
482482
return <Container>{emptyStringValue}</Container>;
483483
}
484-
485-
if (!data.trace) {
486-
return <Container>{getShortEventId(id)}</Container>;
487-
}
488-
489-
const target = generateLinkToEventInTraceView({
490-
traceSlug: data.trace,
491-
timestamp: data.timestamp,
492-
targetId: data['transaction.span_id'],
493-
organization,
494-
location,
495-
spanId: id,
496-
});
497-
498-
return (
499-
<Container>
500-
<Link to={target}>{getShortEventId(id)}</Link>
501-
</Container>
502-
);
484+
return <Container>{getShortEventId(id)}</Container>;
503485
},
504486
},
505487
span_id: {
@@ -564,25 +546,13 @@ const SPECIAL_FIELDS: Record<string, SpecialField> = {
564546
},
565547
trace: {
566548
sortField: 'trace',
567-
renderFunc: (data, {organization, location}) => {
549+
renderFunc: data => {
568550
const id: string | unknown = data?.trace;
569551
if (typeof id !== 'string') {
570552
return emptyValue;
571553
}
572554

573-
const target = getTraceDetailsUrl({
574-
traceSlug: data.trace,
575-
timestamp: data.timestamp,
576-
organization,
577-
dateSelection: {statsPeriod: undefined, start: undefined, end: undefined},
578-
location,
579-
});
580-
581-
return (
582-
<Container>
583-
<Link to={target}>{getShortEventId(id)}</Link>
584-
</Container>
585-
);
555+
return <Container>{getShortEventId(id)}</Container>;
586556
},
587557
},
588558
'issue.id': {

static/app/utils/discover/styles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ export const UserIcon = styled(IconUser)`
6666
export const IconContainer = styled('div')`
6767
display: flex;
6868
gap: ${space(1)};
69-
width: 100%;
69+
overflow: hidden;
70+
text-overflow: ellipsis;
7071
`;

static/app/views/dashboards/datasetConfig/spans.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import pickBy from 'lodash/pickBy';
22

33
import {doEventsRequest} from 'sentry/actionCreators/events';
44
import type {Client} from 'sentry/api';
5+
import {Link} from 'sentry/components/core/link';
56
import type {PageFilters} from 'sentry/types/core';
67
import type {TagCollection} from 'sentry/types/group';
78
import type {
@@ -13,14 +14,17 @@ import type {
1314
import toArray from 'sentry/utils/array/toArray';
1415
import type {CustomMeasurementCollection} from 'sentry/utils/customMeasurements/customMeasurements';
1516
import type {EventsTableData, TableData} from 'sentry/utils/discover/discoverQuery';
16-
import {getFieldRenderer} from 'sentry/utils/discover/fieldRenderers';
17+
import type {RenderFunctionBaggage} from 'sentry/utils/discover/fieldRenderers';
18+
import {emptyStringValue, getFieldRenderer} from 'sentry/utils/discover/fieldRenderers';
1719
import type {Aggregation, QueryFieldValue} from 'sentry/utils/discover/fields';
1820
import {
1921
type DiscoverQueryExtras,
2022
type DiscoverQueryRequestParams,
2123
doDiscoverQuery,
2224
} from 'sentry/utils/discover/genericDiscoverQuery';
2325
import {DiscoverDatasets} from 'sentry/utils/discover/types';
26+
import {generateLinkToEventInTraceView} from 'sentry/utils/discover/urls';
27+
import {getShortEventId} from 'sentry/utils/events';
2428
import {
2529
AggregationKey,
2630
ALLOWED_EXPLORE_VISUALIZE_AGGREGATES,
@@ -172,6 +176,9 @@ export const SpansConfig: DatasetConfig<
172176
transformSeries: transformEventsResponseToSeries,
173177
filterAggregateParams,
174178
getCustomFieldRenderer: (field, meta, widget, _organization) => {
179+
if (field === 'id') {
180+
return renderEventInTraceView;
181+
}
175182
if (field === 'trace') {
176183
return renderTraceAsLinkable(widget);
177184
}
@@ -356,3 +363,23 @@ function filterSeriesSortOptions(columns: Set<string>) {
356363
return columns.has(option.value.meta.name);
357364
};
358365
}
366+
367+
function renderEventInTraceView(
368+
data: any,
369+
{location, organization}: RenderFunctionBaggage
370+
) {
371+
const spanId: string = data.id;
372+
if (!spanId) {
373+
return emptyStringValue;
374+
}
375+
const target = generateLinkToEventInTraceView({
376+
traceSlug: data.trace,
377+
timestamp: data.timestamp,
378+
targetId: data['transaction.span_id'],
379+
organization,
380+
location,
381+
spanId,
382+
});
383+
384+
return <Link to={target}>{getShortEventId(spanId)}</Link>;
385+
}

static/app/views/discover/table/tableView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ function TableView(props: TableViewProps) {
379379

380380
const idLink = (
381381
<StyledLink data-test-id="view-event" to={target}>
382-
{getShortEventId(dataRow[columnKey])}
382+
{cell}
383383
</StyledLink>
384384
);
385385

static/app/views/explore/tables/fieldRenderer.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function BaseExploreFieldRenderer({
146146
source: TraceViewSources.TRACES,
147147
});
148148

149-
rendered = <Link to={target}>{data[field]}</Link>;
149+
rendered = <Link to={target}>{rendered}</Link>;
150150
}
151151

152152
if (['id', 'span_id', 'transaction.id'].includes(field)) {
@@ -162,9 +162,7 @@ function BaseExploreFieldRenderer({
162162
source: TraceViewSources.TRACES,
163163
});
164164

165-
rendered = (
166-
<Link to={target}>{spanId ? getShortEventId(data[field]) : data[field]}</Link>
167-
);
165+
rendered = <Link to={target}>{rendered}</Link>;
168166
}
169167

170168
if (field === 'profile.id') {

static/app/views/performance/transactionEvents.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ describe('Performance > TransactionSummary', function () {
237237
expect(tableFirstRowColumns[2]).toHaveTextContent('(no value)');
238238
expect(tableFirstRowColumns[3]).toHaveTextContent('400.00ms');
239239
expect(tableFirstRowColumns[4]).toHaveTextContent('1234');
240-
expect(tableFirstRowColumns[5]).toHaveTextContent('May 21, 2020 3:31:18 PM UTC');
240+
expect(tableFirstRowColumns[5]).toHaveTextContent('in 3y');
241241

242242
ProjectsStore.reset();
243243
});
@@ -268,7 +268,7 @@ describe('Performance > TransactionSummary', function () {
268268
expect(tableFirstRowColumns[3]).toHaveTextContent('200');
269269
expect(tableFirstRowColumns[4]).toHaveTextContent('400.00ms');
270270
expect(tableFirstRowColumns[5]).toHaveTextContent('1234');
271-
expect(tableFirstRowColumns[6]).toHaveTextContent('May 21, 2020 3:31:18 PM UTC');
271+
expect(tableFirstRowColumns[6]).toHaveTextContent('in 3y');
272272

273273
ProjectsStore.reset();
274274
});

0 commit comments

Comments
 (0)