From f83f9d84da709b855d3e2e40b8f1aaeffc8da0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Thu, 6 Dec 2018 13:56:17 +0100 Subject: [PATCH 1/7] Move to es_schema folder # Conflicts: # x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx # x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx # x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx # x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx # x-pack/plugins/apm/public/services/rest/apm/apm.ts --- x-pack/plugins/apm/common/constants.test.ts | 4 +- .../components/app/Main/routeConfig.tsx | 2 +- .../Transaction/ActionMenu.tsx | 2 +- .../StickyTransactionProperties.tsx | 2 +- .../TransactionPropertiesTable.tsx | 2 +- .../TransactionPropertiesTableForFlyout.tsx | 2 +- .../Waterfall/FlyoutTopLevelProperties.tsx | 2 +- .../Waterfall/SpanFlyout/DatabaseContext.tsx | 2 +- .../Waterfall/SpanFlyout/HttpContext.tsx | 2 +- .../SpanFlyout/StickySpanProperties.tsx | 2 +- .../Waterfall/SpanFlyout/index.tsx | 4 +- .../Waterfall/TransactionFlyout/index.tsx | 2 +- .../waterfall_helpers.test.ts | 4 +- .../waterfall_helpers/waterfall_helpers.ts | 4 +- .../get_agent_marks.test.ts | 2 +- .../WaterfallContainer/get_agent_marks.ts | 2 +- .../Transaction/WaterfallContainer/index.tsx | 2 +- .../TransactionDetails/Transaction/index.tsx | 2 +- .../components/shared/DiscoverButton.tsx | 34 ++++++++ .../components/shared/ImpactBar/index.tsx | 2 +- .../components/shared/ManagedTable/index.tsx | 2 +- .../PropertiesTable/NestedKeyValueTable.tsx | 2 +- .../shared/PropertiesTable/index.tsx | 2 +- .../components/shared/TransactionLink.tsx | 2 +- .../services/__test__/SessionStorageMock.ts | 2 +- .../apm/public/services/rest/apm/apm.ts | 4 +- .../public/services/rest/apm/transactions.ts | 2 +- .../reactReduxRequest/transactionDetails.tsx | 2 +- .../store/reactReduxRequest/waterfall.tsx | 2 +- .../store/reactReduxRequest/waterfallV1.tsx | 4 +- .../store/reactReduxRequest/waterfallV2.tsx | 2 +- .../plugins/apm/public/store/rootReducer.ts | 2 +- .../public/store/selectors/chartSelectors.ts | 2 +- x-pack/plugins/apm/public/utils/url.tsx | 2 +- .../apm/server/lib/traces/get_trace.ts | 4 +- .../server/lib/transaction_groups/fetcher.ts | 2 +- .../lib/transaction_groups/transform.ts | 2 +- .../distribution/get_buckets/fetcher.ts | 2 +- .../lib/transactions/get_transaction/index.ts | 2 +- .../lib/transactions/spans/get_spans.ts | 2 +- x-pack/plugins/apm/typings/Error.ts | 46 ---------- .../apm/typings/{ => es_schemas}/APMDoc.ts | 0 .../plugins/apm/typings/es_schemas/Error.ts | 84 +++++++++++++++++++ .../apm/typings/{ => es_schemas}/Span.ts | 0 .../typings/{ => es_schemas}/Transaction.ts | 0 45 files changed, 164 insertions(+), 92 deletions(-) create mode 100644 x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx delete mode 100644 x-pack/plugins/apm/typings/Error.ts rename x-pack/plugins/apm/typings/{ => es_schemas}/APMDoc.ts (100%) create mode 100644 x-pack/plugins/apm/typings/es_schemas/Error.ts rename x-pack/plugins/apm/typings/{ => es_schemas}/Span.ts (100%) rename x-pack/plugins/apm/typings/{ => es_schemas}/Transaction.ts (100%) diff --git a/x-pack/plugins/apm/common/constants.test.ts b/x-pack/plugins/apm/common/constants.test.ts index c750f937cdb91..63c1da116bcb2 100644 --- a/x-pack/plugins/apm/common/constants.test.ts +++ b/x-pack/plugins/apm/common/constants.test.ts @@ -5,8 +5,8 @@ */ import { get } from 'lodash'; -import { Span } from '../typings/Span'; -import { Transaction } from '../typings/Transaction'; +import { Span } from '../typings/es_schemas/Span'; +import { Transaction } from '../typings/es_schemas/Transaction'; import * as constants from './constants'; describe('Transaction v1:', () => { diff --git a/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx b/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx index 888fc008e3047..bee1716b8a6a2 100644 --- a/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx +++ b/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { Redirect } from 'react-router-dom'; -import { StringMap } from '../../../../typings/common'; +import { StringMap } from '../../../../typings/es_schemas/common'; import { legacyDecodeURIComponent } from '../../../utils/url'; // @ts-ignore import ErrorGroupDetails from '../ErrorGroupDetails'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx index 8486059b3f6fd..beb2764aadab6 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx @@ -12,7 +12,7 @@ import { } from '@elastic/eui'; import React from 'react'; import { KibanaLink } from 'x-pack/plugins/apm/public/utils/url'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { DiscoverTransactionButton } from '../../../shared/DiscoverButtons/DiscoverTransactionButton'; function getInfraMetricsQuery(transaction: Transaction) { diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx index a057c2eabc476..2ec3163397140 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx @@ -12,7 +12,7 @@ import { TRANSACTION_RESULT, USER_ID } from '../../../../../common/constants'; -import { Transaction } from '../../../../../typings/Transaction'; +import { Transaction } from '../../../../../typings/es_schemas/Transaction'; import { asPercent, asTime } from '../../../../utils/formatters'; // @ts-ignore import { diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx index db186e532aea3..3d3a975681a46 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx @@ -14,7 +14,7 @@ import { import { capitalize, first, get } from 'lodash'; import React from 'react'; import styled from 'styled-components'; -import { Transaction } from '../../../../../typings/Transaction'; +import { Transaction } from '../../../../../typings/es_schemas/Transaction'; import { IUrlParams } from '../../../../store/urlParams'; import { px, units } from '../../../../style/variables'; import { fromQuery, history, toQuery } from '../../../../utils/url'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx index 25632040ae325..e9087eaf98e40 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx @@ -8,7 +8,7 @@ import { EuiSpacer, EuiTab, EuiTabs } from '@elastic/eui'; import { capitalize, first, get } from 'lodash'; import React from 'react'; -import { Transaction } from '../../../../../typings/Transaction'; +import { Transaction } from '../../../../../typings/es_schemas/Transaction'; import { IUrlParams } from '../../../../store/urlParams'; // @ts-ignore import { fromQuery, history, toQuery } from '../../../../utils/url'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx index dc26045151f17..2ad668f347fe9 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx @@ -12,7 +12,7 @@ import { import { StickyProperties } from 'x-pack/plugins/apm/public/components/shared/StickyProperties'; import { TransactionLink } from 'x-pack/plugins/apm/public/components/shared/TransactionLink'; import { KibanaLink } from 'x-pack/plugins/apm/public/utils/url'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; interface Props { transaction?: Transaction; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx index 93266464ecdf5..0302212f18e78 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx @@ -27,7 +27,7 @@ import { xcode } from 'react-syntax-highlighter/dist/styles'; import sql from 'react-syntax-highlighter/dist/languages/sql'; import { EuiTitle } from '@elastic/eui'; -import { DbContext } from '../../../../../../../../typings/Span'; +import { DbContext } from '../../../../../../../../typings/es_schemas/Span'; registerLanguage('sql', sql); diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx index 2f760adcd4a88..2e3bd3ab732c5 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx @@ -16,7 +16,7 @@ import { } from '../../../../../../../style/variables'; import { EuiTitle } from '@elastic/eui'; -import { HttpContext } from '../../../../../../../../typings/Span'; +import { HttpContext } from '../../../../../../../../typings/es_schemas/Span'; const DatabaseStatement = styled.div` margin-top: ${px(unit)}; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx index 8ac9c0b7e0b65..df10562c22cff 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx @@ -11,7 +11,7 @@ import { SPAN_NAME, SPAN_TYPE } from 'x-pack/plugins/apm/common/constants'; -import { Span } from '../../../../../../../../typings/Span'; +import { Span } from '../../../../../../../../typings/es_schemas/Span'; import { asMillis, asPercent } from '../../../../../../../utils/formatters'; import { StickyProperties } from '../../../../../../shared/StickyProperties'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx index 471e610daef3f..8c4cc9834fe83 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx @@ -33,8 +33,8 @@ import { HttpContext } from './HttpContext'; import { StickySpanProperties } from './StickySpanProperties'; import { DiscoverSpanButton } from 'x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; -import { Span } from '../../../../../../../../typings/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; +import { Span } from '../../../../../../../../typings/es_schemas/Span'; import { FlyoutTopLevelProperties } from '../FlyoutTopLevelProperties'; const StackTraceContainer = styled.div` diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx index 897e0d71035ef..751e37ac24d60 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx @@ -23,7 +23,7 @@ import styled from 'styled-components'; import { DiscoverTransactionButton } from 'x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton'; import { IUrlParams } from 'x-pack/plugins/apm/public/store/urlParams'; import { APM_AGENT_DROPPED_SPANS_DOCS } from 'x-pack/plugins/apm/public/utils/documentation/agents'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { StickyTransactionProperties } from '../../../StickyTransactionProperties'; import { TransactionPropertiesTableForFlyout } from '../../../TransactionPropertiesTableForFlyout'; import { FlyoutTopLevelProperties } from '../FlyoutTopLevelProperties'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts index 71038b9427831..70e517d4ff365 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts @@ -5,8 +5,8 @@ */ import { groupBy } from 'lodash'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getClockSkew, getWaterfallItems, diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts index ea01288b4f66a..ee4f382f19550 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts @@ -15,8 +15,8 @@ import { zipObject } from 'lodash'; import { colors } from 'x-pack/plugins/apm/public/style/variables'; -import { Span } from '../../../../../../../../typings/Span'; -import { Transaction } from '../../../../../../../../typings/Transaction'; +import { Span } from '../../../../../../../../typings/es_schemas/Span'; +import { Transaction } from '../../../../../../../../typings/es_schemas/Transaction'; export interface IWaterfallIndex { [key: string]: IWaterfallItem; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts index 609d7f5477e5b..c7784577b31fc 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getAgentMarks } from './get_agent_marks'; describe('getAgentMarks', () => { diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts index b0968ed7a1af8..165959bca189d 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts @@ -5,7 +5,7 @@ */ import { sortBy } from 'lodash'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; export interface AgentMark { name: string; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx index 5d78ce85d0775..28e93e8b5e0b2 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx @@ -11,7 +11,7 @@ import { TRACE_ID, TRANSACTION_ID } from '../../../../../../common/constants'; -import { Transaction } from '../../../../../../typings/Transaction'; +import { Transaction } from '../../../../../../typings/es_schemas/Transaction'; import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx index cea8e117e628f..44683bfc67f0b 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx @@ -15,7 +15,7 @@ import { EuiToolTip } from '@elastic/eui'; import React from 'react'; -import { Transaction as ITransaction } from '../../../../../typings/Transaction'; +import { Transaction as ITransaction } from '../../../../../typings/es_schemas/Transaction'; import { IUrlParams } from '../../../../store/urlParams'; import { DiscoverTransactionButton } from '../../../shared/DiscoverButtons/DiscoverTransactionButton'; import { TransactionLink } from '../../../shared/TransactionLink'; diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx new file mode 100644 index 0000000000000..8360fee9624ff --- /dev/null +++ b/x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx @@ -0,0 +1,34 @@ +/* + * 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. + */ + +// @ts-ignore +import { EuiButtonEmpty } from '@elastic/eui'; +import React from 'react'; +import { StringMap } from 'x-pack/plugins/apm/typings/common'; +import { KibanaLink } from '../../utils/url'; + +interface Props { + query: StringMap; +} + +export const DiscoverButton: React.SFC = ({ + query, + children, + ...rest +}) => { + return ( + + + {children || 'View in Discover'} + + + ); +}; diff --git a/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx b/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx index 53f21c4e247c0..72b2d94d7520b 100644 --- a/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx @@ -6,7 +6,7 @@ import { EuiProgress } from '@elastic/eui'; import React from 'react'; -import { StringMap } from '../../../../typings/common'; +import { StringMap } from '../../../../typings/es_schemas/common'; // TODO: extend from EUI's EuiProgress prop interface export interface ImpactBarProps extends StringMap { diff --git a/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx b/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx index 447c34b0189aa..9f35b407660a6 100644 --- a/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx @@ -8,7 +8,7 @@ import { EuiBasicTable } from '@elastic/eui'; import { get, sortByOrder } from 'lodash'; import React, { Component } from 'react'; -import { StringMap } from '../../../../typings/common'; +import { StringMap } from '../../../../typings/es_schemas/common'; // TODO: this should really be imported from EUI export interface ITableColumn { diff --git a/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx b/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx index bea0f145bbac4..4cd901b46cf08 100644 --- a/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx +++ b/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx @@ -8,7 +8,7 @@ import _ from 'lodash'; import React from 'react'; import styled from 'styled-components'; -import { StringMap } from '../../../../typings/common'; +import { StringMap } from '../../../../typings/es_schemas/common'; import { colors, fontFamilyCode, diff --git a/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx b/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx index 856dcd7bb07ad..a2e219c55374e 100644 --- a/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx @@ -9,7 +9,7 @@ import _ from 'lodash'; import React from 'react'; import styled from 'styled-components'; -import { StringMap } from '../../../../typings/common'; +import { StringMap } from '../../../../typings/es_schemas/common'; import { colors, fontSize, diff --git a/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx b/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx index eab7735b5073e..a2b296cd93a09 100644 --- a/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { Transaction } from '../../../typings/Transaction'; +import { Transaction } from '../../../typings/es_schemas/Transaction'; import { KibanaLink, legacyEncodeURIComponent } from '../../utils/url'; interface TransactionLinkProps { diff --git a/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts b/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts index 2423cbd11a2d0..269cdf15ecafd 100644 --- a/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts +++ b/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { StringMap } from 'x-pack/plugins/apm/typings/common'; +import { StringMap } from 'x-pack/plugins/apm/typings/es_schemas/common'; export class SessionStorageMock { private store: StringMap = {}; diff --git a/x-pack/plugins/apm/public/services/rest/apm/apm.ts b/x-pack/plugins/apm/public/services/rest/apm/apm.ts index 8d457ea758ce3..890b9200924d2 100644 --- a/x-pack/plugins/apm/public/services/rest/apm/apm.ts +++ b/x-pack/plugins/apm/public/services/rest/apm/apm.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Span } from 'x-pack/plugins/apm/typings/Span'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { convertKueryToEsQuery, getAPMIndexPatternForKuery } from '../../kuery'; export async function getEncodedEsQuery(kuery?: string) { diff --git a/x-pack/plugins/apm/public/services/rest/apm/transactions.ts b/x-pack/plugins/apm/public/services/rest/apm/transactions.ts index 7f2f23476db4f..3702b96d16c0a 100644 --- a/x-pack/plugins/apm/public/services/rest/apm/transactions.ts +++ b/x-pack/plugins/apm/public/services/rest/apm/transactions.ts @@ -6,7 +6,7 @@ import { TransactionAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/get_transaction'; import { SpanListAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/spans/get_spans'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; import { IUrlParams } from '../../../store/urlParams'; import { callApi } from '../callApi'; import { addVersion, getEncodedEsQuery } from './apm'; diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx index eab1d2390061b..6e5cc6803cc1b 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { Request, RRRRender } from 'react-redux-request'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { loadTransaction } from '../../services/rest/apm/transactions'; import { IReduxState } from '../rootReducer'; import { IUrlParams } from '../urlParams'; diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx index 13038fdea15d7..5029e88ccaf3a 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { RRRRender } from 'react-redux-request'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { IWaterfall } from '../../components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers'; import { IUrlParams } from '../urlParams'; import { WaterfallV1Request } from './waterfallV1'; diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx index 3fe9b1a5f120e..cbcf307267017 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx @@ -11,8 +11,8 @@ import { SERVICE_NAME, TRANSACTION_ID } from 'x-pack/plugins/apm/common/constants'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getWaterfall, IWaterfall diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx index b5e9a28a13e3d..0291a9b2012af 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Request, RRRRender } from 'react-redux-request'; import { TRACE_ID } from 'x-pack/plugins/apm/common/constants'; import { TraceAPIResponse } from 'x-pack/plugins/apm/server/lib/traces/get_trace'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getWaterfall, IWaterfall diff --git a/x-pack/plugins/apm/public/store/rootReducer.ts b/x-pack/plugins/apm/public/store/rootReducer.ts index 5312ca41f4483..6b0f789ac5b28 100644 --- a/x-pack/plugins/apm/public/store/rootReducer.ts +++ b/x-pack/plugins/apm/public/store/rootReducer.ts @@ -6,7 +6,7 @@ import { reducer } from 'react-redux-request'; import { combineReducers } from 'redux'; -import { StringMap } from '../../typings/common'; +import { StringMap } from '../../typings/es_schemas/common'; // @ts-ignore import location from './location'; import { IUrlParams, urlParamsReducer } from './urlParams'; diff --git a/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts b/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts index da8d1600ed611..67875ed64e775 100644 --- a/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts +++ b/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts @@ -11,7 +11,7 @@ import { rgba } from 'polished'; import { TimeSeriesAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts'; import { AnomalyTimeSeriesResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_anomaly_data/transform'; import { ApmTimeSeriesResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform'; -import { StringMap } from 'x-pack/plugins/apm/typings/common'; +import { StringMap } from 'x-pack/plugins/apm/typings/es_schemas/common'; import { Coordinate, RectCoordinate diff --git a/x-pack/plugins/apm/public/utils/url.tsx b/x-pack/plugins/apm/public/utils/url.tsx index f2b0dfc9a34f3..d830b5ecda913 100644 --- a/x-pack/plugins/apm/public/utils/url.tsx +++ b/x-pack/plugins/apm/public/utils/url.tsx @@ -14,7 +14,7 @@ import { Link } from 'react-router-dom'; import rison from 'rison-node'; import chrome from 'ui/chrome'; import url from 'url'; -import { StringMap } from '../../typings/common'; +import { StringMap } from '../../typings/es_schemas/common'; // Kibana default set in: https://github.com/elastic/kibana/blob/e13e47fc4eb6112f2a5401408e9f765eae90f55d/x-pack/plugins/apm/public/utils/timepicker/index.js#L31-L35 // TODO: store this in config or a shared constant? diff --git a/x-pack/plugins/apm/server/lib/traces/get_trace.ts b/x-pack/plugins/apm/server/lib/traces/get_trace.ts index 4adb8ece0c81b..64dab397a9979 100644 --- a/x-pack/plugins/apm/server/lib/traces/get_trace.ts +++ b/x-pack/plugins/apm/server/lib/traces/get_trace.ts @@ -6,8 +6,8 @@ import { SearchParams } from 'elasticsearch'; import { TRACE_ID } from '../../../common/constants'; -import { Span } from '../../../typings/Span'; -import { Transaction } from '../../../typings/Transaction'; +import { Span } from '../../../typings/es_schemas/Span'; +import { Transaction } from '../../../typings/es_schemas/Transaction'; import { Setup } from '../helpers/setup_request'; export type TraceAPIResponse = Array; diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts index eda72b750a7aa..77ba7a9d7bf04 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts @@ -10,7 +10,7 @@ import { TRANSACTION_DURATION, TRANSACTION_NAME } from '../../../common/constants'; -import { Transaction } from '../../../typings/Transaction'; +import { Transaction } from '../../../typings/es_schemas/Transaction'; import { Setup } from '../helpers/setup_request'; interface Bucket { diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts index 53f8ca04d4ee6..fb62bfc91adcb 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts @@ -6,7 +6,7 @@ import moment from 'moment'; import { oc } from 'ts-optchain'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { ESResponse } from './fetcher'; export interface ITransactionGroup { diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts index 746606947aa62..e59d65d61bda6 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts @@ -15,7 +15,7 @@ import { TRANSACTION_TYPE } from 'x-pack/plugins/apm/common/constants'; import { Setup } from 'x-pack/plugins/apm/server/lib/helpers/setup_request'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; interface Bucket { key: number; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts index e88b17d4ef99c..dc86889a52b27 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts @@ -6,7 +6,7 @@ import { SearchParams } from 'elasticsearch'; import { oc } from 'ts-optchain'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { PROCESSOR_EVENT, TRACE_ID, diff --git a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts index a6fb6f7aac711..5a384c5acf83c 100644 --- a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts +++ b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Span } from 'x-pack/plugins/apm/typings/Span'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; import { PROCESSOR_EVENT, SPAN_START, diff --git a/x-pack/plugins/apm/typings/Error.ts b/x-pack/plugins/apm/typings/Error.ts deleted file mode 100644 index b422b1d801a80..0000000000000 --- a/x-pack/plugins/apm/typings/Error.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 { APMDocV1, ContextService, Stackframe } from './APMDoc'; - -export interface Error extends APMDocV1 { - processor: { - name: 'error'; - event: 'error'; - }; - context: { - process?: { - pid: number; - }; - service: ContextService; - }; - transaction?: { - id: string; // transaction ID is not required in v1 - }; - error: { - id?: string; // ID is not required in v1 - timestamp: string; - culprit: string; - grouping_key: string; - // either exception or log are given - exception?: { - message?: string; // either message or type are given - type?: string; - code?: string; - module?: string; - attributes?: unknown; - handled?: boolean; - stacktrace?: Stackframe[]; - }; - log?: { - message: string; - param_message?: string; - logger_name?: string; - level?: string; - stacktrace?: Stackframe[]; - }; - }; -} diff --git a/x-pack/plugins/apm/typings/APMDoc.ts b/x-pack/plugins/apm/typings/es_schemas/APMDoc.ts similarity index 100% rename from x-pack/plugins/apm/typings/APMDoc.ts rename to x-pack/plugins/apm/typings/es_schemas/APMDoc.ts diff --git a/x-pack/plugins/apm/typings/es_schemas/Error.ts b/x-pack/plugins/apm/typings/es_schemas/Error.ts new file mode 100644 index 0000000000000..a1aa9d6ff21e9 --- /dev/null +++ b/x-pack/plugins/apm/typings/es_schemas/Error.ts @@ -0,0 +1,84 @@ +/* + * 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 { APMDocV1, APMDocV2, ContextService, Stackframe } from './APMDoc'; + +interface Agent { + hostname: string; + type: string; + version: string; +} + +interface Processor { + name: 'error'; + event: 'error'; +} + +interface Context { + process?: { + pid: number; + }; + service: ContextService; +} + +interface Exception { + message?: string; // either message or type are given + type?: string; + code?: string; + module?: string; + attributes?: unknown; + handled?: boolean; + stacktrace?: Stackframe[]; +} + +interface Log { + message: string; + param_message?: string; + logger_name?: string; + level?: string; + stacktrace?: Stackframe[]; +} + +interface ErrorV1 extends APMDocV1 { + version: 'v1'; + agent: Agent; + processor: Processor; + context: Context; + transaction?: { + id: string; // transaction ID is not required in v1 + }; + error: { + id?: string; // ID is not required in v1 + timestamp: string; + culprit: string; + grouping_key: string; + // either exception or log are given + exception?: Exception; + log?: Log; + }; +} + +interface ErrorV2 extends APMDocV2 { + version: 'v2'; + agent: Agent; + processor: Processor; + context: Context; + transaction: { + id: string; // transaction ID is required in v2 + }; + error: { + id: string; // ID is required in v2 + timestamp: string; + culprit: string; + grouping_key: string; + // either exception or log are given + exception?: Exception; + log?: Log; + }; +} + +// Not calling it "Error" to avoid clashes with types for native Error +export type APMError = ErrorV1 | ErrorV2; diff --git a/x-pack/plugins/apm/typings/Span.ts b/x-pack/plugins/apm/typings/es_schemas/Span.ts similarity index 100% rename from x-pack/plugins/apm/typings/Span.ts rename to x-pack/plugins/apm/typings/es_schemas/Span.ts diff --git a/x-pack/plugins/apm/typings/Transaction.ts b/x-pack/plugins/apm/typings/es_schemas/Transaction.ts similarity index 100% rename from x-pack/plugins/apm/typings/Transaction.ts rename to x-pack/plugins/apm/typings/es_schemas/Transaction.ts From 3dc2420e02530ecc42ffebd3c4b7571cfa885314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Fri, 7 Dec 2018 01:52:45 +0100 Subject: [PATCH 2/7] Convert error section to typescript --- .../__snapshots__/DetailView.test.js.snap | 1 - .../DetailView/__test__/props.json | 3 +- .../app/ErrorGroupDetails/DetailView/index.js | 5 +- .../DiscoverButtons/DiscoverErrorButton.tsx | 12 +-- .../DiscoverButtons/DiscoverSpanButton.tsx | 2 +- .../DiscoverTransactionButton.tsx | 2 +- .../public/services/rest/apm/error_groups.ts | 16 ++-- ...rDistribution.js => errorDistribution.tsx} | 22 ++++- .../{errorGroup.js => errorGroup.tsx} | 20 +++-- .../{errorGroupList.js => errorGroupList.tsx} | 20 +++-- x-pack/plugins/apm/public/store/urlParams.ts | 4 +- .../{get_buckets.js => get_buckets.ts} | 28 ++++-- .../errors/distribution/get_distribution.js | 28 ------ .../errors/distribution/get_distribution.ts | 46 ++++++++++ ...{get_error_group.js => get_error_group.ts} | 30 +++++-- ...et_error_groups.js => get_error_groups.ts} | 87 +++++++++++++++---- .../apm/server/lib/services/get_service.ts | 6 +- .../apm/server/lib/services/get_services.ts | 10 +-- x-pack/plugins/apm/typings/elasticsearch.ts | 12 +-- 19 files changed, 239 insertions(+), 115 deletions(-) rename x-pack/plugins/apm/public/store/reactReduxRequest/{errorDistribution.js => errorDistribution.tsx} (60%) rename x-pack/plugins/apm/public/store/reactReduxRequest/{errorGroup.js => errorGroup.tsx} (64%) rename x-pack/plugins/apm/public/store/reactReduxRequest/{errorGroupList.js => errorGroupList.tsx} (64%) rename x-pack/plugins/apm/server/lib/errors/distribution/{get_buckets.js => get_buckets.ts} (68%) delete mode 100644 x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.js create mode 100644 x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts rename x-pack/plugins/apm/server/lib/errors/{get_error_group.js => get_error_group.ts} (58%) rename x-pack/plugins/apm/server/lib/errors/{get_error_groups.js => get_error_groups.ts} (57%) diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap index 9ca7ebbed2b04..ae6655248ec33 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap @@ -1102,7 +1102,6 @@ baz", "name": "error", }, }, - "groupId": "c00e245c2fbebaf178fc31eeb2bb0250", "occurrencesCount": 18, }, "status": "SUCCESS", diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/props.json b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/props.json index 8972c69e6dffa..5cd32c463eeed 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/props.json +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/props.json @@ -919,8 +919,7 @@ "version": "7.0.0-alpha1" } }, - "occurrencesCount": 18, - "groupId": "c00e245c2fbebaf178fc31eeb2bb0250" + "occurrencesCount": 18 }, "status": "SUCCESS" }, diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.js b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.js index f0917077c1754..959c8e926b2d7 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.js +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.js @@ -87,7 +87,6 @@ function DetailView({ errorGroup, urlParams, location }) { return null; } - const { serviceName } = urlParams; const stickyProperties = [ { fieldName: '@timestamp', @@ -129,7 +128,6 @@ function DetailView({ errorGroup, urlParams, location }) { const tabs = getTabs(context, logStackframes); const currentTab = getCurrentTab(tabs, urlParams.detailTab); const occurencesCount = errorGroup.data.occurrencesCount; - const groupId = errorGroup.data.groupId; const agentName = get(errorGroup.data.error, SERVICE_AGENT_NAME); return ( @@ -143,8 +141,7 @@ function DetailView({ errorGroup, urlParams, location }) { Error occurrence diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx index c07ffa6d704a5..e31bd567546b8 100644 --- a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx +++ b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx @@ -9,9 +9,12 @@ import { ERROR_GROUP_ID, SERVICE_NAME } from 'x-pack/plugins/apm/common/constants'; +import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; import { DiscoverButton } from './DiscoverButton'; -function getDiscoverQuery(serviceName: string, groupId: string, kuery: string) { +function getDiscoverQuery(error: APMError, kuery: string) { + const serviceName = error.context.service.name; + const groupId = error.error.grouping_key; let query = `${SERVICE_NAME}:"${serviceName}" AND ${ERROR_GROUP_ID}:"${groupId}"`; if (kuery) { query = ` AND ${kuery}`; @@ -30,13 +33,12 @@ function getDiscoverQuery(serviceName: string, groupId: string, kuery: string) { } export const DiscoverErrorButton: React.SFC<{ - readonly serviceName: string; - readonly groupId: string; + readonly error: APMError; readonly kuery: string; -}> = ({ serviceName, groupId, kuery, children }) => { +}> = ({ error, kuery, children }) => { return ( ); diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx index baf4435a07542..3c945dcbe5eed 100644 --- a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx +++ b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { SPAN_HEX_ID, SPAN_ID } from 'x-pack/plugins/apm/common/constants'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; import { DiscoverButton } from './DiscoverButton'; function getDiscoverQuery(span: Span) { diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx index d2ed79b7f9cae..f115eb933db72 100644 --- a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx +++ b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx @@ -10,7 +10,7 @@ import { TRACE_ID, TRANSACTION_ID } from 'x-pack/plugins/apm/common/constants'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { DiscoverButton } from './DiscoverButton'; function getDiscoverQuery(transaction: Transaction) { diff --git a/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts b/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts index 7043f83129c03..c4146f3163233 100644 --- a/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts +++ b/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts @@ -4,7 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { camelizeKeys } from 'humps'; +import { ErrorDistributionAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/distribution/get_distribution'; +import { ErrorGroupAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_group'; +import { ErrorGroupListAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_groups'; import { IUrlParams } from '../../../store/urlParams'; import { callApi } from '../callApi'; import { getEncodedEsQuery } from './apm'; @@ -24,7 +26,7 @@ export async function loadErrorGroupList({ sortField, sortDirection }: ErrorGroupListParams) { - return callApi({ + return callApi({ pathname: `/api/apm/services/${serviceName}/errors`, query: { start, @@ -44,8 +46,7 @@ export async function loadErrorGroupDetails({ kuery, errorGroupId }: IUrlParams) { - // TODO: add types when error section is converted to ts - const res = await callApi( + return callApi( { pathname: `/api/apm/services/${serviceName}/errors/${errorGroupId}`, query: { @@ -58,11 +59,6 @@ export async function loadErrorGroupDetails({ camelcase: false } ); - const camelizedRes: any = camelizeKeys(res); - if (res.error.context) { - camelizedRes.error.context = res.error.context; - } - return camelizedRes; } export async function loadErrorDistribution({ @@ -72,7 +68,7 @@ export async function loadErrorDistribution({ kuery, errorGroupId }: IUrlParams) { - return callApi({ + return callApi({ pathname: `/api/apm/services/${serviceName}/errors/${errorGroupId}/distribution`, query: { start, diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.js b/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.tsx similarity index 60% rename from x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.tsx index a46449e7f6140..18f39e3de16a0 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.tsx @@ -5,19 +5,33 @@ */ import React from 'react'; -import { Request } from 'react-redux-request'; +import { Request, RRRRender } from 'react-redux-request'; +import { ErrorDistributionAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/distribution/get_distribution'; import { loadErrorDistribution } from '../../services/rest/apm/error_groups'; +import { IReduxState } from '../rootReducer'; +import { IUrlParams } from '../urlParams'; +// @ts-ignore import { createInitialDataSelector } from './helpers'; const ID = 'errorDistribution'; -const INITIAL_DATA = { buckets: [], totalHits: 0 }; +const INITIAL_DATA: ErrorDistributionAPIResponse = { + buckets: [], + totalHits: 0, + bucketSize: 0 +}; const withInitialData = createInitialDataSelector(INITIAL_DATA); -export function getErrorDistribution(state) { +export function getErrorDistribution(state: IReduxState) { return withInitialData(state.reactReduxRequest[ID]); } -export function ErrorDistributionRequest({ urlParams, render }) { +export function ErrorDistributionRequest({ + urlParams, + render +}: { + urlParams: IUrlParams; + render: RRRRender; +}) { const { serviceName, start, end, errorGroupId, kuery } = urlParams; if (!(serviceName && start && end && errorGroupId)) { diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.js b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.tsx similarity index 64% rename from x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.tsx index 4717615783542..85bdf94b431b9 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.tsx @@ -5,19 +5,29 @@ */ import React from 'react'; -import { createInitialDataSelector } from './helpers'; -import { Request } from 'react-redux-request'; +import { Request, RRRRender } from 'react-redux-request'; +import { ErrorGroupAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_group'; import { loadErrorGroupDetails } from '../../services/rest/apm/error_groups'; +import { IReduxState } from '../rootReducer'; +import { IUrlParams } from '../urlParams'; +// @ts-ignore +import { createInitialDataSelector } from './helpers'; const ID = 'errorGroupDetails'; -const INITIAL_DATA = {}; +const INITIAL_DATA: ErrorGroupAPIResponse = {}; const withInitialData = createInitialDataSelector(INITIAL_DATA); -export function getErrorGroupDetails(state) { +export function getErrorGroupDetails(state: IReduxState) { return withInitialData(state.reactReduxRequest[ID]); } -export function ErrorGroupDetailsRequest({ urlParams, render }) { +export function ErrorGroupDetailsRequest({ + urlParams, + render +}: { + urlParams: IUrlParams; + render: RRRRender; +}) { const { serviceName, errorGroupId, start, end, kuery } = urlParams; if (!(serviceName && start && end && errorGroupId)) { diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.js b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.tsx similarity index 64% rename from x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.tsx index 9863d5f783529..6ac50245d0952 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.tsx @@ -5,19 +5,29 @@ */ import React from 'react'; -import { createInitialDataSelector } from './helpers'; -import { Request } from 'react-redux-request'; +import { Request, RRRRender } from 'react-redux-request'; +import { ErrorGroupListAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_groups'; import { loadErrorGroupList } from '../../services/rest/apm/error_groups'; +import { IReduxState } from '../rootReducer'; +import { IUrlParams } from '../urlParams'; +// @ts-ignore +import { createInitialDataSelector } from './helpers'; const ID = 'errorGroupList'; -const INITIAL_DATA = []; +const INITIAL_DATA: ErrorGroupListAPIResponse = []; const withInitialData = createInitialDataSelector(INITIAL_DATA); -export function getErrorGroupList(state) { +export function getErrorGroupList(state: IReduxState) { return withInitialData(state.reactReduxRequest[ID]); } -export function ErrorGroupDetailsRequest({ urlParams, render }) { +export function ErrorGroupDetailsRequest({ + urlParams, + render +}: { + urlParams: IUrlParams; + render: RRRRender; +}) { const { serviceName, start, diff --git a/x-pack/plugins/apm/public/store/urlParams.ts b/x-pack/plugins/apm/public/store/urlParams.ts index b0850aa2cf880..5ac0879b31278 100644 --- a/x-pack/plugins/apm/public/store/urlParams.ts +++ b/x-pack/plugins/apm/public/store/urlParams.ts @@ -157,12 +157,14 @@ export const getUrlParams = createSelector( ); export interface IUrlParams { + detailTab?: string; end?: number; errorGroupId?: string; flyoutDetailTab?: string; - detailTab?: string; kuery?: string; serviceName?: string; + sortDirection?: string; + sortField?: string; start?: number; traceId?: string; transactionId?: string; diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts similarity index 68% rename from x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js rename to x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts index 9d77099e6d94f..c8ec98910ece1 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts @@ -4,13 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SERVICE_NAME, ERROR_GROUP_ID } from '../../../../common/constants'; +import { BucketAgg } from 'x-pack/plugins/apm/typings/elasticsearch'; +import { ERROR_GROUP_ID, SERVICE_NAME } from '../../../../common/constants'; +import { Setup } from '../../helpers/setup_request'; -export async function getBuckets({ serviceName, groupId, bucketSize, setup }) { +export async function getBuckets({ + serviceName, + groupId, + bucketSize, + setup +}: { + serviceName: string; + groupId: string; + bucketSize: number; + setup: Setup; +}) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('apm_oss.errorIndices'), + index: config.get('apm_oss.errorIndices'), body: { size: 0, query: { @@ -50,7 +62,13 @@ export async function getBuckets({ serviceName, groupId, bucketSize, setup }) { params.body.query.bool.filter.push(esFilterQuery); } - const resp = await client('search', params); + interface Aggs { + distribution: { + buckets: Array>; + }; + } + + const resp = await client('search', params); const buckets = resp.aggregations.distribution.buckets.map(bucket => ({ key: bucket.key, @@ -58,7 +76,7 @@ export async function getBuckets({ serviceName, groupId, bucketSize, setup }) { })); return { - total_hits: resp.hits.total, + totalHits: resp.hits.total, buckets }; } diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.js b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.js deleted file mode 100644 index 725f5a74903d8..0000000000000 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 { getBuckets } from './get_buckets'; - -function getBucketSize({ start, end, config }) { - const bucketTargetCount = config.get('xpack.apm.bucketTargetCount'); - return Math.floor((end - start) / bucketTargetCount); -} - -export async function getDistribution({ serviceName, groupId, setup }) { - const bucketSize = getBucketSize(setup); - const { buckets, total_hits: totalHits } = await getBuckets({ - serviceName, - groupId, - bucketSize, - setup - }); - - return { - total_hits: totalHits, - buckets, - bucket_size: bucketSize - }; -} diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts new file mode 100644 index 0000000000000..c2ec74d76a1e6 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts @@ -0,0 +1,46 @@ +/* + * 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 { Setup } from '../../helpers/setup_request'; +import { getBuckets } from './get_buckets'; + +function getBucketSize({ start, end, config }: Setup) { + const bucketTargetCount = config.get('xpack.apm.bucketTargetCount'); + return Math.floor((end - start) / bucketTargetCount); +} + +export interface ErrorDistributionAPIResponse { + totalHits: number; + buckets: Array<{ + key: number; + count: number; + }>; + bucketSize: number; +} + +export async function getDistribution({ + serviceName, + groupId, + setup +}: { + serviceName: string; + groupId: string; + setup: Setup; +}): Promise { + const bucketSize = getBucketSize(setup); + const { buckets, totalHits } = await getBuckets({ + serviceName, + groupId, + bucketSize, + setup + }); + + return { + totalHits, + buckets, + bucketSize + }; +} diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_group.js b/x-pack/plugins/apm/server/lib/errors/get_error_group.ts similarity index 58% rename from x-pack/plugins/apm/server/lib/errors/get_error_group.js rename to x-pack/plugins/apm/server/lib/errors/get_error_group.ts index f46a36262b4d2..1f64bd1d6db10 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_group.js +++ b/x-pack/plugins/apm/server/lib/errors/get_error_group.ts @@ -4,14 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SERVICE_NAME, ERROR_GROUP_ID } from '../../../common/constants'; -import { get } from 'lodash'; +import { oc } from 'ts-optchain'; +import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; +import { ERROR_GROUP_ID, SERVICE_NAME } from '../../../common/constants'; +import { Setup } from '../helpers/setup_request'; -export async function getErrorGroup({ serviceName, groupId, setup }) { +export interface ErrorGroupAPIResponse { + error?: APMError; + occurrencesCount?: number; +} + +export async function getErrorGroup({ + serviceName, + groupId, + setup +}: { + serviceName: string; + groupId: string; + setup: Setup; +}): Promise { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('apm_oss.errorIndices'), + index: config.get('apm_oss.errorIndices'), body: { size: 1, query: { @@ -43,11 +58,10 @@ export async function getErrorGroup({ serviceName, groupId, setup }) { params.body.query.bool.filter.push(esFilterQuery); } - const resp = await client('search', params); + const resp = await client('search', params); return { - error: get(resp, 'hits.hits[0]._source', {}), - occurrences_count: get(resp, 'hits.total'), - group_id: get(resp, `hits.hits[0]._source.${ERROR_GROUP_ID}`) + error: oc(resp).hits.hits[0]._source(), + occurrencesCount: oc(resp).hits.total() }; } diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_groups.js b/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts similarity index 57% rename from x-pack/plugins/apm/server/lib/errors/get_error_groups.js rename to x-pack/plugins/apm/server/lib/errors/get_error_groups.ts index 32d3cc685b5d6..5100cbd73297b 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_groups.js +++ b/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts @@ -4,27 +4,45 @@ * you may not use this file except in compliance with the Elastic License. */ +import { oc } from 'ts-optchain'; +import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; import { - SERVICE_NAME, - ERROR_GROUP_ID, ERROR_CULPRIT, + ERROR_EXC_HANDLED, ERROR_EXC_MESSAGE, + ERROR_GROUP_ID, ERROR_LOG_MESSAGE, - ERROR_EXC_HANDLED, - PROCESSOR_EVENT + PROCESSOR_EVENT, + SERVICE_NAME } from '../../../common/constants'; -import { get } from 'lodash'; +import { Setup } from '../helpers/setup_request'; + +interface ErrorResponseItems { + message?: string; + occurrenceCount: number; + culprit?: string; + groupId?: string; + latestOccurrenceAt: string; + handled?: boolean; +} + +export type ErrorGroupListAPIResponse = ErrorResponseItems[]; export async function getErrorGroups({ serviceName, sortField, sortDirection = 'desc', setup -}) { +}: { + serviceName: string; + sortField: string; + sortDirection: 'desc' | 'asc'; + setup: Setup; +}): Promise { const { start, end, esFilterQuery, client, config } = setup; - const params = { - index: config.get('apm_oss.errorIndices'), + const params: any = { + index: config.get('apm_oss.errorIndices'), body: { size: 0, query: { @@ -87,23 +105,58 @@ export async function getErrorGroups({ }; } - const resp = await client('search', params); - const hits = get(resp, 'aggregations.error_groups.buckets', []).map( - bucket => { + interface SampleError { + '@timestamp': APMError['@timestamp']; + error: { + log?: { + message: string; + }; + exception?: { + handled?: boolean; + message?: string; + }; + culprit: APMError['error']['culprit']; + grouping_key: APMError['error']['grouping_key']; + }; + } + + interface Bucket { + key: string; + doc_count: number; + sample: { + hits: { + total: number; + max_score: number | null; + hits: Array<{ + _source: SampleError; + }>; + }; + }; + } + + interface Aggs { + error_groups: { + buckets: Bucket[]; + }; + } + + const resp = await client('search', params); + const hits = oc(resp) + .aggregations.error_groups.buckets([]) + .map(bucket => { const source = bucket.sample.hits.hits[0]._source; const message = - get(source, ERROR_LOG_MESSAGE) || get(source, ERROR_EXC_MESSAGE); + oc(source).error.log.message() || oc(source).error.exception.message(); return { message, occurrenceCount: bucket.doc_count, - culprit: get(source, ERROR_CULPRIT), - groupId: get(source, ERROR_GROUP_ID), + culprit: oc(source).error.culprit(), + groupId: oc(source).error.grouping_key(), latestOccurrenceAt: source['@timestamp'], - handled: get(source, ERROR_EXC_HANDLED) + handled: oc(source).error.exception.handled() }; - } - ); + }); return hits; } diff --git a/x-pack/plugins/apm/server/lib/services/get_service.ts b/x-pack/plugins/apm/server/lib/services/get_service.ts index 05beb6b96883d..c3d8037bf7eb0 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service.ts @@ -5,7 +5,7 @@ */ import { oc } from 'ts-optchain'; -import { TermsAggsBucket } from 'x-pack/plugins/apm/typings/elasticsearch'; +import { BucketAgg } from 'x-pack/plugins/apm/typings/elasticsearch'; import { SERVICE_AGENT_NAME, SERVICE_NAME, @@ -65,10 +65,10 @@ export async function getService( interface Aggs { types: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; agents: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; } diff --git a/x-pack/plugins/apm/server/lib/services/get_services.ts b/x-pack/plugins/apm/server/lib/services/get_services.ts index 023e889e62fe5..014f1fdefdf9d 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services.ts @@ -5,7 +5,7 @@ */ import { oc } from 'ts-optchain'; -import { TermsAggsBucket } from 'x-pack/plugins/apm/typings/elasticsearch'; +import { BucketAgg } from 'x-pack/plugins/apm/typings/elasticsearch'; import { PROCESSOR_EVENT, SERVICE_AGENT_NAME, @@ -85,19 +85,19 @@ export async function getServices( params.body.query.bool.filter.push(esFilterQuery); } - interface ServiceBucket extends TermsAggsBucket { + interface ServiceBucket extends BucketAgg { avg: { value: number; }; agents: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; events: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; } - interface Aggs extends TermsAggsBucket { + interface Aggs extends BucketAgg { services: { buckets: ServiceBucket[]; }; diff --git a/x-pack/plugins/apm/typings/elasticsearch.ts b/x-pack/plugins/apm/typings/elasticsearch.ts index 35b58795ed1ca..ac2c3cacb28d2 100644 --- a/x-pack/plugins/apm/typings/elasticsearch.ts +++ b/x-pack/plugins/apm/typings/elasticsearch.ts @@ -4,19 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SearchResponse } from 'elasticsearch'; - -export interface TermsAggsBucket { - key: string; +export interface BucketAgg { + key: T; doc_count: number; } -type Omit = Pick>; -export type TopHits = Omit< - SearchResponse, - 'took' | 'timed_out' | '_shards' ->; - declare module 'elasticsearch' { // extending SearchResponse to be able to have typed aggregations export interface AggregationSearchResponse From acb92c3c5c120f8f9f9feb95625d006c17819151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Fri, 7 Dec 2018 12:51:08 +0100 Subject: [PATCH 3/7] Fix snapshot --- .../__snapshots__/DetailView.test.js.snap | 962 +++++++++++++++++- 1 file changed, 960 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap index ae6655248ec33..d001e35a8e849 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap @@ -13,8 +13,966 @@ exports[`DetailView should render with data 1`] = ` Error occurrence (server/coffee.js)", + "exception": Object { + "message": "Cannot read property 'level' of undefined", + "stacktrace": Array [ + Object { + "absPath": "/app/server/coffee.js", + "context": Object { + "post": Array [ + " res.send('Of course!')", + " } else {", + " res.send('You can\\\\'t have any!')", + " }", + "})", + "", + "app.get('/log-error', function (req, res) {", + ], + "pre": Array [ + "", + "var express = require('express')", + "var apm = require('elastic-apm-node')", + "", + "var app = module.exports = new express.Router()", + "", + "app.get('/is-it-coffee-time', function (req, res) {", + ], + }, + "filename": "server/coffee.js", + "function": "", + "libraryFrame": false, + "line": Object { + "context": " if (req.paarms.level === 11) {", + "number": 9, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/route.js", + "context": Object { + "post": Array [ + " }", + " }", + "};", + "", + "/**", + " * Add a handler for all HTTP verbs to this route.", + " *", + ], + "pre": Array [ + " if (layer.method && layer.method !== method) {", + " return next(err);", + " }", + "", + " if (err) {", + " layer.handle_error(err, req, res, next);", + " } else {", + ], + }, + "filename": "node_modules/express/lib/router/route.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " layer.handle_request(req, res, next);", + "number": 137, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/route.js", + "context": Object { + "post": Array [ + "", + " function next(err) {", + " // signal to exit route", + " if (err && err === 'route') {", + " return done();", + " }", + "", + ], + "pre": Array [ + " var method = req.method.toLowerCase();", + " if (method === 'head' && !this.methods['head']) {", + " method = 'get';", + " }", + "", + " req.route = this;", + "", + ], + }, + "filename": "node_modules/express/lib/router/route.js", + "function": "dispatch", + "libraryFrame": true, + "line": Object { + "context": " next();", + "number": 112, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " trim_prefix(layer, layerError, layerPath, path);", + " });", + " }", + "", + " function trim_prefix(layer, layerError, layerPath, path) {", + ], + "pre": Array [ + " // this should be done for the layer", + " self.process_params(layer, paramcalled, req, res, function (err) {", + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "", + "libraryFrame": true, + "line": Object { + "context": " return layer.handle_request(req, res, next);", + "number": 281, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " var i = 0;", + " var name;", + " var paramIndex = 0;", + " var key;", + " var paramVal;", + ], + "pre": Array [ + " var params = this.params;", + "", + " // captured parameters from the layer, keys and values", + " var keys = layer.keys;", + "", + " // fast track", + " if (!keys || keys.length === 0) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "process_params", + "libraryFrame": true, + "line": Object { + "context": " return done();", + "number": 335, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + ], + "pre": Array [ + " // Capture one-time layer values", + " req.params = self.mergeParams", + " ? mergeParams(layer.params, parentParams)", + " : layer.params;", + " var layerPath = layer.path;", + "", + " // this should be done for the layer", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " self.process_params(layer, paramcalled, req, res, function (err) {", + "number": 275, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + "", + " function next(err) {", + " var layerError = err === 'route'", + " ? null", + " : err;", + "", + " // remove added slash", + ], + "pre": Array [ + " });", + " }", + "", + " // setup basic req values", + " req.baseUrl = parentUrl;", + " req.originalUrl = req.originalUrl || req.url;", + "", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " next();", + "number": 174, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " // mixin Router class functions", + " setPrototypeOf(router, proto)", + "", + " router.params = {};", + " router._params = [];", + ], + "pre": Array [ + " * @public", + " */", + "", + "var proto = module.exports = function(options) {", + " var opts = options || {};", + "", + " function router(req, res, next) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "router", + "libraryFrame": true, + "line": Object { + "context": " router.handle(req, res, next);", + "number": 47, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + " }", + "};", + "", + "/**", + " * Process any parameters for the layer.", + " * @private", + ], + "pre": Array [ + " }", + "", + " debug('%s %s : %s', layer.name, layerPath, req.originalUrl);", + "", + " if (layerError) {", + " layer.handle_error(layerError, req, res, next);", + " } else {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "trim_prefix", + "libraryFrame": true, + "line": Object { + "context": " layer.handle_request(req, res, next);", + "number": 317, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " });", + " }", + "", + " function trim_prefix(layer, layerError, layerPath, path) {", + " if (layerPath.length !== 0) {", + " // Validate path breaks on a path separator", + " var c = path[layerPath.length]", + ], + "pre": Array [ + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + "", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "", + "libraryFrame": true, + "line": Object { + "context": " trim_prefix(layer, layerError, layerPath, path);", + "number": 284, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " var i = 0;", + " var name;", + " var paramIndex = 0;", + " var key;", + " var paramVal;", + ], + "pre": Array [ + " var params = this.params;", + "", + " // captured parameters from the layer, keys and values", + " var keys = layer.keys;", + "", + " // fast track", + " if (!keys || keys.length === 0) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "process_params", + "libraryFrame": true, + "line": Object { + "context": " return done();", + "number": 335, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + ], + "pre": Array [ + " // Capture one-time layer values", + " req.params = self.mergeParams", + " ? mergeParams(layer.params, parentParams)", + " : layer.params;", + " var layerPath = layer.path;", + "", + " // this should be done for the layer", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " self.process_params(layer, paramcalled, req, res, function (err) {", + "number": 275, + }, + }, + Object { + "absPath": "/app/server.js", + "context": Object { + "post": Array [ + "})", + "", + "app.use(require('./server/coffee'))", + "app.use('/api', require('./server/routes'))", + "app.get('*', function (req, res) {", + " res.sendFile(path.resolve(__dirname, 'client/build', 'index.html'))", + "})", + ], + "pre": Array [ + "app.use(require('body-parser').json())", + "app.use(express.static('client/build'))", + "app.use(function (req, res, next) {", + " apm.setTag('foo', 'bar')", + " apm.setTag('lorem', 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.')", + " apm.setTag('this-is-a-very-long-tag-name-without-any-spaces', 'test')", + " apm.setTag('multi-line', 'foo\\\\nbar\\\\nbaz')", + ], + }, + "filename": "server.js", + "function": "", + "libraryFrame": false, + "line": Object { + "context": " next()", + "number": 27, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + " }", + "};", + "", + "/**", + " * Process any parameters for the layer.", + " * @private", + ], + "pre": Array [ + " }", + "", + " debug('%s %s : %s', layer.name, layerPath, req.originalUrl);", + "", + " if (layerError) {", + " layer.handle_error(layerError, req, res, next);", + " } else {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "trim_prefix", + "libraryFrame": true, + "line": Object { + "context": " layer.handle_request(req, res, next);", + "number": 317, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " });", + " }", + "", + " function trim_prefix(layer, layerError, layerPath, path) {", + " if (layerPath.length !== 0) {", + " // Validate path breaks on a path separator", + " var c = path[layerPath.length]", + ], + "pre": Array [ + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + "", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "", + "libraryFrame": true, + "line": Object { + "context": " trim_prefix(layer, layerError, layerPath, path);", + "number": 284, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " var i = 0;", + " var name;", + " var paramIndex = 0;", + " var key;", + " var paramVal;", + ], + "pre": Array [ + " var params = this.params;", + "", + " // captured parameters from the layer, keys and values", + " var keys = layer.keys;", + "", + " // fast track", + " if (!keys || keys.length === 0) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "process_params", + "libraryFrame": true, + "line": Object { + "context": " return done();", + "number": 335, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + ], + "pre": Array [ + " // Capture one-time layer values", + " req.params = self.mergeParams", + " ? mergeParams(layer.params, parentParams)", + " : layer.params;", + " var layerPath = layer.path;", + "", + " // this should be done for the layer", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " self.process_params(layer, paramcalled, req, res, function (err) {", + "number": 275, + }, + }, + Object { + "absPath": "/app/node_modules/elastic-apm-node/lib/instrumentation/modules/express.js", + "context": Object { + "post": Array [ + " }", + " }", + " }", + " })", + "", + " return express", + "}", + ], + "pre": Array [ + " return function serveStatic (req, res, next) {", + " req._elastic_apm_static = true", + "", + " return origServeStatic(req, res, nextHook)", + "", + " function nextHook (err) {", + " if (!err) req._elastic_apm_static = false", + ], + }, + "filename": "node_modules/elastic-apm-node/lib/instrumentation/modules/express.js", + "function": "nextHook", + "libraryFrame": true, + "line": Object { + "context": " return next.apply(this, arguments)", + "number": 90, + }, + }, + Object { + "absPath": "/app/node_modules/serve-static/index.js", + "context": Object { + "post": Array [ + " })", + "", + " // pipe", + " stream.pipe(res)", + " }", + "}", + "", + ], + "pre": Array [ + " // forward errors", + " stream.on('error', function error (err) {", + " if (forwardError || !(err.statusCode < 500)) {", + " next(err)", + " return", + " }", + "", + ], + }, + "filename": "node_modules/serve-static/index.js", + "function": "error", + "libraryFrame": true, + "line": Object { + "context": " next()", + "number": 121, + }, + }, + Object { + "absPath": "events.js", + "filename": "events.js", + "function": "emitOne", + "libraryFrame": true, + "line": Object { + "number": 96, + }, + }, + Object { + "absPath": "events.js", + "filename": "events.js", + "function": "emit", + "libraryFrame": true, + "line": Object { + "number": 188, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " expose: false", + " }))", + " }", + "", + " var res = this.res", + " var msg = statuses[status] || String(status)", + " var doc = createHtmlDocument('Error', escapeHtml(msg))", + ], + "pre": Array [ + " * @param {Error} [err]", + " * @private", + " */", + "", + "SendStream.prototype.error = function error (status, err) {", + " // emit if listeners instead of responding", + " if (hasListeners(this, 'error')) {", + ], + }, + "filename": "node_modules/send/index.js", + "function": "error", + "libraryFrame": true, + "line": Object { + "context": " return this.emit('error', createError(status, err, {", + "number": 270, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " break", + " default:", + " this.error(500, error)", + " break", + " }", + "}", + "", + ], + "pre": Array [ + " */", + "", + "SendStream.prototype.onStatError = function onStatError (error) {", + " switch (error.code) {", + " case 'ENAMETOOLONG':", + " case 'ENOENT':", + " case 'ENOTDIR':", + ], + }, + "filename": "node_modules/send/index.js", + "function": "onStatError", + "libraryFrame": true, + "line": Object { + "context": " this.error(404, error)", + "number": 421, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " : self.error(404)", + " }", + "", + " var p = path + '.' + self._extensions[i++]", + "", + " debug('stat \\"%s\\"', p)", + " fs.stat(p, function (err, stat) {", + ], + "pre": Array [ + " self.emit('file', path, stat)", + " self.send(path, stat)", + " })", + "", + " function next (err) {", + " if (self._extensions.length <= i) {", + " return err", + ], + }, + "filename": "node_modules/send/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " ? self.onStatError(err)", + "number": 736, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " }", + " if (err) return self.onStatError(err)", + " if (stat.isDirectory()) return self.redirect(path)", + " self.emit('file', path, stat)", + " self.send(path, stat)", + " })", + "", + ], + "pre": Array [ + " var i = 0", + " var self = this", + "", + " debug('stat \\"%s\\"', path)", + " fs.stat(path, function onstat (err, stat) {", + " if (err && err.code === 'ENOENT' && !extname(path) && path[path.length - 1] !== sep) {", + " // not found, check extensions", + ], + }, + "filename": "node_modules/send/index.js", + "function": "onstat", + "libraryFrame": true, + "line": Object { + "context": " return next(err)", + "number": 725, + }, + }, + Object { + "absPath": "/app/node_modules/elastic-apm-node/lib/instrumentation/index.js", + "context": Object { + "post": Array [ + " ins.currentTransaction = prev", + " return result", + " }", + "}", + "", + "Instrumentation.prototype._recoverTransaction = function (trans) {", + " if (this.currentTransaction === trans) return", + ], + "pre": Array [ + " var trans = this.currentTransaction", + "", + " return elasticAPMCallbackWrapper", + "", + " function elasticAPMCallbackWrapper () {", + " var prev = ins.currentTransaction", + " ins.currentTransaction = trans", + ], + }, + "filename": "node_modules/elastic-apm-node/lib/instrumentation/index.js", + "function": "elasticAPMCallbackWrapper", + "libraryFrame": true, + "line": Object { + "context": " var result = original.apply(this, arguments)", + "number": 116, + }, + }, + Object { + "absPath": "fs.js", + "filename": "fs.js", + "function": "FSReqWrap.oncomplete", + "libraryFrame": true, + "line": Object { + "number": 123, + }, + }, + ], + "type": "TypeError", + }, + "groupingKey": "c00e245c2fbebaf178fc31eeb2bb0250", + "id": "c5e55dfc-09cc-4e0d-ace3-1ba4233f66eb", + }, + "processor": Object { + "event": "error", + "name": "error", + }, + } + } > Date: Mon, 10 Dec 2018 11:03:50 +0100 Subject: [PATCH 4/7] Fix ts --- x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx | 2 +- .../plugins/apm/public/components/shared/CodePreview/index.tsx | 2 +- x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx | 2 +- .../plugins/apm/public/components/shared/ManagedTable/index.tsx | 2 +- .../components/shared/PropertiesTable/NestedKeyValueTable.tsx | 2 +- .../apm/public/components/shared/PropertiesTable/index.tsx | 2 +- .../apm/public/components/shared/Stacktrace/FrameHeading.tsx | 2 +- .../public/components/shared/Stacktrace/LibraryStackFrames.tsx | 2 +- .../shared/Stacktrace/__test__/stacktraceUtils.test.ts | 2 +- .../apm/public/components/shared/Stacktrace/stacktraceUtils.ts | 2 +- .../plugins/apm/public/services/__test__/SessionStorageMock.ts | 2 +- x-pack/plugins/apm/public/store/rootReducer.ts | 2 +- x-pack/plugins/apm/public/store/selectors/chartSelectors.ts | 2 +- x-pack/plugins/apm/public/utils/url.tsx | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx b/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx index bee1716b8a6a2..888fc008e3047 100644 --- a/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx +++ b/x-pack/plugins/apm/public/components/app/Main/routeConfig.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { Redirect } from 'react-router-dom'; -import { StringMap } from '../../../../typings/es_schemas/common'; +import { StringMap } from '../../../../typings/common'; import { legacyDecodeURIComponent } from '../../../utils/url'; // @ts-ignore import ErrorGroupDetails from '../ErrorGroupDetails'; diff --git a/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx b/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx index 18f8c6bd01fb8..1d2aa5f8c549b 100644 --- a/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx @@ -25,7 +25,7 @@ import python from 'react-syntax-highlighter/dist/languages/python'; import ruby from 'react-syntax-highlighter/dist/languages/ruby'; // @ts-ignore import { registerLanguage } from 'react-syntax-highlighter/dist/light'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from '../../../../typings/es_schemas/APMDoc'; import { FrameHeading } from '../Stacktrace/FrameHeading'; // @ts-ignore import { Context } from './Context'; diff --git a/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx b/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx index 72b2d94d7520b..53f21c4e247c0 100644 --- a/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx @@ -6,7 +6,7 @@ import { EuiProgress } from '@elastic/eui'; import React from 'react'; -import { StringMap } from '../../../../typings/es_schemas/common'; +import { StringMap } from '../../../../typings/common'; // TODO: extend from EUI's EuiProgress prop interface export interface ImpactBarProps extends StringMap { diff --git a/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx b/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx index 9f35b407660a6..447c34b0189aa 100644 --- a/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx @@ -8,7 +8,7 @@ import { EuiBasicTable } from '@elastic/eui'; import { get, sortByOrder } from 'lodash'; import React, { Component } from 'react'; -import { StringMap } from '../../../../typings/es_schemas/common'; +import { StringMap } from '../../../../typings/common'; // TODO: this should really be imported from EUI export interface ITableColumn { diff --git a/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx b/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx index 4cd901b46cf08..bea0f145bbac4 100644 --- a/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx +++ b/x-pack/plugins/apm/public/components/shared/PropertiesTable/NestedKeyValueTable.tsx @@ -8,7 +8,7 @@ import _ from 'lodash'; import React from 'react'; import styled from 'styled-components'; -import { StringMap } from '../../../../typings/es_schemas/common'; +import { StringMap } from '../../../../typings/common'; import { colors, fontFamilyCode, diff --git a/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx b/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx index a2e219c55374e..856dcd7bb07ad 100644 --- a/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/PropertiesTable/index.tsx @@ -9,7 +9,7 @@ import _ from 'lodash'; import React from 'react'; import styled from 'styled-components'; -import { StringMap } from '../../../../typings/es_schemas/common'; +import { StringMap } from '../../../../typings/common'; import { colors, fontSize, diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx index ade59c1b2a715..ecaef31679cf3 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx @@ -7,7 +7,7 @@ import { get } from 'lodash'; import React, { Fragment } from 'react'; import styled from 'styled-components'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from '../../../../typings/es_schemas/APMDoc'; import { colors, fontFamilyCode, px, units } from '../../../style/variables'; const FileDetails = styled.div` diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx index 2d857a39b0e6c..3503f27df0387 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx @@ -7,7 +7,7 @@ import { EuiLink } from '@elastic/eui'; import React from 'react'; import styled from 'styled-components'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from 'x-pack/plugins/apm/typings/es_schemas/APMDoc'; import { px, units } from '../../../style/variables'; import { CodePreview } from '../../shared/CodePreview'; // @ts-ignore diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts index 8b47b082b0c2e..b5a2709a0de62 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Stackframe } from '../../../../../typings/APMDoc'; +import { Stackframe } from '../../../../../typings/es_schemas/APMDoc'; import { getGroupedStackframes, hasSourceLines } from '../stacktraceUtils'; import stacktracesMock from './stacktraces.json'; diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts b/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts index 0798d0a2d78b7..ecf63952fc2ab 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts @@ -5,7 +5,7 @@ */ import { get, isEmpty } from 'lodash'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from 'x-pack/plugins/apm/typings/es_schemas/APMDoc'; interface StackframesGroup { isLibraryFrame: boolean; diff --git a/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts b/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts index 269cdf15ecafd..2423cbd11a2d0 100644 --- a/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts +++ b/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { StringMap } from 'x-pack/plugins/apm/typings/es_schemas/common'; +import { StringMap } from 'x-pack/plugins/apm/typings/common'; export class SessionStorageMock { private store: StringMap = {}; diff --git a/x-pack/plugins/apm/public/store/rootReducer.ts b/x-pack/plugins/apm/public/store/rootReducer.ts index 6b0f789ac5b28..5312ca41f4483 100644 --- a/x-pack/plugins/apm/public/store/rootReducer.ts +++ b/x-pack/plugins/apm/public/store/rootReducer.ts @@ -6,7 +6,7 @@ import { reducer } from 'react-redux-request'; import { combineReducers } from 'redux'; -import { StringMap } from '../../typings/es_schemas/common'; +import { StringMap } from '../../typings/common'; // @ts-ignore import location from './location'; import { IUrlParams, urlParamsReducer } from './urlParams'; diff --git a/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts b/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts index 67875ed64e775..da8d1600ed611 100644 --- a/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts +++ b/x-pack/plugins/apm/public/store/selectors/chartSelectors.ts @@ -11,7 +11,7 @@ import { rgba } from 'polished'; import { TimeSeriesAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts'; import { AnomalyTimeSeriesResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_anomaly_data/transform'; import { ApmTimeSeriesResponse } from 'x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform'; -import { StringMap } from 'x-pack/plugins/apm/typings/es_schemas/common'; +import { StringMap } from 'x-pack/plugins/apm/typings/common'; import { Coordinate, RectCoordinate diff --git a/x-pack/plugins/apm/public/utils/url.tsx b/x-pack/plugins/apm/public/utils/url.tsx index d830b5ecda913..f2b0dfc9a34f3 100644 --- a/x-pack/plugins/apm/public/utils/url.tsx +++ b/x-pack/plugins/apm/public/utils/url.tsx @@ -14,7 +14,7 @@ import { Link } from 'react-router-dom'; import rison from 'rison-node'; import chrome from 'ui/chrome'; import url from 'url'; -import { StringMap } from '../../typings/es_schemas/common'; +import { StringMap } from '../../typings/common'; // Kibana default set in: https://github.com/elastic/kibana/blob/e13e47fc4eb6112f2a5401408e9f765eae90f55d/x-pack/plugins/apm/public/utils/timepicker/index.js#L31-L35 // TODO: store this in config or a shared constant? From edd6aac4d14ea105b643eae52ea3a9354c2f0180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Mon, 10 Dec 2018 14:07:42 +0100 Subject: [PATCH 5/7] Remove Discover button again --- .../components/shared/DiscoverButton.tsx | 34 ------------------- 1 file changed, 34 deletions(-) delete mode 100644 x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx deleted file mode 100644 index 8360fee9624ff..0000000000000 --- a/x-pack/plugins/apm/public/components/shared/DiscoverButton.tsx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - */ - -// @ts-ignore -import { EuiButtonEmpty } from '@elastic/eui'; -import React from 'react'; -import { StringMap } from 'x-pack/plugins/apm/typings/common'; -import { KibanaLink } from '../../utils/url'; - -interface Props { - query: StringMap; -} - -export const DiscoverButton: React.SFC = ({ - query, - children, - ...rest -}) => { - return ( - - - {children || 'View in Discover'} - - - ); -}; From 1c69b661001fbbdfd8544595f84d2c36d5bfb040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Wed, 12 Dec 2018 11:08:44 +0100 Subject: [PATCH 6/7] Fix imports --- .../components/shared/Stacktrace/index.tsx | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx index ddbc5b747799a..ef1b1d0376485 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx @@ -7,7 +7,7 @@ import { EuiTitle } from '@elastic/eui'; import { isEmpty } from 'lodash'; import React, { PureComponent } from 'react'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from '../../../../typings/es_schemas/APMDoc'; import { CodePreview } from '../../shared/CodePreview'; import { EmptyMessage } from '../../shared/EmptyMessage'; // @ts-ignore @@ -79,16 +79,17 @@ export class Stacktrace extends PureComponent { /> ); } - return groupedStackframes.map((stackframe, idx) => - hasSourceLines(stackframe) ? ( - - ) : ( - - ) + return groupedStackframes.map( + (stackframe, idx) => + hasSourceLines(stackframe) ? ( + + ) : ( + + ) ); } )} From bea829d938181410acf8ba455f81004ea5473718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Wed, 12 Dec 2018 13:48:12 +0100 Subject: [PATCH 7/7] Fix prettier issues --- .../components/shared/Stacktrace/index.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx index ef1b1d0376485..42249e60e9d02 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx @@ -79,17 +79,16 @@ export class Stacktrace extends PureComponent { /> ); } - return groupedStackframes.map( - (stackframe, idx) => - hasSourceLines(stackframe) ? ( - - ) : ( - - ) + return groupedStackframes.map((stackframe, idx) => + hasSourceLines(stackframe) ? ( + + ) : ( + + ) ); } )}