Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/10609.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Update discover traces column names ([#10609](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10609))
22 changes: 22 additions & 0 deletions src/plugins/explore/public/helpers/data_table_helper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,27 @@ describe('data_table_helper', () => {
expect(result[0].isRemoveable).toBe(true); // _source is removeable when there are other columns
expect(result[1].isRemoveable).toBe(true);
});

it('should have human readable column names', () => {
const columns = [
'name',
'durationNano',
'resource.attributes.service.name',
'attributes.service.name',
'attributes.http.status_code',
'status.code',
'spanId',
];

const result = getLegacyDisplayedColumns(columns, mockIndexPattern, true, false);

expect(result[0].displayName).toBe('Service Identifier');
expect(result[1].displayName).toBe('Duration');
expect(result[2].displayName).toBe('Service');
expect(result[3].displayName).toBe('Service.Name');
expect(result[4].displayName).toBe('Status code');
expect(result[5].displayName).toBe('Status');
expect(result[6].displayName).toBe('SpanID');
});
});
});
26 changes: 25 additions & 1 deletion src/plugins/explore/public/helpers/data_table_helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ export function getTimeColumn(
colRightIdx: -1,
};
}

function getColumnDisplayName(column: string): string {
switch (column) {
case 'name':
return 'Service Identifier';
case 'durationNano':
return 'Duration';
case 'resource.attributes.service.name':
return 'Service';
case 'attributes.service.name':
return 'Service.Name';
case 'attributes.http.status_code':
return 'Status code';
case 'status.code':
return 'Status';
case 'spanId':
return 'SpanID';
default:
return column;
}
}

/**
* A given array of column names returns an array of properties
* necessary to display the columns. If the given indexPattern
Expand All @@ -93,13 +115,15 @@ export function getLegacyDisplayedColumns(
if (!Array.isArray(columns) || !indexPattern || !indexPattern.getFieldByName) {
return [];
}

// TODO: Remove overrides once we support PPL/SQL sorting
const osdFieldOverrides = getOsdFieldOverrides();
const columnProps = columns.map((column, idx) => {
const field = indexPattern.getFieldByName(column);
const columnDisplayName = getColumnDisplayName(column);
return {
name: column,
displayName: isShortDots ? shortenDottedString(column) : column,
displayName: isShortDots ? shortenDottedString(columnDisplayName) : columnDisplayName,
isSortable: osdFieldOverrides.sortable ?? !!field?.sortable,
isRemoveable: column !== '_source' || columns.length > 1,
colLeftIdx: idx - 1 < 0 ? -1 : idx - 1,
Expand Down
Loading