File tree Expand file tree Collapse file tree 5 files changed +35
-0
lines changed Expand file tree Collapse file tree 5 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,10 @@ export function init(options: NodeOptions = {}): void {
148148 options . autoSessionTracking = true ;
149149 }
150150
151+ if ( options . instrumenter === undefined ) {
152+ options . instrumenter = 'sentry' ;
153+ }
154+
151155 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
152156 if ( ( domain as any ) . active ) {
153157 setHubOnCarrier ( carrier , getCurrentHub ( ) ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616} from '../src' ;
1717import { ContextLines , LinkedErrors } from '../src/integrations' ;
1818import { defaultStackParser } from '../src/sdk' ;
19+ import { NodeClientOptions } from '../src/types' ;
1920import { getDefaultNodeClientOptions } from './helper/node-client-options' ;
2021
2122jest . mock ( '@sentry/core' , ( ) => {
@@ -470,4 +471,22 @@ describe('SentryNode initialization', () => {
470471 expect ( options . autoSessionTracking ) . toBe ( undefined ) ;
471472 } ) ;
472473 } ) ;
474+
475+ describe ( 'instrumenter' , ( ) => {
476+ it ( 'defaults to sentry instrumenter' , ( ) => {
477+ init ( { dsn } ) ;
478+
479+ const instrumenter = ( getCurrentHub ( ) ?. getClient ( ) ?. getOptions ( ) as NodeClientOptions ) . instrumenter ;
480+
481+ expect ( instrumenter ) . toEqual ( 'sentry' ) ;
482+ } ) ;
483+
484+ it ( 'allows to set instrumenter' , ( ) => {
485+ init ( { dsn, instrumenter : 'otel' } ) ;
486+
487+ const instrumenter = ( getCurrentHub ( ) ?. getClient ( ) ?. getOptions ( ) as NodeClientOptions ) . instrumenter ;
488+
489+ expect ( instrumenter ) . toEqual ( 'otel' ) ;
490+ } ) ;
491+ } ) ;
473492} ) ;
Original file line number Diff line number Diff line change @@ -92,3 +92,4 @@ export type {
9292} from './transport' ;
9393export type { User , UserFeedback } from './user' ;
9494export type { WrappedFunction } from './wrappedfunction' ;
95+ export type { Instrumenter } from './instrumenter' ;
Original file line number Diff line number Diff line change 1+ export type Instrumenter = 'sentry' | 'otel' ;
Original file line number Diff line number Diff line change 11import { Breadcrumb , BreadcrumbHint } from './breadcrumb' ;
22import { Event , EventHint } from './event' ;
3+ import { Instrumenter } from './instrumenter' ;
34import { Integration } from './integration' ;
45import { CaptureContext } from './scope' ;
56import { SdkMetadata } from './sdkmetadata' ;
@@ -58,6 +59,15 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
5859 */
5960 integrations : Integration [ ] ;
6061
62+ /**
63+ * The instrumenter to use. Defaults to `sentry`.
64+ * When not set to `sentry`, auto-instrumentation inside of Sentry will be disabled,
65+ * in favor of using external auto instrumentation.
66+ *
67+ * NOTE: Any option except for `sentry` is highly experimental and subject to change!
68+ */
69+ instrumenter ?: Instrumenter ;
70+
6171 /**
6272 * A function that takes transport options and returns the Transport object which is used to send events to Sentry.
6373 * The function is invoked internally when the client is initialized.
You can’t perform that action at this time.
0 commit comments