Skip to content

Commit

Permalink
Identify uninstrumented services (jaegertracing#659)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
  • Loading branch information
rubenvp8510 authored and vvvprabhakar committed Jul 4, 2021
1 parent a746138 commit 4878f8b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ type SpanBarRowProps = {
serviceName: string;
}
| TNil;
noInstrumentedServer?:
| {
color: string;
serviceName: string;
}
| TNil;
showErrorIcon: boolean;
getViewedBounds: ViewedBoundsFunctionType;
traceStartTime: number;
Expand Down Expand Up @@ -87,6 +93,7 @@ export default class SpanBarRow extends React.PureComponent<SpanBarRowProps> {
isMatchingFilter,
numTicks,
rpc,
noInstrumentedServer,
showErrorIcon,
getViewedBounds,
traceStartTime,
Expand Down Expand Up @@ -151,6 +158,16 @@ export default class SpanBarRow extends React.PureComponent<SpanBarRowProps> {
{rpc.serviceName}
</span>
)}
{noInstrumentedServer && (
<span>
<IoArrowRightA />{' '}
<i
className="SpanBarRow--rpcColorMarker"
style={{ background: noInstrumentedServer.color }}
/>
{noInstrumentedServer.serviceName}
</span>
)}
</span>
<small className="endpoint-name">{rpc ? rpc.operationName : operationName}</small>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,23 @@ describe('<VirtualizedTraceViewImpl>', () => {
)
).toBe(true);
});

it('renders a SpanBarRow with a client span and no instrumented server span', () => {
const externServiceName = 'externalServiceTest';
const leafSpan = trace.spans.find(span => !span.hasChildren);
const leafSpanIndex = trace.spans.indexOf(leafSpan);
const clientTags = [
{ key: 'span.kind', value: 'client' },
{ key: 'peer.service', value: externServiceName },
...leafSpan.tags,
];
const altTrace = updateSpan(trace, leafSpanIndex, { tags: clientTags });
wrapper.setProps({ trace: altTrace });
const rowWrapper = mount(instance.renderRow('some-key', {}, leafSpanIndex, {}));
const spanBarRow = rowWrapper.find(SpanBarRow);
expect(spanBarRow.length).toBe(1);
expect(spanBarRow.prop('noInstrumentedServer')).not.toBeNull();
});
});

describe('shouldScrollToFirstUiFindMatch', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
createViewedBoundsFunc,
findServerChildSpan,
isErrorSpan,
isKindClient,
spanContainsErredSpan,
ViewedBoundsFunctionType,
} from './utils';
Expand All @@ -44,6 +45,7 @@ import TTraceTimeline from '../../../types/TTraceTimeline';

import './VirtualizedTraceView.css';
import updateUiFind from '../../../utils/update-ui-find';
import { PEER_SERVICE } from '../../../constants/tag-keys';

type RowState = {
isDetail: boolean;
Expand Down Expand Up @@ -360,6 +362,17 @@ export class VirtualizedTraceViewImpl extends React.Component<VirtualizedTraceVi
};
}
}
const peerServiceKV = span.tags.find(kv => kv.key === PEER_SERVICE);
// Leaf, kind == client and has peer.service tag, is likely a client span that does a request
// to an uninstrumented/external service
let noInstrumentedServer = null;
if (!span.hasChildren && peerServiceKV && isKindClient(span)) {
noInstrumentedServer = {
serviceName: peerServiceKV.value,
color: colorGenerator.getColorByKey(peerServiceKV.value),
};
}

return (
<div className="VirtualizedTraceView--row" key={key} style={style} {...attrs}>
<SpanBarRow
Expand All @@ -373,6 +386,7 @@ export class VirtualizedTraceViewImpl extends React.Component<VirtualizedTraceVi
onDetailToggled={detailToggle}
onChildrenToggled={childrenToggle}
rpc={rpc}
noInstrumentedServer={noInstrumentedServer}
showErrorIcon={showErrorIcon}
getViewedBounds={this.getViewedBounds()}
traceStartTime={trace.startTime}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@ export function findServerChildSpan(spans: Span[]) {
return null;
}

export const isKindClient = (span: Span): Boolean =>
span.tags.some(({ key, value }) => key === 'span.kind' && value === 'client');

export { formatDuration } from '../../../utils/date';

0 comments on commit 4878f8b

Please sign in to comment.