@@ -151,7 +151,7 @@ describe('The Trace agent', function () {
151151 expect ( rpmMetrics . addStatusCode ) . to . have . been . calledWith ( statusCode )
152152 expect ( agent . totalRequestCount ) . to . eql ( 1 )
153153 expect ( agent . partials ) . to . eql ( { } )
154- expect ( agent . spans ) . to . eql ( [ {
154+ expect ( agent . reservoirSampler . getItems ( ) ) . to . eql ( [ {
155155 requestId : transactionId ,
156156 isForceSampled : true ,
157157 isSampled : false ,
@@ -195,7 +195,7 @@ describe('The Trace agent', function () {
195195 } )
196196
197197 expect ( agent . totalRequestCount ) . to . eql ( 1 )
198- expect ( agent . spans ) . to . eql ( [ ] )
198+ expect ( agent . reservoirSampler . getItems ( ) ) . to . eql ( [ ] )
199199 expect ( agent . partials [ transactionId ] ) . to . eql ( {
200200 requestId : transactionId ,
201201 isForceSampled : false ,
@@ -237,7 +237,7 @@ describe('The Trace agent', function () {
237237 this . sandbox . stub ( agent , 'getSpanId' ) . returns ( spanId )
238238 agent . report ( 'obviously' , { a : 'mock' } )
239239 expect ( agent . totalRequestCount ) . to . eql ( 1 )
240- expect ( agent . spans ) . to . eql ( [ ] )
240+ expect ( agent . reservoirSampler . getItems ( ) ) . to . eql ( [ ] )
241241 expect ( agent . partials [ transactionId ] ) . to . eql ( {
242242 requestId : transactionId ,
243243 isForceSampled : false ,
@@ -281,7 +281,7 @@ describe('The Trace agent', function () {
281281
282282 agent . reportError ( 'mocking a' , new Error ( 'with style' ) )
283283 expect ( agent . totalRequestCount ) . to . eql ( 1 )
284- expect ( agent . spans ) . to . eql ( [ ] )
284+ expect ( agent . reservoirSampler . getItems ( ) ) . to . eql ( [ ] )
285285 expect ( agent . partials [ transactionId ] ) . to . eql ( {
286286 requestId : transactionId ,
287287 isForceSampled : false ,
@@ -311,17 +311,13 @@ describe('The Trace agent', function () {
311311 } )
312312
313313 it ( 'passes sample and span data to the API client' , function ( ) {
314- agent . spans = [
315- 1 ,
316- 2 ,
317- 3
318- ]
314+ agent . reservoirSampler . addReturnsSuccess ( 1 )
319315 agent . totalRequestCount = 6
320316 agent . _send ( )
321317
322318 expect ( agent . totalRequestCount ) . to . eql ( 0 )
323319 expect ( collectorApi . sendSamples ) . to . be . calledWith ( {
324- spans : [ 1 , 2 , 3 ] ,
320+ spans : [ 1 ] ,
325321 sample : {
326322 rate : 1 ,
327323 totalRequestCount : 1
@@ -331,7 +327,9 @@ describe('The Trace agent', function () {
331327
332328 it ( 'limits must-collect count to 20' , function ( ) {
333329 var statusCode = 200
334- agent . mustCollectCount = 20
330+ for ( var i = 0 ; i < 100 ; i += 1 ) {
331+ agent . reservoirSampler . addReturnsSuccess ( 1 )
332+ }
335333 agent . serverReceive ( {
336334 id : transactionId ,
337335 spanId : spanId ,
@@ -349,7 +347,7 @@ describe('The Trace agent', function () {
349347 mustCollect : '1'
350348 } )
351349
352- expect ( agent . spans ) . to . eql ( [ ] )
353- expect ( agent . mustCollectCount ) . to . eql ( 21 )
350+ expect ( agent . reservoirSampler . getItems ( ) . length ) . to . eql ( 100 )
351+ expect ( agent . reservoirSampler . itemsSeen ) . to . eql ( 101 )
354352 } )
355353} )
0 commit comments