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

Fix trace name resolution for spans with remote parents #461

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/model/trace-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

// eslint-disable-next-line import/prefer-default-export
export function getTraceName(spans) {
const span = spans.filter(sp => !sp.references || !sp.references.length)[0];
const span = spans.find(sp => !sp.references || !sp.references.some(ref => ref.traceID === sp.traceID));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like an equivalent or a superset of the previous logic.

I would rather fix this like this:

  • find all spans that either have no parent reference, or a parent reference that is not found in the trace
  • if only one such span is found, it's the root (i.e. source of "trace name")
  • if more than one such span is found, then
    • if exactly one of them has no parent refs, it's the root
    • otherwise give up (or, could still do something like pick the one with the earliest start time)

Clearly, we need a set of unit tests for this logic.

return span ? `${span.process.serviceName}: ${span.operationName}` : '';
}
7 changes: 2 additions & 5 deletions packages/jaeger-ui/src/model/transform-trace-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import _isEqual from 'lodash/isEqual';
import { getTraceSpanIdsAsTree } from '../selectors/trace';
import { KeyValuePair, Span, SpanData, Trace, TraceData } from '../types/trace';
import TreeNode from '../utils/TreeNode';
import { getTraceName } from './trace-viewer';

function deduplicateTags(spanTags: Array<KeyValuePair>) {
const warningsHash: Map<string, string> = new Map<string, string>();
Expand Down Expand Up @@ -87,7 +88,6 @@ export default function transformTraceData(data: TraceData & { spans: SpanData[]
const tree = getTraceSpanIdsAsTree(data);
const spans: Span[] = [];
const svcCounts: Record<string, number> = {};
let traceName = '';

tree.walk((spanID: string, node: TreeNode, depth: number = 0) => {
if (spanID === '__root__') {
Expand All @@ -99,9 +99,6 @@ export default function transformTraceData(data: TraceData & { spans: SpanData[]
}
const { serviceName } = span.process;
svcCounts[serviceName] = (svcCounts[serviceName] || 0) + 1;
if (!span.references || !span.references.length) {
traceName = `${serviceName}: ${span.operationName}`;
}
span.relativeStartTime = span.startTime - traceStartTime;
span.depth = depth - 1;
span.hasChildren = node.children.length > 0;
Expand All @@ -125,7 +122,7 @@ export default function transformTraceData(data: TraceData & { spans: SpanData[]
services,
spans,
traceID,
traceName,
traceName: getTraceName(spans),
// can't use spread operator for intersection types
// repl: https://goo.gl/4Z23MJ
// issue: https://github.com/facebook/flow/issues/1511
Expand Down