Skip to content

Commit

Permalink
Checks for both Producer and Client
Browse files Browse the repository at this point in the history
Signed-off-by: wck-iipi <21dcs006@nith.ac.in>
  • Loading branch information
Wck-iipi committed Aug 14, 2023
1 parent fe8348c commit dcee235
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,21 +357,33 @@ describe('<VirtualizedTraceViewImpl>', () => {
).toBe(true);
});

it('renders a SpanBarRow with a client span and no instrumented server span', () => {
it('renders a SpanBarRow with a client or producer 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 tags = [
[
// client span
{ key: 'span.kind', value: 'client' },
{ key: 'peer.service', value: externServiceName },
...leafSpan.tags,
],
[
// producer span
{ key: 'span.kind', value: 'producer' },
{ 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();

tags.forEach(tag => {
const altTrace = updateSpan(trace, leafSpanIndex, { tags: tag });
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();
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
findServerChildSpan,
isErrorSpan,
isKindClient,
isKindProducer,
spanContainsErredSpan,
ViewedBoundsFunctionType,
} from './utils';
Expand Down Expand Up @@ -369,7 +370,7 @@ export class VirtualizedTraceViewImpl extends React.Component<VirtualizedTraceVi
// 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)) {
if (!span.hasChildren && peerServiceKV && (isKindClient(span) || isKindProducer(span))) {
noInstrumentedServer = {
serviceName: peerServiceKV.value,
color: colorGenerator.getColorByKey(peerServiceKV.value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@ export function findServerChildSpan(spans: Span[]) {
export const isKindClient = (span: Span): Boolean =>
span.tags.some(({ key, value }) => key === 'span.kind' && value === 'client');

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

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

0 comments on commit dcee235

Please sign in to comment.