diff --git a/public/components/app.tsx b/public/components/app.tsx index 56356183f..625c4cfc2 100644 --- a/public/components/app.tsx +++ b/public/components/app.tsx @@ -28,7 +28,6 @@ interface ObservabilityAppDeps { pplService: any; dslService: any; savedObjects: any; - config: PublicConfig; timestampUtils: any; queryManager: QueryManager; startPage: string; @@ -60,7 +59,6 @@ export const App = ({ pplService, dslService, savedObjects, - config, timestampUtils, queryManager, startPage, @@ -94,7 +92,6 @@ export const App = ({ pplService={pplService} dslService={dslService} savedObjects={savedObjects} - config={config} timestampUtils={timestampUtils} queryManager={queryManager} parentBreadcrumb={parentBreadcrumb} diff --git a/public/components/index.tsx b/public/components/index.tsx index 5f5afcb80..b1ebf1211 100644 --- a/public/components/index.tsx +++ b/public/components/index.tsx @@ -10,7 +10,6 @@ import { AppMountParameters, CoreStart } from '../../../../src/core/public'; import { DataSourceManagementPluginSetup } from '../../../../src/plugins/data_source_management/public'; import { AppPluginStartDependencies } from '../types'; import { App } from './app'; -import { PublicConfig } from '../plugin'; export const Observability = ( CoreStartProp: CoreStart, @@ -24,8 +23,7 @@ export const Observability = ( startPage: string, dataSourcePluggables, dataSourceManagement: DataSourceManagementPluginSetup, - savedObjectsMDSClient: CoreStart['savedObjects'], - config: PublicConfig + savedObjectsMDSClient: CoreStart['savedObjects'] ) => { const { setHeaderActionMenu } = AppMountParametersProp; const { dataSource } = DepsStart; @@ -36,7 +34,6 @@ export const Observability = ( pplService={pplService} dslService={dslService} savedObjects={savedObjects} - config={config} timestampUtils={timestampUtils} queryManager={queryManager} startPage={startPage} diff --git a/public/components/trace_analytics/components/traces/trace_view.tsx b/public/components/trace_analytics/components/traces/trace_view.tsx index 6ef75ce7d..9d9f6b0b1 100644 --- a/public/components/trace_analytics/components/traces/trace_view.tsx +++ b/public/components/trace_analytics/components/traces/trace_view.tsx @@ -44,7 +44,7 @@ interface TraceViewProps extends TraceAnalyticsCoreDeps { dataSourceMDSId: DataSourceOption[]; dataSourceManagement: DataSourceManagementPluginSetup; setActionMenu: (menuMount: MountPoint | undefined) => void; - tenant?: string; + tenant?: string | undefined; } export function TraceView(props: TraceViewProps) { diff --git a/public/components/trace_analytics/home.tsx b/public/components/trace_analytics/home.tsx index 1d17a6e0a..330c4f866 100644 --- a/public/components/trace_analytics/home.tsx +++ b/public/components/trace_analytics/home.tsx @@ -20,7 +20,9 @@ import { DataSourceSelectableConfig, } from '../../../../../src/plugins/data_source_management/public'; import { DataSourceOption } from '../../../../../src/plugins/data_source_management/public/components/data_source_menu/types'; +import { coreRefs } from '../../framework/core_refs'; import { FilterType } from './components/common/filters/filters'; +import { loadTenantInfo } from './components/common/indices'; import { SearchBarProps } from './components/common/search_bar'; import { ServiceView, Services } from './components/services'; import { TraceView, Traces } from './components/traces'; @@ -29,8 +31,6 @@ import { handleJaegerIndicesExistRequest, } from './requests/request_handler'; import { TraceSideBar } from './trace_side_nav'; -import { loadTenantInfo } from './components/common/indices'; -import { PublicConfig } from '../../plugin'; export interface TraceAnalyticsCoreDeps { parentBreadcrumb: ChromeBreadcrumb; @@ -43,9 +43,7 @@ export interface TraceAnalyticsCoreDeps { savedObjectsMDSClient: SavedObjectsStart; } -interface HomeProps extends RouteComponentProps, TraceAnalyticsCoreDeps { - config: PublicConfig; -} +interface HomeProps extends RouteComponentProps, TraceAnalyticsCoreDeps {} export type TraceAnalyticsMode = 'jaeger' | 'data_prepper'; @@ -108,7 +106,7 @@ export const Home = (props: HomeProps) => { useEffect(() => { if (!tenantLoaded) - loadTenantInfo(props.http, props.config.multitenancy.enabled).then((tenant) => { + loadTenantInfo(props.http, coreRefs.traceMultitenancyEnabled!).then((tenant) => { setTenantLoaded(true); setTenantName(tenant); handleDataPrepperIndicesExistRequest( @@ -119,7 +117,7 @@ export const Home = (props: HomeProps) => { ); handleJaegerIndicesExistRequest(props.http, setJaegerIndicesExist, tenant); }); - }, [props.config.multitenancy.enabled, tenantLoaded, dataSourceMDSId]); + }, [coreRefs.traceMultitenancyEnabled!, tenantLoaded, dataSourceMDSId]); const modes = [ { id: 'jaeger', title: 'Jaeger', 'data-test-subj': 'jaeger-mode' }, diff --git a/public/components/trace_analytics/requests/request_handler.ts b/public/components/trace_analytics/requests/request_handler.ts index ca19d7f14..41aff3db0 100644 --- a/public/components/trace_analytics/requests/request_handler.ts +++ b/public/components/trace_analytics/requests/request_handler.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { getTenantIndexName } from '../../../../common/utils/tenant_index_name'; import { CoreStart } from '../../../../../../src/core/public'; import { DATA_PREPPER_INDEX_NAME, @@ -12,6 +11,7 @@ import { TRACE_ANALYTICS_DSL_ROUTE, TRACE_ANALYTICS_JAEGER_INDICES_ROUTE, } from '../../../../common/constants/trace_analytics'; +import { getTenantIndexName } from '../../../../common/utils/tenant_index_name'; import { TraceAnalyticsMode } from '../home'; export async function handleDslRequest( @@ -71,7 +71,7 @@ export async function handleDslRequest( export async function handleJaegerIndicesExistRequest( http: CoreStart['http'], - setJaegerIndicesExist, + setJaegerIndicesExist: (val: boolean) => void, dataSourceMDSId?: string, tenant?: string ) { @@ -91,7 +91,7 @@ export async function handleJaegerIndicesExistRequest( export async function handleDataPrepperIndicesExistRequest( http: CoreStart['http'], - setDataPrepperIndicesExist, + setDataPrepperIndicesExist: (val: boolean) => void, dataSourceMDSId?: string, tenant?: string ) { diff --git a/public/framework/core_refs.ts b/public/framework/core_refs.ts index b78240e01..4c8e45f62 100644 --- a/public/framework/core_refs.ts +++ b/public/framework/core_refs.ts @@ -30,6 +30,7 @@ class CoreRefs { public application?: ApplicationStart; public queryAssistEnabled?: boolean; public summarizeEnabled?: boolean; + public traceMultitenancyEnabled?: boolean; public dashboard?: DashboardStart; public dashboardProviders?: unknown; public overlays?: OverlayStart; diff --git a/public/plugin.tsx b/public/plugin.tsx index c7a46dd08..3b75867ac 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React from 'react'; -import { i18n } from '@osd/i18n'; import { htmlIdGenerator } from '@elastic/eui'; +import { i18n } from '@osd/i18n'; +import React from 'react'; import { AppCategory, AppMountParameters, @@ -97,14 +97,14 @@ import { SetupDependencies, } from './types'; -export interface PublicConfig { +interface PublicConfig { query_assist: { enabled: boolean; }; summarize: { enabled: boolean; }; - multitenancy: { + traceMultitenancy: { enabled: boolean; }; } @@ -269,8 +269,7 @@ export class ObservabilityPlugin startPage, dataSourcePluggables, // just pass down for now due to time constraint, later may better expose this as context dataSourceManagement, - coreStart.savedObjects, - this.config + coreStart.savedObjects ); }; @@ -403,6 +402,7 @@ export class ObservabilityPlugin coreRefs.dashboard = startDeps.dashboard; coreRefs.queryAssistEnabled = this.config.query_assist.enabled; coreRefs.summarizeEnabled = this.config.summarize.enabled; + coreRefs.traceMultitenancyEnabled = this.config.traceMultitenancy.enabled; coreRefs.overlays = core.overlays; coreRefs.dataSource = startDeps.dataSource; diff --git a/server/index.ts b/server/index.ts index 7be0b7261..113ac0956 100644 --- a/server/index.ts +++ b/server/index.ts @@ -21,7 +21,7 @@ const observabilityConfig = { summarize: schema.object({ enabled: schema.boolean({ defaultValue: false }), }), - multitenancy: schema.object({ + traceMultitenancy: schema.object({ enabled: schema.boolean({ defaultValue: false }), }), }), @@ -34,6 +34,6 @@ export const config: PluginConfigDescriptor = { exposeToBrowser: { query_assist: true, summarize: true, - multitenancy: true, + traceMultitenancy: true, }, }; diff --git a/server/routes/trace_analytics_dsl_router.ts b/server/routes/trace_analytics_dsl_router.ts index df7f18c43..23def5ea5 100644 --- a/server/routes/trace_analytics_dsl_router.ts +++ b/server/routes/trace_analytics_dsl_router.ts @@ -15,17 +15,15 @@ import { TRACE_ANALYTICS_DSL_ROUTE, TRACE_ANALYTICS_JAEGER_INDICES_ROUTE, } from '../../common/constants/trace_analytics'; -import { addRequestToMetric } from '../common/metrics/metrics_helper'; import { getTenantIndexName } from '../../common/utils/tenant_index_name'; +import { addRequestToMetric } from '../common/metrics/metrics_helper'; export function registerTraceAnalyticsDslRouter(router: IRouter, dataSourceEnabled: boolean) { router.post( { path: TRACE_ANALYTICS_DATA_PREPPER_INDICES_ROUTE, validate: { - body: schema.object({ - tenant: schema.maybe(schema.string()), - }), + body: schema.any(), query: schema.object({ dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), }), @@ -68,9 +66,7 @@ export function registerTraceAnalyticsDslRouter(router: IRouter, dataSourceEnabl { path: TRACE_ANALYTICS_JAEGER_INDICES_ROUTE, validate: { - body: schema.object({ - tenant: schema.maybe(schema.string()), - }), + body: schema.any(), query: schema.object({ dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })), }), @@ -148,7 +144,7 @@ export function registerTraceAnalyticsDslRouter(router: IRouter, dataSourceEnabl }, async (context, request, response) => { addRequestToMetric('trace_analytics', 'get', 'count'); - const { index, size, ...rest } = request.body; + const { index, size, tenant, ...rest } = request.body; const { dataSourceMDSId } = request.query; const params: RequestParams.Search = { index: index || getTenantIndexName(DATA_PREPPER_INDEX_NAME, tenant),