Skip to content

Commit

Permalink
Deduplicate tags for spans
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 May 3, 2019
1 parent fe6c244 commit ce20fcb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/jaeger-ui/src/model/transform-trace-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,32 @@
import _isEqual from 'lodash/isEqual';

import { getTraceSpanIdsAsTree } from '../selectors/trace';
import { Process, Span, SpanData, Trace, TraceData } from '../types/trace';
import { KeyValuePair, Process, Span, SpanData, Trace, TraceData } from '../types/trace';
import TreeNode from '../utils/TreeNode';

type SpanWithProcess = SpanData & { process: Process };
/*
{
key: string;
value: any;
};
*/
function deduplicateTags(span: Span) {
let hasDuplicated: boolean = false;
span.tags = span.tags.reduce<Array<KeyValuePair>>((uniqueTags, tag) => {
if (
!uniqueTags.some(t => {
return t.key === tag.key && t.value == tag.value;
})
) {
uniqueTags.push(tag);
} else {
hasDuplicated = true;
}
return uniqueTags;
}, []);
span.hasDuplicatedTags = hasDuplicated;
}

/**
* NOTE: Mutates `data` - Transform the HTTP response data into the form the app
Expand Down Expand Up @@ -93,6 +115,7 @@ export default function transformTraceData(data: TraceData & { spans: SpanWithPr
span.relativeStartTime = span.startTime - traceStartTime;
span.depth = depth - 1;
span.hasChildren = node.children.length > 0;
deduplicateTags(span);
span.references.forEach(ref => {
const refSpan = spanMap.get(ref.spanID) as Span;
if (refSpan) {
Expand Down
1 change: 1 addition & 0 deletions packages/jaeger-ui/src/types/trace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type Span = SpanData & {
hasChildren: boolean;
process: Process;
relativeStartTime: number;
hasDuplicatedTags: boolean;
};

export type TraceData = {
Expand Down

0 comments on commit ce20fcb

Please sign in to comment.