-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Remove usage of internal client when fetching agent config etags metrics #173001
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,27 +6,33 @@ | |
*/ | ||
|
||
import { APMIndices } from '@kbn/apm-data-access-plugin/server'; | ||
import { APMEventClient } from '../../../lib/helpers/create_es_client/create_apm_event_client'; | ||
import { AgentConfiguration } from '../../../../common/agent_configuration/configuration_types'; | ||
import { convertConfigSettingsToString } from './convert_settings_to_string'; | ||
import { getConfigsAppliedToAgentsThroughFleet } from './get_config_applied_to_agent_through_fleet'; | ||
import { getAgentConfigEtagMetrics } from './get_agent_config_etag_metrics'; | ||
import { APMInternalESClient } from '../../../lib/helpers/create_es_client/create_internal_es_client'; | ||
import { APM_AGENT_CONFIGURATION_INDEX } from '../apm_indices/apm_system_index_constants'; | ||
|
||
export async function listConfigurations( | ||
internalESClient: APMInternalESClient, | ||
apmIndices: APMIndices | ||
) { | ||
export async function listConfigurations({ | ||
internalESClient, | ||
apmEventClient, | ||
apmIndices, | ||
}: { | ||
internalESClient: APMInternalESClient; | ||
apmEventClient?: APMEventClient; | ||
apmIndices: APMIndices; | ||
}) { | ||
const params = { | ||
index: APM_AGENT_CONFIGURATION_INDEX, | ||
size: 200, | ||
}; | ||
|
||
const [agentConfigs, configsAppliedToAgentsThroughFleet] = await Promise.all([ | ||
const [agentConfigs, appliedEtags = []] = await Promise.all([ | ||
internalESClient.search<AgentConfiguration>( | ||
'list_agent_configuration', | ||
params | ||
), | ||
getConfigsAppliedToAgentsThroughFleet(internalESClient, apmIndices), | ||
apmEventClient ? getAgentConfigEtagMetrics(apmEventClient) : undefined, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, |
||
]); | ||
|
||
return agentConfigs.hits.hits | ||
|
@@ -36,7 +42,7 @@ export async function listConfigurations( | |
...hit._source, | ||
applied_by_agent: | ||
hit._source.applied_by_agent || | ||
configsAppliedToAgentsThroughFleet.hasOwnProperty(hit._source.etag), | ||
appliedEtags.includes(hit._source.etag), | ||
}; | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably create a simple unit test to cover this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already covered by the api test. A unit test would mock out the call to
getAgentConfigEtagMetrics
so it would only cover the check onagentConfiguration.applied_by_agent
andappliedEtags.includes(agentConfiguration.etag
. I don't think it's worth it.If it was functionality with value in itself, then maybe, but in this case it's just an implementation detail. It might as well be inlined in
findExactConfiguration
instead of a separate function.