Skip to content

Commit 8baaa5e

Browse files
committed
adding processor event in the query, and refactoring theme
1 parent 9a92fae commit 8baaa5e

File tree

5 files changed

+47
-12
lines changed

5 files changed

+47
-12
lines changed

x-pack/plugins/apm/public/plugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
fetchLandingPageData,
4343
hasData,
4444
} from './services/rest/observability_dashboard';
45+
import { getTheme } from './utils/get_theme';
4546

4647
export type ApmPluginSetup = void;
4748
export type ApmPluginStart = void;
@@ -78,11 +79,13 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
7879
pluginSetupDeps.home.featureCatalogue.register(featureCatalogueEntry);
7980

8081
if (plugins.observability) {
81-
const isDarkMode = core.uiSettings.get('theme:darkMode');
82+
const theme = getTheme({
83+
isDarkMode: core.uiSettings.get('theme:darkMode'),
84+
});
8285
plugins.observability.dashboard.register({
8386
appName: 'apm',
8487
fetchData: async (params) => {
85-
return fetchLandingPageData(params, { isDarkMode });
88+
return fetchLandingPageData(params, { theme });
8689
},
8790
hasData,
8891
});

x-pack/plugins/apm/public/services/rest/observability.dashboard.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import { fetchLandingPageData, hasData } from './observability_dashboard';
88
import * as createCallApmApi from './createCallApmApi';
9+
import { getTheme } from '../../utils/get_theme';
10+
11+
const theme = getTheme({ isDarkMode: false });
912

1013
describe('Observability dashboard data', () => {
1114
const callApmApiMock = jest.spyOn(createCallApmApi, 'callApmApi');
@@ -43,7 +46,7 @@ describe('Observability dashboard data', () => {
4346
endTime: '2',
4447
bucketSize: '3',
4548
},
46-
{ isDarkMode: false }
49+
{ theme }
4750
);
4851
expect(response).toEqual({
4952
title: 'APM',
@@ -85,7 +88,7 @@ describe('Observability dashboard data', () => {
8588
endTime: '2',
8689
bucketSize: '3',
8790
},
88-
{ isDarkMode: false }
91+
{ theme }
8992
);
9093
expect(response).toEqual({
9194
title: 'APM',

x-pack/plugins/apm/public/services/rest/observability_dashboard.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@
66

77
import { i18n } from '@kbn/i18n';
88
import { sum } from 'lodash';
9-
import lightTheme from '@elastic/eui/dist/eui_theme_light.json';
10-
import darkTheme from '@elastic/eui/dist/eui_theme_dark.json';
119
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
1210
import { FetchDataParams } from '../../../../observability/public/data_handler';
1311
import { ApmFetchDataResponse } from '../../../../observability/public/typings/fetch_data_response';
1412
import { callApmApi } from './createCallApmApi';
13+
import { Theme } from '../../utils/get_theme';
1514

1615
interface Options {
17-
isDarkMode: boolean;
16+
theme: Theme;
1817
}
1918

2019
export const fetchLandingPageData = async (
2120
{ startTime, endTime, bucketSize }: FetchDataParams,
22-
{ isDarkMode }: Options
21+
{ theme }: Options
2322
): Promise<ApmFetchDataResponse> => {
24-
const theme = isDarkMode ? darkTheme : lightTheme;
25-
2623
const data = await callApmApi({
2724
pathname: '/api/apm/observability_dashboard',
2825
params: { query: { start: startTime, end: endTime, bucketSize } },
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
import lightTheme from '@elastic/eui/dist/eui_theme_light.json';
7+
import darkTheme from '@elastic/eui/dist/eui_theme_dark.json';
8+
9+
export type Theme = ReturnType<typeof getTheme>;
10+
11+
export function getTheme({ isDarkMode }: { isDarkMode: boolean }) {
12+
return isDarkMode ? darkTheme : lightTheme;
13+
}

x-pack/plugins/apm/server/lib/observability_dashboard/get_service_count.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { ProcessorEvent } from '../../../common/processor_event';
78
import { rangeFilter } from '../../../common/utils/range_filter';
8-
import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames';
9+
import {
10+
SERVICE_NAME,
11+
PROCESSOR_EVENT,
12+
} from '../../../common/elasticsearch_fieldnames';
913
import { Setup, SetupTimeRange } from '../helpers/setup_request';
1014

1115
export async function getServiceCount({
@@ -23,7 +27,22 @@ export async function getServiceCount({
2327
],
2428
body: {
2529
size: 0,
26-
query: { bool: { filter: [{ range: rangeFilter(start, end) }] } },
30+
query: {
31+
bool: {
32+
filter: [
33+
{ range: rangeFilter(start, end) },
34+
{
35+
terms: {
36+
[PROCESSOR_EVENT]: [
37+
ProcessorEvent.error,
38+
ProcessorEvent.transaction,
39+
ProcessorEvent.metric,
40+
],
41+
},
42+
},
43+
],
44+
},
45+
},
2746
aggs: { serviceCount: { cardinality: { field: SERVICE_NAME } } },
2847
},
2948
};

0 commit comments

Comments
 (0)