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

Identify uninstrumented services #659

Merged
merged 1 commit into from
Nov 11, 2020
Merged
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
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';