From 9e930c88d3af70f633e5f9238d4f326a94995cf7 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Wed, 21 Apr 2021 23:52:26 +0000 Subject: [PATCH 1/3] Add null check for service map query --- public/requests/services_request_handler.ts | 42 +++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/public/requests/services_request_handler.ts b/public/requests/services_request_handler.ts index d707a65..e3cb51a 100644 --- a/public/requests/services_request_handler.ts +++ b/public/requests/services_request_handler.ts @@ -37,21 +37,23 @@ export const handleServicesRequest = async ( const serviceObject: ServiceObject = await handleServiceMapRequest(http, DSL); if (setServiceMap) setServiceMap(serviceObject); return Promise.all( - response.aggregations.service.buckets.map((bucket) => { - const connectedServices = [ - ...serviceObject[bucket.key].targetServices, - ...serviceObject[bucket.key].destServices, - ]; - return { - name: bucket.key, - average_latency: serviceObject[bucket.key].latency, - error_rate: serviceObject[bucket.key].error_rate, - throughput: serviceObject[bucket.key].throughput, - traces: bucket.trace_count.value, - connected_services: connectedServices.join(', '), - number_of_connected_services: connectedServices.length, - }; - }) + response.aggregations.service.buckets + .filter((bucket) => serviceObject[bucket.key]) + .map((bucket) => { + const connectedServices = [ + ...serviceObject[bucket.key].targetServices, + ...serviceObject[bucket.key].destServices, + ]; + return { + name: bucket.key, + average_latency: serviceObject[bucket.key].latency, + error_rate: serviceObject[bucket.key].error_rate, + throughput: serviceObject[bucket.key].throughput, + traces: bucket.trace_count.value, + connected_services: connectedServices.join(', '), + number_of_connected_services: connectedServices.length, + }; + }) ); }) .then((newItems) => { @@ -100,10 +102,12 @@ export const handleServiceMapRequest = async (http, DSL, items?, setItems?, curr bucket.resource.buckets.map((resource) => { resource.domain.buckets.map((domain) => { const targetService = targets[resource.key + ':' + domain.key]; - if (map[bucket.key].targetServices.indexOf(targetService) === -1) - map[bucket.key].targetServices.push(targetService); - if (map[targetService].destServices.indexOf(bucket.key) === -1) - map[targetService].destServices.push(bucket.key); + if (targetService) { + if (map[bucket.key].targetServices.indexOf(targetService) === -1) + map[bucket.key].targetServices.push(targetService); + if (map[targetService].destServices.indexOf(bucket.key) === -1) + map[targetService].destServices.push(bucket.key); + } }); }); }) From e088f959fb22fec7e024ca28fb23a1556922eade Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Wed, 21 Apr 2021 23:52:51 +0000 Subject: [PATCH 2/3] Loop through filters when switching percentile filters --- public/components/dashboard/dashboard.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/public/components/dashboard/dashboard.tsx b/public/components/dashboard/dashboard.tsx index 43fd080..9e680b8 100644 --- a/public/components/dashboard/dashboard.tsx +++ b/public/components/dashboard/dashboard.tsx @@ -122,11 +122,17 @@ export function Dashboard(props: DashboardProps) { if (tableItems.length === 0 || Object.keys(percentileMap).length === 0) return; for (let i = 0; i < props.filters.length; i++) { if (props.filters[i].custom) { - const newFilter = JSON.parse( - JSON.stringify(props.filters[i]).replace( - /{"range":{"durationInNanos":{"[gl]te?"/g, - `{"range":{"durationInNanos":{"${condition}"` - ) + const newFilter = JSON.parse(JSON.stringify(props.filters[i])); + newFilter.custom.query.bool.should.forEach((should) => + should.bool.must.forEach((must) => { + const range = must?.range?.['traceGroupFields.durationInNanos']; + if (range) { + const duration = range.lt || range.lte || range.gt || range.gte; + must.range['traceGroupFields.durationInNanos'] = { + [condition]: duration, + }; + } + }) ); newFilter.value = condition === 'gte' ? '>= 95th' : '< 95th'; const newFilters = [...props.filters, ...additionalFilters]; From cf5ce8802f3df49e9a37c1b2add05cab6cfacaee Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Thu, 22 Apr 2021 16:17:46 +0000 Subject: [PATCH 3/3] Add check before changing percentile filter --- public/components/dashboard/dashboard.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/components/dashboard/dashboard.tsx b/public/components/dashboard/dashboard.tsx index 9e680b8..6f983f4 100644 --- a/public/components/dashboard/dashboard.tsx +++ b/public/components/dashboard/dashboard.tsx @@ -128,9 +128,11 @@ export function Dashboard(props: DashboardProps) { const range = must?.range?.['traceGroupFields.durationInNanos']; if (range) { const duration = range.lt || range.lte || range.gt || range.gte; - must.range['traceGroupFields.durationInNanos'] = { - [condition]: duration, - }; + if (duration || duration === 0) { + must.range['traceGroupFields.durationInNanos'] = { + [condition]: duration, + }; + } } }) );