Skip to content

Commit

Permalink
DDG: Remove kind.server filter and handle service calling itself
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 ac02294
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions packages/jaeger-ui/src/model/ddg/transformTracesToPaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { TDdgPayloadEntry, TDdgPayloadPath, TDdgPayload } from './types';
import { FetchedTrace } from '../../types';
import { Span } from '../../types/trace';

const isKindServer = (span: Span) =>
span.tags.find(({ key, value }) => key === 'span.kind' && value === 'server');

function transformTracesToPaths(
traces: Record<string, FetchedTrace>,
focalService: string,
Expand All @@ -36,20 +39,31 @@ function transformTracesToPaths(
return !span.hasChildren;
})
.forEach(leaf => {
const spans = spanAncestorIds(leaf).map(id => {
const spans = spanAncestorIds(leaf).reduce((acumulator: Span[], id: string): Span[] => {
const span = spanMap.get(id);
if (!span) throw new Error(`Ancestor spanID ${id} not found in trace ${traceID}`);
return span;
});
if (acumulator.length > 0) {
const headSpan = acumulator[acumulator.length - 1];
// Transition inside the same service ServiceA -> ServiceA
if (headSpan.processID === span.processID) {
if (isKindServer(span) && !isKindServer(headSpan)) {
acumulator.pop();
acumulator.push(span);
} else if (isKindServer(span) && isKindServer(headSpan)) {
acumulator.push(span);
}
return acumulator;
}
}
acumulator.push(span);
return acumulator;
}, []);
spans.reverse();
spans.push(leaf);

const path: TDdgPayloadEntry[] = spans
.filter(span => span.tags.find(({ key, value }) => key === 'span.kind' && value === 'server'))
.map(({ processID, operationName: operation }) => ({
service: data.processes[processID].serviceName,
operation,
}));
const path: TDdgPayloadEntry[] = spans.map(({ processID, operationName: operation }) => ({
service: data.processes[processID].serviceName,
operation,
}));

if (
path.some(
Expand Down

0 comments on commit ac02294

Please sign in to comment.