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

Dedupled search results DDG paths #558

Merged
merged 2 commits into from
Apr 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions packages/jaeger-ui/src/model/ddg/transformTracesToPaths.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,21 @@ describe('transform traces to ddg paths', () => {
const kindlessTrace = makeTrace([rootSpan, focalSpan, kindlessSpan], 'kindlessTraceID');

const { dependencies: result } = transformTracesToPaths(makeTraces(clientTrace, kindlessTrace), focalSvc);
expect(new Set(result)).toEqual(
new Set([
makeExpectedPath([rootSpan, focalSpan], clientTrace),
makeExpectedPath([rootSpan, focalSpan], kindlessTrace),
])
);

const path = makeExpectedPath([rootSpan, focalSpan], clientTrace);
path.attributes.push({ key: 'exemplar_trace_id', value: kindlessTrace.data.traceID });

expect(new Set(result)).toEqual(new Set([path]));
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
});

it('dedupled paths', () => {
const otherSpan = makeSpan('other-span', focalSpan);
otherSpan.hasChildren = false;
const trace1 = makeTrace([rootSpan, focalSpan, otherSpan], 'trace1');
const trace2 = makeTrace([rootSpan, focalSpan, otherSpan], 'trace2');
const { dependencies: result } = transformTracesToPaths(makeTraces(trace1, trace2), focalSvc);
const path = makeExpectedPath([rootSpan, focalSpan, otherSpan], trace1);
path.attributes.push({ key: 'exemplar_trace_id', value: trace2.data.traceID });
expect(new Set(result)).toEqual(new Set([path]));
});
});
31 changes: 20 additions & 11 deletions packages/jaeger-ui/src/model/ddg/transformTracesToPaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function transformTracesToPaths(
focalService: string,
focalOperation?: string
): TDdgPayload {
const dependencies: TDdgPayloadPath[] = [];
const dependenciesMap = new Map<String, TDdgPayloadPath>();
Object.values(traces).forEach(({ data }) => {
if (data) {
const spanMap: Map<string, Span> = new Map();
Expand Down Expand Up @@ -57,20 +57,29 @@ function transformTracesToPaths(
service === focalService && (!focalOperation || operation === focalOperation)
)
) {
// TODO: Paths should be deduped with all traceIDs #503
dependencies.push({
path,
attributes: [
{
key: 'exemplar_trace_id',
value: traceID,
},
],
});
const pathKey = path.map(value => `${value.operation}:${value.service}`).join('/');
const dependency = dependenciesMap.get(pathKey);
if (!dependency) {
dependenciesMap.set(pathKey, {
path,
attributes: [
{
key: 'exemplar_trace_id',
value: traceID,
},
],
});
} else {
dependency.attributes.push({
key: 'exemplar_trace_id',
value: traceID,
});
}
}
});
}
});
const dependencies = Array.from(dependenciesMap.values());
return { dependencies };
}

Expand Down