Skip to content

Commit

Permalink
Dedupled search results DDG paths
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
  • Loading branch information
rubenvp8510 committed Apr 8, 2020
1 parent 2ba4e7f commit 0f7ca18
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
11 changes: 5 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,10 @@ 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]));
});
});
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

0 comments on commit 0f7ca18

Please sign in to comment.