From 0bb9783dcbe69d0758da40f6d668b7362e27cdfd Mon Sep 17 00:00:00 2001 From: Ats Uiboupin Date: Fri, 23 Feb 2024 09:50:54 +0200 Subject: [PATCH] refactor: extract `checkManuallyProvidedInstrumentationNames` method #1672 --- .../auto-instrumentations-node/src/utils.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/metapackages/auto-instrumentations-node/src/utils.ts b/metapackages/auto-instrumentations-node/src/utils.ts index ce9f6c8966..a6c4422ad1 100644 --- a/metapackages/auto-instrumentations-node/src/utils.ts +++ b/metapackages/auto-instrumentations-node/src/utils.ts @@ -135,12 +135,7 @@ export type InstrumentationConfigMap = { export function getNodeAutoInstrumentations( inputConfigs: InstrumentationConfigMap = {} ): Instrumentation[] { - for (const name of Object.keys(inputConfigs)) { - if (!Object.prototype.hasOwnProperty.call(InstrumentationMap, name)) { - diag.error(`Provided instrumentation name "${name}" not found`); - continue; - } - } + checkManuallyProvidedInstrumentationNames(Object.keys(inputConfigs)); const instrumentations: Instrumentation[] = []; @@ -167,6 +162,16 @@ export function getNodeAutoInstrumentations( return instrumentations; } +function checkManuallyProvidedInstrumentationNames( + manuallyProvidedInstrumentationNames: string[] +) { + for (const name of manuallyProvidedInstrumentationNames) { + if (!Object.prototype.hasOwnProperty.call(InstrumentationMap, name)) { + diag.error(`Provided instrumentation name "${name}" not found`); + } + } +} + export function getResourceDetectorsFromEnv(): Array { const resourceDetectors = new Map< string,