(
client: NodeClient,
options: AdditionalOpenTelemetryOptions = {},
)
| 84 | |
| 85 | /** Just exported for tests. */ |
| 86 | export function setupOtel( |
| 87 | client: NodeClient, |
| 88 | options: AdditionalOpenTelemetryOptions = {}, |
| 89 | ): [BasicTracerProvider, AsyncLocalStorageLookup] { |
| 90 | // Create and configure NodeTracerProvider |
| 91 | const provider = new BasicTracerProvider({ |
| 92 | sampler: new SentrySampler(client), |
| 93 | resource: getSentryResource('node'), |
| 94 | forceFlushTimeoutMillis: 500, |
| 95 | spanProcessors: [ |
| 96 | new SentrySpanProcessor({ |
| 97 | timeout: _clampSpanProcessorTimeout(client.getOptions().maxSpanWaitDuration), |
| 98 | client, |
| 99 | }), |
| 100 | ...(options.spanProcessors || []), |
| 101 | ], |
| 102 | }); |
| 103 | |
| 104 | // Register as globals |
| 105 | trace.setGlobalTracerProvider(provider); |
| 106 | propagation.setGlobalPropagator(new SentryPropagator()); |
| 107 | |
| 108 | const ctxManager = new SentryContextManager(); |
| 109 | context.setGlobalContextManager(ctxManager); |
| 110 | |
| 111 | return [provider, ctxManager.getAsyncLocalStorageLookup()]; |
| 112 | } |
| 113 | |
| 114 | /** Just exported for tests. */ |
| 115 | export function _clampSpanProcessorTimeout(maxSpanWaitDuration: number | undefined): number | undefined { |
no test coverage detected