From a9610dae9cacdb7bb6f2ef937719f3749187c1bc Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Thu, 23 Jan 2025 16:41:54 -0800 Subject: [PATCH] Remove redundant traces call for related services (#2315) * remove traces call for related services Signed-off-by: Shenoy Pratik * remove call and update the number of traces to 500 Signed-off-by: Shenoy Pratik * update snapshots Signed-off-by: Shenoy Pratik --------- Signed-off-by: Shenoy Pratik --- common/constants/trace_analytics.ts | 2 +- .../__snapshots__/log_config.test.tsx.snap | 4 +++ .../service_config.test.tsx.snap | 4 +++ .../__snapshots__/trace_config.test.tsx.snap | 4 +++ .../custom_panel_view.test.tsx.snap | 8 ++++++ .../__snapshots__/panel_grid.test.tsx.snap | 2 ++ .../__snapshots__/metrics_grid.test.tsx.snap | 4 +++ .../__snapshots__/dashboard.test.tsx.snap | 12 +++++++++ .../__snapshots__/services.test.tsx.snap | 12 +++++++++ .../__snapshots__/traces.test.tsx.snap | 12 +++++++++ .../requests/services_request_handler.ts | 27 +------------------ 11 files changed, 64 insertions(+), 27 deletions(-) diff --git a/common/constants/trace_analytics.ts b/common/constants/trace_analytics.ts index 5574bf2bea..85dafdf851 100644 --- a/common/constants/trace_analytics.ts +++ b/common/constants/trace_analytics.ts @@ -12,7 +12,7 @@ export const TRACE_ANALYTICS_PLOTS_DATE_FORMAT = 'MMM D, YYYY HH:mm:ss.SSS'; export const SERVICE_MAP_MAX_NODES = 500; // size limit when requesting edge related queries, not necessarily the number of edges export const SERVICE_MAP_MAX_EDGES = 1000; -export const TRACES_MAX_NUM = 3000; +export const TRACES_MAX_NUM = 500; export const TRACE_ANALYTICS_DOCUMENTATION_LINK = 'https://opensearch.org/docs/latest/observability-plugin/trace/index/'; diff --git a/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap b/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap index 4422eb9c1f..7f61082163 100644 --- a/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap +++ b/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap @@ -90,10 +90,12 @@ exports[`Log Config component renders empty log config 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -760,10 +762,12 @@ exports[`Log Config component renders with query 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap b/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap index b564b3c452..04212cded9 100644 --- a/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap +++ b/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap @@ -90,10 +90,12 @@ exports[`Service Config component renders empty service config 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -1454,10 +1456,12 @@ exports[`Service Config component renders with one service selected 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap b/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap index 08c6d45525..9b0224b6e6 100644 --- a/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap +++ b/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap @@ -89,10 +89,12 @@ exports[`Trace Config component renders empty trace config 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -1015,10 +1017,12 @@ exports[`Trace Config component renders with one trace selected 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap b/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap index 34346b53c9..919589a70d 100644 --- a/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap +++ b/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap @@ -1237,10 +1237,12 @@ exports[`Panels View Component renders panel view container with visualizations "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -3144,10 +3146,12 @@ exports[`Panels View Component renders panel view container with visualizations "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -3605,10 +3609,12 @@ exports[`Panels View Component renders panel view container without visualizatio "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -5396,10 +5402,12 @@ exports[`Panels View Component renders panel view container without visualizatio "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap b/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap index 7562b58210..b8818b70cb 100644 --- a/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap +++ b/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap @@ -247,10 +247,12 @@ exports[`Panel Grid Component renders panel grid component with empty visualizat "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap b/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap index cb4832d470..69529db465 100644 --- a/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap +++ b/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap @@ -100,10 +100,12 @@ exports[`Metrics Grid Component renders Metrics Grid Component 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -277,10 +279,12 @@ exports[`Metrics Grid Component renders Metrics Grid Component 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap b/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap index a4f6cde404..f0ff25358c 100644 --- a/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap +++ b/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap @@ -103,10 +103,12 @@ exports[`Dashboard component renders dashboard 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -496,10 +498,12 @@ exports[`Dashboard component renders dashboard 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -1361,10 +1365,12 @@ exports[`Dashboard component renders empty dashboard 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -1753,10 +1759,12 @@ exports[`Dashboard component renders empty dashboard 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -2618,10 +2626,12 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -3012,10 +3022,12 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap b/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap index d6c8a0dbaf..e83665e6cd 100644 --- a/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap +++ b/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap @@ -103,10 +103,12 @@ exports[`Services component renders empty services page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -334,10 +336,12 @@ exports[`Services component renders empty services page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -2543,10 +2547,12 @@ exports[`Services component renders jaeger services page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -2774,10 +2780,12 @@ exports[`Services component renders jaeger services page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -4245,10 +4253,12 @@ exports[`Services component renders services page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -4475,10 +4485,12 @@ exports[`Services component renders services page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap index c9f184bbfe..f164ba6959 100644 --- a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap +++ b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap @@ -103,10 +103,12 @@ exports[`Traces component renders empty traces page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -343,10 +345,12 @@ exports[`Traces component renders empty traces page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -2554,10 +2558,12 @@ exports[`Traces component renders jaeger traces page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -2794,10 +2800,12 @@ exports[`Traces component renders jaeger traces page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -4845,10 +4853,12 @@ exports[`Traces component renders traces page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { @@ -5084,10 +5094,12 @@ exports[`Traces component renders traces page 1`] = ` "getCenter$": [MockFunction], "getLeft$": [MockFunction], "getLeftBottom$": [MockFunction], + "getPrimaryHeaderRight$": [MockFunction], "getRight$": [MockFunction], "registerCenter": [MockFunction], "registerLeft": [MockFunction], "registerLeftBottom": [MockFunction], + "registerPrimaryHeaderRight": [MockFunction], "registerRight": [MockFunction], }, "navGroup": Object { diff --git a/public/components/trace_analytics/requests/services_request_handler.ts b/public/components/trace_analytics/requests/services_request_handler.ts index 7aa8486063..4480da4b44 100644 --- a/public/components/trace_analytics/requests/services_request_handler.ts +++ b/public/components/trace_analytics/requests/services_request_handler.ts @@ -11,10 +11,10 @@ import DSLService from 'public/services/requests/dsl'; import { HttpSetup, HttpStart } from '../../../../../../src/core/public'; import { TRACE_ANALYTICS_PLOTS_DATE_FORMAT } from '../../../../common/constants/trace_analytics'; import { ServiceTrends, TraceAnalyticsMode } from '../../../../common/types/trace_analytics'; +import { coreRefs } from '../../../../public/framework/core_refs'; import { fixedIntervalToMilli } from '../components/common/helper_functions'; import { ServiceObject } from '../components/common/plots/service_map'; import { - getRelatedServicesQuery, getServiceEdgesQuery, getServiceMetricsQuery, getServiceNodesQuery, @@ -22,7 +22,6 @@ import { getServiceTrendsQuery, } from './queries/services_queries'; import { handleDslRequest } from './request_handler'; -import { coreRefs } from '../../../../public/framework/core_refs'; export const handleServicesRequest = async ( http: HttpSetup, @@ -197,30 +196,6 @@ export const handleServiceMapRequest = async ( } } - if (currService) { - await handleDslRequest(http, DSL, getRelatedServicesQuery(currService), mode, dataSourceMDSId) - .then((response) => - response.aggregations.traces.buckets.filter((bucket: any) => bucket.service.doc_count > 0) - ) - .then((filteredBuckets) => { - const maxNumServices = Object.keys(map).length; - const relatedServices = new Set(); - - // Iterate through the filtered trace buckets - for (let i = 0; i < filteredBuckets.length; i++) { - // Add the current service name to the related services - relatedServices.add(filteredBuckets[i].key); - if (relatedServices.size === maxNumServices) break; - } - - // Add the related services to the map for the current service - map[currService].relatedServices = [...relatedServices]; - }) - .catch((error) => { - console.error('Error retrieving related services:', error); - }); - } - if (setItems) setItems(map); return map; };