Skip to content

Commit 65012d6

Browse files
Abdkhan14Abdullah Khan
and
Abdullah Khan
authored
feat(trace-eap-waterfall): Sorting attributes. (#91814)
<img width="816" alt="Screenshot 2025-05-16 at 2 33 50 PM" src="https://github.com/user-attachments/assets/8aaaa9cb-f6f2-4339-9364-0cf1f8a7af62" /> Co-authored-by: Abdullah Khan <abdullahkhan@PG9Y57YDXQ.local>
1 parent 5d11c18 commit 65012d6

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

static/app/views/performance/newTraceDetails/traceContextTags.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import useOrganization from 'sentry/utils/useOrganization';
1212
import {AttributesTree} from 'sentry/views/explore/components/traceItemAttributes/attributesTree';
1313
import type {TraceRootEventQueryResults} from 'sentry/views/performance/newTraceDetails/traceApi/useTraceRootEvent';
1414
import {isTraceItemDetailsResponse} from 'sentry/views/performance/newTraceDetails/traceApi/utils';
15+
import {sortAttributes} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/utils';
1516
import {useHasTraceTabsUI} from 'sentry/views/performance/newTraceDetails/useHasTraceTabsUI';
1617

1718
type Props = {
@@ -35,7 +36,7 @@ export function TraceContextTags({rootEventResults}: Props) {
3536
const eventDetails = rootEventResults.data!;
3637
const rendered = isTraceItemDetailsResponse(eventDetails) ? (
3738
<AttributesTree
38-
attributes={eventDetails.attributes}
39+
attributes={sortAttributes(eventDetails.attributes)}
3940
rendererExtra={{
4041
theme,
4142
location,

static/app/views/performance/newTraceDetails/traceDrawer/details/span/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ import {FoldSection} from 'sentry/views/issueDetails/streamline/foldSection';
3737
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
3838
import {IssueList} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/issues/issues';
3939
import {TraceDrawerComponents} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/styles';
40-
import {getProfileMeta} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/utils';
40+
import {
41+
getProfileMeta,
42+
sortAttributes,
43+
} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/utils';
4144
import type {TraceTreeNodeDetailsProps} from 'sentry/views/performance/newTraceDetails/traceDrawer/tabs/traceTreeNodeDetails';
4245
import {isEAPSpanNode} from 'sentry/views/performance/newTraceDetails/traceGuards';
4346
import type {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
@@ -390,7 +393,7 @@ function EAPSpanNodeDetails({
390393
>
391394
<AttributesTree
392395
columnCount={columnCount}
393-
attributes={attributes}
396+
attributes={sortAttributes(attributes)}
394397
rendererExtra={{
395398
theme,
396399
location,

static/app/views/performance/newTraceDetails/traceDrawer/details/utils.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,20 @@ export function findSpanAttributeValue(
8282
) {
8383
return attributes.find(attribute => attribute.name === attributeName)?.value.toString();
8484
}
85+
86+
// Sort attributes so that span.* attributes are at the beginning and
87+
// the rest of the attributes are sorted alphabetically.
88+
export function sortAttributes(attributes: TraceItemResponseAttribute[]) {
89+
return [...attributes].sort((a, b) => {
90+
const aIsSpan = a.name.startsWith('span.');
91+
const bIsSpan = b.name.startsWith('span.');
92+
93+
if (aIsSpan && !bIsSpan) {
94+
return -1;
95+
}
96+
if (!aIsSpan && bIsSpan) {
97+
return 1;
98+
}
99+
return a.name.localeCompare(b.name);
100+
});
101+
}

0 commit comments

Comments
 (0)