[Type checks] Fix infra obs ui typecheck (#167217)

## 📓  Summary

These changes fix the type-check issues related to infra obs UI code.
It also includes some fixes for the APM plugin that were stopping the
check step from passing.

---------

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
This commit is contained in:
Marco Antonio Ghiani 2023-09-26 17:05:54 +02:00 committed by GitHub
parent 08d44fe52b
commit 34c084d65a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 36 additions and 20 deletions

View file

@ -110,10 +110,12 @@ export function MobileStats({
defaultMessage: 'Crash rate', defaultMessage: 'Crash rate',
}), }),
icon: getIcon('bug'), icon: getIcon('bug'),
value: data?.currentPeriod?.crashRate?.value ?? NOT_AVAILABLE_LABEL, value: data?.currentPeriod?.crashRate?.value ?? NaN,
valueFormatter: (value: number) => valueFormatter: (value: number) =>
valueFormatter(Number((value * 100).toPrecision(2)), '%'), Number.isNaN(value)
trend: data?.currentPeriod?.crashRate?.timeseries, ? NOT_AVAILABLE_LABEL
: valueFormatter(Number((value * 100).toPrecision(2)), '%'),
trend: data?.currentPeriod?.crashRate?.timeseries ?? [],
extra: getComparisonValueFormatter(data?.previousPeriod.crashRate?.value), extra: getComparisonValueFormatter(data?.previousPeriod.crashRate?.value),
trendShape: MetricTrendShape.Area, trendShape: MetricTrendShape.Area,
}, },
@ -137,8 +139,9 @@ export function MobileStats({
defaultMessage: 'Sessions', defaultMessage: 'Sessions',
}), }),
icon: getIcon('timeslider'), icon: getIcon('timeslider'),
value: data?.currentPeriod?.sessions?.value ?? NOT_AVAILABLE_LABEL, value: data?.currentPeriod?.sessions?.value ?? NaN,
valueFormatter: (value: number) => valueFormatter(value), valueFormatter: (value: number) =>
Number.isNaN(value) ? NOT_AVAILABLE_LABEL : valueFormatter(value),
trend: data?.currentPeriod?.sessions?.timeseries, trend: data?.currentPeriod?.sessions?.timeseries,
extra: getComparisonValueFormatter(data?.previousPeriod.sessions?.value), extra: getComparisonValueFormatter(data?.previousPeriod.sessions?.value),
trendShape: MetricTrendShape.Area, trendShape: MetricTrendShape.Area,
@ -149,10 +152,11 @@ export function MobileStats({
defaultMessage: 'HTTP requests', defaultMessage: 'HTTP requests',
}), }),
icon: getIcon('kubernetesPod'), icon: getIcon('kubernetesPod'),
value: data?.currentPeriod?.requests?.value ?? NOT_AVAILABLE_LABEL,
extra: getComparisonValueFormatter(data?.previousPeriod.requests?.value), extra: getComparisonValueFormatter(data?.previousPeriod.requests?.value),
valueFormatter: (value: number) => valueFormatter(value), value: data?.currentPeriod?.requests?.value ?? NaN,
trend: data?.currentPeriod?.requests?.timeseries, valueFormatter: (value: number) =>
Number.isNaN(value) ? NOT_AVAILABLE_LABEL : valueFormatter(value),
trend: data?.currentPeriod?.requests?.timeseries ?? [],
trendShape: MetricTrendShape.Area, trendShape: MetricTrendShape.Area,
}, },
]; ];

View file

