Skip to content

Commit

Permalink
Fix uiFind matches for spans with leading 0s (jaegertracing#567)
Browse files Browse the repository at this point in the history
Signed-off-by: Everett Ross <reverett@uber.com>
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
  • Loading branch information
everett980 committed Apr 29, 2020
1 parent 56cc4f2 commit a853db4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
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

0 comments on commit a853db4

Please sign in to comment.