Skip to content

Commit

Permalink
Merge pull request jaegertracing#134 from jaegertracing/fix-trace-nam…
Browse files Browse the repository at this point in the history
…e-resolution

Fix trace name resolution
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
  • Loading branch information
tiffon committed Dec 16, 2017
2 parents 6ffcdb4 + 745570b commit 36dc263
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/components/SearchTracePage/TraceResultsScatterPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import dimensions from 'react-dimensions';
import { XYPlot, XAxis, YAxis, MarkSeries, Hint } from 'react-vis';
import { compose, withState, withProps } from 'recompose';

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

import './react-vis.css';
Expand Down Expand Up @@ -47,7 +48,7 @@ function TraceResultsScatterPlotBase(props) {
/>
{overValue && (
<Hint value={overValue}>
<h4 className="scatter-plot-hint">{overValue.name || '¯\\_(ツ)_/¯'}</h4>
<h4 className="scatter-plot-hint">{overValue.name || FALLBACK_TRACE_NAME}</h4>
</Hint>
)}
</XYPlot>
Expand Down
3 changes: 2 additions & 1 deletion src/components/SearchTracePage/TraceSearchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import moment from 'moment';

import { formatDuration } from '../../utils/date';
import TraceServiceTag from './TraceServiceTag';
import FALLBACK_TRACE_NAME from '../../constants/fallback-trace-name';

import './TraceSearchResult.css';

Expand All @@ -36,7 +37,7 @@ export default function TraceSearchResult({ trace, durationPercent = 100 }) {
background: getBackgroundStyle(durationPercent),
}}
>
<span className="trace-search-result--traceName left">{traceName}</span>
<span className="trace-search-result--traceName left">{traceName || FALLBACK_TRACE_NAME}</span>
<span className="trace-search-result--duration right">{formatDuration(duration * 1000)}</span>
</div>
<div className="p1">
Expand Down
3 changes: 2 additions & 1 deletion src/components/TracePage/TracePageHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as React from 'react';
import { Dropdown, Menu } from 'semantic-ui-react';

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

type TracePageHeaderProps = {
Expand Down Expand Up @@ -91,7 +92,7 @@ export default function TracePageHeader(props: TracePageHeaderProps) {
style={{ float: 'none' }}
/>
</a>
{name}
{name || FALLBACK_TRACE_NAME}
</h2>
</div>
<div className="inline-block mr1">
Expand Down
2 changes: 1 addition & 1 deletion src/components/TracePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export default class TracePage extends React.PureComponent<TracePageProps, Trace
<TracePageHeader
duration={duration}
maxDepth={maxSpanDepth}
name={getTraceName(spans, processes)}
name={getTraceName(spans)}
numServices={numberOfServices}
numSpans={spans.length}
slimView={slimView}
Expand Down
15 changes: 15 additions & 0 deletions src/constants/fallback-trace-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export default '<cannot-find-trace-name>';
6 changes: 2 additions & 4 deletions src/model/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ export function getTraceSummary(trace: Trace): TraceSummary {
let numErrorSpans = 0;
// serviceName -> { name, numberOfSpans }
const serviceMap = {};

for (let i = 0; i < spans.length; i++) {
const { duration, processID, spanID, startTime, tags } = spans[i];
const { duration, processID, references, startTime, tags } = spans[i];
// time bounds of trace
minTs = minTs > startTime ? startTime : minTs;
maxTs = maxTs < startTime + duration ? startTime + duration : maxTs;
Expand All @@ -61,8 +60,7 @@ export function getTraceSummary(trace: Trace): TraceSummary {
};
serviceMap[serviceName] = svcData;
}
// trace name
if (spanID === traceID) {
if (!references || !references.length) {
const { operationName } = spans[i];
traceName = `${svcData.name}: ${operationName}`;
}
Expand Down
3 changes: 2 additions & 1 deletion src/model/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('getTraceSummary()', () => {
{
traceID: 'main-id',
processID: 'pid0',
spanID: 'main-id',
spanID: 'span-id-0',
operationName: 'op0',
startTime: 1502221240933000,
duration: 236857,
Expand All @@ -65,6 +65,7 @@ describe('getTraceSummary()', () => {
startTime: 1502221241144382,
duration: 25305,
tags: [],
references: [{ refType: 'CHILD_OF', traceID: 'main-id', spanID: 'span-id-0' }],
},
],
duration: 236857,
Expand Down
6 changes: 3 additions & 3 deletions src/model/trace-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

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

0 comments on commit 36dc263

Please sign in to comment.