-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[APM] Add link-to/transaction route #101731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { EuiEmptyPrompt } from '@elastic/eui'; | ||
| import React from 'react'; | ||
| import { Redirect, RouteComponentProps } from 'react-router-dom'; | ||
| import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common'; | ||
| import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher'; | ||
| import { useUrlParams } from '../../../context/url_params_context/use_url_params'; | ||
| import { getRedirectToTransactionDetailPageUrl } from '../TraceLink/get_redirect_to_transaction_detail_page_url'; | ||
|
|
||
| const CentralizedContainer = euiStyled.div` | ||
| height: 100%; | ||
| display: flex; | ||
| `; | ||
|
|
||
| export function TransactionLink({ | ||
| match, | ||
| }: RouteComponentProps<{ transactionId: string }>) { | ||
| const { transactionId } = match.params; | ||
| const { urlParams } = useUrlParams(); | ||
| const { rangeFrom, rangeTo } = urlParams; | ||
|
|
||
| const { data = { transaction: null }, status } = useFetcher( | ||
| (callApmApi) => { | ||
| if (transactionId) { | ||
| return callApmApi({ | ||
| endpoint: 'GET /api/apm/transactions/{transactionId}', | ||
| params: { | ||
| path: { | ||
| transactionId, | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
| }, | ||
| [transactionId] | ||
| ); | ||
| if (transactionId && status === FETCH_STATUS.SUCCESS) { | ||
| if (data.transaction) { | ||
| return ( | ||
| <Redirect | ||
| to={getRedirectToTransactionDetailPageUrl({ | ||
| transaction: data.transaction, | ||
| rangeFrom, | ||
| rangeTo, | ||
| })} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return <CentralizedContainer />; | ||
| } | ||
|
|
||
| return ( | ||
| <CentralizedContainer> | ||
| <EuiEmptyPrompt | ||
| iconType="apmTrace" | ||
| title={<h2>Fetching transaction...</h2>} | ||
| /> | ||
| </CentralizedContainer> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,11 +21,11 @@ export function getTransaction({ | |
| setup, | ||
| }: { | ||
| transactionId: string; | ||
| traceId: string; | ||
| setup: Setup & SetupTimeRange; | ||
| traceId?: string; | ||
| setup: Setup | (Setup & SetupTimeRange); | ||
| }) { | ||
| return withApmSpan('get_transaction', async () => { | ||
| const { start, end, apmEventClient } = setup; | ||
| const { apmEventClient } = setup; | ||
|
|
||
| const resp = await apmEventClient.search({ | ||
| apm: { | ||
|
|
@@ -37,8 +37,8 @@ export function getTransaction({ | |
| bool: { | ||
| filter: asMutableArray([ | ||
| { term: { [TRANSACTION_ID]: transactionId } }, | ||
| { term: { [TRACE_ID]: traceId } }, | ||
| ...rangeQuery(start, end), | ||
| ...(traceId ? [{ term: { [TRACE_ID]: traceId } }] : []), | ||
| ...('start' in setup ? rangeQuery(setup.start, setup.end) : []), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (or maybe it's the opposite problem I'm thinking about where they are always optional, even when they are required on the api)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is used in different endpoints, one that does have a start/end query parameter, and one that doesn't. The type for |
||
| ]), | ||
| }, | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n this?