Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 8 additions & 50 deletions packages/bun/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,12 @@
import type { BaseTransportOptions, ClientOptions, Options, TracePropagationTargets } from '@sentry/core';
import type { BaseTransportOptions, ClientOptions, Options } from '@sentry/core';
import type { ServerRuntimeOptions } from '@sentry/node-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 ServerRuntimeOptions {}

/**
* Configuration options for the Sentry Bun SDK
Expand Down
2 changes: 1 addition & 1 deletion packages/node-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
147 changes: 88 additions & 59 deletions packages/node-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ 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';

export interface BaseNodeOptions {
/**
* 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, let's ensure that ServerRuntimeOptions only includes the options that can be used across all SDKs using or extending from ServerRuntimeClient.

For the remaining options shared by Node and Bun, we can do whatever makes the most sense. Happy to leave this up to you.

Thanks! :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the description. The new option with OTel support is now called OpenTelemetryServerRuntimeOptions

/**
* List of strings/regex controlling to which outgoing requests
* the SDK will attach tracing headers.
Expand All @@ -24,42 +31,33 @@ export interface BaseNodeOptions {
tracePropagationTargets?: TracePropagationTargets;

/**
* Sets profiling sample rate when @sentry/profiling-node is installed
* Sets an optional server name (device name).
*
* @deprecated
* This is useful for identifying which server or instance is sending events.
*/
profilesSampleRate?: number;
serverName?: string;

/**
* Function to compute profiling sample rate dynamically and filter unwanted profiles.
*
* Profiling is enabled if either this or `profilesSampleRate` is defined. If both are defined, `profilesSampleRate` is
* ignored.
* If you use Spotlight by Sentry during development, use
* this option to forward captured Sentry events to Spotlight.
*
* Will automatically be passed a context object of default and optional custom data.
* Either set it to true, or provide a specific Spotlight Sidecar URL.
*
* @returns A sample rate between 0 and 1 (0 drops the profile, 1 guarantees it will be sent). Returning `true` is
* equivalent to returning 1 and returning `false` is equivalent to returning 0.
* More details: https://spotlightjs.com/
*
* @deprecated
* IMPORTANT: Only set this option to `true` while developing, not in production!
*/
profilesSampler?: (samplingContext: SamplingContext) => number | boolean;
spotlight?: boolean | string;

/**
* Sets profiling session sample rate - only evaluated once per SDK initialization.
* @default 0
* 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`
*/
profileSessionSampleRate?: number;

/**
* Set the lifecycle of the profiler.
*
* - `manual`: The profiler will be manually started and stopped.
* - `trace`: The profiler will be automatically started when when a span is sampled and stopped when there are no more sampled spans.
*
* @default 'manual'
*/
profileLifecycle?: 'manual' | 'trace';
skipOpenTelemetrySetup?: boolean;

/**
* If set to `false`, the SDK will not automatically detect the `serverName`.
Expand All @@ -71,27 +69,24 @@ export interface BaseNodeOptions {
*/
includeServerName?: boolean;

/** Sets an optional server name (device name) */
serverName?: string;
/**
* 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;

/**
* Include local variables with stack traces.
*
* Requires the `LocalVariables` integration.
* 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.
*/
includeLocalVariables?: boolean;
shutdownTimeout?: number;

/**
* 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!
* Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds).
*/
spotlight?: boolean | string;
clientReportFlushInterval?: number;

/**
* Provide an array of OpenTelemetry Instrumentations that should be registered.
Expand All @@ -117,36 +112,70 @@ export interface BaseNodeOptions {
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
* with certain libraries. If you run into problems running your app with this enabled,
* please raise an issue in https://github.com/getsentry/sentry-javascript.
* 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.
*/
export interface BaseNodeOptions extends ServerRuntimeOptions {
/**
* Sets profiling sample rate when @sentry/profiling-node is installed
*
* Defaults to `true`.
* @deprecated
*/
registerEsmLoaderHooks?: boolean;
profilesSampleRate?: number;

/**
* Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds).
* Function to compute profiling sample rate dynamically and filter unwanted profiles.
*
* Profiling is enabled if either this or `profilesSampleRate` is defined. If both are defined, `profilesSampleRate` is
* ignored.
*
* Will automatically be passed a context object of default and optional custom data.
*
* @returns A sample rate between 0 and 1 (0 drops the profile, 1 guarantees it will be sent). Returning `true` is
* equivalent to returning 1 and returning `false` is equivalent to returning 0.
*
* @deprecated
*/
clientReportFlushInterval?: number;
profilesSampler?: (samplingContext: SamplingContext) => number | 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`.
* Sets profiling session sample rate - only evaluated once per SDK initialization.
* @default 0
*/
disableInstrumentationWarnings?: boolean;
profileSessionSampleRate?: number;

/**
* 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.
* Set the lifecycle of the profiler.
*
* - `manual`: The profiler will be manually started and stopped.
* - `trace`: The profiler will be automatically started when when a span is sampled and stopped when there are no more sampled spans.
*
* @default 'manual'
*/
shutdownTimeout?: number;
profileLifecycle?: 'manual' | 'trace';

/** Callback that is executed when a fatal global error occurs. */
onFatalError?(this: void, error: Error): void;
/**
* Include local variables with stack traces.
*
* Requires the `LocalVariables` integration.
*/
includeLocalVariables?: boolean;

/**
* 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
* with certain libraries. If you run into problems running your app with this enabled,
* please raise an issue in https://github.com/getsentry/sentry-javascript.
*
* Defaults to `true`.
*/
registerEsmLoaderHooks?: boolean;
}

/**
Expand Down
Loading
Loading