* Internal initialization function.
(
options: NodeOptions | undefined = {},
getDefaultIntegrationsImpl: (options: Options) => Integration[],
)
| 69 | * Internal initialization function. |
| 70 | */ |
| 71 | function _init( |
| 72 | options: NodeOptions | undefined = {}, |
| 73 | getDefaultIntegrationsImpl: (options: Options) => Integration[], |
| 74 | ): NodeClient | undefined { |
| 75 | applySdkMetadata(options, 'node'); |
| 76 | |
| 77 | // EXPERIMENTAL: diagnostics-channel injection, opted into via |
| 78 | // `experimentalUseDiagnosticsChannelInjection()`. Gated on span recording to |
| 79 | // match the OTel integrations it replaces. With tracing off there are no |
| 80 | // channel subscribers, so injecting is pointless work. `resolve...()` is |
| 81 | // memoized, so `getDefaultIntegrations()` (below) sees the same instance. |
| 82 | const diagnosticsChannelInjection = |
| 83 | isDiagnosticsChannelInjectionEnabled() && hasSpansEnabled(options) |
| 84 | ? resolveDiagnosticsChannelInjection() |
| 85 | : undefined; |
| 86 | |
| 87 | // Install the channel-injection hooks as early as possible, before the app |
| 88 | // imports its instrumented modules. |
| 89 | if (diagnosticsChannelInjection) { |
| 90 | diagnosticsChannelInjection.register(); |
| 91 | } |
| 92 | |
| 93 | const client = initNodeCore({ |
| 94 | ...options, |
| 95 | // Only use Node SDK defaults if none provided |
| 96 | defaultIntegrations: options.defaultIntegrations ?? getDefaultIntegrationsImpl(options), |
| 97 | }); |
| 98 | |
| 99 | // Add Node SDK specific OpenTelemetry setup |
| 100 | if (client && !options.skipOpenTelemetrySetup) { |
| 101 | initOpenTelemetry(client, { |
| 102 | spanProcessors: options.openTelemetrySpanProcessors, |
| 103 | }); |
| 104 | validateOpenTelemetrySetup(); |
| 105 | } |
| 106 | |
| 107 | // Warn about missing or doubled channel injection. Runs after the client |
| 108 | // is created so the debug logger is enabled and the warning is emitted. |
| 109 | if (diagnosticsChannelInjection) { |
| 110 | diagnosticsChannelInjection.detect(); |
| 111 | } |
| 112 | |
| 113 | return client; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Initialize Sentry for Node, without any integrations added by default. |
no test coverage detected