@@ -139,6 +139,36 @@ describe('instrumentQueueProducer', () => {
139139 expect ( Array . isArray ( passed ) ) . toBe ( true ) ;
140140 expect ( passed ) . toHaveLength ( 2 ) ;
141141 } ) ;
142+
143+ test ( 'omits body size when all payloads cannot be serialized' , async ( ) => {
144+ const startSpanSpy = vi . spyOn ( SentryCore , 'startSpan' ) ;
145+ const queue = createMockQueue ( ) ;
146+ const wrapped = instrumentQueueProducer ( queue , 'MY_QUEUE' ) ;
147+
148+ const circular1 : Record < string , unknown > = { } ;
149+ circular1 . self = circular1 ;
150+ const circular2 : Record < string , unknown > = { } ;
151+ circular2 . self = circular2 ;
152+
153+ await wrapped . sendBatch ( [ { body : circular1 } , { body : circular2 } ] ) ;
154+
155+ const attrs = startSpanSpy . mock . calls [ 0 ] ! [ 0 ] . attributes ! ;
156+ expect ( attrs [ 'messaging.message.body.size' ] ) . toBeUndefined ( ) ;
157+ } ) ;
158+
159+ test ( 'sums only sizable bodies when batch contains mixed payloads' , async ( ) => {
160+ const startSpanSpy = vi . spyOn ( SentryCore , 'startSpan' ) ;
161+ const queue = createMockQueue ( ) ;
162+ const wrapped = instrumentQueueProducer ( queue , 'MY_QUEUE' ) ;
163+
164+ const circular : Record < string , unknown > = { } ;
165+ circular . self = circular ;
166+
167+ await wrapped . sendBatch ( [ { body : 'aa' } , { body : circular } , { body : 'bbb' } ] ) ;
168+
169+ const attrs = startSpanSpy . mock . calls [ 0 ] ! [ 0 ] . attributes ! ;
170+ expect ( attrs [ 'messaging.message.body.size' ] ) . toBe ( 5 ) ;
171+ } ) ;
142172 } ) ;
143173
144174 test ( 'forwards unknown property accesses transparently' , ( ) => {
0 commit comments