Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version-decoupling for Observability #1953

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,18 +20,19 @@
} 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;
renderProps: RouteComponentProps<any, StaticContext, any>;

Check warning on line 35 in public/components/metrics/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 35 in public/components/metrics/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
pplService: PPLService;
savedObjects: SavedObjects;
setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => void;
Expand Down Expand Up @@ -82,6 +83,7 @@
dispatch(setSelectedDataSourceMDSId(id));
}, 300);
};

const DataSourceMenu = dataSourceManagement?.ui?.getDataSourceMenu<DataSourceSelectableConfig>();
const dataSourceMenuComponent = useMemo(() => {
return (
Expand All @@ -94,10 +96,11 @@
fullWidth: true,
// activeOption: dataSourceMDSId,
onSelectedDataSources: onSelectedDataSource,
dataSourceFilter: dataSourceFilterFn,
}}
/>
);
}, [setActionMenu, savedObjectsMDSClient.client, notifications]);

Check warning on line 103 in public/components/metrics/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useMemo has a missing dependency: 'onSelectedDataSource'. Either include it or remove the dependency array

return (
<>
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 @@
} 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 @@ -206,7 +207,7 @@
if (para.visSavedObjId !== '') setVisInput(JSON.parse(para.vizObjectInput));
fetchVisualizations();
}
}, [dataSourceMDSId]);

Check warning on line 210 in public/components/notebooks/components/paragraph_components/paragraphs.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'fetchVisualizations', 'para.isVizualisation', 'para.visSavedObjId', and 'para.vizObjectInput'. Either include them or remove the dependency array

const createDashboardVizObject = (objectId: string) => {
const vizUniqueId = htmlIdGenerator()();
Expand Down Expand Up @@ -549,6 +550,7 @@
setDataSourceMDSId(dataConnectionId);
handleSelectedDataSourceChange(dataConnectionId, dataConnectionLabel);
};

if (dataSourceEnabled) {
DataSourceSelector = dataSourceManagement.ui.DataSourceSelector;
}
Expand All @@ -569,6 +571,7 @@
{ 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 @@
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 { 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 All @@ -64,7 +65,7 @@

export function ServiceView(props: ServiceViewProps) {
const { mode, page, setCurrentSelectedService } = props;
const [fields, setFields] = useState<any>({});

Check warning on line 68 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [serviceMap, setServiceMap] = useState<ServiceObject>({});
const [serviceMapIdSelected, setServiceMapIdSelected] = useState<
'latency' | 'error_rate' | 'throughput'
Expand Down Expand Up @@ -260,6 +261,7 @@
componentConfig={{
activeOption: props.dataSourceMDSId,
fullWidth: true,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
Expand Down Expand Up @@ -382,12 +384,12 @@

const [currentSpan, setCurrentSpan] = useState('');
const storedFilters = sessionStorage.getItem('TraceAnalyticsSpanFilters');
const [spanFilters, setSpanFilters] = useState<Array<{ field: string; value: any }>>(

Check warning on line 387 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
storedFilters ? JSON.parse(storedFilters) : []
);
const [DSL, setDSL] = useState<any>({});

Check warning on line 390 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

const setSpanFiltersWithStorage = (newFilters: Array<{ field: string; value: any }>) => {

Check warning on line 392 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
setSpanFilters(newFilters);
sessionStorage.setItem('TraceAnalyticsSpanFilters', JSON.stringify(newFilters));
};
Expand Down Expand Up @@ -425,7 +427,7 @@
setDSL(spanDSL);
}, [props.startTime, props.endTime, props.serviceName, spanFilters]);

const addSpanFilter = (field: string, value: any) => {

Check warning on line 430 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const newFilters = [...spanFilters];
const index = newFilters.findIndex(({ field: filterField }) => field === filterField);
if (index === -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
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 { 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 All @@ -63,7 +64,7 @@
};
const DataSourceMenu = props.dataSourceManagement?.ui?.getDataSourceMenu<DataSourceViewConfig>();

const renderOverview = (fields: any) => {

Check warning on line 67 in public/components/trace_analytics/components/traces/trace_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
return (
<EuiPanel>
<PanelTitle title="Overview" />
Expand Down Expand Up @@ -260,6 +261,7 @@
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
Loading