-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update mobile filters to include new fields
- Loading branch information
Showing
5 changed files
with
84 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
...ic/components/app/service_overview/service_overview_charts/latency_map/use_map_filters.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../components/app/service_overview/service_overview_charts/use_filters_for_mobile_charts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { useMemo } from 'react'; | ||
import { type QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; | ||
import { isNil, isEmpty } from 'lodash'; | ||
import { ProcessorEvent } from '@kbn/observability-plugin/common'; | ||
import { environmentQuery } from '../../../../../common/utils/environment_query'; | ||
import { useApmParams } from '../../../../hooks/use_apm_params'; | ||
import { | ||
SERVICE_NAME, | ||
TRANSACTION_TYPE, | ||
PROCESSOR_EVENT, | ||
HOST_OS_VERSION, | ||
DEVICE_MODEL_IDENTIFIER, | ||
NETWORK_CONNECTION_TYPE, | ||
SERVICE_VERSION, | ||
} from '../../../../../common/elasticsearch_fieldnames'; | ||
|
||
function termQuery<T extends string>( | ||
field: T, | ||
value: string | boolean | number | undefined | null | ||
): QueryDslQueryContainer[] { | ||
if (isNil(value) || isEmpty(value)) { | ||
return []; | ||
} | ||
|
||
return [{ term: { [field]: value } }]; | ||
} | ||
|
||
export function useFiltersForMobileCharts() { | ||
const { | ||
path: { serviceName }, | ||
query: { | ||
environment, | ||
transactionType, | ||
device, | ||
osVersion, | ||
appVersion, | ||
netConnectionType, | ||
}, | ||
} = useApmParams('/services/{serviceName}/overview'); | ||
|
||
return useMemo( | ||
() => | ||
[ | ||
...termQuery(PROCESSOR_EVENT, ProcessorEvent.transaction), | ||
...termQuery(SERVICE_NAME, serviceName), | ||
...termQuery(TRANSACTION_TYPE, transactionType), | ||
...termQuery(HOST_OS_VERSION, osVersion), | ||
...termQuery(DEVICE_MODEL_IDENTIFIER, device), | ||
...termQuery(NETWORK_CONNECTION_TYPE, netConnectionType), | ||
...termQuery(SERVICE_VERSION, appVersion), | ||
...environmentQuery(environment), | ||
].map((query) => ({ | ||
meta: {}, | ||
query, | ||
})), | ||
[ | ||
environment, | ||
transactionType, | ||
serviceName, | ||
osVersion, | ||
device, | ||
netConnectionType, | ||
appVersion, | ||
] | ||
); | ||
} |