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] Show errors on the timeline instead of under the transaction #53756

Merged
merged 27 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6ac0705
creating error marker and refactoring some stuff
cauemarcondes Dec 12, 2019
445cf8f
styling popover
cauemarcondes Dec 13, 2019
28678df
adding agent marks and errors to waterfall items
cauemarcondes Dec 17, 2019
73c69ca
adding agent marks and errors to waterfall items
cauemarcondes Dec 17, 2019
babdd19
adding agent marks and errors to waterfall items
cauemarcondes Dec 17, 2019
0feccc0
fixing tests and typescript checking
cauemarcondes Dec 17, 2019
5b21328
refactoring helper
cauemarcondes Dec 18, 2019
b4958ea
changing transaction error badge style
cauemarcondes Dec 18, 2019
ac82eb0
adding unit test
cauemarcondes Dec 18, 2019
c3c95aa
fixing agent marker position
cauemarcondes Dec 18, 2019
911fa67
fixing offset when error is registered before its parent
cauemarcondes Dec 18, 2019
ce545a6
refactoring error marker
cauemarcondes Dec 19, 2019
a5219ef
refactoring error marker
cauemarcondes Dec 19, 2019
814f4c1
refactoring error marker
cauemarcondes Dec 19, 2019
1b8ab45
refactoring error marker
cauemarcondes Dec 19, 2019
9d32ab9
refactoring error marker
cauemarcondes Dec 19, 2019
18566b6
refactoring waterfall helper
cauemarcondes Dec 19, 2019
0ddd1b5
refactoring waterfall helper
cauemarcondes Dec 19, 2019
a0d2e2b
refactoring waterfall helper api
cauemarcondes Dec 20, 2019
4c6644a
refactoring waterfall helper
cauemarcondes Dec 20, 2019
65a19c3
removing unused code
cauemarcondes Dec 23, 2019
3f90dc2
refactoring waterfall helper
cauemarcondes Dec 24, 2019
49faaa6
changing unit test
cauemarcondes Dec 24, 2019
a58e6aa
removing comment
cauemarcondes Dec 24, 2019
af9e22e
refactoring marker component and waterfall helper
cauemarcondes Jan 6, 2020
6ad0f3a
removing servicecolor from waterfall item and adding it to errormark
cauemarcondes Jan 7, 2020
d2904b4
fixing trace order
cauemarcondes Jan 7, 2020
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
@@ -0,0 +1,32 @@
/*
* 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 { EuiText, EuiTextColor } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';

interface Props {
count: number;
}

export const ErrorCount = ({ count }: Props) => (
<EuiText size="xs">
<h4>
<EuiTextColor
color="danger"
onClick={(e: React.MouseEvent) => {
e.stopPropagation();
}}
>
{i18n.translate('xpack.apm.transactionDetails.errorCount', {
defaultMessage:
'{errorCount, number} {errorCount, plural, one {Error} other {Errors}}',
values: { errorCount: count }
})}
</EuiTextColor>
</h4>
</EuiText>
);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export const MaybeViewTraceLink = ({
}
);

const { rootTransaction } = waterfall;
// the traceroot cannot be found, so we cannot link to it
if (!waterfall.traceRoot) {
if (!rootTransaction) {
return (
<EuiFlexItem grow={false}>
<EuiToolTip
Expand All @@ -45,8 +46,7 @@ export const MaybeViewTraceLink = ({
);
}

const isRoot =
transaction.transaction.id === waterfall.traceRoot.transaction.id;
const isRoot = transaction.transaction.id === rootTransaction.transaction.id;

// the user is already viewing the full trace, so don't link to it
if (isRoot) {
Expand All @@ -69,15 +69,14 @@ export const MaybeViewTraceLink = ({

// the user is viewing a zoomed in version of the trace. Link to the full trace
} else {
const traceRoot = waterfall.traceRoot;
return (
<EuiFlexItem grow={false}>
<TransactionDetailLink
serviceName={traceRoot.service.name}
transactionId={traceRoot.transaction.id}
traceId={traceRoot.trace.id}
transactionName={traceRoot.transaction.name}
transactionType={traceRoot.transaction.type}
serviceName={rootTransaction.service.name}
transactionId={rootTransaction.transaction.id}
traceId={rootTransaction.trace.id}
transactionName={rootTransaction.transaction.name}
transactionType={rootTransaction.transaction.type}
>
<EuiButton iconType="apmTrace">{viewFullTraceButtonLabel}</EuiButton>
</TransactionDetailLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export function TransactionTabs({

{currentTab.key === timelineTab.key ? (
<WaterfallContainer
transaction={transaction}
location={location}
urlParams={urlParams}
waterfall={waterfall}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Transaction } from '../../../../../../typings/es_schemas/ui/Transaction';
import { getAgentMarks } from './get_agent_marks';
import { Transaction } from '../../../../../../../../typings/es_schemas/ui/Transaction';
import { getAgentMarks } from '../get_agent_marks';

describe('getAgentMarks', () => {
it('should sort the marks by time', () => {
Expand All @@ -21,9 +21,24 @@ describe('getAgentMarks', () => {
}
} as any;
expect(getAgentMarks(transaction)).toEqual([
{ name: 'timeToFirstByte', us: 10000 },
{ name: 'domInteractive', us: 117000 },
{ name: 'domComplete', us: 118000 }
{
id: 'timeToFirstByte',
offset: 10000,
type: 'agentMark',
verticalLine: true
},
{
id: 'domInteractive',
offset: 117000,
type: 'agentMark',
verticalLine: true
},
{
id: 'domComplete',
offset: 118000,
type: 'agentMark',
verticalLine: true
}
]);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* 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 { IWaterfallItem } from '../../Waterfall/waterfall_helpers/waterfall_helpers';
import { getErrorMarks } from '../get_error_marks';

describe('getErrorMarks', () => {
describe('returns empty array', () => {
it('when items are missing', () => {
expect(getErrorMarks([], {})).toEqual([]);
});
it('when any error is available', () => {
const items = [
{ docType: 'span' },
{ docType: 'transaction' }
] as IWaterfallItem[];
expect(getErrorMarks(items, {})).toEqual([]);
});
});

it('returns error marks', () => {
const items = [
{
docType: 'error',
offset: 10,
skew: 5,
doc: { error: { id: 1 }, service: { name: 'opbeans-java' } }
} as unknown,
{ docType: 'transaction' },
{
docType: 'error',
offset: 50,
skew: 0,
doc: { error: { id: 2 }, service: { name: 'opbeans-node' } }
} as unknown
] as IWaterfallItem[];
expect(
getErrorMarks(items, { 'opbeans-java': 'red', 'opbeans-node': 'blue' })
).toEqual([
{
type: 'errorMark',
offset: 15,
verticalLine: false,
id: 1,
error: { error: { id: 1 }, service: { name: 'opbeans-java' } },
serviceColor: 'red'
},
{
type: 'errorMark',
offset: 50,
verticalLine: false,
id: 2,
error: { error: { id: 2 }, service: { name: 'opbeans-node' } },
serviceColor: 'blue'
}
]);
});

it('returns error marks without service color', () => {
const items = [
{
docType: 'error',
offset: 10,
skew: 5,
doc: { error: { id: 1 }, service: { name: 'opbeans-java' } }
} as unknown,
{ docType: 'transaction' },
{
docType: 'error',
offset: 50,
skew: 0,
doc: { error: { id: 2 }, service: { name: 'opbeans-node' } }
} as unknown
] as IWaterfallItem[];
expect(getErrorMarks(items, {})).toEqual([
{
type: 'errorMark',
offset: 15,
verticalLine: false,
id: 1,
error: { error: { id: 1 }, service: { name: 'opbeans-java' } },
serviceColor: undefined
},
{
type: 'errorMark',
offset: 50,
verticalLine: false,
id: 2,
error: { error: { id: 2 }, service: { name: 'opbeans-node' } },
serviceColor: undefined
}
]);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 { sortBy } from 'lodash';
import { Transaction } from '../../../../../../../typings/es_schemas/ui/Transaction';
import { Mark } from '.';

// Extends Mark without adding new properties to it.
export interface AgentMark extends Mark {
type: 'agentMark';
}

export function getAgentMarks(transaction?: Transaction): AgentMark[] {
const agent = transaction?.transaction.marks?.agent;
if (!agent) {
return [];
}

return sortBy(
Object.entries(agent).map(([name, ms]) => ({
type: 'agentMark',
id: name,
offset: ms * 1000,
verticalLine: true
})),
'offset'
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 { isEmpty } from 'lodash';
import { ErrorRaw } from '../../../../../../../typings/es_schemas/raw/ErrorRaw';
import {
IWaterfallItem,
IWaterfallError,
IServiceColors
} from '../Waterfall/waterfall_helpers/waterfall_helpers';
import { Mark } from '.';

export interface ErrorMark extends Mark {
type: 'errorMark';
error: ErrorRaw;
serviceColor?: string;
}

export const getErrorMarks = (
items: IWaterfallItem[],
serviceColors: IServiceColors
): ErrorMark[] => {
if (isEmpty(items)) {
return [];
}

return (items.filter(
item => item.docType === 'error'
) as IWaterfallError[]).map(error => ({
type: 'errorMark',
offset: error.offset + error.skew,
verticalLine: false,
id: error.doc.error.id,
error: error.doc,
serviceColor: serviceColors[error.doc.service.name]
}));
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

export interface Mark {
type: string;
offset: number;
verticalLine: boolean;
id: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import styled from 'styled-components';
import { px, unit } from '../../../../../style/variables';
// @ts-ignore
import Legend from '../../../../shared/charts/Legend';
import { Legend } from '../../../../shared/charts/Legend';
import { IServiceColors } from './Waterfall/waterfall_helpers/waterfall_helpers';

const Legends = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function SpanFlyout({
const dbContext = span.span.db;
const httpContext = span.span.http;
const spanTypes = getSpanTypes(span);
const spanHttpStatusCode = httpContext?.response.status_code;
const spanHttpStatusCode = httpContext?.response?.status_code;
const spanHttpUrl = httpContext?.url?.original;
const spanHttpMethod = httpContext?.method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { DroppedSpansWarning } from './DroppedSpansWarning';
interface Props {
onClose: () => void;
transaction?: Transaction;
errorCount: number;
traceRootDuration?: number;
errorCount?: number;
rootTransactionDuration?: number;
}

function TransactionPropertiesTable({
Expand All @@ -49,8 +49,8 @@ function TransactionPropertiesTable({
export function TransactionFlyout({
transaction: transactionDoc,
onClose,
errorCount,
traceRootDuration
errorCount = 0,
rootTransactionDuration
}: Props) {
if (!transactionDoc) {
return null;
Expand Down Expand Up @@ -84,7 +84,7 @@ export function TransactionFlyout({
<EuiSpacer size="m" />
<TransactionSummary
transaction={transactionDoc}
totalDuration={traceRootDuration}
totalDuration={rootTransactionDuration}
errorCount={errorCount}
/>
<EuiHorizontalRule margin="m" />
Expand Down
Loading