Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uiFind matches for spans with leading 0s #567

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
22 changes: 22 additions & 0 deletions packages/jaeger-ui/src/utils/filter-spans.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,28 @@ describe('filterSpans', () => {
expect(filterSpans(spanID2, spans)).toEqual(new Set([spanID2]));
});

it('should return spans whose spanID matches a filter except for leading 0s', () => {
const spanID0WithLeading0s = `00${spanID0}`;
const spanID2WithLeading0s = `00${spanID2}`;

expect(filterSpans('spanID', spans)).toEqual(new Set([]));
expect(filterSpans(spanID0WithLeading0s, spans)).toEqual(new Set([spanID0]));
expect(filterSpans(spanID2WithLeading0s, spans)).toEqual(new Set([spanID2]));

const spansWithLeading0s = [
{
...span0,
spanID: spanID0WithLeading0s,
},
{
...span2,
spanID: spanID2WithLeading0s,
},
];
expect(filterSpans(spanID0, spansWithLeading0s)).toEqual(new Set([spanID0WithLeading0s]));
expect(filterSpans(spanID2, spansWithLeading0s)).toEqual(new Set([spanID2WithLeading0s]));
});

it('should return spans whose operationName match a filter', () => {
expect(filterSpans('operationName', spans)).toEqual(new Set([spanID0, spanID2]));
expect(filterSpans('operationName0', spans)).toEqual(new Set([spanID0]));
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/utils/filter-spans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function filterSpans(textFilter: string, spans: Span[] | TNil) {
isTextInKeyValues(span.tags) ||
span.logs.some(log => isTextInKeyValues(log.fields)) ||
isTextInKeyValues(span.process.tags) ||
includeFilters.some(filter => filter === span.spanID);
includeFilters.some(filter => filter.replace(/^0*/, '') === span.spanID.replace(/^0*/, ''));

// declare as const because need to disambiguate the type
const rv: Set<string> = new Set(spans.filter(isSpanAMatch).map((span: Span) => span.spanID));
Expand Down