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 24 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 @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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 { Location } from 'history';
import React from 'react';
import { SpanFlyout } from './SpanFlyout';
import { TransactionFlyout } from './TransactionFlyout';
import { IWaterfall } from './waterfall_helpers/waterfall_helpers';

interface Props {
waterfallItemId?: string;
waterfall: IWaterfall;
location: Location;
toggleFlyout: ({ location }: { location: Location }) => void;
}
export const WaterfallFlyout: React.FC<Props> = ({
waterfallItemId,
waterfall,
location,
toggleFlyout
}) => {
const currentItem = waterfall.items.find(item => item.id === waterfallItemId);

if (!currentItem) {
return null;
}

switch (currentItem.docType) {
case 'span':
const parentTransaction =
currentItem.parent?.docType === 'transaction'
? currentItem.parent?.custom
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
: undefined;

return (
<SpanFlyout
totalDuration={waterfall.duration}
span={currentItem.custom}
parentTransaction={parentTransaction}
onClose={() => toggleFlyout({ location })}
/>
);
case 'transaction':
return (
<TransactionFlyout
transaction={currentItem.custom}
onClose={() => toggleFlyout({ location })}
rootTransactionDuration={
waterfall.rootTransaction?.transaction.duration.us
}
errorCount={waterfall.errorsPerTransaction[currentItem.id]}
/>
);
default:
return null;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { i18n } from '@kbn/i18n';
import { isRumAgentName } from '../../../../../../../common/agent_name';
import { px, unit, units } from '../../../../../../style/variables';
import { asDuration } from '../../../../../../utils/formatters';
import { ErrorCountBadge } from '../../ErrorCountBadge';
import { ErrorCount } from '../../ErrorCount';
import { IWaterfallItem } from './waterfall_helpers/waterfall_helpers';
import { ErrorOverviewLink } from '../../../../../shared/Links/apm/ErrorOverviewLink';
import { TRACE_ID } from '../../../../../../../common/elasticsearch_fieldnames';

type ItemType = 'transaction' | 'span';
type ItemType = 'transaction' | 'span' | 'error' | 'agentMark';
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved

interface IContainerStyleProps {
type: ItemType;
Expand Down Expand Up @@ -89,24 +89,29 @@ interface IWaterfallItemProps {
}

function PrefixIcon({ item }: { item: IWaterfallItem }) {
if (item.docType === 'span') {
// icon for database spans
const isDbType = item.span.span.type.startsWith('db');
if (isDbType) {
return <EuiIcon type="database" />;
switch (item.docType) {
case 'span': {
// icon for database spans
const isDbType = item.custom.span.type.startsWith('db');
if (isDbType) {
return <EuiIcon type="database" />;
}

// omit icon for other spans
return null;
}

// omit icon for other spans
return null;
}

// icon for RUM agent transactions
if (isRumAgentName(item.transaction.agent.name)) {
return <EuiIcon type="globe" />;
case 'transaction': {
// icon for RUM agent transactions
if (isRumAgentName(item.custom.agent.name)) {
return <EuiIcon type="globe" />;
}

// icon for other transactions
return <EuiIcon type="merge" />;
}
default:
return null;
}

// icon for other transactions
return <EuiIcon type="merge" />;
}

interface SpanActionToolTipProps {
Expand All @@ -117,10 +122,10 @@ const SpanActionToolTip: React.FC<SpanActionToolTipProps> = ({
item,
children
}) => {
if (item && item.docType === 'span') {
if (item?.docType === 'span') {
return (
<EuiToolTip
content={`${item.span.span.subtype}.${item.span.span.action}`}
content={`${item.custom.span.subtype}.${item.custom.span.action}`}
>
<>{children}</>
</EuiToolTip>
Expand All @@ -140,9 +145,8 @@ function Duration({ item }: { item: IWaterfallItem }) {
function HttpStatusCode({ item }: { item: IWaterfallItem }) {
// http status code for transactions of type 'request'
const httpStatusCode =
item.docType === 'transaction' &&
item.transaction.transaction.type === 'request'
? item.transaction.transaction.result
item.docType === 'transaction' && item.custom.transaction.type === 'request'
? item.custom.transaction.result
: undefined;

if (!httpStatusCode) {
Expand All @@ -153,14 +157,18 @@ function HttpStatusCode({ item }: { item: IWaterfallItem }) {
}

function NameLabel({ item }: { item: IWaterfallItem }) {
if (item.docType === 'span') {
return <EuiText size="s">{item.name}</EuiText>;
switch (item.docType) {
case 'span':
return <EuiText size="s">{item.custom.span.name}</EuiText>;
case 'transaction':
return (
<EuiTitle size="xxs">
<h5>{item.custom.transaction.name}</h5>
</EuiTitle>
);
default:
return null;
}
return (
<EuiTitle size="xxs">
<h5>{item.name}</h5>
</EuiTitle>
);
}

export function WaterfallItem({
Expand Down Expand Up @@ -210,24 +218,17 @@ export function WaterfallItem({
<NameLabel item={item} />
{errorCount > 0 && item.docType === 'transaction' ? (
<ErrorOverviewLink
serviceName={item.transaction.service.name}
serviceName={item.custom.service.name}
query={{
kuery: encodeURIComponent(
`${TRACE_ID} : "${item.transaction.trace.id}" and transaction.id : "${item.transaction.transaction.id}"`
`${TRACE_ID} : "${item.custom.trace.id}" and transaction.id : "${item.custom.transaction.id}"`
)
}}
color="danger"
style={{ textDecoration: 'none' }}
>
<EuiToolTip content={tooltipContent}>
<ErrorCountBadge
onClick={event => {
event.stopPropagation();
}}
onClickAriaLabel={tooltipContent}
>
{errorCount}
</ErrorCountBadge>
<ErrorCount count={errorCount} />
</EuiToolTip>
</ErrorOverviewLink>
) : null}
Expand Down
Loading