Skip to content

Commit

Permalink
pass logger to QueryService to avoid npe
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <[email protected]>
  • Loading branch information
joshuali925 committed Oct 30, 2024
1 parent e587cb7 commit 42303b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ export class ObservabilityPlugin
core.savedObjects.registerType(integrationTemplateType);

// Register server side APIs
setupRoutes({ router, client: openSearchObservabilityClient, dataSourceEnabled });
setupRoutes({
router,
client: openSearchObservabilityClient,
dataSourceEnabled,
logger: this.logger,
});

core.savedObjects.registerType(getVisualizationSavedObject(dataSourceEnabled));
core.savedObjects.registerType(getSearchSavedObject(dataSourceEnabled));
Expand Down
6 changes: 4 additions & 2 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ILegacyClusterClient, IRouter } from '../../../../src/core/server';
import { ILegacyClusterClient, IRouter, Logger } from '../../../../src/core/server';
import { DSLFacet } from '../services/facets/dsl_facet';
import { PPLFacet } from '../services/facets/ppl_facet';
import SavedObjectFacet from '../services/facets/saved_objects';
Expand All @@ -30,10 +30,12 @@ export function setupRoutes({
router,
client,
dataSourceEnabled,
logger,
}: {
router: IRouter;
client: ILegacyClusterClient;
dataSourceEnabled: boolean;
logger: Logger;
}) {
PanelsRouter(router);
VisualizationsRouter(router);
Expand All @@ -49,7 +51,7 @@ export function setupRoutes({
registerParaRoute(router);
registerNoteRoute(router);
registerVizRoute(router, dataSourceEnabled);
const queryService = new QueryService(client);
const queryService = new QueryService(client, logger);
registerSqlRoute(router, queryService, dataSourceEnabled);

registerMetricsRoute(router, dataSourceEnabled);
Expand Down
3 changes: 2 additions & 1 deletion server/services/queryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import 'core-js/stable';
import _ from 'lodash';
import 'regenerator-runtime/runtime';
import { Logger } from '../../../../src/core/server';

export class QueryService {
private client: any;
constructor(client: any) {
constructor(client: any, private readonly logger: Logger) {
this.client = client;
}

Expand Down

0 comments on commit 42303b3

Please sign in to comment.