Skip to content

Commit

Permalink
Version-decoupling for Observability (#1953)
Browse files Browse the repository at this point in the history
* Version-decoupling for Observability

Signed-off-by: sumukhswamy <[email protected]>

* added change for support of backend

Signed-off-by: sumukhswamy <[email protected]>

* added change for support of backend

Signed-off-by: sumukhswamy <[email protected]>

* added shared filter

Signed-off-by: sumukhswamy <[email protected]>

---------

Signed-off-by: sumukhswamy <[email protected]>
  • Loading branch information
sumukhswamy authored Jul 22, 2024
1 parent 0b472ec commit 9c25095
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 14 deletions.
13 changes: 13 additions & 0 deletions common/utils/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import semver from 'semver';
import { SavedObject } from '../../../../src/core/public';
import { DataSourceAttributes } from '../../../../src/plugins/data_source/common/data_sources';
import * as pluginManifest from '../../opensearch_dashboards.json';
import { coreRefs } from '../../public/framework/core_refs';

/**
Expand Down Expand Up @@ -62,3 +66,12 @@ export const basePathLink = (link: string): string => {
return link;
}
};

export const dataSourceFilterFn = (dataSource: SavedObject<DataSourceAttributes>) => {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || '';
const installedPlugins = dataSource?.attributes?.installedPlugins || [];
return (
semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) &&
pluginManifest.requiredOSDataSourcePlugins.every((plugin) => installedPlugins.includes(plugin))
);
};
5 changes: 4 additions & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
],
"configPath": [
"observability"
]
],
"supportedOSDataSourceVersions": ">=2.9.0",
"requiredOSDataSourcePlugins": ["opensearch-sql","opensearch-observability"]

}
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ exports[`Panels View Component render panel view container and refresh panel 1`]
class="euiToolTipAnchor"
>
<button
class="euiButton euiButton--primary euiSuperUpdateButton"
class="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
type="button"
>
Expand Down Expand Up @@ -734,7 +734,7 @@ exports[`Panels View Component render panel view so container and reload dashboa
class="euiToolTipAnchor"
>
<button
class="euiButton euiButton--primary euiSuperUpdateButton"
class="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
type="button"
>
Expand Down Expand Up @@ -2334,6 +2334,7 @@ exports[`Panels View Component renders panel view container with visualizations
className="euiSuperUpdateButton"
color="primary"
data-test-subj="superDatePickerApplyTimeButton"
fill={true}
iconType="refresh"
isDisabled={false}
isLoading={false}
Expand All @@ -2353,6 +2354,7 @@ exports[`Panels View Component renders panel view container with visualizations
data-test-subj="superDatePickerApplyTimeButton"
disabled={false}
element="button"
fill={true}
iconType="refresh"
isDisabled={false}
isLoading={false}
Expand All @@ -2367,7 +2369,7 @@ exports[`Panels View Component renders panel view container with visualizations
type="button"
>
<button
className="euiButton euiButton--primary euiSuperUpdateButton"
className="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
disabled={false}
onBlur={[Function]}
Expand Down Expand Up @@ -4579,6 +4581,7 @@ exports[`Panels View Component renders panel view container without visualizatio
className="euiSuperUpdateButton"
color="primary"
data-test-subj="superDatePickerApplyTimeButton"
fill={true}
iconType="refresh"
isDisabled={false}
isLoading={false}
Expand All @@ -4598,6 +4601,7 @@ exports[`Panels View Component renders panel view container without visualizatio
data-test-subj="superDatePickerApplyTimeButton"
disabled={false}
element="button"
fill={true}
iconType="refresh"
isDisabled={false}
isLoading={false}
Expand All @@ -4612,7 +4616,7 @@ exports[`Panels View Component renders panel view container without visualizatio
type="button"
>
<button
className="euiButton euiButton--primary euiSuperUpdateButton"
className="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
disabled={false}
onBlur={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ exports[`Panels View SO Component render panel view container and refresh panel
class="euiToolTipAnchor"
>
<button
class="euiButton euiButton--primary euiSuperUpdateButton"
class="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
type="button"
>
Expand Down Expand Up @@ -734,7 +734,7 @@ exports[`Panels View SO Component render panel view so container and reload dash
class="euiToolTipAnchor"
>
<button
class="euiButton euiButton--primary euiSuperUpdateButton"
class="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
type="button"
>
Expand Down Expand Up @@ -1167,7 +1167,7 @@ exports[`Panels View SO Component renders panels view SO container with visualiz
class="euiToolTipAnchor"
>
<button
class="euiButton euiButton--primary euiSuperUpdateButton"
class="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
type="button"
>
Expand Down
5 changes: 4 additions & 1 deletion public/components/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import {
} from '../../../../../src/plugins/data_source_management/public';
import { DataSourceOption } from '../../../../../src/plugins/data_source_management/public/components/data_source_menu/types';
import { OptionType } from '../../../common/types/metrics';
import { setNavBreadCrumbs } from '../../../common/utils/set_nav_bread_crumbs';
import { dataSourceFilterFn } from '../../../common/utils/shared';
import PPLService from '../../services/requests/ppl';
import SavedObjects from '../../services/saved_objects/event_analytics/saved_objects';
import './index.scss';
import { setSelectedDataSourceMDSId } from './redux/slices/metrics_slice';
import { Sidebar } from './sidebar/sidebar';
import { TopMenu } from './top_menu/top_menu';
import { MetricsGrid } from './view/metrics_grid';
import { setNavBreadCrumbs } from '../../../common/utils/set_nav_bread_crumbs';

interface MetricsProps {
parentBreadcrumb: ChromeBreadcrumb;
Expand Down Expand Up @@ -82,6 +83,7 @@ export const Home = ({
dispatch(setSelectedDataSourceMDSId(id));
}, 300);
};

const DataSourceMenu = dataSourceManagement?.ui?.getDataSourceMenu<DataSourceSelectableConfig>();
const dataSourceMenuComponent = useMemo(() => {
return (
Expand All @@ -94,6 +96,7 @@ export const Home = ({
fullWidth: true,
// activeOption: dataSourceMDSId,
onSelectedDataSources: onSelectedDataSource,
dataSourceFilter: dataSourceFilterFn,
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ exports[`Metrics Top Menu Component renders Top Menu Component when enabled 1`]
className="euiSuperUpdateButton"
color="primary"
data-test-subj="superDatePickerApplyTimeButton"
fill={true}
iconType="refresh"
isDisabled={false}
isLoading={false}
Expand All @@ -716,6 +717,7 @@ exports[`Metrics Top Menu Component renders Top Menu Component when enabled 1`]
data-test-subj="superDatePickerApplyTimeButton"
disabled={false}
element="button"
fill={true}
iconType="refresh"
isDisabled={false}
isLoading={false}
Expand All @@ -730,7 +732,7 @@ exports[`Metrics Top Menu Component renders Top Menu Component when enabled 1`]
type="button"
>
<button
className="euiButton euiButton--primary euiSuperUpdateButton"
className="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
data-test-subj="superDatePickerApplyTimeButton"
disabled={false}
onBlur={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
} from '../../../../../common/constants/shared';
import { ParaType } from '../../../../../common/types/notebooks';
import { uiSettingsService } from '../../../../../common/utils';
import { dataSourceFilterFn } from '../../../../../common/utils/shared';
import PPLService from '../../../../services/requests/ppl';
import { SavedObjectsActions } from '../../../../services/saved_objects/saved_object_client/saved_objects_actions';
import { ObservabilitySavedVisualization } from '../../../../services/saved_objects/saved_object_client/types';
Expand Down Expand Up @@ -549,6 +550,7 @@ export const Paragraphs = forwardRef((props: ParagraphProps, ref) => {
setDataSourceMDSId(dataConnectionId);
handleSelectedDataSourceChange(dataConnectionId, dataConnectionLabel);
};

if (dataSourceEnabled) {
DataSourceSelector = dataSourceManagement.ui.DataSourceSelector;
}
Expand All @@ -569,6 +571,7 @@ export const Paragraphs = forwardRef((props: ParagraphProps, ref) => {
{ id: paradataSourceMDSId, label: dataSourceMDSLabel },
]
}
dataSourceFilter={dataSourceFilterFn}
/>
)}
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
DEFAULT_DATA_SOURCE_TYPE,
} from '../../../../../common/constants/data_sources';
import { observabilityLogsID } from '../../../../../common/constants/shared';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';
import { dataSourceFilterFn } from '../../../../../common/utils/shared';
import { coreRefs } from '../../../../framework/core_refs';
import { TraceAnalyticsComponentDeps } from '../../home';
import {
Expand All @@ -50,7 +52,6 @@ import { SearchBarProps, renderDatePicker } from '../common/search_bar';
import { SpanDetailFlyout } from '../traces/span_detail_flyout';
import { SpanDetailTable } from '../traces/span_detail_table';
import { ServiceMetrics } from './service_metrics';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';

interface ServiceViewProps extends TraceAnalyticsComponentDeps {
serviceName: string;
Expand Down Expand Up @@ -260,6 +261,7 @@ export function ServiceView(props: ServiceViewProps) {
componentConfig={{
activeOption: props.dataSourceMDSId,
fullWidth: true,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
DataSourceViewConfig,
} from '../../../../../../../src/plugins/data_source_management/public';
import { DataSourceOption } from '../../../../../../../src/plugins/data_source_management/public/components/data_source_menu/types';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';
import { dataSourceFilterFn } from '../../../../../common/utils/shared';
import { TraceAnalyticsCoreDeps, TraceAnalyticsMode } from '../../home';
import { handleServiceMapRequest } from '../../requests/services_request_handler';
import {
Expand All @@ -37,7 +39,6 @@ import { PanelTitle, filtersToDsl, processTimeStamp } from '../common/helper_fun
import { ServiceMap, ServiceObject } from '../common/plots/service_map';
import { ServiceBreakdownPanel } from './service_breakdown_panel';
import { SpanDetailPanel } from './span_detail_panel';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';

interface TraceViewProps extends TraceAnalyticsCoreDeps {
traceId: string;
Expand Down Expand Up @@ -260,6 +261,7 @@ export function TraceView(props: TraceViewProps) {
componentConfig={{
activeOption: props.dataSourceMDSId,
fullWidth: true,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import { EuiAccordion, EuiPanel, EuiSpacer, PropertySort } from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import { DataSourceViewConfig } from '../../../../../../../src/plugins/data_source_management/public';
import { dataSourceFilterFn } from '../../../../../common/utils/shared';
import { coreRefs } from '../../../../framework/core_refs';
import { handleTracesRequest } from '../../requests/traces_request_handler';
import { getValidFilterFields } from '../common/filters/filter_helpers';
import { filtersToDsl, processTimeStamp } from '../common/helper_functions';
import { SearchBar } from '../common/search_bar';
import { DashboardContent } from '../dashboard/dashboard_content';
import { TracesProps } from './traces';
import { TracesTable } from './traces_table';
import { coreRefs } from '../../../../framework/core_refs';

export function TracesContent(props: TracesProps) {
const {
Expand Down Expand Up @@ -120,6 +121,7 @@ export function TracesContent(props: TracesProps) {
componentConfig={{
activeOption: dataSourceMDSId,
fullWidth: true,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
Expand Down
4 changes: 3 additions & 1 deletion public/components/trace_analytics/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { EuiGlobalToastList } from '@elastic/eui';
import { Toast } from '@elastic/eui/src/components/toast/global_toast_list';
import React, { ReactChild, useEffect, useState } from 'react';
import { HashRouter, Route, RouteComponentProps, Redirect } from 'react-router-dom';
import { HashRouter, Redirect, Route, RouteComponentProps } from 'react-router-dom';
import {
ChromeBreadcrumb,
ChromeStart,
Expand All @@ -21,6 +21,7 @@ import {
} from '../../../../../src/plugins/data_source_management/public';
import { DataSourceOption } from '../../../../../src/plugins/data_source_management/public/components/data_source_menu/types';
import { DATA_PREPPER_INDEX_NAME } from '../../../common/constants/trace_analytics';
import { dataSourceFilterFn } from '../../../common/utils/shared';
import { coreRefs } from '../../framework/core_refs';
import { FilterType } from './components/common/filters/filters';
import { getAttributes } from './components/common/helper_functions';
Expand Down Expand Up @@ -283,6 +284,7 @@ export const Home = (props: HomeProps) => {
fullWidth: true,
activeOption: dataSourceMDSId,
onSelectedDataSources: onSelectedDataSource,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
Expand Down

0 comments on commit 9c25095

Please sign in to comment.