Skip to content

Commit

Permalink
Merge branch 'master' into reporting/switch-to-tm
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 7, 2021
2 parents 8dbabd5 + e2abb03 commit 2b7b49c
Show file tree
Hide file tree
Showing 18 changed files with 706 additions and 203 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 18 additions & 19 deletions src/plugins/data/common/es_query/kuery/ast/ast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ describe('kuery AST API', () => {
test('should support exclusive range operators', () => {
const expected = nodeTypes.function.buildNode('and', [
nodeTypes.function.buildNode('range', 'bytes', {
gt: 1000,
gt: '1000',
}),
nodeTypes.function.buildNode('range', 'bytes', {
lt: 8000,
lt: '8000',
}),
]);
const actual = fromKueryExpression('bytes > 1000 and bytes < 8000');
Expand All @@ -181,10 +181,10 @@ describe('kuery AST API', () => {
test('should support inclusive range operators', () => {
const expected = nodeTypes.function.buildNode('and', [
nodeTypes.function.buildNode('range', 'bytes', {
gte: 1000,
gte: '1000',
}),
nodeTypes.function.buildNode('range', 'bytes', {
lte: 8000,
lte: '8000',
}),
]);
const actual = fromKueryExpression('bytes >= 1000 and bytes <= 8000');
Expand Down Expand Up @@ -279,25 +279,24 @@ describe('kuery AST API', () => {
const stringLiteral = nodeTypes.literal.buildNode('foo');
const booleanFalseLiteral = nodeTypes.literal.buildNode(false);
const booleanTrueLiteral = nodeTypes.literal.buildNode(true);
const numberLiteral = nodeTypes.literal.buildNode(42);

expect(fromLiteralExpression('foo')).toEqual(stringLiteral);
expect(fromLiteralExpression('true')).toEqual(booleanTrueLiteral);
expect(fromLiteralExpression('false')).toEqual(booleanFalseLiteral);
expect(fromLiteralExpression('42')).toEqual(numberLiteral);

expect(fromLiteralExpression('.3').value).toEqual(0.3);
expect(fromLiteralExpression('.36').value).toEqual(0.36);
expect(fromLiteralExpression('.00001').value).toEqual(0.00001);
expect(fromLiteralExpression('3').value).toEqual(3);
expect(fromLiteralExpression('-4').value).toEqual(-4);
expect(fromLiteralExpression('0').value).toEqual(0);
expect(fromLiteralExpression('0.0').value).toEqual(0);
expect(fromLiteralExpression('2.0').value).toEqual(2.0);
expect(fromLiteralExpression('0.8').value).toEqual(0.8);
expect(fromLiteralExpression('790.9').value).toEqual(790.9);
expect(fromLiteralExpression('0.0001').value).toEqual(0.0001);
expect(fromLiteralExpression('96565646732345').value).toEqual(96565646732345);

expect(fromLiteralExpression('.3').value).toEqual('.3');
expect(fromLiteralExpression('.36').value).toEqual('.36');
expect(fromLiteralExpression('.00001').value).toEqual('.00001');
expect(fromLiteralExpression('3').value).toEqual('3');
expect(fromLiteralExpression('-4').value).toEqual('-4');
expect(fromLiteralExpression('0').value).toEqual('0');
expect(fromLiteralExpression('0.0').value).toEqual('0.0');
expect(fromLiteralExpression('2.0').value).toEqual('2.0');
expect(fromLiteralExpression('0.8').value).toEqual('0.8');
expect(fromLiteralExpression('790.9').value).toEqual('790.9');
expect(fromLiteralExpression('0.0001').value).toEqual('0.0001');
expect(fromLiteralExpression('96565646732345').value).toEqual('96565646732345');
expect(fromLiteralExpression('070').value).toEqual('070');

expect(fromLiteralExpression('..4').value).toEqual('..4');
expect(fromLiteralExpression('.3text').value).toEqual('.3text');
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/common/es_query/kuery/ast/kuery.peg
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ UnquotedLiteral
if (sequence === 'true') return buildLiteralNode(true);
if (sequence === 'false') return buildLiteralNode(false);
if (chars.includes(wildcardSymbol)) return buildWildcardNode(sequence);
const isNumberPattern = /^(-?[1-9]+\d*([.]\d+)?)$|^(-?0[.]\d*[1-9]+)$|^0$|^0.0$|^[.]\d{1,}$/
return buildLiteralNode(isNumberPattern.test(sequence) ? Number(sequence) : sequence);
return buildLiteralNode(sequence);
}

UnquotedCharacter
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/common/search/aggs/buckets/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('Filters Agg', () => {
"should": Array [
Object {
"match": Object {
"field": 200,
"field": "200",
},
},
],
Expand All @@ -171,7 +171,7 @@ describe('Filters Agg', () => {
Object {
"range": Object {
"field": Object {
"gt": 500,
"gt": "500",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getErrorMarks } from './get_error_marks';
describe('getErrorMarks', () => {
describe('returns empty array', () => {
it('when items are missing', () => {
expect(getErrorMarks([], {})).toEqual([]);
expect(getErrorMarks([])).toEqual([]);
});
});

Expand All @@ -22,17 +22,17 @@ describe('getErrorMarks', () => {
offset: 10,
skew: 5,
doc: { error: { id: 1 }, service: { name: 'opbeans-java' } },
color: 'red',
} as unknown,
{
docType: 'error',
offset: 50,
skew: 0,
doc: { error: { id: 2 }, service: { name: 'opbeans-node' } },
color: 'blue',
} as unknown,
] as IWaterfallError[];
expect(
getErrorMarks(items, { 'opbeans-java': 'red', 'opbeans-node': 'blue' })
).toEqual([
expect(getErrorMarks(items)).toEqual([
{
type: 'errorMark',
offset: 15,
Expand All @@ -59,30 +59,32 @@ describe('getErrorMarks', () => {
offset: 10,
skew: 5,
doc: { error: { id: 1 }, service: { name: 'opbeans-java' } },
color: '',
} as unknown,
{
docType: 'error',
offset: 50,
skew: 0,
doc: { error: { id: 2 }, service: { name: 'opbeans-node' } },
color: '',
} as unknown,
] as IWaterfallError[];
expect(getErrorMarks(items, {})).toEqual([
expect(getErrorMarks(items)).toEqual([
{
type: 'errorMark',
offset: 15,
verticalLine: false,
id: 1,
error: { error: { id: 1 }, service: { name: 'opbeans-java' } },
serviceColor: undefined,
serviceColor: '',
},
{
type: 'errorMark',
offset: 50,
verticalLine: false,
id: 2,
error: { error: { id: 2 }, service: { name: 'opbeans-node' } },
serviceColor: undefined,
serviceColor: '',
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@

import { isEmpty } from 'lodash';
import { ErrorRaw } from '../../../../../../../typings/es_schemas/raw/error_raw';
import {
IWaterfallError,
IServiceColors,
} from '../Waterfall/waterfall_helpers/waterfall_helpers';
import { IWaterfallError } from '../Waterfall/waterfall_helpers/waterfall_helpers';
import { Mark } from '.';

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

export const getErrorMarks = (
errorItems: IWaterfallError[],
serviceColors: IServiceColors
): ErrorMark[] => {
export const getErrorMarks = (errorItems: IWaterfallError[]): ErrorMark[] => {
if (isEmpty(errorItems)) {
return [];
}
Expand All @@ -33,6 +27,6 @@ export const getErrorMarks = (
verticalLine: false,
id: error.doc.error.id,
error: error.doc,
serviceColor: serviceColors[error.doc.service.name],
serviceColor: error.color,
}));
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { asDuration } from '../../../../../../../common/utils/formatters';
import { isRumAgentName } from '../../../../../../../common/agent_name';
import { px, unit, units } from '../../../../../../style/variables';
import { ErrorCount } from '../../ErrorCount';
import { IWaterfallItem } from './waterfall_helpers/waterfall_helpers';
import { IWaterfallSpanOrTransaction } from './waterfall_helpers/waterfall_helpers';
import { ErrorOverviewLink } from '../../../../../shared/Links/apm/ErrorOverviewLink';
import { TRACE_ID } from '../../../../../../../common/elasticsearch_fieldnames';
import { SyncBadge } from './SyncBadge';
Expand Down Expand Up @@ -75,14 +75,14 @@ const ItemText = euiStyled.span`
interface IWaterfallItemProps {
timelineMargins: Margins;
totalDuration?: number;
item: IWaterfallItem;
item: IWaterfallSpanOrTransaction;
color: string;
isSelected: boolean;
errorCount: number;
onClick: () => unknown;
}

function PrefixIcon({ item }: { item: IWaterfallItem }) {
function PrefixIcon({ item }: { item: IWaterfallSpanOrTransaction }) {
switch (item.docType) {
case 'span': {
// icon for database spans
Expand Down Expand Up @@ -110,7 +110,7 @@ function PrefixIcon({ item }: { item: IWaterfallItem }) {

interface SpanActionToolTipProps {
children: ReactNode;
item?: IWaterfallItem;
item?: IWaterfallSpanOrTransaction;
}

function SpanActionToolTip({ item, children }: SpanActionToolTipProps) {
Expand All @@ -124,15 +124,15 @@ function SpanActionToolTip({ item, children }: SpanActionToolTipProps) {
return <>{children}</>;
}

function Duration({ item }: { item: IWaterfallItem }) {
function Duration({ item }: { item: IWaterfallSpanOrTransaction }) {
return (
<EuiText color="subdued" size="xs">
{asDuration(item.duration)}
</EuiText>
);
}

function HttpStatusCode({ item }: { item: IWaterfallItem }) {
function HttpStatusCode({ item }: { item: IWaterfallSpanOrTransaction }) {
// http status code for transactions of type 'request'
const httpStatusCode =
item.docType === 'transaction' && item.doc.transaction.type === 'request'
Expand All @@ -146,7 +146,7 @@ function HttpStatusCode({ item }: { item: IWaterfallItem }) {
return <EuiText size="xs">{httpStatusCode}</EuiText>;
}

function NameLabel({ item }: { item: IWaterfallItem }) {
function NameLabel({ item }: { item: IWaterfallSpanOrTransaction }) {
switch (item.docType) {
case 'span':
return <EuiText size="s">{item.doc.span.name}</EuiText>;
Expand All @@ -156,8 +156,6 @@ function NameLabel({ item }: { item: IWaterfallItem }) {
<h5>{item.doc.transaction.name}</h5>
</EuiTitle>
);
default:
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ import { Margins } from '../../../../../shared/charts/Timeline';
import { WaterfallItem } from './WaterfallItem';
import {
IWaterfall,
IWaterfallItem,
IWaterfallSpanOrTransaction,
} from './waterfall_helpers/waterfall_helpers';

interface AccordionWaterfallProps {
isOpen: boolean;
item: IWaterfallItem;
item: IWaterfallSpanOrTransaction;
level: number;
serviceColors: IWaterfall['serviceColors'];
duration: IWaterfall['duration'];
waterfallItemId?: string;
location: Location;
errorsPerTransaction: IWaterfall['errorsPerTransaction'];
childrenByParentId: Record<string, IWaterfallItem[]>;
childrenByParentId: Record<string, IWaterfallSpanOrTransaction[]>;
onToggleEntryTransaction?: () => void;
timelineMargins: Margins;
onClickWaterfallItem: (item: IWaterfallItem) => void;
onClickWaterfallItem: (item: IWaterfallSpanOrTransaction) => void;
}

const StyledAccordion = euiStyled(EuiAccordion).withConfig({
Expand Down Expand Up @@ -98,7 +97,6 @@ export function AccordionWaterfall(props: AccordionWaterfallProps) {
const {
item,
level,
serviceColors,
duration,
childrenByParentId,
waterfallItemId,
Expand Down Expand Up @@ -134,7 +132,7 @@ export function AccordionWaterfall(props: AccordionWaterfallProps) {
<WaterfallItem
key={item.id}
timelineMargins={timelineMargins}
color={serviceColors[item.doc.service.name]}
color={item.color}
item={item}
totalDuration={duration}
isSelected={item.id === waterfallItemId}
Expand All @@ -161,7 +159,6 @@ export function AccordionWaterfall(props: AccordionWaterfallProps) {
isOpen={isOpen}
item={child}
level={nextLevel}
serviceColors={serviceColors}
waterfallItemId={waterfallItemId}
location={location}
errorsPerTransaction={errorsPerTransaction}
Expand Down
Loading

0 comments on commit 2b7b49c

Please sign in to comment.