File tree Expand file tree Collapse file tree 15 files changed +163
-1
lines changed
Expand file tree Collapse file tree 15 files changed +163
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ export class Http implements Integration {
3838 */
3939 public name : string = Http . id ;
4040
41+ /**
42+ * If the integration was skipped due to internal checks.
43+ */
44+ public _wasSkipped : boolean = false ;
45+
4146 /**
4247 * @inheritDoc
4348 */
@@ -65,13 +70,15 @@ export class Http implements Integration {
6570 ) : void {
6671 // No need to instrument if we don't want to track anything
6772 if ( ! this . _breadcrumbs && ! this . _tracing ) {
73+ this . _wasSkipped = true ;
6874 return ;
6975 }
7076
7177 const clientOptions = setupOnceGetCurrentHub ( ) . getClient < NodeClient > ( ) ?. getOptions ( ) ;
7278
7379 // Do not auto-instrument for other instrumenter
7480 if ( clientOptions && clientOptions . instrumenter !== 'sentry' ) {
81+ this . _wasSkipped = true ;
7582 return ;
7683 }
7784
Original file line number Diff line number Diff line change @@ -188,6 +188,26 @@ describe('tracing', () => {
188188 expect ( transaction . metadata . propagations ) . toBe ( 2 ) ;
189189 } ) ;
190190
191+ it ( "doesn't attach when using otel instrumenter" , ( ) => {
192+ const options = getDefaultNodeClientOptions ( {
193+ dsn : 'https://dogsarebadatkeepingsecrets@squirrelchasers.ingest.sentry.io/12312012' ,
194+ tracesSampleRate : 1.0 ,
195+ integrations : [ new HttpIntegration ( { tracing : true } ) ] ,
196+ release : '1.0.0' ,
197+ environment : 'production' ,
198+ instrumenter : 'otel' ,
199+ } ) ;
200+ const hub = new Hub ( new NodeClient ( options ) ) ;
201+
202+ const integration = new HttpIntegration ( ) as HttpIntegration & { _wasSkipped : boolean } ;
203+ integration . setupOnce (
204+ ( ) => { } ,
205+ ( ) => hub ,
206+ ) ;
207+
208+ expect ( integration . _wasSkipped ) . toBe ( true ) ;
209+ } ) ;
210+
191211 describe ( 'tracePropagationTargets option' , ( ) => {
192212 beforeEach ( ( ) => {
193213 // hacky way of restoring monkey patched functions
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ export class Apollo implements Integration {
2424 */
2525 public name : string = Apollo . id ;
2626
27+ /**
28+ * If the integration was skipped due to internal checks.
29+ */
30+ public _wasSkipped : boolean = false ;
31+
2732 /**
2833 * @inheritDoc
2934 */
@@ -38,11 +43,13 @@ export class Apollo implements Integration {
3843
3944 if ( ! pkg ) {
4045 __DEBUG_BUILD__ && logger . error ( 'Apollo Integration was unable to require apollo-server-core package.' ) ;
46+ this . _wasSkipped = true ;
4147 return ;
4248 }
4349
4450 if ( shouldDisableAutoInstrumentation ( getCurrentHub ) ) {
4551 __DEBUG_BUILD__ && logger . log ( 'Apollo Integration is skipped because of instrumenter configuration.' ) ;
52+ this . _wasSkipped = true ;
4653 return ;
4754 }
4855
Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ export class Express implements Integration {
9090 */
9191 public name : string = Express . id ;
9292
93+ /**
94+ * If the integration was skipped due to internal checks.
95+ */
96+ public _wasSkipped : boolean = false ;
97+
9398 /**
9499 * Express App instance
95100 */
@@ -110,11 +115,13 @@ export class Express implements Integration {
110115 public setupOnce ( _ : unknown , getCurrentHub : ( ) => Hub ) : void {
111116 if ( ! this . _router ) {
112117 __DEBUG_BUILD__ && logger . error ( 'ExpressIntegration is missing an Express instance' ) ;
118+ this . _wasSkipped = true ;
113119 return ;
114120 }
115121
116122 if ( shouldDisableAutoInstrumentation ( getCurrentHub ) ) {
117123 __DEBUG_BUILD__ && logger . log ( 'Express Integration is skipped because of instrumenter configuration.' ) ;
124+ this . _wasSkipped = true ;
118125 return ;
119126 }
120127
Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ export class GraphQL implements Integration {
1616 */
1717 public name : string = GraphQL . id ;
1818
19+ /**
20+ * If the integration was skipped due to internal checks.
21+ */
22+ public _wasSkipped : boolean = false ;
23+
1924 /**
2025 * @inheritDoc
2126 */
@@ -26,11 +31,13 @@ export class GraphQL implements Integration {
2631
2732 if ( ! pkg ) {
2833 __DEBUG_BUILD__ && logger . error ( 'GraphQL Integration was unable to require graphql/execution package.' ) ;
34+ this . _wasSkipped = true ;
2935 return ;
3036 }
3137
3238 if ( shouldDisableAutoInstrumentation ( getCurrentHub ) ) {
3339 __DEBUG_BUILD__ && logger . log ( 'GraphQL Integration is skipped because of instrumenter configuration.' ) ;
40+ this . _wasSkipped = true ;
3441 return ;
3542 }
3643
Original file line number Diff line number Diff line change @@ -102,6 +102,11 @@ export class Mongo implements Integration {
102102 */
103103 public name : string = Mongo . id ;
104104
105+ /**
106+ * If the integration was skipped due to internal checks.
107+ */
108+ public _wasSkipped : boolean = false ;
109+
105110 private _operations : Operation [ ] ;
106111 private _describeOperations ?: boolean | Operation [ ] ;
107112 private _useMongoose : boolean ;
@@ -124,11 +129,13 @@ export class Mongo implements Integration {
124129
125130 if ( ! pkg ) {
126131 __DEBUG_BUILD__ && logger . error ( `Mongo Integration was unable to require \`${ moduleName } \` package.` ) ;
132+ this . _wasSkipped = true ;
127133 return ;
128134 }
129135
130136 if ( shouldDisableAutoInstrumentation ( getCurrentHub ) ) {
131137 __DEBUG_BUILD__ && logger . log ( 'Mongo Integration is skipped because of instrumenter configuration.' ) ;
138+ this . _wasSkipped = true ;
132139 return ;
133140 }
134141
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ export class Mysql implements Integration {
2020 */
2121 public name : string = Mysql . id ;
2222
23+ /**
24+ * If the integration was skipped due to internal checks.
25+ */
26+ public _wasSkipped : boolean = false ;
27+
2328 /**
2429 * @inheritDoc
2530 */
@@ -28,11 +33,13 @@ export class Mysql implements Integration {
2833
2934 if ( ! pkg ) {
3035 __DEBUG_BUILD__ && logger . error ( 'Mysql Integration was unable to require `mysql` package.' ) ;
36+ this . _wasSkipped = true ;
3137 return ;
3238 }
3339
3440 if ( shouldDisableAutoInstrumentation ( getCurrentHub ) ) {
3541 __DEBUG_BUILD__ && logger . log ( 'Mysql Integration is skipped because of instrumenter configuration.' ) ;
42+ this . _wasSkipped = true ;
3643 return ;
3744 }
3845
Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ export class Postgres implements Integration {
2626 */
2727 public name : string = Postgres . id ;
2828
29+ /**
30+ * If the integration was skipped due to internal checks.
31+ */
32+ public _wasSkipped : boolean = false ;
33+
2934 private _usePgNative : boolean ;
3035
3136 public constructor ( options : PgOptions = { } ) {
@@ -40,11 +45,13 @@ export class Postgres implements Integration {
4045
4146 if ( ! pkg ) {
4247 __DEBUG_BUILD__ && logger . error ( 'Postgres Integration was unable to require `pg` package.' ) ;
48+ this . _wasSkipped = true ;
4349 return ;
4450 }
4551
4652 if ( shouldDisableAutoInstrumentation ( getCurrentHub ) ) {
4753 __DEBUG_BUILD__ && logger . log ( 'Postgres Integration is skipped because of instrumenter configuration.' ) ;
54+ this . _wasSkipped = true ;
4855 return ;
4956 }
5057
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ export class Prisma implements Integration {
5454 */
5555 public name : string = Prisma . id ;
5656
57+ /**
58+ * If the integration was skipped due to internal checks.
59+ */
60+ public _wasSkipped : boolean = false ;
61+
5762 /**
5863 * Prisma ORM Client Instance
5964 */
@@ -79,11 +84,13 @@ export class Prisma implements Integration {
7984 public setupOnce ( _ : ( callback : EventProcessor ) => void , getCurrentHub : ( ) => Hub ) : void {
8085 if ( ! this . _client ) {
8186 __DEBUG_BUILD__ && logger . error ( 'PrismaIntegration is missing a Prisma Client Instance' ) ;
87+ this . _wasSkipped = true ;
8288 return ;
8389 }
8490
8591 if ( shouldDisableAutoInstrumentation ( getCurrentHub ) ) {
8692 __DEBUG_BUILD__ && logger . log ( 'Prisma Integration is skipped because of instrumenter configuration.' ) ;
93+ this . _wasSkipped = true ;
8794 return ;
8895 }
8996
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { Hub, Scope } from '@sentry/core';
33
44import { Apollo } from '../../src/integrations/node/apollo' ;
55import { Span } from '../../src/span' ;
6+ import { getTestClient } from '../testutils' ;
67
78type ApolloResolverGroup = {
89 [ key : string ] : ( ) => any ;
@@ -100,4 +101,17 @@ describe('setupOnce', () => {
100101 } ) ;
101102 expect ( childSpan . finish ) . toBeCalled ( ) ;
102103 } ) ;
104+
105+ it ( "doesn't attach when using otel instrumenter" , ( ) => {
106+ const client = getTestClient ( { instrumenter : 'otel' } ) ;
107+ const hub = new Hub ( client ) ;
108+
109+ const integration = new Apollo ( ) as Apollo & { _wasSkipped : boolean } ;
110+ integration . setupOnce (
111+ ( ) => { } ,
112+ ( ) => hub ,
113+ ) ;
114+
115+ expect ( integration . _wasSkipped ) . toBe ( true ) ;
116+ } ) ;
103117} ) ;
You can’t perform that action at this time.
0 commit comments