Skip to content

Commit c024a48

Browse files
committed
Review feedback
1 parent 5bf33fd commit c024a48

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export class Plugin {
7171
);
7272

7373
// create static index pattern and store as saved object. Not needed by APM UI but for legacy reasons in Discover, Dashboard etc.
74-
createStaticIndexPattern(core.http);
74+
createStaticIndexPattern(core.http).catch(e => {
75+
// eslint-disable-next-line no-console
76+
console.log('Error fetching static index pattern', e);
77+
});
7578
}
7679
}

x-pack/legacy/plugins/apm/server/lib/apm_telemetry/index.ts

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

7-
import { Server } from 'hapi';
87
import { countBy } from 'lodash';
98
import { SavedObjectAttributes } from 'src/core/server';
109
import { isAgentName } from '../../../common/agent_name';
@@ -13,15 +12,7 @@ import {
1312
APM_SERVICES_TELEMETRY_SAVED_OBJECT_TYPE,
1413
APM_SERVICES_TELEMETRY_SAVED_OBJECT_ID
1514
} from '../../../common/apm_saved_object_constants';
16-
17-
type ServerWithUsageCollector = Server & {
18-
usage: {
19-
collectorSet: {
20-
makeUsageCollector: (options: unknown) => unknown;
21-
register: (options: unknown) => unknown;
22-
};
23-
};
24-
};
15+
import { APMLegacyServer } from '../../routes/typings';
2516

2617
export function createApmTelementry(
2718
agentNames: string[] = []
@@ -34,7 +25,7 @@ export function createApmTelementry(
3425
}
3526

3627
export async function storeApmServicesTelemetry(
37-
server: ServerWithUsageCollector,
28+
server: APMLegacyServer,
3829
apmTelemetry: SavedObjectAttributes
3930
) {
4031
try {
@@ -52,7 +43,7 @@ export async function storeApmServicesTelemetry(
5243
}
5344
}
5445

55-
export function makeApmUsageCollector(server: ServerWithUsageCollector) {
46+
export function makeApmUsageCollector(server: APMLegacyServer) {
5647
const apmUsageCollector = server.usage.collectorSet.makeUsageCollector({
5748
type: 'apm',
5849
fetch: async () => {

x-pack/legacy/plugins/apm/server/lib/helpers/saved_objects_client.ts

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

7-
import { Server } from 'hapi';
7+
import { APMLegacyServer } from '../../routes/typings';
88

9-
export function getInternalSavedObjectsClient(server: Server) {
9+
export function getInternalSavedObjectsClient(server: APMLegacyServer) {
1010
const { SavedObjectsClient, getSavedObjectsRepository } = server.savedObjects;
1111
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster(
1212
'admin'

x-pack/legacy/plugins/apm/server/routes/index_pattern.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import * as t from 'io-ts';
7-
import Boom from 'boom';
87
import { createStaticIndexPattern } from '../lib/index_pattern/create_static_index_pattern';
98
import { createRoute } from './create_route';
109
import { setupRequest } from '../lib/helpers/setup_request';
@@ -17,7 +16,7 @@ export const staticIndexPatternRoute = createRoute(() => ({
1716
await createStaticIndexPattern(setup, context);
1817

1918
// send empty response regardless of outcome
20-
throw Boom.notFound();
19+
return undefined;
2120
}
2221
}));
2322

x-pack/legacy/plugins/apm/server/routes/typings.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,26 @@ export interface Route<
4949
}) => Promise<TReturn>;
5050
}
5151

52+
export type APMLegacyServer = Pick<Server, 'usage' | 'savedObjects' | 'log'> & {
53+
usage: {
54+
collectorSet: {
55+
makeUsageCollector: (options: unknown) => unknown;
56+
register: (options: unknown) => unknown;
57+
};
58+
};
59+
plugins: {
60+
elasticsearch: Server['plugins']['elasticsearch'];
61+
};
62+
};
63+
5264
export type APMRequestHandlerContext<
5365
TDecodedParams extends { [key in keyof Params]: any } = {}
5466
> = RequestHandlerContext & {
5567
params: { query: { _debug: boolean } } & TDecodedParams;
5668
config: APMConfig;
5769
logger: Logger;
5870
__LEGACY: {
59-
server: Server;
71+
server: APMLegacyServer;
6072
};
6173
};
6274

0 commit comments

Comments
 (0)