@@ -81,6 +81,69 @@ describe('instrumentDurableObjectWithSentry', () => {
8181 expect ( initCore ) . nthCalledWith ( 2 , expect . any ( Function ) , expect . objectContaining ( { orgId : 2 } ) ) ;
8282 } ) ;
8383
84+ it ( 'does not create RPC spans without metadata when both RPC options are set' , ( ) => {
85+ const startSpanSpy = vi . spyOn ( SentryCore , 'startSpan' ) ;
86+ vi . spyOn ( SentryCore , 'getClient' ) . mockReturnValue ( undefined ) ;
87+
88+ const testClass = class {
89+ rpcMethod ( ) {
90+ return 'result' ;
91+ }
92+ } ;
93+ const instrumented = instrumentDurableObjectWithSentry (
94+ vi . fn ( ) . mockReturnValue ( {
95+ enableRpcTracePropagation : true ,
96+ instrumentPrototypeMethods : true ,
97+ } ) ,
98+ testClass as any ,
99+ ) ;
100+ const obj = Reflect . construct ( instrumented , [ ] ) ;
101+
102+ expect ( obj . rpcMethod ( ) ) . toBe ( 'result' ) ;
103+ expect ( startSpanSpy ) . not . toHaveBeenCalled ( ) ;
104+ } ) ;
105+
106+ it ( 'does not create RPC spans without metadata when enableRpcTracePropagation is true' , ( ) => {
107+ const startSpanSpy = vi . spyOn ( SentryCore , 'startSpan' ) ;
108+ vi . spyOn ( SentryCore , 'getClient' ) . mockReturnValue ( undefined ) ;
109+
110+ const testClass = class {
111+ rpcMethod ( ) {
112+ return 'result' ;
113+ }
114+ } ;
115+ const instrumented = instrumentDurableObjectWithSentry (
116+ vi . fn ( ) . mockReturnValue ( {
117+ enableRpcTracePropagation : true ,
118+ instrumentPrototypeMethods : false ,
119+ } ) ,
120+ testClass as any ,
121+ ) ;
122+ const obj = Reflect . construct ( instrumented , [ ] ) ;
123+
124+ expect ( obj . rpcMethod ( ) ) . toBe ( 'result' ) ;
125+ expect ( startSpanSpy ) . not . toHaveBeenCalled ( ) ;
126+ } ) ;
127+
128+ it ( 'creates RPC spans without metadata when using deprecated instrumentPrototypeMethods' , ( ) => {
129+ const startSpanSpy = vi . spyOn ( SentryCore , 'startSpan' ) . mockImplementation ( ( _ , callback ) => callback ( { } as any ) ) ;
130+ vi . spyOn ( SentryCore , 'getClient' ) . mockReturnValue ( undefined ) ;
131+
132+ const testClass = class {
133+ rpcMethod ( ) {
134+ return 'result' ;
135+ }
136+ } ;
137+ const instrumented = instrumentDurableObjectWithSentry (
138+ vi . fn ( ) . mockReturnValue ( { instrumentPrototypeMethods : true } ) ,
139+ testClass as any ,
140+ ) ;
141+ const obj = Reflect . construct ( instrumented , [ ] ) ;
142+
143+ expect ( obj . rpcMethod ( ) ) . toBe ( 'result' ) ;
144+ expect ( startSpanSpy ) . toHaveBeenCalled ( ) ;
145+ } ) ;
146+
84147 it ( 'Binds prototype methods to original object when enableRpcTracePropagation is true' , ( ) => {
85148 const testClass = class {
86149 method ( ) {
0 commit comments