Skip to content

Commit a4fd775

Browse files
k-fishadrian-codecov
authored andcommitted
fix(ourlogs): Prettify attribute name in log table header (#88644)
### Summary We're returning 'tags[...,number]' now we should prettify the header as well.
1 parent bf9537b commit a4fd775

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

static/app/views/explore/logs/logsTable.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
useSetLogsCursor,
2626
useSetLogsSortBys,
2727
} from 'sentry/views/explore/contexts/logs/logsPageParams';
28+
import {useTraceItemAttributes} from 'sentry/views/explore/contexts/traceItemAttributeContext';
2829
import {LogRowContent} from 'sentry/views/explore/logs/logsTableRow';
2930
import {
3031
FirstTableHeadCell,
@@ -53,6 +54,9 @@ export function LogsTable({
5354
const search = useLogsSearch();
5455
const setCursor = useSetLogsCursor();
5556
const isTableEditingFrozen = useLogsIsTableEditingFrozen();
57+
const {attributes: stringAttributes} = useTraceItemAttributes('string');
58+
const {attributes: numberAttributes} = useTraceItemAttributes('number');
59+
5660
const {data, isError, isPending, pageLinks, meta} = tableData;
5761

5862
const tableRef = useRef<HTMLTableElement>(null);
@@ -81,7 +85,11 @@ export function LogsTable({
8185

8286
const fieldType = meta?.fields?.[field];
8387
const align = logsFieldAlignment(field, fieldType);
84-
const headerLabel = getTableHeaderLabel(field);
88+
const headerLabel = getTableHeaderLabel(
89+
field,
90+
stringAttributes,
91+
numberAttributes
92+
);
8593

8694
if (isPending) {
8795
return <TableHeadCell key={index} isFirst={index === 0} />;

static/app/views/explore/logs/utils.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as Sentry from '@sentry/react';
22

33
import {t} from 'sentry/locale';
4+
import type {TagCollection} from 'sentry/types/group';
45
import {defined} from 'sentry/utils';
56
import type {TableDataRow} from 'sentry/utils/discover/discoverQuery';
67
import type {EventsMetaType} from 'sentry/utils/discover/eventView';
@@ -132,7 +133,7 @@ export function logsFieldAlignment(...args: Parameters<typeof fieldAlignment>) {
132133
return fieldAlignment(...args);
133134
}
134135

135-
export function removePrefixes(key: string) {
136+
function removePrefixes(key: string) {
136137
return key.replace('log.', '').replace('sentry.', '');
137138
}
138139

@@ -152,8 +153,16 @@ export function adjustAliases(key: string) {
152153
}
153154
}
154155

155-
export function getTableHeaderLabel(field: OurLogFieldKey) {
156-
return LogAttributesHumanLabel[field] ?? removePrefixes(field);
156+
export function getTableHeaderLabel(
157+
field: OurLogFieldKey,
158+
stringAttributes: TagCollection,
159+
numberAttributes: TagCollection
160+
) {
161+
const attribute = stringAttributes[field] ?? numberAttributes[field] ?? null;
162+
163+
return (
164+
LogAttributesHumanLabel[field] ?? attribute?.name ?? prettifyAttributeName(field)
165+
);
157166
}
158167

159168
export function isLogAttributeUnit(unit: string | null): unit is LogAttributeUnits {

0 commit comments

Comments
 (0)