-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ProfilingxAPM] Link APM from Profiling UI (#180677)
closes #178719 A new ES API has been created to support linking APM from the Profiling UI. It's called `topN/functions`. The new API allows grouping fields. So we first fetch functions grouping by `service.name` and when the user opens the APM Transactions we make another request grouping by `transaction.name`. A new Advanced setting was created to toggle the old API on (fetch functions from Stacktraces API): It's turned off by default. <img width="1235" alt="Screenshot 2024-04-12 at 10 39 36" src="https://github.com/elastic/kibana/assets/55978943/ee6e7731-2f44-43ca-9793-23ba87e22e6e"> When there are services on the selected function: *If we cannot find the transaction, we show `N/A`. <img width="933" alt="Screenshot 2024-04-12 at 10 16 34" src="https://github.com/elastic/kibana/assets/55978943/2c5dbf60-3a47-4f4c-a46d-8a0984e0e482"> When there are **no** services on the selected function: *hide the APM transactions section <img width="921" alt="Screenshot 2024-04-12 at 10 59 14" src="https://github.com/elastic/kibana/assets/55978943/3fc4c5b1-da62-47c8-97a8-8bcbd1ae1b75"> -- Performance boost: The new API is faster than the Stacktraces API, especially because there's no logic on the Kibana side. Stacktraces API: <img width="1210" alt="Screenshot 2024-04-12 at 10 50 26" src="https://github.com/elastic/kibana/assets/55978943/158d73d1-ed91-4652-97c1-c7c3328d5e3d"> TopN/Functions API: <img width="1195" alt="Screenshot 2024-04-12 at 10 51 20" src="https://github.com/elastic/kibana/assets/55978943/2de4ef46-eb8a-4557-b7b8-a1c2fed6fd8a"> --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
d769242
commit b900b86
Showing
39 changed files
with
1,267 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export interface Frame { | ||
frame_type: number; | ||
inline: boolean; | ||
address_or_line: number; | ||
function_name: string; | ||
file_name: string; | ||
line_number: number; | ||
executable_file_name: string; | ||
} | ||
|
||
interface TopNFunction { | ||
id: string; | ||
rank: number; | ||
frame: Frame; | ||
sub_groups: Record<string, number>; | ||
self_count: number; | ||
total_count: number; | ||
self_annual_co2_tons: number; | ||
total_annual_co2_tons: number; | ||
self_annual_costs_usd: number; | ||
total_annual_costs_usd: number; | ||
} | ||
|
||
export interface ESTopNFunctions { | ||
self_count: number; | ||
total_count: number; | ||
self_annual_co2_tons: number; | ||
self_annual_cost_usd: number; | ||
topn: TopNFunction[]; | ||
} | ||
|
||
export type AggregationField = 'service.name' | 'transaction.name'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...ugins/observability_solution/apm/public/components/app/transaction_details_link/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { Redirect } from 'react-router-dom'; | ||
import { css } from '@emotion/react'; | ||
import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher'; | ||
import { getRedirectToTransactionDetailPageUrl } from '../trace_link/get_redirect_to_transaction_detail_page_url'; | ||
import { useApmParams } from '../../../hooks/use_apm_params'; | ||
import { useTimeRange } from '../../../hooks/use_time_range'; | ||
|
||
export function TransactionDetailsByNameLink() { | ||
const { | ||
query: { | ||
rangeFrom = 'now-15m', | ||
rangeTo = 'now', | ||
transactionName, | ||
serviceName, | ||
}, | ||
} = useApmParams('/link-to/transaction'); | ||
|
||
const { start, end } = useTimeRange({ rangeFrom, rangeTo }); | ||
|
||
const { data = { transaction: null }, status } = useFetcher( | ||
(callApmApi) => { | ||
return callApmApi('GET /internal/apm/transactions', { | ||
params: { | ||
query: { | ||
start, | ||
end, | ||
transactionName, | ||
serviceName, | ||
}, | ||
}, | ||
}); | ||
}, | ||
[start, end, transactionName, serviceName] | ||
); | ||
|
||
if (status === FETCH_STATUS.SUCCESS) { | ||
if (data.transaction) { | ||
return ( | ||
<Redirect | ||
to={getRedirectToTransactionDetailPageUrl({ | ||
transaction: data.transaction, | ||
rangeFrom, | ||
rangeTo, | ||
})} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<div | ||
css={css` | ||
height: 100%; | ||
display: flex; | ||
`} | ||
> | ||
<EuiEmptyPrompt | ||
iconType="apmTrace" | ||
title={ | ||
<h2> | ||
{i18n.translate( | ||
'xpack.apm.transactionDetailsLink.h2.transactionNotFound', | ||
{ defaultMessage: 'No transaction found' } | ||
)} | ||
</h2> | ||
} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div | ||
css={css` | ||
height: 100%; | ||
display: flex; | ||
`} | ||
> | ||
<EuiEmptyPrompt | ||
iconType="apmTrace" | ||
title={ | ||
<h2> | ||
{i18n.translate( | ||
'xpack.apm.transactionDetailsLink.h2.fetchingTransactionLabel', | ||
{ defaultMessage: 'Fetching transaction...' } | ||
)} | ||
</h2> | ||
} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ns/observability_solution/apm/server/routes/transactions/get_transaction_by_name/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 { rangeQuery } from '@kbn/observability-plugin/server'; | ||
import { ApmDocumentType } from '../../../../common/document_type'; | ||
import { | ||
SERVICE_NAME, | ||
TRANSACTION_NAME, | ||
} from '../../../../common/es_fields/apm'; | ||
import { RollupInterval } from '../../../../common/rollup'; | ||
import { asMutableArray } from '../../../../common/utils/as_mutable_array'; | ||
import { APMEventClient } from '../../../lib/helpers/create_es_client/create_apm_event_client'; | ||
|
||
export async function getTransactionByName({ | ||
transactionName, | ||
serviceName, | ||
apmEventClient, | ||
start, | ||
end, | ||
}: { | ||
transactionName: string; | ||
serviceName: string; | ||
apmEventClient: APMEventClient; | ||
start: number; | ||
end: number; | ||
}) { | ||
const resp = await apmEventClient.search('get_transaction', { | ||
apm: { | ||
sources: [ | ||
{ | ||
documentType: ApmDocumentType.TransactionEvent, | ||
rollupInterval: RollupInterval.None, | ||
}, | ||
], | ||
}, | ||
body: { | ||
track_total_hits: false, | ||
size: 1, | ||
terminate_after: 1, | ||
query: { | ||
bool: { | ||
filter: asMutableArray([ | ||
{ term: { [TRANSACTION_NAME]: transactionName } }, | ||
{ term: { [SERVICE_NAME]: serviceName } }, | ||
...rangeQuery(start, end), | ||
]), | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
return resp.hits.hits[0]?._source; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.