mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[APM] Explicit return types for routes (#123266)
This commit is contained in:
parent
0c6edb492b
commit
7f5e6c3d9f
144 changed files with 2304 additions and 1350 deletions
|
@ -871,7 +871,7 @@
|
|||
"terser-webpack-plugin": "^4.2.3",
|
||||
"tough-cookie": "^4.0.0",
|
||||
"ts-loader": "^7.0.5",
|
||||
"ts-morph": "^11.0.0",
|
||||
"ts-morph": "^13.0.2",
|
||||
"tsd": "^0.13.1",
|
||||
"typescript": "4.5.3",
|
||||
"unlazy-loader": "^0.1.3",
|
||||
|
|
|
@ -80,7 +80,7 @@ export function buildApiDeclaration(node: Node, opts: BuildApiDecOpts): ApiDecla
|
|||
Node.isVariableDeclaration(node)
|
||||
) {
|
||||
return buildVariableDec(node, opts);
|
||||
} else if (Node.isTypeLiteralNode(node)) {
|
||||
} else if (Node.isTypeLiteral(node)) {
|
||||
return buildTypeLiteralDec(node, opts);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ export function maybeCollectReferences({
|
|||
apiDec,
|
||||
captureReferences,
|
||||
}: MaybeCollectReferencesOpt): ApiReference[] | undefined {
|
||||
if (Node.isReferenceFindableNode(node)) {
|
||||
if (Node.isReferenceFindable(node)) {
|
||||
return captureReferences || apiDec.deprecated
|
||||
? getReferences({ node, plugins, currentPluginId, log })
|
||||
: undefined;
|
||||
|
|
|
@ -30,11 +30,11 @@ export function getCommentsFromNode(node: Node): TextWithLinks | undefined {
|
|||
}
|
||||
|
||||
export function getJSDocs(node: Node): JSDoc[] | undefined {
|
||||
if (Node.isJSDocableNode(node)) {
|
||||
if (Node.isJSDocable(node)) {
|
||||
return node.getJsDocs();
|
||||
} else if (Node.isVariableDeclaration(node)) {
|
||||
const gparent = node.getParent()?.getParent();
|
||||
if (Node.isJSDocableNode(gparent)) {
|
||||
if (Node.isJSDocable(gparent)) {
|
||||
return gparent.getJsDocs();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,10 @@ import { isNamedNode } from '../tsmorph_utils';
|
|||
export const pathsOutsideScopes: { [key: string]: string } = {};
|
||||
|
||||
export function isPrivate(node: ParameterDeclaration | ClassMemberTypes): boolean {
|
||||
return node.getModifiers().find((mod) => mod.getText() === 'private') !== undefined;
|
||||
if (Node.isModifierable(node)) {
|
||||
return node.getModifiers().find((mod) => mod.getText() === 'private') !== undefined;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,12 +27,9 @@ export function createServerRouteFactory<
|
|||
TReturnType,
|
||||
TRouteCreateOptions
|
||||
>
|
||||
) => ServerRoute<
|
||||
) => Record<
|
||||
TEndpoint,
|
||||
TRouteParamsRT,
|
||||
TRouteHandlerResources,
|
||||
TReturnType,
|
||||
TRouteCreateOptions
|
||||
ServerRoute<TEndpoint, TRouteParamsRT, TRouteHandlerResources, TReturnType, TRouteCreateOptions>
|
||||
> {
|
||||
return (route) => route;
|
||||
return (route) => ({ [route.endpoint]: route } as any);
|
||||
}
|
||||
|
|
|
@ -1,39 +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
|
||||
* 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.
|
||||
*/
|
||||
import {
|
||||
ServerRouteHandlerResources,
|
||||
ServerRouteRepository,
|
||||
ServerRouteCreateOptions,
|
||||
} from './typings';
|
||||
|
||||
export function createServerRouteRepository<
|
||||
TRouteHandlerResources extends ServerRouteHandlerResources = never,
|
||||
TRouteCreateOptions extends ServerRouteCreateOptions = never
|
||||
>(): ServerRouteRepository<TRouteHandlerResources, TRouteCreateOptions, {}> {
|
||||
let routes: Record<string, any> = {};
|
||||
|
||||
return {
|
||||
add(route) {
|
||||
routes = {
|
||||
...routes,
|
||||
[route.endpoint]: route,
|
||||
};
|
||||
|
||||
return this as any;
|
||||
},
|
||||
merge(repository) {
|
||||
routes = {
|
||||
...routes,
|
||||
...Object.fromEntries(repository.getRoutes().map((route) => [route.endpoint, route])),
|
||||
};
|
||||
|
||||
return this as any;
|
||||
},
|
||||
getRoutes: () => Object.values(routes),
|
||||
};
|
||||
}
|
|
@ -6,7 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export { createServerRouteRepository } from './create_server_route_repository';
|
||||
export { createServerRouteFactory } from './create_server_route_factory';
|
||||
export { formatRequest } from './format_request';
|
||||
export { parseEndpoint } from './parse_endpoint';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
import * as t from 'io-ts';
|
||||
import { createServerRouteRepository } from './create_server_route_repository';
|
||||
import { createServerRouteFactory } from './create_server_route_factory';
|
||||
import { decodeRequestParams } from './decode_request_params';
|
||||
import { EndpointOf, ReturnOf, RouteRepositoryClient } from './typings';
|
||||
|
||||
|
@ -14,18 +14,9 @@ function assertType<TShape = never>(value: TShape) {
|
|||
return value;
|
||||
}
|
||||
|
||||
// Generic arguments for createServerRouteRepository should be set,
|
||||
// if not, registering routes should not be allowed
|
||||
createServerRouteRepository().add({
|
||||
// @ts-expect-error
|
||||
endpoint: 'any_endpoint',
|
||||
// @ts-expect-error
|
||||
handler: async ({ params }) => {},
|
||||
});
|
||||
|
||||
// If a params codec is not set, its type should not be available in
|
||||
// the request handler.
|
||||
createServerRouteRepository<{}, {}>().add({
|
||||
createServerRouteFactory<{}, {}>()({
|
||||
endpoint: 'endpoint_without_params',
|
||||
handler: async (resources) => {
|
||||
// @ts-expect-error Argument of type '{}' is not assignable to parameter of type '{ params: any; }'.
|
||||
|
@ -35,7 +26,7 @@ createServerRouteRepository<{}, {}>().add({
|
|||
|
||||
// If a params codec is set, its type _should_ be available in the
|
||||
// request handler.
|
||||
createServerRouteRepository<{}, {}>().add({
|
||||
createServerRouteFactory<{}, {}>()({
|
||||
endpoint: 'endpoint_with_params',
|
||||
params: t.type({
|
||||
path: t.type({
|
||||
|
@ -48,7 +39,7 @@ createServerRouteRepository<{}, {}>().add({
|
|||
});
|
||||
|
||||
// Resources should be passed to the request handler.
|
||||
createServerRouteRepository<{ context: { getSpaceId: () => string } }, {}>().add({
|
||||
createServerRouteFactory<{ context: { getSpaceId: () => string } }, {}>()({
|
||||
endpoint: 'endpoint_with_params',
|
||||
params: t.type({
|
||||
path: t.type({
|
||||
|
@ -62,7 +53,7 @@ createServerRouteRepository<{ context: { getSpaceId: () => string } }, {}>().add
|
|||
});
|
||||
|
||||
// Create options are available when registering a route.
|
||||
createServerRouteRepository<{}, { options: { tags: string[] } }>().add({
|
||||
createServerRouteFactory<{}, { options: { tags: string[] } }>()({
|
||||
endpoint: 'endpoint_with_params',
|
||||
params: t.type({
|
||||
path: t.type({
|
||||
|
@ -77,16 +68,18 @@ createServerRouteRepository<{}, { options: { tags: string[] } }>().add({
|
|||
},
|
||||
});
|
||||
|
||||
const repository = createServerRouteRepository<{}, {}>()
|
||||
.add({
|
||||
const createServerRoute = createServerRouteFactory<{}, {}>();
|
||||
|
||||
const repository = {
|
||||
...createServerRoute({
|
||||
endpoint: 'endpoint_without_params',
|
||||
handler: async () => {
|
||||
return {
|
||||
noParamsForMe: true,
|
||||
};
|
||||
},
|
||||
})
|
||||
.add({
|
||||
}),
|
||||
...createServerRoute({
|
||||
endpoint: 'endpoint_with_params',
|
||||
params: t.type({
|
||||
path: t.type({
|
||||
|
@ -98,8 +91,8 @@ const repository = createServerRouteRepository<{}, {}>()
|
|||
yesParamsForMe: true,
|
||||
};
|
||||
},
|
||||
})
|
||||
.add({
|
||||
}),
|
||||
...createServerRoute({
|
||||
endpoint: 'endpoint_with_optional_params',
|
||||
params: t.partial({
|
||||
query: t.partial({
|
||||
|
@ -111,7 +104,8 @@ const repository = createServerRouteRepository<{}, {}>()
|
|||
someParamsForMe: true,
|
||||
};
|
||||
},
|
||||
});
|
||||
}),
|
||||
};
|
||||
|
||||
type TestRepository = typeof repository;
|
||||
|
||||
|
@ -146,26 +140,21 @@ const client: TestClient = {} as any;
|
|||
// It should respect any additional create options.
|
||||
|
||||
// @ts-expect-error Property 'timeout' is missing
|
||||
client({
|
||||
endpoint: 'endpoint_without_params',
|
||||
});
|
||||
client('endpoint_without_params', {});
|
||||
|
||||
client({
|
||||
endpoint: 'endpoint_without_params',
|
||||
client('endpoint_without_params', {
|
||||
timeout: 1,
|
||||
});
|
||||
|
||||
// It does not allow params for routes without a params codec
|
||||
client({
|
||||
endpoint: 'endpoint_without_params',
|
||||
client('endpoint_without_params', {
|
||||
// @ts-expect-error Object literal may only specify known properties, and 'params' does not exist in type
|
||||
params: {},
|
||||
timeout: 1,
|
||||
});
|
||||
|
||||
// It requires params for routes with a params codec
|
||||
client({
|
||||
endpoint: 'endpoint_with_params',
|
||||
client('endpoint_with_params', {
|
||||
params: {
|
||||
// @ts-expect-error property 'serviceName' is missing in type '{}'
|
||||
path: {},
|
||||
|
@ -174,14 +163,12 @@ client({
|
|||
});
|
||||
|
||||
// Params are optional if the codec has no required keys
|
||||
client({
|
||||
endpoint: 'endpoint_with_optional_params',
|
||||
client('endpoint_with_optional_params', {
|
||||
timeout: 1,
|
||||
});
|
||||
|
||||
// If optional, an error will still occur if the params do not match
|
||||
client({
|
||||
endpoint: 'endpoint_with_optional_params',
|
||||
client('endpoint_with_optional_params', {
|
||||
timeout: 1,
|
||||
params: {
|
||||
// @ts-expect-error Object literal may only specify known properties, and 'path' does not exist in type
|
||||
|
@ -190,8 +177,7 @@ client({
|
|||
});
|
||||
|
||||
// The return type is correctly inferred
|
||||
client({
|
||||
endpoint: 'endpoint_with_params',
|
||||
client('endpoint_with_params', {
|
||||
params: {
|
||||
path: {
|
||||
serviceName: '',
|
||||
|
|
|
@ -50,58 +50,10 @@ export type ServerRoute<
|
|||
: {})) => Promise<TReturnType>;
|
||||
} & TRouteCreateOptions;
|
||||
|
||||
export interface ServerRouteRepository<
|
||||
TRouteHandlerResources extends ServerRouteHandlerResources = ServerRouteHandlerResources,
|
||||
TRouteCreateOptions extends ServerRouteCreateOptions = ServerRouteCreateOptions,
|
||||
TRouteState extends RouteState = RouteState
|
||||
> {
|
||||
add<
|
||||
TEndpoint extends string,
|
||||
TReturnType,
|
||||
TRouteParamsRT extends RouteParamsRT | undefined = undefined
|
||||
>(
|
||||
route: ServerRoute<
|
||||
TEndpoint,
|
||||
TRouteParamsRT,
|
||||
TRouteHandlerResources,
|
||||
TReturnType,
|
||||
TRouteCreateOptions
|
||||
>
|
||||
): ServerRouteRepository<
|
||||
TRouteHandlerResources,
|
||||
TRouteCreateOptions,
|
||||
TRouteState & {
|
||||
[key in TEndpoint]: ServerRoute<
|
||||
TEndpoint,
|
||||
TRouteParamsRT,
|
||||
TRouteHandlerResources,
|
||||
TReturnType,
|
||||
TRouteCreateOptions
|
||||
>;
|
||||
}
|
||||
>;
|
||||
merge<
|
||||
TServerRouteRepository extends ServerRouteRepository<
|
||||
TRouteHandlerResources,
|
||||
TRouteCreateOptions
|
||||
>
|
||||
>(
|
||||
repository: TServerRouteRepository
|
||||
): TServerRouteRepository extends ServerRouteRepository<
|
||||
TRouteHandlerResources,
|
||||
TRouteCreateOptions,
|
||||
infer TRouteStateToMerge
|
||||
>
|
||||
? ServerRouteRepository<
|
||||
TRouteHandlerResources,
|
||||
TRouteCreateOptions,
|
||||
TRouteState & TRouteStateToMerge
|
||||
>
|
||||
: never;
|
||||
getRoutes: () => Array<
|
||||
ServerRoute<string, RouteParamsRT, TRouteHandlerResources, unknown, TRouteCreateOptions>
|
||||
>;
|
||||
}
|
||||
export type ServerRouteRepository = Record<
|
||||
string,
|
||||
ServerRoute<string, RouteParamsRT | undefined, any, any, Record<string, any>>
|
||||
>;
|
||||
|
||||
type ClientRequestParamsOfType<TRouteParamsRT extends RouteParamsRT> =
|
||||
TRouteParamsRT extends t.Mixed
|
||||
|
@ -117,72 +69,62 @@ type DecodedRequestParamsOfType<TRouteParamsRT extends RouteParamsRT> =
|
|||
}>
|
||||
: {};
|
||||
|
||||
export type EndpointOf<TServerRouteRepository extends ServerRouteRepository<any, any, any>> =
|
||||
TServerRouteRepository extends ServerRouteRepository<any, any, infer TRouteState>
|
||||
? keyof TRouteState
|
||||
: never;
|
||||
export type EndpointOf<TServerRouteRepository extends ServerRouteRepository> =
|
||||
keyof TServerRouteRepository;
|
||||
|
||||
export type ReturnOf<
|
||||
TServerRouteRepository extends ServerRouteRepository<any, any, any>,
|
||||
TEndpoint extends EndpointOf<TServerRouteRepository>
|
||||
> = TServerRouteRepository extends ServerRouteRepository<any, any, infer TRouteState>
|
||||
? TEndpoint extends keyof TRouteState
|
||||
? TRouteState[TEndpoint] extends ServerRoute<
|
||||
any,
|
||||
any,
|
||||
any,
|
||||
infer TReturnType,
|
||||
ServerRouteCreateOptions
|
||||
>
|
||||
? TReturnType
|
||||
: never
|
||||
: never
|
||||
TServerRouteRepository extends ServerRouteRepository,
|
||||
TEndpoint extends keyof TServerRouteRepository
|
||||
> = TServerRouteRepository[TEndpoint] extends ServerRoute<
|
||||
any,
|
||||
any,
|
||||
any,
|
||||
infer TReturnType,
|
||||
ServerRouteCreateOptions
|
||||
>
|
||||
? TReturnType
|
||||
: never;
|
||||
|
||||
export type DecodedRequestParamsOf<
|
||||
TServerRouteRepository extends ServerRouteRepository<any, any, any>,
|
||||
TEndpoint extends EndpointOf<TServerRouteRepository>
|
||||
> = TServerRouteRepository extends ServerRouteRepository<any, any, infer TRouteState>
|
||||
? TEndpoint extends keyof TRouteState
|
||||
? TRouteState[TEndpoint] extends ServerRoute<
|
||||
any,
|
||||
infer TRouteParamsRT,
|
||||
any,
|
||||
any,
|
||||
ServerRouteCreateOptions
|
||||
>
|
||||
? TRouteParamsRT extends RouteParamsRT
|
||||
? DecodedRequestParamsOfType<TRouteParamsRT>
|
||||
: {}
|
||||
: never
|
||||
: never
|
||||
TServerRouteRepository extends ServerRouteRepository,
|
||||
TEndpoint extends keyof TServerRouteRepository
|
||||
> = TServerRouteRepository[TEndpoint] extends ServerRoute<
|
||||
any,
|
||||
infer TRouteParamsRT,
|
||||
any,
|
||||
any,
|
||||
ServerRouteCreateOptions
|
||||
>
|
||||
? TRouteParamsRT extends RouteParamsRT
|
||||
? DecodedRequestParamsOfType<TRouteParamsRT>
|
||||
: {}
|
||||
: never;
|
||||
|
||||
export type ClientRequestParamsOf<
|
||||
TServerRouteRepository extends ServerRouteRepository<any, any, any>,
|
||||
TEndpoint extends EndpointOf<TServerRouteRepository>
|
||||
> = TServerRouteRepository extends ServerRouteRepository<any, any, infer TRouteState>
|
||||
? TEndpoint extends keyof TRouteState
|
||||
? TRouteState[TEndpoint] extends ServerRoute<
|
||||
any,
|
||||
infer TRouteParamsRT,
|
||||
any,
|
||||
any,
|
||||
ServerRouteCreateOptions
|
||||
>
|
||||
? TRouteParamsRT extends RouteParamsRT
|
||||
? ClientRequestParamsOfType<TRouteParamsRT>
|
||||
: {}
|
||||
: never
|
||||
: never
|
||||
TServerRouteRepository extends ServerRouteRepository,
|
||||
TEndpoint extends keyof TServerRouteRepository
|
||||
> = TServerRouteRepository[TEndpoint] extends ServerRoute<
|
||||
any,
|
||||
infer TRouteParamsRT,
|
||||
any,
|
||||
any,
|
||||
ServerRouteCreateOptions
|
||||
>
|
||||
? TRouteParamsRT extends RouteParamsRT
|
||||
? ClientRequestParamsOfType<TRouteParamsRT>
|
||||
: {}
|
||||
: never;
|
||||
|
||||
type MaybeOptionalArgs<T extends Record<string, any>> = RequiredKeys<T> extends never
|
||||
? [T] | []
|
||||
: [T];
|
||||
|
||||
export type RouteRepositoryClient<
|
||||
TServerRouteRepository extends ServerRouteRepository<any, any, any>,
|
||||
TServerRouteRepository extends ServerRouteRepository,
|
||||
TAdditionalClientOptions extends Record<string, any>
|
||||
> = <TEndpoint extends EndpointOf<TServerRouteRepository>>(
|
||||
options: {
|
||||
endpoint: TEndpoint;
|
||||
} & ClientRequestParamsOf<TServerRouteRepository, TEndpoint> &
|
||||
TAdditionalClientOptions
|
||||
> = <TEndpoint extends keyof TServerRouteRepository>(
|
||||
endpoint: TEndpoint,
|
||||
...args: MaybeOptionalArgs<
|
||||
ClientRequestParamsOf<TServerRouteRepository, TEndpoint> & TAdditionalClientOptions
|
||||
>
|
||||
) => Promise<ReturnOf<TServerRouteRepository, TEndpoint>>;
|
||||
|
|
|
@ -24,7 +24,7 @@ import { isEqual, pull, merge, castArray } from 'lodash';
|
|||
);
|
||||
*/
|
||||
|
||||
type JoinedReturnType<
|
||||
export type JoinedReturnType<
|
||||
T extends Record<string, any>,
|
||||
U extends UnionToIntersection<T>
|
||||
> = Array<
|
||||
|
|
|
@ -60,19 +60,20 @@ export function ErrorCountAlertTrigger(props: Props) {
|
|||
windowUnit: params.windowUnit as TimeUnit,
|
||||
});
|
||||
if (interval && start && end) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/alerts/chart_preview/transaction_error_count',
|
||||
params: {
|
||||
query: {
|
||||
environment: params.environment,
|
||||
serviceName: params.serviceName,
|
||||
interval,
|
||||
start,
|
||||
end,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/alerts/chart_preview/transaction_error_count',
|
||||
{
|
||||
params: {
|
||||
query: {
|
||||
environment: params.environment,
|
||||
serviceName: params.serviceName,
|
||||
interval,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -98,21 +98,22 @@ export function TransactionDurationAlertTrigger(props: Props) {
|
|||
windowUnit: params.windowUnit as TimeUnit,
|
||||
});
|
||||
if (interval && start && end) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/alerts/chart_preview/transaction_duration',
|
||||
params: {
|
||||
query: {
|
||||
aggregationType: params.aggregationType,
|
||||
environment: params.environment,
|
||||
serviceName: params.serviceName,
|
||||
transactionType: params.transactionType,
|
||||
interval,
|
||||
start,
|
||||
end,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/alerts/chart_preview/transaction_duration',
|
||||
{
|
||||
params: {
|
||||
query: {
|
||||
aggregationType: params.aggregationType,
|
||||
environment: params.environment,
|
||||
serviceName: params.serviceName,
|
||||
transactionType: params.transactionType,
|
||||
interval,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -67,20 +67,21 @@ export function TransactionErrorRateAlertTrigger(props: Props) {
|
|||
windowUnit: params.windowUnit as TimeUnit,
|
||||
});
|
||||
if (interval && start && end) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/alerts/chart_preview/transaction_error_rate',
|
||||
params: {
|
||||
query: {
|
||||
environment: params.environment,
|
||||
serviceName: params.serviceName,
|
||||
transactionType: params.transactionType,
|
||||
interval,
|
||||
start,
|
||||
end,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/alerts/chart_preview/transaction_error_rate',
|
||||
{
|
||||
params: {
|
||||
query: {
|
||||
environment: params.environment,
|
||||
serviceName: params.serviceName,
|
||||
transactionType: params.transactionType,
|
||||
interval,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -75,8 +75,7 @@ async function saveApmIndices({
|
|||
}: {
|
||||
apmIndices: Record<string, string>;
|
||||
}) {
|
||||
await callApmApi({
|
||||
endpoint: 'POST /internal/apm/settings/apm-indices/save',
|
||||
await callApmApi('POST /internal/apm/settings/apm-indices/save', {
|
||||
signal: null,
|
||||
params: {
|
||||
body: apmIndices,
|
||||
|
@ -103,9 +102,7 @@ export function ApmIndices() {
|
|||
const { data = INITIAL_STATE, refetch } = useFetcher(
|
||||
(_callApmApi) => {
|
||||
if (canSave) {
|
||||
return _callApmApi({
|
||||
endpoint: `GET /internal/apm/settings/apm-index-settings`,
|
||||
});
|
||||
return _callApmApi(`GET /internal/apm/settings/apm-index-settings`);
|
||||
}
|
||||
},
|
||||
[canSave]
|
||||
|
|
|
@ -28,8 +28,7 @@ interface Props {
|
|||
export function ServicePage({ newConfig, setNewConfig, onClickNext }: Props) {
|
||||
const { data: serviceNamesData, status: serviceNamesStatus } = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /api/apm/settings/agent-configuration/services',
|
||||
return callApmApi('GET /api/apm/settings/agent-configuration/services', {
|
||||
isCachable: true,
|
||||
});
|
||||
},
|
||||
|
@ -41,12 +40,14 @@ export function ServicePage({ newConfig, setNewConfig, onClickNext }: Props) {
|
|||
const { data: environmentsData, status: environmentsStatus } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (newConfig.service.name) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /api/apm/settings/agent-configuration/environments',
|
||||
params: {
|
||||
query: { serviceName: omitAllOption(newConfig.service.name) },
|
||||
},
|
||||
});
|
||||
return callApmApi(
|
||||
'GET /api/apm/settings/agent-configuration/environments',
|
||||
{
|
||||
params: {
|
||||
query: { serviceName: omitAllOption(newConfig.service.name) },
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[newConfig.service.name],
|
||||
|
@ -63,10 +64,12 @@ export function ServicePage({ newConfig, setNewConfig, onClickNext }: Props) {
|
|||
return;
|
||||
}
|
||||
|
||||
const { agentName } = await callApmApi({
|
||||
endpoint: 'GET /api/apm/settings/agent-configuration/agent_name',
|
||||
params: { query: { serviceName } },
|
||||
});
|
||||
const { agentName } = await callApmApi(
|
||||
'GET /api/apm/settings/agent-configuration/agent_name',
|
||||
{
|
||||
params: { query: { serviceName } },
|
||||
}
|
||||
);
|
||||
|
||||
setNewConfig((prev) => ({ ...prev, agent_name: agentName }));
|
||||
},
|
||||
|
|
|
@ -25,8 +25,7 @@ export async function saveConfig({
|
|||
toasts: NotificationsStart['toasts'];
|
||||
}) {
|
||||
try {
|
||||
await callApmApi({
|
||||
endpoint: 'PUT /api/apm/settings/agent-configuration',
|
||||
await callApmApi('PUT /api/apm/settings/agent-configuration', {
|
||||
signal: null,
|
||||
params: {
|
||||
query: { overwrite: isEditMode },
|
||||
|
|
|
@ -71,8 +71,7 @@ async function deleteConfig(
|
|||
toasts: NotificationsStart['toasts']
|
||||
) {
|
||||
try {
|
||||
await callApmApi({
|
||||
endpoint: 'DELETE /api/apm/settings/agent-configuration',
|
||||
await callApmApi('DELETE /api/apm/settings/agent-configuration', {
|
||||
signal: null,
|
||||
params: {
|
||||
body: {
|
||||
|
|
|
@ -30,8 +30,7 @@ export function AgentConfigurations() {
|
|||
data = INITIAL_DATA,
|
||||
status,
|
||||
} = useFetcher(
|
||||
(callApmApi) =>
|
||||
callApmApi({ endpoint: 'GET /api/apm/settings/agent-configuration' }),
|
||||
(callApmApi) => callApmApi('GET /api/apm/settings/agent-configuration'),
|
||||
[],
|
||||
{ preservePreviousData: false, showToastOnError: false }
|
||||
);
|
||||
|
|
|
@ -25,8 +25,7 @@ export function ConfirmDeleteModal({ agentKey, onCancel, onConfirm }: Props) {
|
|||
|
||||
const deleteAgentKey = async () => {
|
||||
try {
|
||||
await callApmApi({
|
||||
endpoint: 'POST /internal/apm/api_key/invalidate',
|
||||
await callApmApi('POST /internal/apm/api_key/invalidate', {
|
||||
signal: null,
|
||||
params: {
|
||||
body: { id },
|
||||
|
|
|
@ -85,8 +85,7 @@ export function CreateAgentKeyFlyout({ onCancel, onSuccess, onError }: Props) {
|
|||
privileges.push(PrivilegeType.AGENT_CONFIG);
|
||||
}
|
||||
|
||||
const { agentKey } = await callApmApi({
|
||||
endpoint: 'POST /api/apm/agent_keys',
|
||||
const { agentKey } = await callApmApi('POST /api/apm/agent_keys', {
|
||||
signal: null,
|
||||
params: {
|
||||
body: {
|
||||
|
|
|
@ -44,9 +44,7 @@ export function AgentKeys() {
|
|||
status: privilegesStatus,
|
||||
} = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/agent_keys/privileges',
|
||||
});
|
||||
return callApmApi('GET /internal/apm/agent_keys/privileges');
|
||||
},
|
||||
[],
|
||||
{ showToastOnError: false }
|
||||
|
@ -59,9 +57,7 @@ export function AgentKeys() {
|
|||
} = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (areApiKeysEnabled && canManage) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/agent_keys',
|
||||
});
|
||||
return callApmApi('GET /internal/apm/agent_keys');
|
||||
}
|
||||
},
|
||||
[areApiKeysEnabled, canManage],
|
||||
|
|
|
@ -49,9 +49,7 @@ export function AddEnvironments({
|
|||
const { toasts } = notifications;
|
||||
const { data = INITIAL_DATA, status } = useFetcher(
|
||||
(callApmApi) =>
|
||||
callApmApi({
|
||||
endpoint: `GET /internal/apm/settings/anomaly-detection/environments`,
|
||||
}),
|
||||
callApmApi(`GET /internal/apm/settings/anomaly-detection/environments`),
|
||||
[],
|
||||
{ preservePreviousData: false }
|
||||
);
|
||||
|
|
|
@ -27,8 +27,7 @@ export async function createJobs({
|
|||
toasts: NotificationsStart['toasts'];
|
||||
}) {
|
||||
try {
|
||||
await callApmApi({
|
||||
endpoint: 'POST /internal/apm/settings/anomaly-detection/jobs',
|
||||
await callApmApi('POST /internal/apm/settings/anomaly-detection/jobs', {
|
||||
signal: null,
|
||||
params: {
|
||||
body: { environments },
|
||||
|
|
|
@ -172,11 +172,12 @@ export function JobsList({
|
|||
}}
|
||||
onUpgradeClick={() => {
|
||||
if (setupState === AnomalyDetectionSetupState.UpgradeableJobs) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'POST /internal/apm/settings/anomaly-detection/update_to_v3',
|
||||
signal: null,
|
||||
}).then(() => {
|
||||
return callApmApi(
|
||||
'POST /internal/apm/settings/anomaly-detection/update_to_v3',
|
||||
{
|
||||
signal: null,
|
||||
}
|
||||
).then(() => {
|
||||
core.notifications.toasts.addSuccess({
|
||||
title: i18n.translate(
|
||||
'xpack.apm.jobsList.updateCompletedToastTitle',
|
||||
|
|
|
@ -48,8 +48,7 @@ async function deleteConfig(
|
|||
toasts: NotificationsStart['toasts']
|
||||
) {
|
||||
try {
|
||||
await callApmApi({
|
||||
endpoint: 'DELETE /internal/apm/settings/custom_links/{id}',
|
||||
await callApmApi('DELETE /internal/apm/settings/custom_links/{id}', {
|
||||
signal: null,
|
||||
params: {
|
||||
path: { id: customLinkId },
|
||||
|
|
|
@ -32,11 +32,13 @@ export interface LinkPreviewProps {
|
|||
|
||||
const fetchTransaction = debounce(
|
||||
async (filters: Filter[], callback: (transaction: Transaction) => void) => {
|
||||
const transaction = await callApmApi({
|
||||
signal: null,
|
||||
endpoint: 'GET /internal/apm/settings/custom_links/transaction',
|
||||
params: { query: convertFiltersToQuery(filters) },
|
||||
});
|
||||
const transaction = await callApmApi(
|
||||
'GET /internal/apm/settings/custom_links/transaction',
|
||||
{
|
||||
signal: null,
|
||||
params: { query: convertFiltersToQuery(filters) },
|
||||
}
|
||||
);
|
||||
callback(transaction);
|
||||
},
|
||||
1000
|
||||
|
|
|
@ -34,8 +34,7 @@ export async function saveCustomLink({
|
|||
};
|
||||
|
||||
if (id) {
|
||||
await callApmApi({
|
||||
endpoint: 'PUT /internal/apm/settings/custom_links/{id}',
|
||||
await callApmApi('PUT /internal/apm/settings/custom_links/{id}', {
|
||||
signal: null,
|
||||
params: {
|
||||
path: { id },
|
||||
|
@ -43,8 +42,7 @@ export async function saveCustomLink({
|
|||
},
|
||||
});
|
||||
} else {
|
||||
await callApmApi({
|
||||
endpoint: 'POST /internal/apm/settings/custom_links',
|
||||
await callApmApi('POST /internal/apm/settings/custom_links', {
|
||||
signal: null,
|
||||
params: {
|
||||
body: customLink,
|
||||
|
|
|
@ -37,9 +37,7 @@ export function CustomLinkOverview() {
|
|||
const { data, status, refetch } = useFetcher(
|
||||
async (callApmApi) => {
|
||||
if (hasValidLicense) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/settings/custom_links',
|
||||
});
|
||||
return callApmApi('GET /internal/apm/settings/custom_links');
|
||||
}
|
||||
},
|
||||
[hasValidLicense]
|
||||
|
|
|
@ -46,8 +46,7 @@ export function Schema() {
|
|||
data = {} as FleetMigrationCheckResponse,
|
||||
status,
|
||||
} = useFetcher(
|
||||
(callApi) =>
|
||||
callApi({ endpoint: 'GET /internal/apm/fleet/migration_check' }),
|
||||
(callApi) => callApi('GET /internal/apm/fleet/migration_check'),
|
||||
[],
|
||||
{ preservePreviousData: false }
|
||||
);
|
||||
|
@ -120,10 +119,12 @@ async function getUnsupportedApmServerConfigs(
|
|||
toasts: NotificationsStart['toasts']
|
||||
) {
|
||||
try {
|
||||
const { unsupported } = await callApmApi({
|
||||
endpoint: 'GET /internal/apm/fleet/apm_server_schema/unsupported',
|
||||
signal: null,
|
||||
});
|
||||
const { unsupported } = await callApmApi(
|
||||
'GET /internal/apm/fleet/apm_server_schema/unsupported',
|
||||
{
|
||||
signal: null,
|
||||
}
|
||||
);
|
||||
return unsupported;
|
||||
} catch (error) {
|
||||
toasts.addDanger({
|
||||
|
@ -144,10 +145,12 @@ async function createCloudApmPackagePolicy(
|
|||
) {
|
||||
updateLocalStorage(FETCH_STATUS.LOADING);
|
||||
try {
|
||||
const { cloudApmPackagePolicy } = await callApmApi({
|
||||
endpoint: 'POST /internal/apm/fleet/cloud_apm_package_policy',
|
||||
signal: null,
|
||||
});
|
||||
const { cloudApmPackagePolicy } = await callApmApi(
|
||||
'POST /internal/apm/fleet/cloud_apm_package_policy',
|
||||
{
|
||||
signal: null,
|
||||
}
|
||||
);
|
||||
updateLocalStorage(FETCH_STATUS.SUCCESS);
|
||||
return cloudApmPackagePolicy;
|
||||
} catch (error) {
|
||||
|
|
|
@ -28,14 +28,16 @@ export function TraceLink() {
|
|||
const { data = { transaction: null }, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (traceId) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/traces/{traceId}/root_transaction',
|
||||
params: {
|
||||
path: {
|
||||
traceId,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/traces/{traceId}/root_transaction',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
traceId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[traceId]
|
||||
|
|
|
@ -40,8 +40,7 @@ export function BackendDetailDependenciesTable() {
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/backends/upstream_services',
|
||||
return callApmApi('GET /internal/apm/backends/upstream_services', {
|
||||
params: {
|
||||
query: {
|
||||
backendName,
|
||||
|
|
|
@ -40,8 +40,7 @@ export function BackendFailedTransactionRateChart({
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/backends/charts/error_rate',
|
||||
return callApmApi('GET /internal/apm/backends/charts/error_rate', {
|
||||
params: {
|
||||
query: {
|
||||
backendName,
|
||||
|
|
|
@ -36,8 +36,7 @@ export function BackendLatencyChart({ height }: { height: number }) {
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/backends/charts/latency',
|
||||
return callApmApi('GET /internal/apm/backends/charts/latency', {
|
||||
params: {
|
||||
query: {
|
||||
backendName,
|
||||
|
|
|
@ -32,8 +32,7 @@ export function BackendThroughputChart({ height }: { height: number }) {
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/backends/charts/throughput',
|
||||
return callApmApi('GET /internal/apm/backends/charts/throughput', {
|
||||
params: {
|
||||
query: {
|
||||
backendName,
|
||||
|
|
|
@ -44,8 +44,7 @@ export function BackendInventoryDependenciesTable() {
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/backends/top_backends',
|
||||
return callApmApi('GET /internal/apm/backends/top_backends', {
|
||||
params: {
|
||||
query: { start, end, environment, numBuckets: 20, offset, kuery },
|
||||
},
|
||||
|
|
|
@ -185,8 +185,7 @@ export function TopValues({
|
|||
fieldName !== undefined &&
|
||||
fieldValue !== undefined
|
||||
) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/correlations/field_value_stats',
|
||||
return callApmApi('GET /internal/apm/correlations/field_value_stats', {
|
||||
params: {
|
||||
query: {
|
||||
...params,
|
||||
|
|
|
@ -82,8 +82,7 @@ export function useFailedTransactionsCorrelations() {
|
|||
const [overallHistogramResponse, errorHistogramRespone] =
|
||||
await Promise.all([
|
||||
// Initial call to fetch the overall distribution for the log-log plot.
|
||||
callApmApi({
|
||||
endpoint: 'POST /internal/apm/latency/overall_distribution',
|
||||
callApmApi('POST /internal/apm/latency/overall_distribution', {
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
|
@ -92,8 +91,7 @@ export function useFailedTransactionsCorrelations() {
|
|||
},
|
||||
},
|
||||
}),
|
||||
callApmApi({
|
||||
endpoint: 'POST /internal/apm/latency/overall_distribution',
|
||||
callApmApi('POST /internal/apm/latency/overall_distribution', {
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
|
@ -128,13 +126,15 @@ export function useFailedTransactionsCorrelations() {
|
|||
});
|
||||
setResponse.flush();
|
||||
|
||||
const { fieldCandidates: candidates } = await callApmApi({
|
||||
endpoint: 'GET /internal/apm/correlations/field_candidates',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
query: fetchParams,
|
||||
},
|
||||
});
|
||||
const { fieldCandidates: candidates } = await callApmApi(
|
||||
'GET /internal/apm/correlations/field_candidates',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
query: fetchParams,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (abortCtrl.current.signal.aborted) {
|
||||
return;
|
||||
|
@ -156,13 +156,15 @@ export function useFailedTransactionsCorrelations() {
|
|||
const fieldCandidatesChunks = chunk(fieldCandidates, chunkSize);
|
||||
|
||||
for (const fieldCandidatesChunk of fieldCandidatesChunks) {
|
||||
const pValues = await callApmApi({
|
||||
endpoint: 'POST /internal/apm/correlations/p_values',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: { ...fetchParams, fieldCandidates: fieldCandidatesChunk },
|
||||
},
|
||||
});
|
||||
const pValues = await callApmApi(
|
||||
'POST /internal/apm/correlations/p_values',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: { ...fetchParams, fieldCandidates: fieldCandidatesChunk },
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (pValues.failedTransactionsCorrelations.length > 0) {
|
||||
pValues.failedTransactionsCorrelations.forEach((d) => {
|
||||
|
@ -193,16 +195,18 @@ export function useFailedTransactionsCorrelations() {
|
|||
|
||||
setResponse.flush();
|
||||
|
||||
const { stats } = await callApmApi({
|
||||
endpoint: 'POST /internal/apm/correlations/field_stats',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
fieldsToSample: [...fieldsToSample],
|
||||
const { stats } = await callApmApi(
|
||||
'POST /internal/apm/correlations/field_stats',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
fieldsToSample: [...fieldsToSample],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
responseUpdate.fieldStats = stats;
|
||||
setResponse({ ...responseUpdate, loaded: LOADED_DONE, isRunning: false });
|
||||
|
|
|
@ -81,16 +81,18 @@ export function useLatencyCorrelations() {
|
|||
};
|
||||
|
||||
// Initial call to fetch the overall distribution for the log-log plot.
|
||||
const { overallHistogram, percentileThresholdValue } = await callApmApi({
|
||||
endpoint: 'POST /internal/apm/latency/overall_distribution',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
percentileThreshold: DEFAULT_PERCENTILE_THRESHOLD,
|
||||
const { overallHistogram, percentileThresholdValue } = await callApmApi(
|
||||
'POST /internal/apm/latency/overall_distribution',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
percentileThreshold: DEFAULT_PERCENTILE_THRESHOLD,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
responseUpdate.overallHistogram = overallHistogram;
|
||||
responseUpdate.percentileThresholdValue = percentileThresholdValue;
|
||||
|
||||
|
@ -104,13 +106,15 @@ export function useLatencyCorrelations() {
|
|||
});
|
||||
setResponse.flush();
|
||||
|
||||
const { fieldCandidates } = await callApmApi({
|
||||
endpoint: 'GET /internal/apm/correlations/field_candidates',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
query: fetchParams,
|
||||
},
|
||||
});
|
||||
const { fieldCandidates } = await callApmApi(
|
||||
'GET /internal/apm/correlations/field_candidates',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
query: fetchParams,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (abortCtrl.current.signal.aborted) {
|
||||
return;
|
||||
|
@ -128,16 +132,18 @@ export function useLatencyCorrelations() {
|
|||
const fieldCandidateChunks = chunk(fieldCandidates, chunkSize);
|
||||
|
||||
for (const fieldCandidateChunk of fieldCandidateChunks) {
|
||||
const fieldValuePairChunkResponse = await callApmApi({
|
||||
endpoint: 'POST /internal/apm/correlations/field_value_pairs',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
fieldCandidates: fieldCandidateChunk,
|
||||
const fieldValuePairChunkResponse = await callApmApi(
|
||||
'POST /internal/apm/correlations/field_value_pairs',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
fieldCandidates: fieldCandidateChunk,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if (fieldValuePairChunkResponse.fieldValuePairs.length > 0) {
|
||||
fieldValuePairs.push(...fieldValuePairChunkResponse.fieldValuePairs);
|
||||
|
@ -172,13 +178,15 @@ export function useLatencyCorrelations() {
|
|||
);
|
||||
|
||||
for (const fieldValuePairChunk of fieldValuePairChunks) {
|
||||
const significantCorrelations = await callApmApi({
|
||||
endpoint: 'POST /internal/apm/correlations/significant_correlations',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: { ...fetchParams, fieldValuePairs: fieldValuePairChunk },
|
||||
},
|
||||
});
|
||||
const significantCorrelations = await callApmApi(
|
||||
'POST /internal/apm/correlations/significant_correlations',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: { ...fetchParams, fieldValuePairs: fieldValuePairChunk },
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (significantCorrelations.latencyCorrelations.length > 0) {
|
||||
significantCorrelations.latencyCorrelations.forEach((d) => {
|
||||
|
@ -207,16 +215,18 @@ export function useLatencyCorrelations() {
|
|||
|
||||
setResponse.flush();
|
||||
|
||||
const { stats } = await callApmApi({
|
||||
endpoint: 'POST /internal/apm/correlations/field_stats',
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
fieldsToSample: [...fieldsToSample],
|
||||
const { stats } = await callApmApi(
|
||||
'POST /internal/apm/correlations/field_stats',
|
||||
{
|
||||
signal: abortCtrl.current.signal,
|
||||
params: {
|
||||
body: {
|
||||
...fetchParams,
|
||||
fieldsToSample: [...fieldsToSample],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
responseUpdate.fieldStats = stats;
|
||||
setResponse({
|
||||
|
|
|
@ -136,21 +136,23 @@ export function ErrorGroupDetails() {
|
|||
const { data: errorGroupData } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/errors/{groupId}',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
groupId,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/errors/{groupId}',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
groupId,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[environment, kuery, serviceName, start, end, groupId]
|
||||
|
|
|
@ -83,24 +83,25 @@ export function ErrorGroupOverview() {
|
|||
sortDirection === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
if (start && end && transactionType) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/main_statistics',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/main_statistics',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
transactionType,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
sortField,
|
||||
sortDirection: normalizedSortDirection,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
transactionType,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
sortField,
|
||||
sortDirection: normalizedSortDirection,
|
||||
},
|
||||
},
|
||||
}).then((response) => {
|
||||
}
|
||||
).then((response) => {
|
||||
return {
|
||||
// Everytime the main statistics is refetched, updates the requestId making the comparison API to be refetched.
|
||||
requestId: uuid(),
|
||||
|
@ -134,26 +135,27 @@ export function ErrorGroupOverview() {
|
|||
end &&
|
||||
transactionType
|
||||
) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/detailed_statistics',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
groupIds: JSON.stringify(
|
||||
errorGroupMainStatistics.map(({ groupId }) => groupId).sort()
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/detailed_statistics',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
groupIds: JSON.stringify(
|
||||
errorGroupMainStatistics.map(({ groupId }) => groupId).sort()
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
// only fetches agg results when requestId changes
|
||||
|
|
|
@ -54,8 +54,7 @@ export function Metrics() {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (uxQuery) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/client-metrics',
|
||||
return callApmApi('GET /internal/apm/ux/client-metrics', {
|
||||
params: {
|
||||
query: {
|
||||
...uxQuery,
|
||||
|
|
|
@ -9,8 +9,6 @@ import { useFetcher } from '../../../../hooks/use_fetcher';
|
|||
|
||||
export function useHasRumData() {
|
||||
return useFetcher((callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /api/apm/observability_overview/has_rum_data',
|
||||
});
|
||||
return callApmApi('GET /api/apm/observability_overview/has_rum_data');
|
||||
}, []);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,7 @@ export function JSErrors() {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end && serviceName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/js-errors',
|
||||
return callApmApi('GET /internal/apm/ux/js-errors', {
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
|
|
|
@ -50,8 +50,7 @@ export function PageLoadDistribution() {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end && serviceName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/page-load-distribution',
|
||||
return callApmApi('GET /internal/apm/ux/page-load-distribution', {
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
|
|
|
@ -23,24 +23,26 @@ export const useBreakdowns = ({ percentileRange, field, value }: Props) => {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end && field && value) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/page-load-distribution/breakdown',
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
end,
|
||||
breakdown: value,
|
||||
uiFilters: JSON.stringify(uxUiFilters),
|
||||
urlQuery: searchTerm,
|
||||
...(minP && maxP
|
||||
? {
|
||||
minPercentile: String(minP),
|
||||
maxPercentile: String(maxP),
|
||||
}
|
||||
: {}),
|
||||
return callApmApi(
|
||||
'GET /internal/apm/ux/page-load-distribution/breakdown',
|
||||
{
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
end,
|
||||
breakdown: value,
|
||||
uiFilters: JSON.stringify(uxUiFilters),
|
||||
urlQuery: searchTerm,
|
||||
...(minP && maxP
|
||||
? {
|
||||
minPercentile: String(minP),
|
||||
maxPercentile: String(maxP),
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[end, start, uxUiFilters, field, value, minP, maxP, searchTerm]
|
||||
|
|
|
@ -38,8 +38,7 @@ export function PageViewsTrend() {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end && serviceName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/page-view-trends',
|
||||
return callApmApi('GET /internal/apm/ux/page-view-trends', {
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
|
|
|
@ -19,8 +19,7 @@ export function WebApplicationSelect() {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/services',
|
||||
return callApmApi('GET /internal/apm/ux/services', {
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
|
|
|
@ -37,8 +37,7 @@ export const useUrlSearch = ({ popoverIsOpen, query }: Props) => {
|
|||
return useFetcher(
|
||||
(callApmApi) => {
|
||||
if (uxQuery && popoverIsOpen) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/url-search',
|
||||
return callApmApi('GET /internal/apm/ux/url-search', {
|
||||
params: {
|
||||
query: {
|
||||
...uxQuery,
|
||||
|
|
|
@ -33,8 +33,7 @@ export function UXMetrics() {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (uxQuery) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/web-core-vitals',
|
||||
return callApmApi('GET /internal/apm/ux/web-core-vitals', {
|
||||
params: {
|
||||
query: uxQuery,
|
||||
},
|
||||
|
|
|
@ -55,8 +55,7 @@ export function KeyUXMetrics({ data, loading }: Props) {
|
|||
const { data: longTaskData, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (uxQuery) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/long-task-metrics',
|
||||
return callApmApi('GET /internal/apm/ux/long-task-metrics', {
|
||||
params: {
|
||||
query: {
|
||||
...uxQuery,
|
||||
|
|
|
@ -20,8 +20,7 @@ export const fetchUxOverviewDate = async ({
|
|||
relativeTime,
|
||||
serviceName,
|
||||
}: FetchDataParams): Promise<UxFetchDataResponse> => {
|
||||
const data = await callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/web-core-vitals',
|
||||
const data = await callApmApi('GET /internal/apm/ux/web-core-vitals', {
|
||||
signal: null,
|
||||
params: {
|
||||
query: {
|
||||
|
@ -41,8 +40,7 @@ export const fetchUxOverviewDate = async ({
|
|||
export async function hasRumData(
|
||||
params: HasDataParams
|
||||
): Promise<UXHasDataResponse> {
|
||||
return await callApmApi({
|
||||
endpoint: 'GET /api/apm/observability_overview/has_rum_data',
|
||||
return await callApmApi('GET /api/apm/observability_overview/has_rum_data', {
|
||||
signal: null,
|
||||
params: {
|
||||
query: params?.absoluteTime
|
||||
|
|
|
@ -22,8 +22,7 @@ export function VisitorBreakdown() {
|
|||
const { serviceName } = uxUiFilters;
|
||||
|
||||
if (start && end && serviceName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/ux/visitor-breakdown',
|
||||
return callApmApi('GET /internal/apm/ux/visitor-breakdown', {
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
|
|
|
@ -28,21 +28,22 @@ export function ServiceDependenciesBreakdownChart({
|
|||
|
||||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/dependencies/breakdown',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/dependencies/breakdown',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
start,
|
||||
end,
|
||||
kuery,
|
||||
environment,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
start,
|
||||
end,
|
||||
kuery,
|
||||
environment,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[serviceName, start, end, kuery, environment]
|
||||
);
|
||||
|
|
|
@ -63,8 +63,7 @@ function useServicesFetcher() {
|
|||
const { data = initialData, status: mainStatisticsStatus } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services',
|
||||
return callApmApi('GET /internal/apm/services', {
|
||||
params: {
|
||||
query: {
|
||||
environment,
|
||||
|
@ -89,8 +88,7 @@ function useServicesFetcher() {
|
|||
const { data: comparisonData } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end && mainStatisticsData.items.length) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/detailed_statistics',
|
||||
return callApmApi('GET /internal/apm/services/detailed_statistics', {
|
||||
params: {
|
||||
query: {
|
||||
environment,
|
||||
|
|
|
@ -35,18 +35,20 @@ export function ServiceLogs() {
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/infrastructure',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/infrastructure',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[environment, kuery, serviceName, start, end]
|
||||
|
|
|
@ -54,8 +54,7 @@ export function BackendContents({
|
|||
const { data = INITIAL_STATE, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (backendName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/service-map/backend',
|
||||
return callApmApi('GET /internal/apm/service-map/backend', {
|
||||
params: {
|
||||
query: {
|
||||
backendName,
|
||||
|
|
|
@ -67,13 +67,15 @@ export function ServiceContents({
|
|||
const { data = INITIAL_STATE, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (serviceName && start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/service-map/service/{serviceName}',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { environment, start, end, offset },
|
||||
},
|
||||
});
|
||||
return callApmApi(
|
||||
'GET /internal/apm/service-map/service/{serviceName}',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { environment, start, end, offset },
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[environment, serviceName, start, end, offset]
|
||||
|
|
|
@ -122,9 +122,8 @@ export function ServiceMap({
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
return callApmApi('GET /internal/apm/service-map', {
|
||||
isCachable: false,
|
||||
endpoint: 'GET /internal/apm/service-map',
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
|
|
|
@ -83,18 +83,19 @@ export function ServiceNodeMetrics() {
|
|||
const { data: { host, containerId } = INITIAL_DATA, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/node/{serviceNodeName}/metadata',
|
||||
params: {
|
||||
path: { serviceName, serviceNodeName },
|
||||
query: {
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/node/{serviceNodeName}/metadata',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName, serviceNodeName },
|
||||
query: {
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[kuery, serviceName, serviceNodeName, start, end]
|
||||
|
|
|
@ -46,20 +46,22 @@ function ServiceNodeOverview() {
|
|||
if (!start || !end) {
|
||||
return undefined;
|
||||
}
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/serviceNodes',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/serviceNodes',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
kuery,
|
||||
environment,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
kuery,
|
||||
environment,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[kuery, environment, serviceName, start, end]
|
||||
);
|
||||
|
|
|
@ -60,13 +60,15 @@ export function ServiceOverviewDependenciesTable({
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/dependencies',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end, environment, numBuckets: 20, offset },
|
||||
},
|
||||
});
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/dependencies',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end, environment, numBuckets: 20, offset },
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
[start, end, serviceName, environment, offset]
|
||||
);
|
||||
|
|
|
@ -95,20 +95,21 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
|
|||
if (!start || !end || !transactionType) {
|
||||
return;
|
||||
}
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/main_statistics',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/main_statistics',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
},
|
||||
},
|
||||
},
|
||||
}).then((response) => {
|
||||
}
|
||||
).then((response) => {
|
||||
const currentPageErrorGroups = orderBy(
|
||||
response.errorGroups,
|
||||
field,
|
||||
|
@ -148,26 +149,27 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
|
|||
} = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (requestId && items.length && start && end && transactionType) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/detailed_statistics',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
groupIds: JSON.stringify(
|
||||
items.map(({ groupId: groupId }) => groupId).sort()
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/errors/groups/detailed_statistics',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
groupIds: JSON.stringify(
|
||||
items.map(({ groupId: groupId }) => groupId).sort()
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
// only fetches agg results when requestId changes
|
||||
|
|
|
@ -98,25 +98,26 @@ export function ServiceOverviewInstancesChartAndTable({
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/service_overview_instances/main_statistics',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/service_overview_instances/main_statistics',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
latencyAggregationType,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
latencyAggregationType,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
}).then((response) => {
|
||||
}
|
||||
).then((response) => {
|
||||
return {
|
||||
// Everytime the main statistics is refetched, updates the requestId making the detailed API to be refetched.
|
||||
requestId: uuid(),
|
||||
|
@ -179,29 +180,30 @@ export function ServiceOverviewInstancesChartAndTable({
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
latencyAggregationType,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
serviceNodeIds: JSON.stringify(
|
||||
currentPeriodOrderedItems.map((item) => item.serviceNodeName)
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
latencyAggregationType,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
serviceNodeIds: JSON.stringify(
|
||||
currentPeriodOrderedItems.map((item) => item.serviceNodeName)
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
// only fetches detailed statistics when requestId is invalidated by main statistics api call
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
|
|
@ -26,17 +26,18 @@ export function useInstanceDetailsFetcher({
|
|||
if (!start || !end) {
|
||||
return;
|
||||
}
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/service_overview_instances/details/{serviceNodeName}',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
serviceNodeName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/service_overview_instances/details/{serviceNodeName}',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
serviceNodeName,
|
||||
},
|
||||
query: { start, end },
|
||||
},
|
||||
query: { start, end },
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[serviceName, serviceNodeName, start, end]
|
||||
);
|
||||
|
|
|
@ -74,24 +74,26 @@ export function ServiceOverviewThroughputChart({
|
|||
const { data = INITIAL_STATE, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (serviceName && transactionType && start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/throughput',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/throughput',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
transactionName,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
transactionName,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -37,18 +37,20 @@ export function ServiceProfiling() {
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/profiling/timeline',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
environment,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/profiling/timeline',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
environment,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[kuery, start, end, serviceName, environment]
|
||||
);
|
||||
|
|
|
@ -146,22 +146,23 @@ export function ServiceProfilingFlamegraph({
|
|||
return undefined;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/profiling/statistics',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/profiling/statistics',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
environment,
|
||||
valueType,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
environment,
|
||||
valueType,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[kuery, start, end, environment, serviceName, valueType]
|
||||
);
|
||||
|
|
|
@ -34,8 +34,7 @@ export function TraceOverview() {
|
|||
const { status, data = DEFAULT_RESPONSE } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/traces',
|
||||
return callApmApi('GET /internal/apm/traces', {
|
||||
params: {
|
||||
query: {
|
||||
environment,
|
||||
|
|
|
@ -37,8 +37,7 @@ export const useTransactionDistributionChartData = () => {
|
|||
params.start &&
|
||||
params.end
|
||||
) {
|
||||
return callApmApi({
|
||||
endpoint: 'POST /internal/apm/latency/overall_distribution',
|
||||
return callApmApi('POST /internal/apm/latency/overall_distribution', {
|
||||
params: {
|
||||
body: {
|
||||
...params,
|
||||
|
@ -84,8 +83,7 @@ export const useTransactionDistributionChartData = () => {
|
|||
params.start &&
|
||||
params.end
|
||||
) {
|
||||
return callApmApi({
|
||||
endpoint: 'POST /internal/apm/latency/overall_distribution',
|
||||
return callApmApi('POST /internal/apm/latency/overall_distribution', {
|
||||
params: {
|
||||
body: {
|
||||
...params,
|
||||
|
|
|
@ -35,8 +35,7 @@ export function useWaterfallFetcher() {
|
|||
} = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (traceId && start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/traces/{traceId}',
|
||||
return callApmApi('GET /internal/apm/traces/{traceId}', {
|
||||
params: {
|
||||
path: { traceId },
|
||||
query: {
|
||||
|
|
|
@ -27,8 +27,7 @@ export function TransactionLink() {
|
|||
const { data = { transaction: null }, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (transactionId) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/transactions/{transactionId}',
|
||||
return callApmApi('GET /internal/apm/transactions/{transactionId}', {
|
||||
params: {
|
||||
path: {
|
||||
transactionId,
|
||||
|
|
|
@ -21,8 +21,7 @@ export function EditAgentConfigurationRouteView() {
|
|||
|
||||
const res = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /api/apm/settings/agent-configuration/view',
|
||||
return callApmApi('GET /api/apm/settings/agent-configuration/view', {
|
||||
params: { query: { name, environment } },
|
||||
});
|
||||
},
|
||||
|
|
|
@ -51,7 +51,7 @@ export function ApmMainTemplate({
|
|||
const ObservabilityPageTemplate = observability.navigation.PageTemplate;
|
||||
|
||||
const { data } = useFetcher((callApmApi) => {
|
||||
return callApmApi({ endpoint: 'GET /internal/apm/has_data' });
|
||||
return callApmApi('GET /internal/apm/has_data');
|
||||
}, []);
|
||||
|
||||
const noDataConfig = getNoDataConfig({
|
||||
|
|
|
@ -31,8 +31,7 @@ export function BackendDetailTemplate({ title, children }: Props) {
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/backends/metadata',
|
||||
return callApmApi('GET /internal/apm/backends/metadata', {
|
||||
params: {
|
||||
query: {
|
||||
backendName,
|
||||
|
|
|
@ -85,25 +85,26 @@ export function FailedTransactionRateChart({
|
|||
const { data = INITIAL_STATE, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (transactionType && serviceName && start && end) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/transactions/charts/error_rate',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/transactions/charts/error_rate',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
transactionName,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
transactionName,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -37,21 +37,22 @@ export function useTransactionBreakdown({
|
|||
} = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (serviceName && start && end && transactionType) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/transaction/charts/breakdown',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionName,
|
||||
transactionType,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/transaction/charts/breakdown',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionName,
|
||||
transactionType,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -19,15 +19,17 @@ interface Props {
|
|||
export function ErrorMetadata({ error }: Props) {
|
||||
const { data: errorEvent, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/event_metadata/{processorEvent}/{id}',
|
||||
params: {
|
||||
path: {
|
||||
processorEvent: ProcessorEvent.error,
|
||||
id: error.error.id,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/event_metadata/{processorEvent}/{id}',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
processorEvent: ProcessorEvent.error,
|
||||
id: error.error.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[error.error.id]
|
||||
);
|
||||
|
|
|
@ -19,15 +19,17 @@ interface Props {
|
|||
export function SpanMetadata({ span }: Props) {
|
||||
const { data: spanEvent, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/event_metadata/{processorEvent}/{id}',
|
||||
params: {
|
||||
path: {
|
||||
processorEvent: ProcessorEvent.span,
|
||||
id: span.span.id,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/event_metadata/{processorEvent}/{id}',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
processorEvent: ProcessorEvent.span,
|
||||
id: span.span.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[span.span.id]
|
||||
);
|
||||
|
|
|
@ -19,15 +19,17 @@ interface Props {
|
|||
export function TransactionMetadata({ transaction }: Props) {
|
||||
const { data: transactionEvent, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/event_metadata/{processorEvent}/{id}',
|
||||
params: {
|
||||
path: {
|
||||
processorEvent: ProcessorEvent.transaction,
|
||||
id: transaction.transaction.id,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/event_metadata/{processorEvent}/{id}',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
processorEvent: ProcessorEvent.transaction,
|
||||
id: transaction.transaction.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[transaction.transaction.id]
|
||||
);
|
||||
|
|
|
@ -180,8 +180,7 @@ describe('ServiceIcons', () => {
|
|||
|
||||
describe('details', () => {
|
||||
const callApmApi =
|
||||
(apisMockData: Record<string, object>) =>
|
||||
({ endpoint }: { endpoint: string }) => {
|
||||
(apisMockData: Record<string, object>) => (endpoint: string) => {
|
||||
return apisMockData[endpoint];
|
||||
};
|
||||
it('Shows loading spinner while fetching data', () => {
|
||||
|
|
|
@ -69,13 +69,15 @@ export function ServiceIcons({ start, end, serviceName }: Props) {
|
|||
const { data: icons, status: iconsFetchStatus } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (serviceName && start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/metadata/icons',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end },
|
||||
},
|
||||
});
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/metadata/icons',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end },
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[serviceName, start, end]
|
||||
|
@ -84,14 +86,16 @@ export function ServiceIcons({ start, end, serviceName }: Props) {
|
|||
const { data: details, status: detailsFetchStatus } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (selectedIconPopover && serviceName && start && end) {
|
||||
return callApmApi({
|
||||
isCachable: true,
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/metadata/details',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end },
|
||||
},
|
||||
});
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/metadata/details',
|
||||
{
|
||||
isCachable: true,
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end },
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[selectedIconPopover, serviceName, start, end]
|
||||
|
|
|
@ -44,8 +44,7 @@ export function SuggestionsSelect({
|
|||
|
||||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/suggestions',
|
||||
return callApmApi('GET /internal/apm/suggestions', {
|
||||
params: {
|
||||
query: { field, string: searchValue },
|
||||
},
|
||||
|
|
|
@ -59,9 +59,8 @@ export function CustomLinkMenuSection({
|
|||
|
||||
const { data, status, refetch } = useFetcher(
|
||||
(callApmApi) =>
|
||||
callApmApi({
|
||||
callApmApi('GET /internal/apm/settings/custom_links', {
|
||||
isCachable: false,
|
||||
endpoint: 'GET /internal/apm/settings/custom_links',
|
||||
params: { query: convertFiltersToQuery(filters) },
|
||||
}),
|
||||
[filters]
|
||||
|
|
|
@ -112,21 +112,22 @@ export function TransactionsTable({
|
|||
if (!start || !end || !latencyAggregationType || !transactionType) {
|
||||
return;
|
||||
}
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/transactions/groups/main_statistics',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
latencyAggregationType,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/transactions/groups/main_statistics',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
latencyAggregationType,
|
||||
},
|
||||
},
|
||||
},
|
||||
}).then((response) => {
|
||||
}
|
||||
).then((response) => {
|
||||
const currentPageTransactionGroups = orderBy(
|
||||
response.transactionGroups,
|
||||
field,
|
||||
|
@ -185,27 +186,28 @@ export function TransactionsTable({
|
|||
transactionType &&
|
||||
latencyAggregationType
|
||||
) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/transactions/groups/detailed_statistics',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
latencyAggregationType,
|
||||
transactionNames: JSON.stringify(
|
||||
transactionGroups.map(({ name }) => name).sort()
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/transactions/groups/detailed_statistics',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
numBuckets: 20,
|
||||
transactionType,
|
||||
latencyAggregationType,
|
||||
transactionNames: JSON.stringify(
|
||||
transactionGroups.map(({ name }) => name).sort()
|
||||
),
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
// only fetches detailed statistics when requestId is invalidated by main statistics api call
|
||||
|
|
|
@ -31,19 +31,21 @@ export function AnnotationsContextProvider({
|
|||
const { data = INITIAL_STATE } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end && serviceName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /api/apm/services/{serviceName}/annotation/search',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /api/apm/services/{serviceName}/annotation/search',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[environment, start, end, serviceName]
|
||||
|
|
|
@ -45,9 +45,7 @@ export function AnomalyDetectionJobsContextProvider({
|
|||
if (!isAuthorized) {
|
||||
return;
|
||||
}
|
||||
return callApmApi({
|
||||
endpoint: `GET /internal/apm/settings/anomaly-detection/jobs`,
|
||||
});
|
||||
return callApmApi(`GET /internal/apm/settings/anomaly-detection/jobs`);
|
||||
},
|
||||
[isAuthorized],
|
||||
{ showToastOnError: false }
|
||||
|
|
|
@ -28,8 +28,7 @@ export function useServiceAgentFetcher({
|
|||
} = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (serviceName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/agent',
|
||||
return callApmApi('GET /internal/apm/services/{serviceName}/agent', {
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end },
|
||||
|
|
|
@ -40,8 +40,7 @@ export function useServiceAlertsFetcher({
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/alerts',
|
||||
return callApmApi('GET /internal/apm/services/{serviceName}/alerts', {
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
|
|
|
@ -21,14 +21,15 @@ export function useServiceTransactionTypesFetcher({
|
|||
const { data = INITIAL_DATA } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (serviceName && start && end) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/transaction_types',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end },
|
||||
},
|
||||
});
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/transaction_types',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: { start, end },
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[serviceName, start, end]
|
||||
|
|
|
@ -53,19 +53,21 @@ export function ServiceAnomalyTimeseriesContextProvider({
|
|||
return;
|
||||
}
|
||||
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/anomaly_charts',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/anomaly_charts',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
[serviceName, canGetAnomalies, transactionType, start, end]
|
||||
);
|
||||
|
|
|
@ -9,8 +9,7 @@ import { useFetcher } from './use_fetcher';
|
|||
|
||||
export function useDynamicDataViewFetcher() {
|
||||
const { data, status } = useFetcher((callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/data_view/dynamic',
|
||||
return callApmApi('GET /internal/apm/data_view/dynamic', {
|
||||
isCachable: true,
|
||||
});
|
||||
}, []);
|
||||
|
|
|
@ -37,8 +37,7 @@ export function useEnvironmentsFetcher({
|
|||
const { data = INITIAL_DATA, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/environments',
|
||||
return callApmApi('GET /internal/apm/environments', {
|
||||
params: {
|
||||
query: {
|
||||
start,
|
||||
|
|
|
@ -35,22 +35,23 @@ export function useErrorGroupDistributionFetcher({
|
|||
const { data, status } = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (start && end) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/errors/distribution',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
groupId,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/errors/distribution',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
groupId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -18,8 +18,7 @@ export function useFallbackToTransactionsFetcher({ kuery }: { kuery: string }) {
|
|||
|
||||
const { data = { fallbackToTransactions: false } } = useFetcher(
|
||||
(callApmApi) => {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/fallback_to_transactions',
|
||||
return callApmApi('GET /internal/apm/fallback_to_transactions', {
|
||||
params: {
|
||||
query: { kuery, start, end },
|
||||
},
|
||||
|
|
|
@ -49,8 +49,11 @@ function getDetailsFromErrorResponse(
|
|||
const createAutoAbortedAPMClient = (
|
||||
signal: AbortSignal
|
||||
): AutoAbortedAPMClient => {
|
||||
return ((options: Parameters<AutoAbortedAPMClient>[0]) => {
|
||||
return callApmApi({ ...options, signal });
|
||||
return ((endpoint, options) => {
|
||||
return callApmApi(endpoint, {
|
||||
...options,
|
||||
signal,
|
||||
} as any);
|
||||
}) as AutoAbortedAPMClient;
|
||||
};
|
||||
|
||||
|
|
|
@ -41,20 +41,22 @@ export function useServiceMetricChartsFetcher({
|
|||
} = useFetcher(
|
||||
(callApmApi) => {
|
||||
if (serviceName && start && end && agentName) {
|
||||
return callApmApi({
|
||||
endpoint: 'GET /internal/apm/services/{serviceName}/metrics/charts',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
serviceNodeName,
|
||||
start,
|
||||
end,
|
||||
agentName,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/metrics/charts',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
serviceNodeName,
|
||||
start,
|
||||
end,
|
||||
agentName,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[environment, kuery, serviceName, start, end, agentName, serviceNodeName]
|
||||
|
|
|
@ -55,24 +55,25 @@ export function useTransactionLatencyChartsFetcher({
|
|||
transactionType &&
|
||||
latencyAggregationType
|
||||
) {
|
||||
return callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/transactions/charts/latency',
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
transactionName,
|
||||
latencyAggregationType,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
return callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/transactions/charts/latency',
|
||||
{
|
||||
params: {
|
||||
path: { serviceName },
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
transactionName,
|
||||
latencyAggregationType,
|
||||
comparisonStart,
|
||||
comparisonEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
|
@ -48,27 +48,28 @@ export function useTransactionTraceSamplesFetcher({
|
|||
} = useFetcher(
|
||||
async (callApmApi) => {
|
||||
if (serviceName && start && end && transactionType && transactionName) {
|
||||
const response = await callApmApi({
|
||||
endpoint:
|
||||
'GET /internal/apm/services/{serviceName}/transactions/traces/samples',
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
const response = await callApmApi(
|
||||
'GET /internal/apm/services/{serviceName}/transactions/traces/samples',
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
serviceName,
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
transactionName,
|
||||
transactionId,
|
||||
traceId,
|
||||
sampleRangeFrom,
|
||||
sampleRangeTo,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
environment,
|
||||
kuery,
|
||||
start,
|
||||
end,
|
||||
transactionType,
|
||||
transactionName,
|
||||
transactionId,
|
||||
traceId,
|
||||
sampleRangeFrom,
|
||||
sampleRangeTo,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ describe('callApmApi', () => {
|
|||
});
|
||||
|
||||
it('should format the pathname with the given path params', async () => {
|
||||
await callApmApi({
|
||||
endpoint: 'GET /internal/apm/{param1}/to/{param2}',
|
||||
// @ts-expect-error
|
||||
await callApmApi('GET /internal/apm/{param1}/to/{param2}', {
|
||||
params: {
|
||||
path: {
|
||||
param1: 'foo',
|
||||
|
@ -42,8 +42,8 @@ describe('callApmApi', () => {
|
|||
});
|
||||
|
||||
it('should add the query parameters to the options object', async () => {
|
||||
await callApmApi({
|
||||
endpoint: 'GET /internal/apm',
|
||||
// @ts-expect-error
|
||||
await callApmApi('GET /internal/apm', {
|
||||
params: {
|
||||
query: {
|
||||
foo: 'bar',
|
||||
|
@ -65,8 +65,8 @@ describe('callApmApi', () => {
|
|||
});
|
||||
|
||||
it('should stringify the body and add it to the options object', async () => {
|
||||
await callApmApi({
|
||||
endpoint: 'POST /internal/apm',
|
||||
// @ts-expect-error
|
||||
await callApmApi('POST /internal/apm', {
|
||||
params: {
|
||||
body: {
|
||||
foo: 'bar',
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue