APM TypeScript improvements (#68572)
* Add `compilerOptions.noErrorTrunctation` to the tsconfig template * Remove unused parameters Not adding `noUnusedParamaters` to the tsconfig since we get too many hits from dependencies when running `tsc`. These do show up in the editor as warnings, though.
This commit is contained in:
parent
ab226f02ae
commit
d1ed207945
21 changed files with 53 additions and 57 deletions
|
@ -103,7 +103,7 @@ const ErrorGroupList: React.FC<Props> = (props) => {
|
||||||
}),
|
}),
|
||||||
field: 'type',
|
field: 'type',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
render: (type: string, item: ErrorGroupListAPIResponse[0]) => {
|
render: (type: string) => {
|
||||||
return (
|
return (
|
||||||
<ErrorLink
|
<ErrorLink
|
||||||
title={type}
|
title={type}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import { getOptionLabel } from '../../../../../../../common/agent_configuration/
|
||||||
|
|
||||||
function removeEmpty<T>(obj: T): T {
|
function removeEmpty<T>(obj: T): T {
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
Object.entries(obj).filter(([k, v]) => v != null && v !== '')
|
Object.entries(obj).filter(([_, v]) => v != null && v !== '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { storiesOf } from '@storybook/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ErrorRateAlertTrigger } from '.';
|
import { ErrorRateAlertTrigger } from '.';
|
||||||
|
|
||||||
storiesOf('app/ErrorRateAlertTrigger', module).add('example', (props) => {
|
storiesOf('app/ErrorRateAlertTrigger', module).add('example', () => {
|
||||||
const params = {
|
const params = {
|
||||||
threshold: 2,
|
threshold: 2,
|
||||||
window: '5m',
|
window: '5m',
|
||||||
|
|
|
@ -69,7 +69,6 @@ function getPropertyLabel({ fieldName, label }: Partial<IStickyProperty>) {
|
||||||
|
|
||||||
function getPropertyValue({
|
function getPropertyValue({
|
||||||
val,
|
val,
|
||||||
fieldName,
|
|
||||||
truncated = false,
|
truncated = false,
|
||||||
}: Partial<IStickyProperty>) {
|
}: Partial<IStickyProperty>) {
|
||||||
if (truncated) {
|
if (truncated) {
|
||||||
|
|
|
@ -14,37 +14,34 @@ import {
|
||||||
import { MockUrlParamsContextProvider } from '../../../context/UrlParamsContext/MockUrlParamsContextProvider';
|
import { MockUrlParamsContextProvider } from '../../../context/UrlParamsContext/MockUrlParamsContextProvider';
|
||||||
import { ApmPluginContextValue } from '../../../context/ApmPluginContext';
|
import { ApmPluginContextValue } from '../../../context/ApmPluginContext';
|
||||||
|
|
||||||
storiesOf('app/TransactionDurationAlertTrigger', module).add(
|
storiesOf('app/TransactionDurationAlertTrigger', module).add('example', () => {
|
||||||
'example',
|
const params = {
|
||||||
(context) => {
|
threshold: 1500,
|
||||||
const params = {
|
aggregationType: 'avg' as const,
|
||||||
threshold: 1500,
|
window: '5m',
|
||||||
aggregationType: 'avg' as const,
|
};
|
||||||
window: '5m',
|
|
||||||
};
|
|
||||||
|
|
||||||
const contextMock = (merge(cloneDeep(mockApmPluginContextValue), {
|
const contextMock = (merge(cloneDeep(mockApmPluginContextValue), {
|
||||||
core: {
|
core: {
|
||||||
http: {
|
http: {
|
||||||
get: () => {
|
get: () => {
|
||||||
return Promise.resolve({ transactionTypes: ['request'] });
|
return Promise.resolve({ transactionTypes: ['request'] });
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}) as unknown) as ApmPluginContextValue;
|
},
|
||||||
|
}) as unknown) as ApmPluginContextValue;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ width: 400 }}>
|
<div style={{ width: 400 }}>
|
||||||
<MockApmPluginContextWrapper value={contextMock}>
|
<MockApmPluginContextWrapper value={contextMock}>
|
||||||
<MockUrlParamsContextProvider>
|
<MockUrlParamsContextProvider>
|
||||||
<TransactionDurationAlertTrigger
|
<TransactionDurationAlertTrigger
|
||||||
alertParams={params as any}
|
alertParams={params as any}
|
||||||
setAlertParams={() => undefined}
|
setAlertParams={() => undefined}
|
||||||
setAlertProperty={() => undefined}
|
setAlertProperty={() => undefined}
|
||||||
/>
|
/>
|
||||||
</MockUrlParamsContextProvider>
|
</MockUrlParamsContextProvider>
|
||||||
</MockApmPluginContextWrapper>
|
</MockApmPluginContextWrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ export const ChoroplethMap: React.FC<Props> = (props) => {
|
||||||
}, [map, items, tooltipState]);
|
}, [map, items, tooltipState]);
|
||||||
|
|
||||||
const updateTooltipStateOnMousemoveRef = useRef(
|
const updateTooltipStateOnMousemoveRef = useRef(
|
||||||
(event: mapboxgl.MapMouseEvent & mapboxgl.EventData) => {}
|
(_event: mapboxgl.MapMouseEvent & mapboxgl.EventData) => {}
|
||||||
);
|
);
|
||||||
|
|
||||||
// initialization side effect, only runs once
|
// initialization side effect, only runs once
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { useDelayedVisibility } from '../components/shared/useDelayedVisibility'
|
||||||
|
|
||||||
export const LoadingIndicatorContext = React.createContext({
|
export const LoadingIndicatorContext = React.createContext({
|
||||||
statuses: {},
|
statuses: {},
|
||||||
dispatchStatus: (action: Action) => {},
|
dispatchStatus: (_action: Action) => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
|
|
@ -40,7 +40,7 @@ function useUiFilters(params: IUrlParams): UIFilters {
|
||||||
return useDeepObjectIdentity({ kuery, environment, ...localUiFilters });
|
return useDeepObjectIdentity({ kuery, environment, ...localUiFilters });
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultRefresh = (time: TimeRange) => {};
|
const defaultRefresh = (_time: TimeRange) => {};
|
||||||
|
|
||||||
const UrlParamsContext = createContext({
|
const UrlParamsContext = createContext({
|
||||||
urlParams: {} as IUrlParams,
|
urlParams: {} as IUrlParams,
|
||||||
|
|
|
@ -36,7 +36,7 @@ interface StartedMLJobApiResponse {
|
||||||
jobs: MlResponseItem[];
|
jobs: MlResponseItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTransactionIndices(http: HttpSetup) {
|
async function getTransactionIndices() {
|
||||||
const indices = await callApmApi({
|
const indices = await callApmApi({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
pathname: `/api/apm/settings/apm-indices`,
|
pathname: `/api/apm/settings/apm-indices`,
|
||||||
|
@ -53,7 +53,7 @@ export async function startMLJob({
|
||||||
transactionType: string;
|
transactionType: string;
|
||||||
http: HttpSetup;
|
http: HttpSetup;
|
||||||
}) {
|
}) {
|
||||||
const transactionIndices = await getTransactionIndices(http);
|
const transactionIndices = await getTransactionIndices();
|
||||||
const groups = [
|
const groups = [
|
||||||
'apm',
|
'apm',
|
||||||
encodeForMlApi(serviceName),
|
encodeForMlApi(serviceName),
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
"./plugins/observability/**/*",
|
"./plugins/observability/**/*",
|
||||||
"./typings/**/*"
|
"./typings/**/*"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": ["**/__fixtures__/**/*", "./plugins/apm/e2e/cypress/**/*"],
|
||||||
"**/__fixtures__/**/*",
|
"compilerOptions": {
|
||||||
"./plugins/apm/e2e/cypress/**/*"
|
"noErrorTruncation": true
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ export async function generateSampleDocuments(
|
||||||
const dateOfScriptExecution = new Date();
|
const dateOfScriptExecution = new Date();
|
||||||
|
|
||||||
return flatten(
|
return flatten(
|
||||||
range(0, opts.instances).map((instanceNo) => {
|
range(0, opts.instances).map(() => {
|
||||||
const instanceId = uuid.v4();
|
const instanceId = uuid.v4();
|
||||||
const defaults = {
|
const defaults = {
|
||||||
cluster_uuid: instanceId,
|
cluster_uuid: instanceId,
|
||||||
|
|
|
@ -120,7 +120,7 @@ export async function createApmTelemetry({
|
||||||
|
|
||||||
usageCollector.registerCollector(collector);
|
usageCollector.registerCollector(collector);
|
||||||
|
|
||||||
core.getStartServices().then(([coreStart, pluginsStart]) => {
|
core.getStartServices().then(([_coreStart, pluginsStart]) => {
|
||||||
const { taskManager: taskManagerStart } = pluginsStart as {
|
const { taskManager: taskManagerStart } = pluginsStart as {
|
||||||
taskManager: TaskManagerStartContract;
|
taskManager: TaskManagerStartContract;
|
||||||
};
|
};
|
||||||
|
|
|
@ -270,7 +270,7 @@ export async function getServiceMapFromTraceIds({
|
||||||
return conns;
|
return conns;
|
||||||
}, [] as Connection[]);
|
}, [] as Connection[]);
|
||||||
}, [] as Connection[]),
|
}, [] as Connection[]),
|
||||||
(value, index, array) => {
|
(value, _index, array) => {
|
||||||
return find(array, value);
|
return find(array, value);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -41,7 +41,7 @@ export async function getServiceAnnotations({
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
if (storedAnnotations.length) {
|
if (storedAnnotations.length) {
|
||||||
derivedAnnotationsPromise.catch((error) => {
|
derivedAnnotationsPromise.catch(() => {
|
||||||
// handle error silently to prevent Kibana from crashing
|
// handle error silently to prevent Kibana from crashing
|
||||||
});
|
});
|
||||||
return { annotations: storedAnnotations };
|
return { annotations: storedAnnotations };
|
||||||
|
|
|
@ -28,6 +28,6 @@ export async function saveApmIndices(
|
||||||
function removeEmpty(apmIndices: Partial<ApmIndicesConfig>) {
|
function removeEmpty(apmIndices: Partial<ApmIndicesConfig>) {
|
||||||
return Object.entries(apmIndices)
|
return Object.entries(apmIndices)
|
||||||
.map(([key, value]) => [key, value?.trim()])
|
.map(([key, value]) => [key, value?.trim()])
|
||||||
.filter(([key, value]) => !!value)
|
.filter(([_, value]) => !!value)
|
||||||
.reduce((obj, [key, value]) => ({ ...obj, [key as string]: value }), {});
|
.reduce((obj, [key, value]) => ({ ...obj, [key as string]: value }), {});
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { getErrorGroups } from '../lib/errors/get_error_groups';
|
||||||
import { setupRequest } from '../lib/helpers/setup_request';
|
import { setupRequest } from '../lib/helpers/setup_request';
|
||||||
import { uiFiltersRt, rangeRt } from './default_api_types';
|
import { uiFiltersRt, rangeRt } from './default_api_types';
|
||||||
|
|
||||||
export const errorsRoute = createRoute((core) => ({
|
export const errorsRoute = createRoute(() => ({
|
||||||
path: '/api/apm/services/{serviceName}/errors',
|
path: '/api/apm/services/{serviceName}/errors',
|
||||||
params: {
|
params: {
|
||||||
path: t.type({
|
path: t.type({
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { setupRequest } from '../lib/helpers/setup_request';
|
||||||
import { getServiceNodes } from '../lib/service_nodes';
|
import { getServiceNodes } from '../lib/service_nodes';
|
||||||
import { rangeRt, uiFiltersRt } from './default_api_types';
|
import { rangeRt, uiFiltersRt } from './default_api_types';
|
||||||
|
|
||||||
export const serviceNodesRoute = createRoute((core) => ({
|
export const serviceNodesRoute = createRoute(() => ({
|
||||||
path: '/api/apm/services/{serviceName}/serviceNodes',
|
path: '/api/apm/services/{serviceName}/serviceNodes',
|
||||||
params: {
|
params: {
|
||||||
path: t.type({
|
path: t.type({
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { uiFiltersRt, rangeRt } from './default_api_types';
|
||||||
import { getServiceAnnotations } from '../lib/services/annotations';
|
import { getServiceAnnotations } from '../lib/services/annotations';
|
||||||
import { dateAsStringRt } from '../../common/runtime_types/date_as_string_rt';
|
import { dateAsStringRt } from '../../common/runtime_types/date_as_string_rt';
|
||||||
|
|
||||||
export const servicesRoute = createRoute((core) => ({
|
export const servicesRoute = createRoute(() => ({
|
||||||
path: '/api/apm/services',
|
path: '/api/apm/services',
|
||||||
params: {
|
params: {
|
||||||
query: t.intersection([uiFiltersRt, rangeRt]),
|
query: t.intersection([uiFiltersRt, rangeRt]),
|
||||||
|
|
|
@ -24,7 +24,7 @@ import {
|
||||||
import { jsonRt } from '../../../common/runtime_types/json_rt';
|
import { jsonRt } from '../../../common/runtime_types/json_rt';
|
||||||
|
|
||||||
// get list of configurations
|
// get list of configurations
|
||||||
export const agentConfigurationRoute = createRoute((core) => ({
|
export const agentConfigurationRoute = createRoute(() => ({
|
||||||
path: '/api/apm/settings/agent-configuration',
|
path: '/api/apm/settings/agent-configuration',
|
||||||
handler: async ({ context, request }) => {
|
handler: async ({ context, request }) => {
|
||||||
const setup = await setupRequest(context, request);
|
const setup = await setupRequest(context, request);
|
||||||
|
@ -137,7 +137,7 @@ export const createOrUpdateAgentConfigurationRoute = createRoute(() => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Lookup single configuration (used by APM Server)
|
// Lookup single configuration (used by APM Server)
|
||||||
export const agentConfigurationSearchRoute = createRoute((core) => ({
|
export const agentConfigurationSearchRoute = createRoute(() => ({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: '/api/apm/settings/agent-configuration/search',
|
path: '/api/apm/settings/agent-configuration/search',
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -34,7 +34,7 @@ export const apmIndicesRoute = createRoute(() => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// save ui indices
|
// save ui indices
|
||||||
export const saveApmIndicesRoute = createRoute((core) => ({
|
export const saveApmIndicesRoute = createRoute(() => ({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: '/api/apm/settings/apm-indices/save',
|
path: '/api/apm/settings/apm-indices/save',
|
||||||
options: {
|
options: {
|
||||||
|
@ -50,7 +50,7 @@ export const saveApmIndicesRoute = createRoute((core) => ({
|
||||||
'apm_oss.metricsIndices': t.string,
|
'apm_oss.metricsIndices': t.string,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
handler: async ({ context, request }) => {
|
handler: async ({ context }) => {
|
||||||
const { body } = context.params;
|
const { body } = context.params;
|
||||||
const savedObjectsClient = context.core.savedObjects.client;
|
const savedObjectsClient = context.core.savedObjects.client;
|
||||||
return await saveApmIndices(savedObjectsClient, body);
|
return await saveApmIndices(savedObjectsClient, body);
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { getTransaction } from '../../lib/settings/custom_link/get_transaction';
|
||||||
import { listCustomLinks } from '../../lib/settings/custom_link/list_custom_links';
|
import { listCustomLinks } from '../../lib/settings/custom_link/list_custom_links';
|
||||||
import { createRoute } from '../create_route';
|
import { createRoute } from '../create_route';
|
||||||
|
|
||||||
export const customLinkTransactionRoute = createRoute((core) => ({
|
export const customLinkTransactionRoute = createRoute(() => ({
|
||||||
path: '/api/apm/settings/custom_links/transaction',
|
path: '/api/apm/settings/custom_links/transaction',
|
||||||
params: {
|
params: {
|
||||||
query: filterOptionsRt,
|
query: filterOptionsRt,
|
||||||
|
@ -31,7 +31,7 @@ export const customLinkTransactionRoute = createRoute((core) => ({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const listCustomLinksRoute = createRoute((core) => ({
|
export const listCustomLinksRoute = createRoute(() => ({
|
||||||
path: '/api/apm/settings/custom_links',
|
path: '/api/apm/settings/custom_links',
|
||||||
params: {
|
params: {
|
||||||
query: filterOptionsRt,
|
query: filterOptionsRt,
|
||||||
|
|
Loading…
Reference in a new issue