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

Fixes lens crash when trace data lacks localEndpoint.serviceName #3099

Merged
merged 1 commit into from May 29, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions zipkin-lens/src/components/DiscoverPage/TracesTab/util.js
Expand Up @@ -39,9 +39,6 @@ export const sortTraceSummaries = (traceSummaries, sortingMethod) => {
export const extractAllServiceNames = (traceSummaries) => {
const result = [];
traceSummaries.forEach((traceSummary) => {
if (!traceSummary.serviceSummaries) {
return;
}
traceSummary.serviceSummaries.forEach((serviceSummary) => {
result.push(serviceSummary.serviceName);
});
Expand Down
2 changes: 2 additions & 0 deletions zipkin-lens/src/zipkin/trace.js
Expand Up @@ -215,6 +215,8 @@ export function traceSummaries(serviceName, summaries, utc = false) {
10,
);
}
} else {
res.serviceSummaries = [];
}

if (t.errorType !== 'none') res.infoClass = `trace-error-${t.errorType}`;
Expand Down
62 changes: 62 additions & 0 deletions zipkin-lens/src/zipkin/trace.test.js
Expand Up @@ -94,8 +94,63 @@ const httpTrace = [
},
];

const missingLocalEndpointTrace = [
{
traceId: '0b3ba16a811130ed',
parentId: '0b3ba16a811130ed',
id: '37c9d5cfc985592b',
kind: 'SERVER',
name: 'get',
timestamp: 1587434790009238,
duration: 10803,
remoteEndpoint: {
ipv4: '127.0.0.1',
port: 64529,
},
tags: {
'http.method': 'GET',
'http.path': '/api',
'mvc.controller.class': 'Backend',
},
shared: true,
},
{
traceId: '0b3ba16a811130ed',
parentId: '0b3ba16a811130ed',
id: '37c9d5cfc985592b',
kind: 'CLIENT',
name: 'get',
timestamp: 1587434789956001,
duration: 74362,
tags: {
'http.method': 'GET',
'http.path': '/api',
},
},
{
traceId: '0b3ba16a811130ed',
id: '0b3ba16a811130ed',
kind: 'SERVER',
name: 'get',
timestamp: 1587434789934510,
duration: 103410,
remoteEndpoint: {
ipv6: '::1',
port: 64528,
},
tags: {
'http.method': 'GET',
'http.path': '/',
'mvc.controller.class': 'Frontend',
},
},
];

// renders data into a tree for traceMustache
const cleanedHttpTrace = treeCorrectedForClockSkew(httpTrace);
const cleanedMissingLocalEndpointTrace = treeCorrectedForClockSkew(
missingLocalEndpointTrace,
);

describe('traceSummary', () => {
it('should classify durations local to the endpoint', () => {
Expand Down Expand Up @@ -182,6 +237,13 @@ describe('traceSummariesToMustache', () => {
expect(model[0].duration).toBe(168.731);
});

it('should render empty serviceSummaries when spans lack localEndpoint', () => {
const model = traceSummaries(null, [
traceSummary(cleanedMissingLocalEndpointTrace),
]);
expect(model[0].serviceSummaries).toEqual([]);
});

it('should get service summaries, ordered descending by max span duration', () => {
const model = traceSummaries(null, [summary]);
expect(model[0].serviceSummaries).toEqual([
Expand Down