Skip to content

Commit

Permalink
refactor: extract checkManuallyProvidedInstrumentationNames method
Browse files Browse the repository at this point in the history
  • Loading branch information
atsu85 committed Mar 7, 2024
1 parent fa7e2f5 commit 0bb9783
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions metapackages/auto-instrumentations-node/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];

Expand All @@ -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<Detector | DetectorSync> {
const resourceDetectors = new Map<
string,
Expand Down

0 comments on commit 0bb9783

Please sign in to comment.