-
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.
[APM] use react-redux-request (#24117)
* [APM] use react-redux-request * Stricter type checking
- Loading branch information
Showing
15 changed files
with
234 additions
and
131 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
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
55 changes: 55 additions & 0 deletions
55
x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.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,55 @@ | ||
/* | ||
* 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 { get } from 'lodash'; | ||
import React from 'react'; | ||
import { Request, RRRRender } from 'react-redux-request'; | ||
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 { WaterfallResponse } from 'x-pack/plugins/apm/typings/waterfall'; | ||
// @ts-ignore | ||
import { loadSpans, loadTrace } from '../../services/rest/apm'; | ||
import { IUrlParams } from '../urlParams'; | ||
// @ts-ignore | ||
import { createInitialDataSelector } from './helpers'; | ||
|
||
const ID = 'waterfallV1'; | ||
|
||
interface Props { | ||
urlParams: IUrlParams; | ||
transaction: Transaction; | ||
render: RRRRender<WaterfallResponse>; | ||
} | ||
|
||
export function WaterfallV1Request({ urlParams, transaction, render }: Props) { | ||
const { start, end } = urlParams; | ||
const transactionId: string = get(transaction, TRANSACTION_ID); | ||
const serviceName: string = get(transaction, SERVICE_NAME); | ||
|
||
if (!(serviceName && transactionId && start && end)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Request<Span[]> | ||
id={ID} | ||
fn={loadSpans} | ||
args={[{ serviceName, start, end, transactionId }]} | ||
render={({ status, data, args }) => { | ||
const res = { | ||
hits: [transaction, ...data], | ||
services: [serviceName] | ||
}; | ||
|
||
return render({ status, data: res, args }); | ||
}} | ||
/> | ||
); | ||
} |
47 changes: 47 additions & 0 deletions
47
x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.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,47 @@ | ||
/* | ||
* 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 { get } from 'lodash'; | ||
import React from 'react'; | ||
import { Request, RRRRender } from 'react-redux-request'; | ||
import { TRACE_ID } from 'x-pack/plugins/apm/common/constants'; | ||
import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; | ||
import { WaterfallResponse } from 'x-pack/plugins/apm/typings/waterfall'; | ||
|
||
// @ts-ignore | ||
import { loadSpans, loadTrace } from '../../services/rest/apm'; | ||
import { IUrlParams } from '../urlParams'; | ||
// @ts-ignore | ||
import { createInitialDataSelector } from './helpers'; | ||
|
||
const ID = 'waterfallV2'; | ||
|
||
interface Props { | ||
urlParams: IUrlParams; | ||
transaction: Transaction; | ||
render: RRRRender<WaterfallResponse>; | ||
} | ||
|
||
const defaultData = { hits: [], services: [] }; | ||
export function WaterfallV2Request({ urlParams, transaction, render }: Props) { | ||
const { start, end } = urlParams; | ||
const traceId: string = get(transaction, TRACE_ID); | ||
|
||
if (!(traceId && start && end)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Request<WaterfallResponse> | ||
id={ID} | ||
fn={loadTrace} | ||
args={[{ traceId, start, end }]} | ||
render={({ args, data = defaultData, status }) => | ||
render({ args, data, status }) | ||
} | ||
/> | ||
); | ||
} |
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.