Skip to content

Commit

Permalink
chore: remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna committed Mar 4, 2024
1 parent 813e845 commit 2070aa2
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions packages/opentelemetry-node/lib/instrumentations.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,19 @@ const INSTRUMENTATIONS = {
*/
function getInstrumentations(opts) {
// User decided to write his/her own list
// TODO: log if also `instrumentationProviders` is defined???
if (opts.instrumentations && Array.isArray(opts.instrumentations)) {
return opts.instrumentations;
}

// Provide default instrumentations if no providers present
if (
!opts.instrumentationProviders ||
!Array.isArray(opts.instrumentationProviders)
) {
return Object.values(INSTRUMENTATIONS).map((fn) => fn());
}

// TODO: discuss this approach. Use providers to replace current instruentations
// the shape of a provider is
// {
// for: "name_of_the_instrumentation",
// use: () => { new CustomInstrumentation() }
// }
// ----
// also we could pass directly an instrumentation for add/replace
// PROS:
// - no need to rewrite all instrumentations
// - all options are possible (add, remove, replace)
// - no messing with OTel config types, we're extending
// CONS:
// - typos coud lead to unexpected behaviors (double instrumentation)
// - `instrumentationName` may be not unique???
// OTHER OPTIONS:
// - use `instrumentations` and have a `mode` property
// - mode extend to add new classes and replace
// - mode replace to completelly rewrite instrumentations
//
// CRAZY IDEA:
// have a mode to include only the instrumentations of the detected packages
// for performance gains
// - method should be recursive to check all app dependencies
// - it would require to scan all instrumentations to extract the modules they patch
// - or we could have a map per instrumentation name
// - eg. 'mongoose' => ['@opentelemetry/instrumentation-mongoose', '@opentelemetry/instrumentation-mongodb']
// - would require to use a function similar to `safeGetPackageVersion`
// - using `module-details-from-path`
/** @type {Array<any>} */
const providers = opts.instrumentationProviders;
const result = [];
Expand All @@ -85,6 +58,8 @@ function getInstrumentations(opts) {
result.push(instr);
}
});

return result;
}

module.exports = {
Expand Down

0 comments on commit 2070aa2

Please sign in to comment.