Skip to content

Commit

Permalink
[Profiling] fix bug when APM server is no available
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Sep 6, 2023
1 parent 1b0c095 commit 6e45606
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions x-pack/plugins/profiling/server/lib/setup/fleet_policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,23 @@ export async function validateProfilingInApmPackagePolicy({
soClient,
packagePolicyClient,
}: ProfilingSetupOptions): Promise<PartialSetupState> {
const apmPolicy = await getApmPolicy({ packagePolicyClient, soClient });

return {
policies: {
apm: {
profilingEnabled: !!(
apmPolicy && apmPolicy?.inputs[0].config?.['apm-server'].value?.profiling
),
try {
const apmPolicy = await getApmPolicy({ packagePolicyClient, soClient });
return {
policies: {
apm: {
profilingEnabled: !!(
apmPolicy && apmPolicy?.inputs[0].config?.['apm-server'].value?.profiling
),
},
},
},
};
};
} catch (e) {
// In case apm server is not available ignore the error and return as profiling is not enabled on apm
return {
policies: { apm: { profilingEnabled: false } },
};
}
}

export async function removeProfilingFromApmPackagePolicy({
Expand Down

0 comments on commit 6e45606

Please sign in to comment.