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

Gracefully handle spans without logs field #2191

Merged
merged 1 commit into from
Mar 1, 2024
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
14 changes: 14 additions & 0 deletions packages/jaeger-ui/src/utils/filter-spans.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ describe('filterSpans', () => {
},
],
};

// span3 contain empty logs
const spanID3 = 'span-id-3';
const span3 = {
spanID: spanID3,
operationName: 'operationName3',
process: {
serviceName: 'serviceName3',
},
};
const spans = [span0, span2];

it('should return `null` if spans is falsy', () => {
Expand Down Expand Up @@ -242,6 +252,10 @@ describe('filterSpans', () => {
expect(filterSpans('"processTag Value3" -processTagKey3', spans)).toEqual(new Set());
});

it("span without log shouldn't break filtering", () => {
expect(filterSpans('operationName2', [span2, span3])).toEqual(new Set([spanID2]));
});

// This test may false positive if other tests are failing
it('should return an empty set if no spans match the filter', () => {
expect(filterSpans('-processTagKey1', spans)).toEqual(new Set());
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 @@ -60,7 +60,7 @@ export default function filterSpans(textFilter: string, spans: Span[] | TNil) {
isTextInFilters(includeFilters, span.operationName) ||
isTextInFilters(includeFilters, span.process.serviceName) ||
isTextInKeyValues(span.tags) ||
(span.logs !== null && span.logs.some(log => isTextInKeyValues(log.fields))) ||
(Array.isArray(span.logs) && span.logs.some(log => isTextInKeyValues(log.fields))) ||
isTextInKeyValues(span.process.tags) ||
includeFilters.some(filter => filter.replace(/^0*/, '') === span.spanID.replace(/^0*/, ''));

Expand Down
Loading