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

[APM] switch get environment function to use terms_enum api #150175

Merged
merged 17 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c1bbce2
switch get environment function to use terms_enum api instead of aggr…
achyutjhunjhunwala Feb 2, 2023
ad1cd3e
pass service as empty string if unavailable
achyutjhunjhunwala Feb 2, 2023
274b7e6
Merge branch 'main' into switch_get_environments_to_terms_enum_api
achyutjhunjhunwala Feb 2, 2023
3f4323b
Merge branch 'main' into switch_get_environments_to_terms_enum_api
achyutjhunjhunwala Feb 6, 2023
9a66237
change environment fetcher logic to use suggestion api when no servic…
achyutjhunjhunwala Feb 6, 2023
9627da0
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Feb 6, 2023
9ac0a17
adjusting environment fetching logic based on useFetcher
achyutjhunjhunwala Feb 6, 2023
b87d22d
Merge remote-tracking branch 'origin/switch_get_environments_to_terms…
achyutjhunjhunwala Feb 6, 2023
f00787e
remove any type to more specific type
achyutjhunjhunwala Feb 7, 2023
3d0f71a
Merge branch 'main' into switch_get_environments_to_terms_enum_api
achyutjhunjhunwala Feb 7, 2023
8758f45
fix logic which broke the inspector component
achyutjhunjhunwala Feb 7, 2023
0a1e907
simplified type for getEnvironments on the server side
achyutjhunjhunwala Feb 7, 2023
122dcaf
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Feb 7, 2023
315ec23
fix final code reviews
achyutjhunjhunwala Feb 7, 2023
4e723d1
add api tests for getEnvironments
achyutjhunjhunwala Feb 7, 2023
f413e8d
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Feb 7, 2023
b05a3a2
Merge branch 'main' into switch_get_environments_to_terms_enum_api
achyutjhunjhunwala Feb 7, 2023
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
29 changes: 24 additions & 5 deletions x-pack/plugins/apm/public/hooks/use_environments_fetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { SERVICE_ENVIRONMENT } from '../../common/es_fields/apm';
import { useFetcher } from './use_fetcher';

const INITIAL_DATA = { environments: [] };
achyutjhunjhunwala marked this conversation as resolved.
Show resolved Hide resolved
import { Environment } from '../../common/environment_rt';

export function useEnvironmentsFetcher({
serviceName,
Expand All @@ -18,9 +18,13 @@ export function useEnvironmentsFetcher({
start?: string;
end?: string;
}) {
const { data = INITIAL_DATA, status } = useFetcher(
const { data, status } = useFetcher(
achyutjhunjhunwala marked this conversation as resolved.
Show resolved Hide resolved
(callApmApi) => {
if (start && end) {
if (!start || !end) {
return;
}

if (serviceName) {
return callApmApi('GET /internal/apm/environments', {
params: {
query: {
Expand All @@ -31,9 +35,24 @@ export function useEnvironmentsFetcher({
},
});
}
return callApmApi('GET /internal/apm/suggestions', {
params: {
query: {
start,
end,
fieldName: SERVICE_ENVIRONMENT,
fieldValue: '',
},
},
});
},
[start, end, serviceName]
);

return { environments: data.environments, status };
return {
environments: ((data as any)?.environments ||
(data as any)?.terms ||
[]) as Environment[],
achyutjhunjhunwala marked this conversation as resolved.
Show resolved Hide resolved
status,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Environment } from '../../../common/environment_rt';
import { APMEventClient } from '../../lib/helpers/create_es_client/create_apm_event_client';

/**
* This is used for getting the list of environments for the environments selector,
* This is used for getting the list of environments for the environment selector,
* filtered by range.
*/
export async function getEnvironments({
Expand Down