Skip to content
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 @@ -47,4 +47,11 @@ describe('Dependency operation', () => {
cy.getByTestSubj('apmActionMenuButtonInvestigateButton').click();
cy.getByTestSubj('apmActionMenuInvestigateButtonPopup');
});

it('opens Span link flyout', () => {
cy.visitKibana(dependencyOperationHref);
cy.contains('Span links').click();
cy.contains('Span details');
cy.contains('Span B');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,28 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { apm, timerange } from '@kbn/apm-synthtrace-client';
import type { ApmFields } from '@kbn/apm-synthtrace-client';
import { apm, timerange, generateLongId, generateShortId } from '@kbn/apm-synthtrace-client';
import { shuffle, compact } from 'lodash';

function generateExternalSpanLinks() {
return Array(2)
.fill(0)
.map(() => ({ span: { id: generateShortId() }, trace: { id: generateLongId() } }));
}

function getSpanLinksFromEvents(events: ApmFields[]) {
return compact(
events.map((event) => {
const spanId = event['span.id'];
return spanId ? { span: { id: spanId }, trace: { id: event['trace.id']! } } : undefined;
})
);
}

export function opbeans({ from, to }: { from: number; to: number }) {
const range = timerange(from, to);
const producerTimestamps = range.ratePerMinute(1);

const opbeansJava = apm
.service({
Expand All @@ -32,6 +50,25 @@ export function opbeans({ from, to }: { from: number; to: number }) {
userAgent: apm.getChromeUserAgentDefaults(),
});

const opbeansJavaInternalOnlyEvents = producerTimestamps.generator((timestamp) =>
opbeansJava
.transaction({ transactionName: 'Transaction A' })
.timestamp(timestamp)
.duration(1000)
.success()
.children(
opbeansJava
.span({ spanName: 'Span A', spanType: 'messaging', spanSubtype: 'kafka' })
.timestamp(timestamp)
.duration(100)
.success()
)
);

const serializedOpbeansJavaInternalOnlyEvents = Array.from(opbeansJavaInternalOnlyEvents).flatMap(
(event) => event.serialize()
);

return range
.interval('1s')
.rate(1)
Expand All @@ -57,7 +94,17 @@ export function opbeans({ from, to }: { from: number; to: number }) {
.timestamp(timestamp)
.duration(50)
.failure()
.destination('postgresql')
.destination('postgresql'),
opbeansJava
.span({ spanName: 'Span B', spanType: 'messaging', spanSubtype: 'kafka' })
.defaults({
'span.links': shuffle([
...generateExternalSpanLinks(),
...getSpanLinksFromEvents(serializedOpbeansJavaInternalOnlyEvents),
]),
})
.timestamp(timestamp)
.duration(900)
),
opbeansNode
.transaction({ transactionName: 'GET /api/product/:id' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function SpanLinks({ spanLinksCount, traceId, spanId, processorEvent }: P
} = useAnyOfApmParams(
'/services/{serviceName}/transactions/view',
'/mobile-services/{serviceName}/transactions/view',
'/traces/explorer/waterfall'
'/traces/explorer/waterfall',
'/dependencies/operation'
);
const { start, end } = useTimeRange({ rangeFrom, rangeTo });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function SpanLinksTable({ items }: Props) {
} = useAnyOfApmParams(
'/services/{serviceName}/transactions/view',
'/mobile-services/{serviceName}/transactions/view',
'/traces/explorer/waterfall'
'/traces/explorer/waterfall',
'/dependencies/operation'
);
const [idActionMenuOpen, setIdActionMenuOpen] = useState<string | undefined>();
const {
Expand Down