Skip to content

Commit

Permalink
feat(node): Allow to pass registerEsmLoaderHooks to preload (#12998)
Browse files Browse the repository at this point in the history
As mentioned in here:
#12912 (comment)
there is no way today to exclude/include esm modules when preloading
today.

This PR adds the option to pass `registerEsmLoaderHooks` as option to
`preloadOpenTelemetry`, which allows to exclude/include packages there
as well. Users can then write their own custom `preload` script and
configure this there, if wanted.

## Naming

I chose to use the same option naming here than for `init`, although the
semantics are a bit different - here we can't actually disable the
wrapping (because that's the only reason to even call this). We can also
use a different name if we want, but I thought this would maybe be
easier to understand that this is the same thing 🤔
  • Loading branch information
mydea authored Jul 22, 2024
1 parent eb23dc4 commit 81e20c3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/node/src/sdk/initOtel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function maybeInitializeEsmLoader(esmHookConfig?: EsmLoaderHookOptions):
interface NodePreloadOptions {
debug?: boolean;
integrations?: string[];
registerEsmLoaderHooks?: EsmLoaderHookOptions;
}

/**
Expand All @@ -79,7 +80,7 @@ export function preloadOpenTelemetry(options: NodePreloadOptions = {}): void {
}

if (!isCjs()) {
maybeInitializeEsmLoader();
maybeInitializeEsmLoader(options.registerEsmLoaderHooks);
}

// These are all integrations that we need to pre-load to ensure they are set up before any other code runs
Expand Down

0 comments on commit 81e20c3

Please sign in to comment.