File tree 5 files changed +35
-0
lines changed
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 {
148
148
options . autoSessionTracking = true ;
149
149
}
150
150
151
+ if ( options . instrumenter === undefined ) {
152
+ options . instrumenter = 'sentry' ;
153
+ }
154
+
151
155
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
152
156
if ( ( domain as any ) . active ) {
153
157
setHubOnCarrier ( carrier , getCurrentHub ( ) ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
} from '../src' ;
17
17
import { ContextLines , LinkedErrors } from '../src/integrations' ;
18
18
import { defaultStackParser } from '../src/sdk' ;
19
+ import { NodeClientOptions } from '../src/types' ;
19
20
import { getDefaultNodeClientOptions } from './helper/node-client-options' ;
20
21
21
22
jest . mock ( '@sentry/core' , ( ) => {
@@ -470,4 +471,22 @@ describe('SentryNode initialization', () => {
470
471
expect ( options . autoSessionTracking ) . toBe ( undefined ) ;
471
472
} ) ;
472
473
} ) ;
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
+ } ) ;
473
492
} ) ;
Original file line number Diff line number Diff line change @@ -92,3 +92,4 @@ export type {
92
92
} from './transport' ;
93
93
export type { User , UserFeedback } from './user' ;
94
94
export 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 1
1
import { Breadcrumb , BreadcrumbHint } from './breadcrumb' ;
2
2
import { Event , EventHint } from './event' ;
3
+ import { Instrumenter } from './instrumenter' ;
3
4
import { Integration } from './integration' ;
4
5
import { CaptureContext } from './scope' ;
5
6
import { SdkMetadata } from './sdkmetadata' ;
@@ -58,6 +59,15 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
58
59
*/
59
60
integrations : Integration [ ] ;
60
61
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
+
61
71
/**
62
72
* A function that takes transport options and returns the Transport object which is used to send events to Sentry.
63
73
* The function is invoked internally when the client is initialized.
You can’t perform that action at this time.
0 commit comments