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

[APM] Cannot click through to details of an error on the waterfall page if the error is missing transaction.id #66386

Merged
merged 3 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -6,8 +6,8 @@

import { shallow } from 'enzyme';
import React from 'react';
import { AgentMarker } from '../AgentMarker';
import { AgentMark } from '../../../../../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks';
import { AgentMarker } from './AgentMarker';
import { AgentMark } from '../../../../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks';

describe('AgentMarker', () => {
const mark = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { ErrorMarker } from './ErrorMarker';
import { ErrorMark } from '../../../../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks';
import { render, fireEvent } from '@testing-library/react';
import { act } from '@testing-library/react-hooks';
import { expectTextsInDocument } from '../../../../../utils/testHelpers';

describe('ErrorMarker', () => {
const mark = {
id: 'agent',
offset: 10000,
type: 'errorMark',
verticalLine: true,
error: {
trace: { id: '123' },
transaction: { id: '456' },
error: { grouping_key: '123' },
service: { name: 'bar' }
},
serviceColor: '#fff'
} as ErrorMark;

function openPopover(errorMark: ErrorMark) {
const component = render(<ErrorMarker mark={errorMark} />);
act(() => {
fireEvent.click(component.getByTestId('popover'));
});
expectTextsInDocument(component, ['10,000 μs']);
return component;
}
it('renders link with trace and transaction', () => {
const component = openPopover(mark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery=trace.id%2520%253A%2520%2522123%2522%2520and%2520transaction.id%2520%253A%2520%2522456%2522'
);
});
it('renders link with trace', () => {
const { transaction, ...withoutTransaction } = mark.error;
const newMark = {
...mark,
error: withoutTransaction
} as ErrorMark;
const component = openPopover(newMark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery=trace.id%2520%253A%2520%2522123%2522'
);
});
it('renders link with transaction', () => {
const { trace, ...withoutTrace } = mark.error;
const newMark = {
...mark,
error: withoutTrace
} as ErrorMark;
const component = openPopover(newMark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery=transaction.id%2520%253A%2520%2522456%2522'
);
});
it('renders link without trance and transaction', () => {
const { trace, transaction, ...withoutTraceAndTransaction } = mark.error;
const newMark = {
...mark,
error: withoutTraceAndTransaction
} as ErrorMark;
const component = openPopover(newMark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery='
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const ErrorMarker: React.FC<Props> = ({ mark }) => {

const button = (
<Button
data-test-subj="popover"
clickable
color={theme.euiColorDanger}
shape={Shape.square}
Expand All @@ -60,9 +61,15 @@ export const ErrorMarker: React.FC<Props> = ({ mark }) => {
const { error } = mark;

const { rangeTo, rangeFrom } = urlParams;

const query = {
kuery: encodeURIComponent(
`${TRACE_ID} : "${error.trace?.id}" and ${TRANSACTION_ID} : "${error.transaction?.id}"`
[
...(error.trace?.id ? [`${TRACE_ID} : "${error.trace?.id}"`] : []),
...(error.transaction?.id
? [`${TRANSACTION_ID} : "${error.transaction?.id}"`]
: [])
].join(' and ')
),
rangeFrom,
rangeTo
Expand Down Expand Up @@ -90,6 +97,7 @@ export const ErrorMarker: React.FC<Props> = ({ mark }) => {
/>
<EuiText size="s">
<ErrorLink
data-test-subj="errorLink"
serviceName={error.service.name}
errorGroupId={error.error.grouping_key}
query={query}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import { shallow } from 'enzyme';
import React from 'react';
import { Marker } from '../';
import { AgentMark } from '../../../../../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks';
import { ErrorMark } from '../../../../../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks';
import { Marker } from './';
import { AgentMark } from '../../../../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks';
import { ErrorMark } from '../../../../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks';

describe('Marker', () => {
it('renders agent marker', () => {
Expand Down