From f0cf261723fcfbb49cb6b6e28813a280ab2cca4e Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 8 Jan 2026 10:33:50 +0100 Subject: [PATCH 1/5] feat(core): Consolidate bun and node types with BaseWinterTCOptions --- packages/bun/src/types.ts | 57 +++------------------- packages/core/src/index.ts | 2 +- packages/core/src/types-hoist/options.ts | 61 ++++++++++++++++++++++++ packages/node-core/src/types.ts | 44 +++-------------- packages/node/src/types.ts | 56 +++------------------- 5 files changed, 81 insertions(+), 139 deletions(-) diff --git a/packages/bun/src/types.ts b/packages/bun/src/types.ts index 91686f9cf8c3..a346bf7cf668 100644 --- a/packages/bun/src/types.ts +++ b/packages/bun/src/types.ts @@ -1,54 +1,11 @@ -import type { BaseTransportOptions, ClientOptions, Options, TracePropagationTargets } from '@sentry/core'; +import type { BaseTransportOptions, BaseWinterTCOptions, ClientOptions, Options } from '@sentry/core'; -export interface BaseBunOptions { - /** - * List of strings/regex controlling to which outgoing requests - * the SDK will attach tracing headers. - * - * By default the SDK will attach those headers to all outgoing - * requests. If this option is provided, the SDK will match the - * request URL of outgoing requests against the items in this - * array, and only attach tracing headers if a match was found. - * - * @example - * ```js - * Sentry.init({ - * tracePropagationTargets: ['api.site.com'], - * }); - * ``` - */ - tracePropagationTargets?: TracePropagationTargets; - - /** Sets an optional server name (device name) */ - serverName?: string; - - /** - * If you use Spotlight by Sentry during development, use - * this option to forward captured Sentry events to Spotlight. - * - * Either set it to true, or provide a specific Spotlight Sidecar URL. - * - * More details: https://spotlightjs.com/ - * - * IMPORTANT: Only set this option to `true` while developing, not in production! - */ - spotlight?: boolean | string; - - /** - * If this is set to true, the SDK will not set up OpenTelemetry automatically. - * In this case, you _have_ to ensure to set it up correctly yourself, including: - * * The `SentrySpanProcessor` - * * The `SentryPropagator` - * * The `SentryContextManager` - * * The `SentrySampler` - * - * If you are registering your own OpenTelemetry Loader Hooks (or `import-in-the-middle` hooks), it is also recommended to set the `registerEsmLoaderHooks` option to false. - */ - skipOpenTelemetrySetup?: boolean; - - /** Callback that is executed when a fatal global error occurs. */ - onFatalError?(this: void, error: Error): void; -} +/** + * Base options for the Sentry Bun SDK. + * Extends the common WinterTC options shared with Node.js and other server-side SDKs. + */ +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface BaseBunOptions extends BaseWinterTCOptions {} /** * Configuration options for the Sentry Bun SDK diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 28495fed10a4..99f8abc1a919 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -387,7 +387,7 @@ export type { Extra, Extras } from './types-hoist/extra'; export type { Integration, IntegrationFn } from './types-hoist/integration'; export type { Mechanism } from './types-hoist/mechanism'; export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; -export type { ClientOptions, CoreOptions as Options } from './types-hoist/options'; +export type { BaseWinterTCOptions, ClientOptions, CoreOptions as Options } from './types-hoist/options'; export type { Package } from './types-hoist/package'; export type { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; export type { diff --git a/packages/core/src/types-hoist/options.ts b/packages/core/src/types-hoist/options.ts index ac4ce839ff85..7019a5524ba6 100644 --- a/packages/core/src/types-hoist/options.ts +++ b/packages/core/src/types-hoist/options.ts @@ -11,6 +11,67 @@ import type { StackLineParser, StackParser } from './stacktrace'; import type { TracePropagationTargets } from './tracing'; import type { BaseTransportOptions, Transport } from './transport'; +/** + * Base options for WinterTC-compatible server-side JavaScript runtimes. + * This interface contains common configuration options shared between + * Node.js, Bun, and other WinterTC-compliant runtime SDKs. + * + * @see https://wintercg.org/ + */ +export interface BaseWinterTCOptions { + /** + * List of strings/regex controlling to which outgoing requests + * the SDK will attach tracing headers. + * + * By default the SDK will attach those headers to all outgoing + * requests. If this option is provided, the SDK will match the + * request URL of outgoing requests against the items in this + * array, and only attach tracing headers if a match was found. + * + * @example + * ```js + * Sentry.init({ + * tracePropagationTargets: ['api.site.com'], + * }); + * ``` + */ + tracePropagationTargets?: TracePropagationTargets; + + /** + * Sets an optional server name (device name). + * + * This is useful for identifying which server or instance is sending events. + */ + serverName?: string; + + /** + * If you use Spotlight by Sentry during development, use + * this option to forward captured Sentry events to Spotlight. + * + * Either set it to true, or provide a specific Spotlight Sidecar URL. + * + * More details: https://spotlightjs.com/ + * + * IMPORTANT: Only set this option to `true` while developing, not in production! + */ + spotlight?: boolean | string; + + /** + * If this is set to true, the SDK will not set up OpenTelemetry automatically. + * In this case, you _have_ to ensure to set it up correctly yourself, including: + * * The `SentrySpanProcessor` + * * The `SentryPropagator` + * * The `SentryContextManager` + * * The `SentrySampler` + */ + skipOpenTelemetrySetup?: boolean; + + /** + * Callback that is executed when a fatal global error occurs. + */ + onFatalError?(this: void, error: Error): void; +} + /** * A filter object for ignoring spans. * At least one of the properties (`op` or `name`) must be set. diff --git a/packages/node-core/src/types.ts b/packages/node-core/src/types.ts index a331b876166d..b49a255f5948 100644 --- a/packages/node-core/src/types.ts +++ b/packages/node-core/src/types.ts @@ -1,28 +1,14 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; import type { Instrumentation } from '@opentelemetry/instrumentation'; import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'; -import type { ClientOptions, Options, SamplingContext, Scope, Span, TracePropagationTargets } from '@sentry/core'; +import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; import type { NodeTransportOptions } from './transports'; -export interface BaseNodeOptions { - /** - * List of strings/regex controlling to which outgoing requests - * the SDK will attach tracing headers. - * - * By default the SDK will attach those headers to all outgoing - * requests. If this option is provided, the SDK will match the - * request URL of outgoing requests against the items in this - * array, and only attach tracing headers if a match was found. - * - * @example - * ```js - * Sentry.init({ - * tracePropagationTargets: ['api.site.com'], - * }); - * ``` - */ - tracePropagationTargets?: TracePropagationTargets; - +/** + * Base options for the Sentry Node SDK. + * Extends the common WinterTC options shared with Bun and other server-side SDKs. + */ +export interface BaseNodeOptions extends BaseWinterTCOptions { /** * Sets profiling sample rate when @sentry/profiling-node is installed * @@ -71,9 +57,6 @@ export interface BaseNodeOptions { */ includeServerName?: boolean; - /** Sets an optional server name (device name) */ - serverName?: string; - /** * Include local variables with stack traces. * @@ -81,18 +64,6 @@ export interface BaseNodeOptions { */ includeLocalVariables?: boolean; - /** - * If you use Spotlight by Sentry during development, use - * this option to forward captured Sentry events to Spotlight. - * - * Either set it to true, or provide a specific Spotlight Sidecar URL. - * - * More details: https://spotlightjs.com/ - * - * IMPORTANT: Only set this option to `true` while developing, not in production! - */ - spotlight?: boolean | string; - /** * Provide an array of OpenTelemetry Instrumentations that should be registered. * @@ -144,9 +115,6 @@ export interface BaseNodeOptions { * problems. */ shutdownTimeout?: number; - - /** Callback that is executed when a fatal global error occurs. */ - onFatalError?(this: void, error: Error): void; } /** diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index 1f84b69a9f28..8cdba57d1564 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -1,28 +1,14 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; import type { Instrumentation } from '@opentelemetry/instrumentation'; import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'; -import type { ClientOptions, Options, SamplingContext, Scope, Span, TracePropagationTargets } from '@sentry/core'; +import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; import type { NodeTransportOptions } from '@sentry/node-core'; -export interface BaseNodeOptions { - /** - * List of strings/regex controlling to which outgoing requests - * the SDK will attach tracing headers. - * - * By default the SDK will attach those headers to all outgoing - * requests. If this option is provided, the SDK will match the - * request URL of outgoing requests against the items in this - * array, and only attach tracing headers if a match was found. - * - * @example - * ```js - * Sentry.init({ - * tracePropagationTargets: ['api.site.com'], - * }); - * ``` - */ - tracePropagationTargets?: TracePropagationTargets; - +/** + * Base options for the Sentry Node SDK. + * Extends the common WinterTC options shared with Bun and other server-side SDKs. + */ +export interface BaseNodeOptions extends BaseWinterTCOptions { /** * Sets profiling sample rate when @sentry/profiling-node is installed * @@ -74,9 +60,6 @@ export interface BaseNodeOptions { */ includeServerName?: boolean; - /** Sets an optional server name (device name) */ - serverName?: string; - /** * Include local variables with stack traces. * @@ -84,30 +67,6 @@ export interface BaseNodeOptions { */ includeLocalVariables?: boolean; - /** - * If you use Spotlight by Sentry during development, use - * this option to forward captured Sentry events to Spotlight. - * - * Either set it to true, or provide a specific Spotlight Sidecar URL. - * - * More details: https://spotlightjs.com/ - * - * IMPORTANT: Only set this option to `true` while developing, not in production! - */ - spotlight?: boolean | string; - - /** - * If this is set to true, the SDK will not set up OpenTelemetry automatically. - * In this case, you _have_ to ensure to set it up correctly yourself, including: - * * The `SentrySpanProcessor` - * * The `SentryPropagator` - * * The `SentryContextManager` - * * The `SentrySampler` - * - * If you are registering your own OpenTelemetry Loader Hooks (or `import-in-the-middle` hooks), it is also recommended to set the `registerEsmLoaderHooks` option to false. - */ - skipOpenTelemetrySetup?: boolean; - /** * Provide an array of OpenTelemetry Instrumentations that should be registered. * @@ -159,9 +118,6 @@ export interface BaseNodeOptions { * problems. */ shutdownTimeout?: number; - - /** Callback that is executed when a fatal global error occurs. */ - onFatalError?(this: void, error: Error): void; } /** From 026bea91233c2ffced571ba2bd69cd6925aa4668 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 8 Jan 2026 11:53:06 +0100 Subject: [PATCH 2/5] feat(core): Add more types to BaseWinterTCOptions --- packages/core/src/types-hoist/options.ts | 54 +++++++++++++++++++++++ packages/node-core/src/types.ts | 55 +----------------------- packages/node/src/types.ts | 55 +----------------------- 3 files changed, 56 insertions(+), 108 deletions(-) diff --git a/packages/core/src/types-hoist/options.ts b/packages/core/src/types-hoist/options.ts index 7019a5524ba6..69eebe85a5cd 100644 --- a/packages/core/src/types-hoist/options.ts +++ b/packages/core/src/types-hoist/options.ts @@ -1,3 +1,5 @@ +import type { Instrumentation } from '@opentelemetry/instrumentation'; +import type { SpanProcessor } from '@opentelemetry/sdk-trace-base'; import type { CaptureContext } from '../scope'; import type { Breadcrumb, BreadcrumbHint } from './breadcrumb'; import type { ErrorEvent, EventHint, TransactionEvent } from './event'; @@ -66,6 +68,58 @@ export interface BaseWinterTCOptions { */ skipOpenTelemetrySetup?: boolean; + /** + * If set to `false`, the SDK will not automatically detect the `serverName`. + * + * This is useful if you are using the SDK in a CLI app or Electron where the + * hostname might be considered PII. + * + * @default true + */ + includeServerName?: boolean; + + /** + * By default, the SDK will try to identify problems with your instrumentation setup and warn you about it. + * If you want to disable these warnings, set this to `true`. + */ + disableInstrumentationWarnings?: boolean; + + /** + * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause + * problems for sending events from command line applications. Setting it too + * high can cause the application to block for users with network connectivity + * problems. + */ + shutdownTimeout?: number; + + /** + * Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds). + */ + clientReportFlushInterval?: number; + + /** + * Provide an array of OpenTelemetry Instrumentations that should be registered. + * + * Use this option if you want to register OpenTelemetry instrumentation that the Sentry SDK does not yet have support for. + */ + openTelemetryInstrumentations?: Instrumentation[]; + + /** + * Provide an array of additional OpenTelemetry SpanProcessors that should be registered. + */ + openTelemetrySpanProcessors?: SpanProcessor[]; + + /** + * The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span. + * The SDK will automatically clean up spans that have no finished parent after this duration. + * This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing. + * However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early. + * In this case, you can increase this duration to a value that fits your expected data. + * + * Defaults to 300 seconds (5 minutes). + */ + maxSpanWaitDuration?: number; + /** * Callback that is executed when a fatal global error occurs. */ diff --git a/packages/node-core/src/types.ts b/packages/node-core/src/types.ts index b49a255f5948..ed1953adc3bc 100644 --- a/packages/node-core/src/types.ts +++ b/packages/node-core/src/types.ts @@ -1,6 +1,5 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; -import type { Instrumentation } from '@opentelemetry/instrumentation'; -import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'; +import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; import type { NodeTransportOptions } from './transports'; @@ -47,16 +46,6 @@ export interface BaseNodeOptions extends BaseWinterTCOptions { */ profileLifecycle?: 'manual' | 'trace'; - /** - * If set to `false`, the SDK will not automatically detect the `serverName`. - * - * This is useful if you are using the SDK in a CLI app or Electron where the - * hostname might be considered PII. - * - * @default true - */ - includeServerName?: boolean; - /** * Include local variables with stack traces. * @@ -64,29 +53,6 @@ export interface BaseNodeOptions extends BaseWinterTCOptions { */ includeLocalVariables?: boolean; - /** - * Provide an array of OpenTelemetry Instrumentations that should be registered. - * - * Use this option if you want to register OpenTelemetry instrumentation that the Sentry SDK does not yet have support for. - */ - openTelemetryInstrumentations?: Instrumentation[]; - - /** - * Provide an array of additional OpenTelemetry SpanProcessors that should be registered. - */ - openTelemetrySpanProcessors?: SpanProcessor[]; - - /** - * The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span. - * The SDK will automatically clean up spans that have no finished parent after this duration. - * This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing. - * However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early. - * In this case, you can increase this duration to a value that fits your expected data. - * - * Defaults to 300 seconds (5 minutes). - */ - maxSpanWaitDuration?: number; - /** * Whether to register ESM loader hooks to automatically instrument libraries. * This is necessary to auto instrument libraries that are loaded via ESM imports, but it can cause issues @@ -96,25 +62,6 @@ export interface BaseNodeOptions extends BaseWinterTCOptions { * Defaults to `true`. */ registerEsmLoaderHooks?: boolean; - - /** - * Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds). - */ - clientReportFlushInterval?: number; - - /** - * By default, the SDK will try to identify problems with your instrumentation setup and warn you about it. - * If you want to disable these warnings, set this to `true`. - */ - disableInstrumentationWarnings?: boolean; - - /** - * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause - * problems for sending events from command line applications. Setting it too - * high can cause the application to block for users with network connectivity - * problems. - */ - shutdownTimeout?: number; } /** diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index 8cdba57d1564..f3d46cdad0b2 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -1,6 +1,5 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; -import type { Instrumentation } from '@opentelemetry/instrumentation'; -import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'; +import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; import type { NodeTransportOptions } from '@sentry/node-core'; @@ -50,16 +49,6 @@ export interface BaseNodeOptions extends BaseWinterTCOptions { */ profileLifecycle?: 'manual' | 'trace'; - /** - * If set to `false`, the SDK will not automatically detect the `serverName`. - * - * This is useful if you are using the SDK in a CLI app or Electron where the - * hostname might be considered PII. - * - * @default true - */ - includeServerName?: boolean; - /** * Include local variables with stack traces. * @@ -67,29 +56,6 @@ export interface BaseNodeOptions extends BaseWinterTCOptions { */ includeLocalVariables?: boolean; - /** - * Provide an array of OpenTelemetry Instrumentations that should be registered. - * - * Use this option if you want to register OpenTelemetry instrumentation that the Sentry SDK does not yet have support for. - */ - openTelemetryInstrumentations?: Instrumentation[]; - - /** - * Provide an array of additional OpenTelemetry SpanProcessors that should be registered. - */ - openTelemetrySpanProcessors?: SpanProcessor[]; - - /** - * The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span. - * The SDK will automatically clean up spans that have no finished parent after this duration. - * This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing. - * However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early. - * In this case, you can increase this duration to a value that fits your expected data. - * - * Defaults to 300 seconds (5 minutes). - */ - maxSpanWaitDuration?: number; - /** * Whether to register ESM loader hooks to automatically instrument libraries. * This is necessary to auto instrument libraries that are loaded via ESM imports, but it can cause issues @@ -99,25 +65,6 @@ export interface BaseNodeOptions extends BaseWinterTCOptions { * Defaults to `true`. */ registerEsmLoaderHooks?: boolean; - - /** - * Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds). - */ - clientReportFlushInterval?: number; - - /** - * By default, the SDK will try to identify problems with your instrumentation setup and warn you about it. - * If you want to disable these warnings, set this to `true`. - */ - disableInstrumentationWarnings?: boolean; - - /** - * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause - * problems for sending events from command line applications. Setting it too - * high can cause the application to block for users with network connectivity - * problems. - */ - shutdownTimeout?: number; } /** From b2241a170fafc99ae4cc195701f7867c09820e20 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 8 Jan 2026 17:16:32 +0100 Subject: [PATCH 3/5] ref: BaseWinterTCOptions -> ServerRuntimeClientOptions --- packages/bun/src/types.ts | 4 ++-- packages/core/src/index.ts | 2 +- packages/core/src/types-hoist/options.ts | 2 +- packages/node-core/src/types.ts | 4 ++-- packages/node/src/types.ts | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/bun/src/types.ts b/packages/bun/src/types.ts index a346bf7cf668..8ad40714de61 100644 --- a/packages/bun/src/types.ts +++ b/packages/bun/src/types.ts @@ -1,11 +1,11 @@ -import type { BaseTransportOptions, BaseWinterTCOptions, ClientOptions, Options } from '@sentry/core'; +import type { BaseTransportOptions, ClientOptions, Options, ServerRuntimeOptions } from '@sentry/core'; /** * Base options for the Sentry Bun SDK. * Extends the common WinterTC options shared with Node.js and other server-side SDKs. */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface BaseBunOptions extends BaseWinterTCOptions {} +export interface BaseBunOptions extends ServerRuntimeOptions {} /** * Configuration options for the Sentry Bun SDK diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 99f8abc1a919..85c4ee88ef9a 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -387,7 +387,7 @@ export type { Extra, Extras } from './types-hoist/extra'; export type { Integration, IntegrationFn } from './types-hoist/integration'; export type { Mechanism } from './types-hoist/mechanism'; export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; -export type { BaseWinterTCOptions, ClientOptions, CoreOptions as Options } from './types-hoist/options'; +export type { ServerRuntimeOptions, ClientOptions, CoreOptions as Options } from './types-hoist/options'; export type { Package } from './types-hoist/package'; export type { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; export type { diff --git a/packages/core/src/types-hoist/options.ts b/packages/core/src/types-hoist/options.ts index 69eebe85a5cd..7b3eb16443b7 100644 --- a/packages/core/src/types-hoist/options.ts +++ b/packages/core/src/types-hoist/options.ts @@ -20,7 +20,7 @@ import type { BaseTransportOptions, Transport } from './transport'; * * @see https://wintercg.org/ */ -export interface BaseWinterTCOptions { +export interface ServerRuntimeOptions { /** * List of strings/regex controlling to which outgoing requests * the SDK will attach tracing headers. diff --git a/packages/node-core/src/types.ts b/packages/node-core/src/types.ts index ed1953adc3bc..83b592666f60 100644 --- a/packages/node-core/src/types.ts +++ b/packages/node-core/src/types.ts @@ -1,13 +1,13 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; +import type { ClientOptions, Options, SamplingContext, Scope, ServerRuntimeOptions, Span } from '@sentry/core'; import type { NodeTransportOptions } from './transports'; /** * Base options for the Sentry Node SDK. * Extends the common WinterTC options shared with Bun and other server-side SDKs. */ -export interface BaseNodeOptions extends BaseWinterTCOptions { +export interface BaseNodeOptions extends ServerRuntimeOptions { /** * Sets profiling sample rate when @sentry/profiling-node is installed * diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index f3d46cdad0b2..a143f270d346 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -1,13 +1,13 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; +import type { ClientOptions, Options, SamplingContext, Scope, ServerRuntimeOptions, Span } from '@sentry/core'; import type { NodeTransportOptions } from '@sentry/node-core'; /** * Base options for the Sentry Node SDK. * Extends the common WinterTC options shared with Bun and other server-side SDKs. */ -export interface BaseNodeOptions extends BaseWinterTCOptions { +export interface BaseNodeOptions extends ServerRuntimeOptions { /** * Sets profiling sample rate when @sentry/profiling-node is installed * From 9f867053fbac518af4e8c6ccfef5bf287f7adab6 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Mon, 12 Jan 2026 13:51:15 +0100 Subject: [PATCH 4/5] ref: Move types from core to node-core --- packages/bun/src/types.ts | 3 +- packages/core/src/index.ts | 2 +- packages/core/src/types-hoist/options.ts | 115 ---------------------- packages/node-core/src/index.ts | 2 +- packages/node-core/src/types.ts | 118 ++++++++++++++++++++++- packages/node/src/types.ts | 4 +- 6 files changed, 122 insertions(+), 122 deletions(-) diff --git a/packages/bun/src/types.ts b/packages/bun/src/types.ts index 8ad40714de61..98fc36bf9809 100644 --- a/packages/bun/src/types.ts +++ b/packages/bun/src/types.ts @@ -1,4 +1,5 @@ -import type { BaseTransportOptions, ClientOptions, Options, ServerRuntimeOptions } from '@sentry/core'; +import type { BaseTransportOptions, ClientOptions, Options } from '@sentry/core'; +import type { ServerRuntimeOptions } from '@sentry/node-core'; /** * Base options for the Sentry Bun SDK. diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 85c4ee88ef9a..28495fed10a4 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -387,7 +387,7 @@ export type { Extra, Extras } from './types-hoist/extra'; export type { Integration, IntegrationFn } from './types-hoist/integration'; export type { Mechanism } from './types-hoist/mechanism'; export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; -export type { ServerRuntimeOptions, ClientOptions, CoreOptions as Options } from './types-hoist/options'; +export type { ClientOptions, CoreOptions as Options } from './types-hoist/options'; export type { Package } from './types-hoist/package'; export type { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; export type { diff --git a/packages/core/src/types-hoist/options.ts b/packages/core/src/types-hoist/options.ts index 7b3eb16443b7..ac4ce839ff85 100644 --- a/packages/core/src/types-hoist/options.ts +++ b/packages/core/src/types-hoist/options.ts @@ -1,5 +1,3 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; -import type { SpanProcessor } from '@opentelemetry/sdk-trace-base'; import type { CaptureContext } from '../scope'; import type { Breadcrumb, BreadcrumbHint } from './breadcrumb'; import type { ErrorEvent, EventHint, TransactionEvent } from './event'; @@ -13,119 +11,6 @@ import type { StackLineParser, StackParser } from './stacktrace'; import type { TracePropagationTargets } from './tracing'; import type { BaseTransportOptions, Transport } from './transport'; -/** - * Base options for WinterTC-compatible server-side JavaScript runtimes. - * This interface contains common configuration options shared between - * Node.js, Bun, and other WinterTC-compliant runtime SDKs. - * - * @see https://wintercg.org/ - */ -export interface ServerRuntimeOptions { - /** - * List of strings/regex controlling to which outgoing requests - * the SDK will attach tracing headers. - * - * By default the SDK will attach those headers to all outgoing - * requests. If this option is provided, the SDK will match the - * request URL of outgoing requests against the items in this - * array, and only attach tracing headers if a match was found. - * - * @example - * ```js - * Sentry.init({ - * tracePropagationTargets: ['api.site.com'], - * }); - * ``` - */ - tracePropagationTargets?: TracePropagationTargets; - - /** - * Sets an optional server name (device name). - * - * This is useful for identifying which server or instance is sending events. - */ - serverName?: string; - - /** - * If you use Spotlight by Sentry during development, use - * this option to forward captured Sentry events to Spotlight. - * - * Either set it to true, or provide a specific Spotlight Sidecar URL. - * - * More details: https://spotlightjs.com/ - * - * IMPORTANT: Only set this option to `true` while developing, not in production! - */ - spotlight?: boolean | string; - - /** - * If this is set to true, the SDK will not set up OpenTelemetry automatically. - * In this case, you _have_ to ensure to set it up correctly yourself, including: - * * The `SentrySpanProcessor` - * * The `SentryPropagator` - * * The `SentryContextManager` - * * The `SentrySampler` - */ - skipOpenTelemetrySetup?: boolean; - - /** - * If set to `false`, the SDK will not automatically detect the `serverName`. - * - * This is useful if you are using the SDK in a CLI app or Electron where the - * hostname might be considered PII. - * - * @default true - */ - includeServerName?: boolean; - - /** - * By default, the SDK will try to identify problems with your instrumentation setup and warn you about it. - * If you want to disable these warnings, set this to `true`. - */ - disableInstrumentationWarnings?: boolean; - - /** - * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause - * problems for sending events from command line applications. Setting it too - * high can cause the application to block for users with network connectivity - * problems. - */ - shutdownTimeout?: number; - - /** - * Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds). - */ - clientReportFlushInterval?: number; - - /** - * Provide an array of OpenTelemetry Instrumentations that should be registered. - * - * Use this option if you want to register OpenTelemetry instrumentation that the Sentry SDK does not yet have support for. - */ - openTelemetryInstrumentations?: Instrumentation[]; - - /** - * Provide an array of additional OpenTelemetry SpanProcessors that should be registered. - */ - openTelemetrySpanProcessors?: SpanProcessor[]; - - /** - * The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span. - * The SDK will automatically clean up spans that have no finished parent after this duration. - * This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing. - * However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early. - * In this case, you can increase this duration to a value that fits your expected data. - * - * Defaults to 300 seconds (5 minutes). - */ - maxSpanWaitDuration?: number; - - /** - * Callback that is executed when a fatal global error occurs. - */ - onFatalError?(this: void, error: Error): void; -} - /** * A filter object for ignoring spans. * At least one of the properties (`op` or `name`) must be set. diff --git a/packages/node-core/src/index.ts b/packages/node-core/src/index.ts index 8ab20e9dfd4c..6ffbc9fb1402 100644 --- a/packages/node-core/src/index.ts +++ b/packages/node-core/src/index.ts @@ -50,7 +50,7 @@ export { NodeClient } from './sdk/client'; export { cron } from './cron'; export { NODE_VERSION } from './nodeVersion'; -export type { NodeOptions } from './types'; +export type { NodeOptions, ServerRuntimeOptions } from './types'; export { // This needs exporting so the NodeClient can be used without calling init diff --git a/packages/node-core/src/types.ts b/packages/node-core/src/types.ts index 83b592666f60..ec9a1adf9a98 100644 --- a/packages/node-core/src/types.ts +++ b/packages/node-core/src/types.ts @@ -1,8 +1,122 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; -import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import type { ClientOptions, Options, SamplingContext, Scope, ServerRuntimeOptions, Span } from '@sentry/core'; +import type { Instrumentation } from '@opentelemetry/instrumentation'; +import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'; +import type { ClientOptions, Options, SamplingContext, Scope, Span, TracePropagationTargets } from '@sentry/core'; import type { NodeTransportOptions } from './transports'; +/** + * Base options for WinterTC-compatible server-side JavaScript runtimes. + * This interface contains common configuration options shared between + * Node.js, Bun, and other WinterTC-compliant runtime SDKs. + * + * @see https://wintercg.org/ + */ +export interface ServerRuntimeOptions { + /** + * List of strings/regex controlling to which outgoing requests + * the SDK will attach tracing headers. + * + * By default the SDK will attach those headers to all outgoing + * requests. If this option is provided, the SDK will match the + * request URL of outgoing requests against the items in this + * array, and only attach tracing headers if a match was found. + * + * @example + * ```js + * Sentry.init({ + * tracePropagationTargets: ['api.site.com'], + * }); + * ``` + */ + tracePropagationTargets?: TracePropagationTargets; + + /** + * Sets an optional server name (device name). + * + * This is useful for identifying which server or instance is sending events. + */ + serverName?: string; + + /** + * If you use Spotlight by Sentry during development, use + * this option to forward captured Sentry events to Spotlight. + * + * Either set it to true, or provide a specific Spotlight Sidecar URL. + * + * More details: https://spotlightjs.com/ + * + * IMPORTANT: Only set this option to `true` while developing, not in production! + */ + spotlight?: boolean | string; + + /** + * If this is set to true, the SDK will not set up OpenTelemetry automatically. + * In this case, you _have_ to ensure to set it up correctly yourself, including: + * * The `SentrySpanProcessor` + * * The `SentryPropagator` + * * The `SentryContextManager` + * * The `SentrySampler` + */ + skipOpenTelemetrySetup?: boolean; + + /** + * If set to `false`, the SDK will not automatically detect the `serverName`. + * + * This is useful if you are using the SDK in a CLI app or Electron where the + * hostname might be considered PII. + * + * @default true + */ + includeServerName?: boolean; + + /** + * By default, the SDK will try to identify problems with your instrumentation setup and warn you about it. + * If you want to disable these warnings, set this to `true`. + */ + disableInstrumentationWarnings?: boolean; + + /** + * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause + * problems for sending events from command line applications. Setting it too + * high can cause the application to block for users with network connectivity + * problems. + */ + shutdownTimeout?: number; + + /** + * Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds). + */ + clientReportFlushInterval?: number; + + /** + * Provide an array of OpenTelemetry Instrumentations that should be registered. + * + * Use this option if you want to register OpenTelemetry instrumentation that the Sentry SDK does not yet have support for. + */ + openTelemetryInstrumentations?: Instrumentation[]; + + /** + * Provide an array of additional OpenTelemetry SpanProcessors that should be registered. + */ + openTelemetrySpanProcessors?: SpanProcessor[]; + + /** + * The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span. + * The SDK will automatically clean up spans that have no finished parent after this duration. + * This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing. + * However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early. + * In this case, you can increase this duration to a value that fits your expected data. + * + * Defaults to 300 seconds (5 minutes). + */ + maxSpanWaitDuration?: number; + + /** + * Callback that is executed when a fatal global error occurs. + */ + onFatalError?(this: void, error: Error): void; +} + /** * Base options for the Sentry Node SDK. * Extends the common WinterTC options shared with Bun and other server-side SDKs. diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index a143f270d346..0fb6ffa629d0 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -1,7 +1,7 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import type { ClientOptions, Options, SamplingContext, Scope, ServerRuntimeOptions, Span } from '@sentry/core'; -import type { NodeTransportOptions } from '@sentry/node-core'; +import type { ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; +import type { NodeTransportOptions, ServerRuntimeOptions } from '@sentry/node-core'; /** * Base options for the Sentry Node SDK. From 733e70c76f0dd234a11d0e21251b9f5fcd389420 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Tue, 13 Jan 2026 11:09:06 +0100 Subject: [PATCH 5/5] ref: Split ServerRuntimeOptions into two w/ and w/o OTel --- packages/bun/src/types.ts | 6 +- packages/core/src/index.ts | 2 +- packages/core/src/types-hoist/options.ts | 89 +++++++++++++++++++++ packages/node-core/src/index.ts | 2 +- packages/node-core/src/types.ts | 98 ++---------------------- packages/node/src/types.ts | 6 +- 6 files changed, 104 insertions(+), 99 deletions(-) diff --git a/packages/bun/src/types.ts b/packages/bun/src/types.ts index 98fc36bf9809..a48adf27a23e 100644 --- a/packages/bun/src/types.ts +++ b/packages/bun/src/types.ts @@ -1,12 +1,12 @@ import type { BaseTransportOptions, ClientOptions, Options } from '@sentry/core'; -import type { ServerRuntimeOptions } from '@sentry/node-core'; +import type { OpenTelemetryServerRuntimeOptions } from '@sentry/node-core'; /** * Base options for the Sentry Bun SDK. - * Extends the common WinterTC options shared with Node.js and other server-side SDKs. + * Extends the common WinterTC options with OpenTelemetry support shared with Node.js and other server-side SDKs. */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface BaseBunOptions extends ServerRuntimeOptions {} +export interface BaseBunOptions extends OpenTelemetryServerRuntimeOptions {} /** * Configuration options for the Sentry Bun SDK diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 28495fed10a4..de3cd46772e7 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -387,7 +387,7 @@ export type { Extra, Extras } from './types-hoist/extra'; export type { Integration, IntegrationFn } from './types-hoist/integration'; export type { Mechanism } from './types-hoist/mechanism'; export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; -export type { ClientOptions, CoreOptions as Options } from './types-hoist/options'; +export type { ClientOptions, CoreOptions as Options, ServerRuntimeOptions } from './types-hoist/options'; export type { Package } from './types-hoist/package'; export type { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; export type { diff --git a/packages/core/src/types-hoist/options.ts b/packages/core/src/types-hoist/options.ts index ac4ce839ff85..55de8581fb21 100644 --- a/packages/core/src/types-hoist/options.ts +++ b/packages/core/src/types-hoist/options.ts @@ -11,6 +11,95 @@ import type { StackLineParser, StackParser } from './stacktrace'; import type { TracePropagationTargets } from './tracing'; import type { BaseTransportOptions, Transport } from './transport'; +/** + * Base options for WinterTC-compatible server-side JavaScript runtimes. + * This interface contains common configuration options shared between + * SDKs. + */ +export interface ServerRuntimeOptions { + /** + * List of strings/regex controlling to which outgoing requests + * the SDK will attach tracing headers. + * + * By default the SDK will attach those headers to all outgoing + * requests. If this option is provided, the SDK will match the + * request URL of outgoing requests against the items in this + * array, and only attach tracing headers if a match was found. + * + * @example + * ```js + * Sentry.init({ + * tracePropagationTargets: ['api.site.com'], + * }); + * ``` + */ + tracePropagationTargets?: TracePropagationTargets; + + /** + * Sets an optional server name (device name). + * + * This is useful for identifying which server or instance is sending events. + */ + serverName?: string; + + /** + * If you use Spotlight by Sentry during development, use + * this option to forward captured Sentry events to Spotlight. + * + * Either set it to true, or provide a specific Spotlight Sidecar URL. + * + * More details: https://spotlightjs.com/ + * + * IMPORTANT: Only set this option to `true` while developing, not in production! + */ + spotlight?: boolean | string; + + /** + * If set to `false`, the SDK will not automatically detect the `serverName`. + * + * This is useful if you are using the SDK in a CLI app or Electron where the + * hostname might be considered PII. + * + * @default true + */ + includeServerName?: boolean; + + /** + * By default, the SDK will try to identify problems with your instrumentation setup and warn you about it. + * If you want to disable these warnings, set this to `true`. + */ + disableInstrumentationWarnings?: boolean; + + /** + * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause + * problems for sending events from command line applications. Setting it too + * high can cause the application to block for users with network connectivity + * problems. + */ + shutdownTimeout?: number; + + /** + * Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds). + */ + clientReportFlushInterval?: number; + + /** + * The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span. + * The SDK will automatically clean up spans that have no finished parent after this duration. + * This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing. + * However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early. + * In this case, you can increase this duration to a value that fits your expected data. + * + * Defaults to 300 seconds (5 minutes). + */ + maxSpanWaitDuration?: number; + + /** + * Callback that is executed when a fatal global error occurs. + */ + onFatalError?(this: void, error: Error): void; +} + /** * A filter object for ignoring spans. * At least one of the properties (`op` or `name`) must be set. diff --git a/packages/node-core/src/index.ts b/packages/node-core/src/index.ts index 6ffbc9fb1402..46734aa509e6 100644 --- a/packages/node-core/src/index.ts +++ b/packages/node-core/src/index.ts @@ -50,7 +50,7 @@ export { NodeClient } from './sdk/client'; export { cron } from './cron'; export { NODE_VERSION } from './nodeVersion'; -export type { NodeOptions, ServerRuntimeOptions } from './types'; +export type { NodeOptions, OpenTelemetryServerRuntimeOptions } from './types'; export { // This needs exporting so the NodeClient can be used without calling init diff --git a/packages/node-core/src/types.ts b/packages/node-core/src/types.ts index ec9a1adf9a98..ee94322089b9 100644 --- a/packages/node-core/src/types.ts +++ b/packages/node-core/src/types.ts @@ -1,54 +1,15 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; import type { Instrumentation } from '@opentelemetry/instrumentation'; import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'; -import type { ClientOptions, Options, SamplingContext, Scope, Span, TracePropagationTargets } from '@sentry/core'; +import type { ClientOptions, Options, SamplingContext, Scope, ServerRuntimeOptions, Span } from '@sentry/core'; import type { NodeTransportOptions } from './transports'; /** - * Base options for WinterTC-compatible server-side JavaScript runtimes. - * This interface contains common configuration options shared between - * Node.js, Bun, and other WinterTC-compliant runtime SDKs. - * - * @see https://wintercg.org/ + * Base options for WinterTC-compatible server-side JavaScript runtimes with OpenTelemetry support. + * This interface extends the base ServerRuntimeOptions from @sentry/core with OpenTelemetry-specific configuration options. + * Used by Node.js, Bun, and other WinterTC-compliant runtime SDKs that support OpenTelemetry instrumentation. */ -export interface ServerRuntimeOptions { - /** - * List of strings/regex controlling to which outgoing requests - * the SDK will attach tracing headers. - * - * By default the SDK will attach those headers to all outgoing - * requests. If this option is provided, the SDK will match the - * request URL of outgoing requests against the items in this - * array, and only attach tracing headers if a match was found. - * - * @example - * ```js - * Sentry.init({ - * tracePropagationTargets: ['api.site.com'], - * }); - * ``` - */ - tracePropagationTargets?: TracePropagationTargets; - - /** - * Sets an optional server name (device name). - * - * This is useful for identifying which server or instance is sending events. - */ - serverName?: string; - - /** - * If you use Spotlight by Sentry during development, use - * this option to forward captured Sentry events to Spotlight. - * - * Either set it to true, or provide a specific Spotlight Sidecar URL. - * - * More details: https://spotlightjs.com/ - * - * IMPORTANT: Only set this option to `true` while developing, not in production! - */ - spotlight?: boolean | string; - +export interface OpenTelemetryServerRuntimeOptions extends ServerRuntimeOptions { /** * If this is set to true, the SDK will not set up OpenTelemetry automatically. * In this case, you _have_ to ensure to set it up correctly yourself, including: @@ -59,35 +20,6 @@ export interface ServerRuntimeOptions { */ skipOpenTelemetrySetup?: boolean; - /** - * If set to `false`, the SDK will not automatically detect the `serverName`. - * - * This is useful if you are using the SDK in a CLI app or Electron where the - * hostname might be considered PII. - * - * @default true - */ - includeServerName?: boolean; - - /** - * By default, the SDK will try to identify problems with your instrumentation setup and warn you about it. - * If you want to disable these warnings, set this to `true`. - */ - disableInstrumentationWarnings?: boolean; - - /** - * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause - * problems for sending events from command line applications. Setting it too - * high can cause the application to block for users with network connectivity - * problems. - */ - shutdownTimeout?: number; - - /** - * Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds). - */ - clientReportFlushInterval?: number; - /** * Provide an array of OpenTelemetry Instrumentations that should be registered. * @@ -99,29 +31,13 @@ export interface ServerRuntimeOptions { * Provide an array of additional OpenTelemetry SpanProcessors that should be registered. */ openTelemetrySpanProcessors?: SpanProcessor[]; - - /** - * The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span. - * The SDK will automatically clean up spans that have no finished parent after this duration. - * This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing. - * However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early. - * In this case, you can increase this duration to a value that fits your expected data. - * - * Defaults to 300 seconds (5 minutes). - */ - maxSpanWaitDuration?: number; - - /** - * Callback that is executed when a fatal global error occurs. - */ - onFatalError?(this: void, error: Error): void; } /** * Base options for the Sentry Node SDK. - * Extends the common WinterTC options shared with Bun and other server-side SDKs. + * Extends the common WinterTC options with OpenTelemetry support shared with Bun and other server-side SDKs. */ -export interface BaseNodeOptions extends ServerRuntimeOptions { +export interface BaseNodeOptions extends OpenTelemetryServerRuntimeOptions { /** * Sets profiling sample rate when @sentry/profiling-node is installed * diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index 0fb6ffa629d0..3a0cb1e7e5fc 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -1,13 +1,13 @@ import type { Span as WriteableSpan } from '@opentelemetry/api'; import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; import type { ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core'; -import type { NodeTransportOptions, ServerRuntimeOptions } from '@sentry/node-core'; +import type { NodeTransportOptions, OpenTelemetryServerRuntimeOptions } from '@sentry/node-core'; /** * Base options for the Sentry Node SDK. - * Extends the common WinterTC options shared with Bun and other server-side SDKs. + * Extends the common WinterTC options with OpenTelemetry support shared with Bun and other server-side SDKs. */ -export interface BaseNodeOptions extends ServerRuntimeOptions { +export interface BaseNodeOptions extends OpenTelemetryServerRuntimeOptions { /** * Sets profiling sample rate when @sentry/profiling-node is installed *