@ -205,7 +205,7 @@ function SummaryMetric({
loading: boolean; loading: boolean;
hasData: boolean; hasData: boolean;
}) { }) {
const xlFontSize = useEuiFontSize('xl', { measurement: 'px' }); const xlFontSize = useEuiFontSize('xl', { unit: 'px' });
const { euiTheme } = useEuiTheme(); const { euiTheme } = useEuiTheme();
return ( return (

View file

@ -25,7 +25,7 @@ const apmRouter = {
} as ApmRouter; } as ApmRouter;
const infraLocators = infraLocatorsMock; const infraLocators = infraLocatorsMock;
const observabilityLogExplorerLocators = observabilityLogExplorerLocatorsMock; const { allDatasetsLocator } = observabilityLogExplorerLocatorsMock;
const expectInfraLocatorsToBeCalled = () => { const expectInfraLocatorsToBeCalled = () => {
expect(infraLocators.nodeLogsLocator.getRedirectUrl).toBeCalledTimes(3); expect(infraLocators.nodeLogsLocator.getRedirectUrl).toBeCalledTimes(3);
@ -65,7 +65,7 @@ describe('Transaction action menu', () => {
location, location,
apmRouter, apmRouter,
infraLocators, infraLocators,
observabilityLogExplorerLocators, allDatasetsLocator,
infraLinksAvailable: false, infraLinksAvailable: false,
rangeFrom: 'now-24h', rangeFrom: 'now-24h',
rangeTo: 'now', rangeTo: 'now',
@ -131,7 +131,7 @@ describe('Transaction action menu', () => {
location, location,
apmRouter, apmRouter,
infraLocators, infraLocators,
observabilityLogExplorerLocators, allDatasetsLocator,
infraLinksAvailable: true, infraLinksAvailable: true,
rangeFrom: 'now-24h', rangeFrom: 'now-24h',
rangeTo: 'now', rangeTo: 'now',
@ -216,7 +216,7 @@ describe('Transaction action menu', () => {
location, location,
apmRouter, apmRouter,
infraLocators, infraLocators,
observabilityLogExplorerLocators, allDatasetsLocator,
infraLinksAvailable: true, infraLinksAvailable: true,
rangeFrom: 'now-24h', rangeFrom: 'now-24h',
rangeTo: 'now', rangeTo: 'now',

View file

@ -132,6 +132,11 @@ export const infraLocatorsMock: InfraLocators = {
nodeLogsLocator: sharePluginMock.createLocator(), nodeLogsLocator: sharePluginMock.createLocator(),
}; };
export const observabilityLogExplorerLocatorsMock = {
allDatasetsLocator: sharePluginMock.createLocator(),
singleDatasetLocator: sharePluginMock.createLocator(),
};
const mockCorePlugins = { const mockCorePlugins = {
embeddable: {}, embeddable: {},
inspector: {}, inspector: {},

View file

@ -191,7 +191,7 @@ const getApmErrorDocRoute = createApmServerRoute({
}, },
}); });
interface ApmServicesListItem { export interface ApmServicesListItem {
'service.name': string; 'service.name': string;
'agent.name'?: string; 'agent.name'?: string;
'transaction.type'?: string; 'transaction.type'?: string;

View file

@ -5,6 +5,7 @@
* 2.0. * 2.0.
*/ */
import { loggerMock } from '@kbn/logging-mocks';
import { getTraceItems } from './get_trace_items'; import { getTraceItems } from './get_trace_items';
import { import {
SearchParamsMock, SearchParamsMock,
@ -26,6 +27,7 @@ describe('trace queries', () => {
apmEventClient: mockApmEventClient, apmEventClient: mockApmEventClient,
start: 0, start: 0,
end: 50000, end: 50000,
logger: loggerMock.create(),
}) })
); );

View file

@ -18,7 +18,7 @@ import { TimestampUs } from './fields/timestamp_us';
import { Url } from './fields/url'; import { Url } from './fields/url';
import { User } from './fields/user'; import { User } from './fields/user';
interface Processor { export interface Processor {
name: 'error'; name: 'error';
event: 'error'; event: 'error';
} }

View file

@ -9,3 +9,4 @@ export { assetDetailsDashboards } from './asset_details';
export { hostsViewDashboards } from './hosts_view'; export { hostsViewDashboards } from './hosts_view';
export { AVERAGE_SUBTITLE, METRICS_TOOLTIP } from './translations'; export { AVERAGE_SUBTITLE, METRICS_TOOLTIP } from './translations';
export { XY_MISSING_VALUE_DOTTED_LINE_CONFIG, KPI_CHART_HEIGHT } from './constants'; export { XY_MISSING_VALUE_DOTTED_LINE_CONFIG, KPI_CHART_HEIGHT } from './constants';
export * from './types';

View file

@ -57,8 +57,8 @@ export const DatasetsPopover = ({
<EuiIcon type={iconType} /> <EuiIcon type={iconType} />
) : hasIntegration ? ( ) : hasIntegration ? (
<PackageIcon <PackageIcon
packageName={parentIntegration.name} packageName={parentIntegration.name ?? ''}
version={parentIntegration.version} version={parentIntegration.version ?? '1.0.0'}
icons={parentIntegration.icons} icons={parentIntegration.icons}
size="m" size="m"
tryApi tryApi

View file

@ -6,7 +6,7 @@
*/ */
import { DependencyList } from 'react'; import { DependencyList } from 'react';
import { MlPluginStart } from '..'; import { MlPluginSetup } from '..';
import { MlLocatorParams } from '../../common/types/locator'; import { MlLocatorParams } from '../../common/types/locator';
/** /**
@ -14,7 +14,7 @@ import { MlLocatorParams } from '../../common/types/locator';
* TODO remove basePath parameter * TODO remove basePath parameter
*/ */
export const useMlHref = ( export const useMlHref = (
ml: MlPluginStart | undefined, ml: MlPluginSetup | undefined,
basePath: string | undefined, basePath: string | undefined,
params: MlLocatorParams, params: MlLocatorParams,
dependencies?: DependencyList dependencies?: DependencyList

View file

@ -5,4 +5,8 @@
* 2.0. * 2.0.
*/ */
export { SingleDatasetLocatorDefinition, AllDatasetsLocatorDefinition } from './locators'; export {
type ObservabilityLogExplorerLocators,
SingleDatasetLocatorDefinition,
AllDatasetsLocatorDefinition,
} from './locators';