mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 03:11:01 -06:00
Traces: Order keys in span filter select (#66689)
* Order logs keys last * Add tests
This commit is contained in:
parent
3bc002cd27
commit
5c2a344ce1
@ -151,6 +151,23 @@ describe('SpanFilters', () => {
|
||||
await selectAndCheckValue(user, tagValue, 'TagValue0');
|
||||
});
|
||||
|
||||
it('should order tag filters', async () => {
|
||||
render(<SpanFiltersWithProps />);
|
||||
const tagKey = screen.getByLabelText('Select tag key');
|
||||
|
||||
await user.click(tagKey);
|
||||
jest.advanceTimersByTime(1000);
|
||||
await waitFor(() => {
|
||||
const container = screen.getByText('TagKey0').parentElement?.parentElement?.parentElement;
|
||||
expect(container?.childNodes[0].textContent).toBe('ProcessKey0');
|
||||
expect(container?.childNodes[1].textContent).toBe('ProcessKey1');
|
||||
expect(container?.childNodes[2].textContent).toBe('TagKey0');
|
||||
expect(container?.childNodes[3].textContent).toBe('TagKey1');
|
||||
expect(container?.childNodes[4].textContent).toBe('LogKey0');
|
||||
expect(container?.childNodes[5].textContent).toBe('LogKey1');
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow adding/removing tags', async () => {
|
||||
render(<SpanFiltersWithProps />);
|
||||
expect(screen.getAllByLabelText('Select tag key').length).toBe(1);
|
||||
|
@ -112,7 +112,8 @@ export const SpanFilters = memo((props: SpanFilterProps) => {
|
||||
|
||||
const getTagKeys = () => {
|
||||
if (!tagKeys) {
|
||||
const keys: string[] = [];
|
||||
let keys: string[] = [];
|
||||
let logKeys: string[] = [];
|
||||
|
||||
trace.spans.forEach((span) => {
|
||||
span.tags.forEach((tag) => {
|
||||
@ -124,18 +125,18 @@ export const SpanFilters = memo((props: SpanFilterProps) => {
|
||||
if (span.logs !== null) {
|
||||
span.logs.forEach((log) => {
|
||||
log.fields.forEach((field) => {
|
||||
keys.push(field.key);
|
||||
logKeys.push(field.key);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
keys = uniq(keys).sort();
|
||||
logKeys = uniq(logKeys).sort();
|
||||
|
||||
setTagKeys(
|
||||
uniq(keys)
|
||||
.sort()
|
||||
.map((name) => {
|
||||
return toOption(name);
|
||||
})
|
||||
[...keys, ...logKeys].map((name) => {
|
||||
return toOption(name);
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user