Skip to content

Commit cbc3025

Browse files
authored
Merge pull request #134 from jaegertracing/fix-trace-name-resolution
Fix trace name resolution
2 parents 6e5fa22 + c6cc8fe commit cbc3025

File tree

8 files changed

+29
-12
lines changed

8 files changed

+29
-12
lines changed

src/components/SearchTracePage/TraceResultsScatterPlot.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import dimensions from 'react-dimensions';
1919
import { XYPlot, XAxis, YAxis, MarkSeries, Hint } from 'react-vis';
2020
import { compose, withState, withProps } from 'recompose';
2121

22+
import FALLBACK_TRACE_NAME from '../../constants/fallback-trace-name';
2223
import { formatDuration } from '../../utils/date';
2324

2425
import './react-vis.css';
@@ -47,7 +48,7 @@ function TraceResultsScatterPlotBase(props) {
4748
/>
4849
{overValue && (
4950
<Hint value={overValue}>
50-
<h4 className="scatter-plot-hint">{overValue.name || '¯\\_(ツ)_/¯'}</h4>
51+
<h4 className="scatter-plot-hint">{overValue.name || FALLBACK_TRACE_NAME}</h4>
5152
</Hint>
5253
)}
5354
</XYPlot>

src/components/SearchTracePage/TraceSearchResult.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import moment from 'moment';
1919

2020
import { formatDuration } from '../../utils/date';
2121
import TraceServiceTag from './TraceServiceTag';
22+
import FALLBACK_TRACE_NAME from '../../constants/fallback-trace-name';
2223

2324
import './TraceSearchResult.css';
2425

@@ -36,7 +37,7 @@ export default function TraceSearchResult({ trace, durationPercent = 100 }) {
3637
background: getBackgroundStyle(durationPercent),
3738
}}
3839
>
39-
<span className="trace-search-result--traceName left">{traceName}</span>
40+
<span className="trace-search-result--traceName left">{traceName || FALLBACK_TRACE_NAME}</span>
4041
<span className="trace-search-result--duration right">{formatDuration(duration * 1000)}</span>
4142
</div>
4243
<div className="p1">

src/components/TracePage/TracePageHeader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as React from 'react';
1818
import { Dropdown, Menu } from 'semantic-ui-react';
1919

2020
import KeyboardShortcutsHelp from './KeyboardShortcutsHelp';
21+
import FALLBACK_TRACE_NAME from '../../constants/fallback-trace-name';
2122
import { formatDatetime, formatDuration } from '../../utils/date';
2223

2324
type TracePageHeaderProps = {
@@ -91,7 +92,7 @@ export default function TracePageHeader(props: TracePageHeaderProps) {
9192
style={{ float: 'none' }}
9293
/>
9394
</a>
94-
{name}
95+
{name || FALLBACK_TRACE_NAME}
9596
</h2>
9697
</div>
9798
<div className="inline-block mr1">

src/components/TracePage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export default class TracePage extends React.PureComponent<TracePageProps, Trace
243243
<TracePageHeader
244244
duration={duration}
245245
maxDepth={maxSpanDepth}
246-
name={getTraceName(spans, processes)}
246+
name={getTraceName(spans)}
247247
numServices={numberOfServices}
248248
numSpans={spans.length}
249249
slimView={slimView}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2017 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
export default '<cannot-find-trace-name>';

src/model/search.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ export function getTraceSummary(trace: Trace): TraceSummary {
3939
let numErrorSpans = 0;
4040
// serviceName -> { name, numberOfSpans }
4141
const serviceMap = {};
42-
4342
for (let i = 0; i < spans.length; i++) {
44-
const { duration, processID, spanID, startTime, tags } = spans[i];
43+
const { duration, processID, references, startTime, tags } = spans[i];
4544
// time bounds of trace
4645
minTs = minTs > startTime ? startTime : minTs;
4746
maxTs = maxTs < startTime + duration ? startTime + duration : maxTs;
@@ -61,8 +60,7 @@ export function getTraceSummary(trace: Trace): TraceSummary {
6160
};
6261
serviceMap[serviceName] = svcData;
6362
}
64-
// trace name
65-
if (spanID === traceID) {
63+
if (!references || !references.length) {
6664
const { operationName } = spans[i];
6765
traceName = `${svcData.name}: ${operationName}`;
6866
}

src/model/search.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('getTraceSummary()', () => {
5151
{
5252
traceID: 'main-id',
5353
processID: 'pid0',
54-
spanID: 'main-id',
54+
spanID: 'span-id-0',
5555
operationName: 'op0',
5656
startTime: 1502221240933000,
5757
duration: 236857,
@@ -65,6 +65,7 @@ describe('getTraceSummary()', () => {
6565
startTime: 1502221241144382,
6666
duration: 25305,
6767
tags: [],
68+
references: [{ refType: 'CHILD_OF', traceID: 'main-id', spanID: 'span-id-0' }],
6869
},
6970
],
7071
duration: 236857,

src/model/trace-viewer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
// eslint-disable-next-line import/prefer-default-export
16-
export function getTraceName(spans, processes) {
17-
const span = spans.find(sp => sp.spanID === sp.traceID) || spans[0];
18-
return span ? `${processes[span.processID].serviceName}: ${span.operationName}` : '';
16+
export function getTraceName(spans) {
17+
const span = spans.filter(sp => !sp.references || !sp.references.length)[0];
18+
return span ? `${span.process.serviceName}: ${span.operationName}` : '';
1919
}

0 commit comments

Comments
 (0)