Skip to content

Commit

Permalink
[Type checks] Fix infra obs ui typecheck (elastic#167217)
Browse files Browse the repository at this point in the history
## 📓  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 <[email protected]>
  • Loading branch information
tonyghiani and Marco Antonio Ghiani authored Sep 26, 2023
1 parent 08d44fe commit 34c084d
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ export function MobileStats({
defaultMessage: 'Crash rate',
}),
icon: getIcon('bug'),
value: data?.currentPeriod?.crashRate?.value ?? NOT_AVAILABLE_LABEL,
value: data?.currentPeriod?.crashRate?.value ?? NaN,
valueFormatter: (value: number) =>
valueFormatter(Number((value * 100).toPrecision(2)), '%'),
trend: data?.currentPeriod?.crashRate?.timeseries,
Number.isNaN(value)
? NOT_AVAILABLE_LABEL
: valueFormatter(Number((value * 100).toPrecision(2)), '%'),
trend: data?.currentPeriod?.crashRate?.timeseries ?? [],
extra: getComparisonValueFormatter(data?.previousPeriod.crashRate?.value),
trendShape: MetricTrendShape.Area,
},
Expand All @@ -137,8 +139,9 @@ export function MobileStats({
defaultMessage: 'Sessions',
}),
icon: getIcon('timeslider'),
value: data?.currentPeriod?.sessions?.value ?? NOT_AVAILABLE_LABEL,
valueFormatter: (value: number) => valueFormatter(value),
value: data?.currentPeriod?.sessions?.value ?? NaN,
valueFormatter: (value: number) =>
Number.isNaN(value) ? NOT_AVAILABLE_LABEL : valueFormatter(value),
trend: data?.currentPeriod?.sessions?.timeseries,
extra: getComparisonValueFormatter(data?.previousPeriod.sessions?.value),
trendShape: MetricTrendShape.Area,
Expand All @@ -149,10 +152,11 @@ export function MobileStats({
defaultMessage: 'HTTP requests',
}),
icon: getIcon('kubernetesPod'),
value: data?.currentPeriod?.requests?.value ?? NOT_AVAILABLE_LABEL,
extra: getComparisonValueFormatter(data?.previousPeriod.requests?.value),
valueFormatter: (value: number) => valueFormatter(value),
trend: data?.currentPeriod?.requests?.timeseries,
value: data?.currentPeriod?.requests?.value ?? NaN,
valueFormatter: (value: number) =>
Number.isNaN(value) ? NOT_AVAILABLE_LABEL : valueFormatter(value),
trend: data?.currentPeriod?.requests?.timeseries ?? [],
trendShape: MetricTrendShape.Area,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function SummaryMetric({
loading: boolean;
hasData: boolean;
}) {
const xlFontSize = useEuiFontSize('xl', { measurement: 'px' });
const xlFontSize = useEuiFontSize('xl', { unit: 'px' });
const { euiTheme } = useEuiTheme();

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const apmRouter = {
} as ApmRouter;

const infraLocators = infraLocatorsMock;
const observabilityLogExplorerLocators = observabilityLogExplorerLocatorsMock;
const { allDatasetsLocator } = observabilityLogExplorerLocatorsMock;

const expectInfraLocatorsToBeCalled = () => {
expect(infraLocators.nodeLogsLocator.getRedirectUrl).toBeCalledTimes(3);
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Transaction action menu', () => {
location,
apmRouter,
infraLocators,
observabilityLogExplorerLocators,
allDatasetsLocator,
infraLinksAvailable: false,
rangeFrom: 'now-24h',
rangeTo: 'now',
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('Transaction action menu', () => {
location,
apmRouter,
infraLocators,
observabilityLogExplorerLocators,
allDatasetsLocator,
infraLinksAvailable: true,
rangeFrom: 'now-24h',
rangeTo: 'now',
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('Transaction action menu', () => {
location,
apmRouter,
infraLocators,
observabilityLogExplorerLocators,
allDatasetsLocator,
infraLinksAvailable: true,
rangeFrom: 'now-24h',
rangeTo: 'now',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ export const infraLocatorsMock: InfraLocators = {
nodeLogsLocator: sharePluginMock.createLocator(),
};

export const observabilityLogExplorerLocatorsMock = {
allDatasetsLocator: sharePluginMock.createLocator(),
singleDatasetLocator: sharePluginMock.createLocator(),
};

const mockCorePlugins = {
embeddable: {},
inspector: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const getApmErrorDocRoute = createApmServerRoute({
},
});

interface ApmServicesListItem {
export interface ApmServicesListItem {
'service.name': string;
'agent.name'?: string;
'transaction.type'?: string;
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/apm/server/routes/traces/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

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

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/typings/es_schemas/raw/error_raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { TimestampUs } from './fields/timestamp_us';
import { Url } from './fields/url';
import { User } from './fields/user';

interface Processor {
export interface Processor {
name: 'error';
event: 'error';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export { assetDetailsDashboards } from './asset_details';
export { hostsViewDashboards } from './hosts_view';
export { AVERAGE_SUBTITLE, METRICS_TOOLTIP } from './translations';
export { XY_MISSING_VALUE_DOTTED_LINE_CONFIG, KPI_CHART_HEIGHT } from './constants';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export const DatasetsPopover = ({
<EuiIcon type={iconType} />
) : hasIntegration ? (
<PackageIcon
packageName={parentIntegration.name}
version={parentIntegration.version}
packageName={parentIntegration.name ?? ''}
version={parentIntegration.version ?? '1.0.0'}
icons={parentIntegration.icons}
size="m"
tryApi
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/public/locator/use_ml_href.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
*/

import { DependencyList } from 'react';
import { MlPluginStart } from '..';
import { MlPluginSetup } from '..';
import { MlLocatorParams } from '../../common/types/locator';

/**
* Provides a URL to ML plugin page
* TODO remove basePath parameter
*/
export const useMlHref = (
ml: MlPluginStart | undefined,
ml: MlPluginSetup | undefined,
basePath: string | undefined,
params: MlLocatorParams,
dependencies?: DependencyList
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/observability_log_explorer/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
* 2.0.
*/

export { SingleDatasetLocatorDefinition, AllDatasetsLocatorDefinition } from './locators';
export {
type ObservabilityLogExplorerLocators,
SingleDatasetLocatorDefinition,
AllDatasetsLocatorDefinition,
} from './locators';

0 comments on commit 34c084d

Please sign in to comment.