Skip to content

Commit

Permalink
add guards for execution_hint
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 committed Sep 20, 2024
1 parent 15d3840 commit 0ba456b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
/* eslint-disable react-hooks/exhaustive-deps */

import datemath from '@elastic/datemath';
import {
EuiAccordion,
EuiFlexGroup,
Expand Down Expand Up @@ -154,6 +155,7 @@ export function TracesContent(props: TracesProps) {
processTimeStamp(endTime, mode),
page
);
const isUnderOneHour = datemath.parse(endTime)?.diff(datemath.parse(startTime), 'hours')! < 1;

if (mode === 'custom_data_prepper') {
// service map should not be filtered by service name
Expand All @@ -172,7 +174,8 @@ export function TracesContent(props: TracesProps) {
mode,
props.dataSourceMDSId[0].id,
sort,
tracesTableMode
tracesTableMode,
isUnderOneHour
);
else {
await handleTracesRequest(
Expand All @@ -183,7 +186,8 @@ export function TracesContent(props: TracesProps) {
setTableItems,
mode,
props.dataSourceMDSId[0].id,
sort
sort,
isUnderOneHour
);
}
await handleServiceMapRequest(
Expand All @@ -204,7 +208,8 @@ export function TracesContent(props: TracesProps) {
setTableItems,
mode,
props.dataSourceMDSId[0].id,
sort
sort,
isUnderOneHour
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export const getTraceGroupPercentilesQuery = () => {
export const getTracesQuery = (
mode: TraceAnalyticsMode,
traceId: string = '',
sort?: PropertySort
sort?: PropertySort,
isUnderOneHour?: boolean
) => {
const field = sort?.field || '_key';
const direction = sort?.direction || 'asc';
Expand All @@ -72,7 +73,7 @@ export const getTracesQuery = (
order: {
[field]: direction,
},
execution_hint: 'map',
...(isUnderOneHour && { execution_hint: 'map' }),
},
aggs: {
latency: {
Expand Down Expand Up @@ -139,7 +140,7 @@ export const getTracesQuery = (
order: {
[field]: direction,
},
execution_hint: 'map',
...(isUnderOneHour && { execution_hint: 'map' }),
},
aggs: {
latency: {
Expand Down Expand Up @@ -472,7 +473,8 @@ export const getCustomIndicesTracesQuery = (
mode: TraceAnalyticsMode,
traceId: string = '',
sort?: PropertySort,
queryMode?: TraceQueryMode
queryMode?: TraceQueryMode,
isUnderOneHour?: boolean
) => {
const jaegerQuery: any = {
size: 0,
Expand All @@ -492,7 +494,7 @@ export const getCustomIndicesTracesQuery = (
order: {
[sort?.field || '_key']: sort?.direction || 'asc',
},
execution_hint: 'map',
...(isUnderOneHour && { execution_hint: 'map' }),
},
aggs: {
latency: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ export const handleCustomIndicesTracesRequest = async (
mode: TraceAnalyticsMode,
dataSourceMDSId?: string,
sort?: PropertySort,
queryMode?: TraceQueryMode
queryMode?: TraceQueryMode,
isUnderOneHour?: boolean
) => {
const responsePromise = handleDslRequest(
http,
DSL,
getCustomIndicesTracesQuery(mode, undefined, sort, queryMode),
getCustomIndicesTracesQuery(mode, undefined, sort, queryMode, isUnderOneHour),
mode,
dataSourceMDSId
);
Expand Down Expand Up @@ -90,7 +91,8 @@ export const handleTracesRequest = async (
setItems: (items: any) => void,
mode: TraceAnalyticsMode,
dataSourceMDSId?: string,
sort?: PropertySort
sort?: PropertySort,
isUnderOneHour?: boolean
) => {
const binarySearch = (arr: number[], target: number) => {
if (!arr) return Number.NaN;
Expand All @@ -108,7 +110,7 @@ export const handleTracesRequest = async (
const responsePromise = handleDslRequest(
http,
DSL,
getTracesQuery(mode, undefined, sort),
getTracesQuery(mode, undefined, sort, isUnderOneHour),
mode,
dataSourceMDSId
);
Expand Down

0 comments on commit 0ba456b

Please sign in to comment.