@@ -23,6 +23,7 @@ describe('The HttpTransaction module', function () {
2323
2424 it ( 'can be instantiated' , function ( ) {
2525 var httpTransaction = HttpTransaction . create ( eventBus , { } ) ;
26+ expect ( httpTransaction . totalRequestCount ) . to . be . eql ( 0 ) ;
2627 expect ( httpTransaction ) . to . be . ok ;
2728 } ) ;
2829
@@ -48,6 +49,45 @@ describe('The HttpTransaction module', function () {
4849 expect ( httpTransaction . partials [ traceId ] . events [ 0 ] . data ) . to . eql ( data ) ;
4950 } ) ;
5051
52+ it ( 'emits a send event onto the event bus' , function ( ) {
53+ var emitStub = this . sandbox . stub ( eventBus , 'emit' ) ;
54+
55+ var httpTransaction = HttpTransaction . create ( eventBus , {
56+ service : 'aladdin'
57+ } ) ;
58+
59+ var options = {
60+ isSync : false
61+ } ;
62+
63+ var totalRequestCount = 10000 ;
64+ var sampleSize = 60 ;
65+ var sampleRate = 1 ;
66+ var newSampleRate = Math . floor ( totalRequestCount / sampleSize ) ;
67+
68+ var databag = {
69+ sampleRate : sampleRate ,
70+ samples : [
71+ 1
72+ ] ,
73+ totalRequestCount : totalRequestCount
74+ } ;
75+
76+ httpTransaction . totalRequestCount = totalRequestCount ;
77+ httpTransaction . sampleSize = sampleSize ;
78+ httpTransaction . traces = [
79+ 1
80+ ] ;
81+
82+ httpTransaction . _send ( options ) ;
83+
84+ expect ( httpTransaction . totalRequestCount ) . to . be . eql ( 0 ) ;
85+ expect ( httpTransaction . sampleRate ) . to . be . eql ( newSampleRate ) ;
86+
87+ expect ( emitStub ) . to . be . calledOnce ;
88+ expect ( emitStub ) . to . be . calledWith ( eventBus . HTTP_TRANSACTION_STACK_TRACE , databag ) ;
89+ } ) ;
90+
5191 describe ( 'events' , function ( ) {
5292
5393 it ( 'stores the "ClientReceive" events w/ `x-span-id`' , function ( ) {
@@ -179,6 +219,8 @@ describe('The HttpTransaction module', function () {
179219 ]
180220 }
181221 } ) ;
222+
223+ expect ( httpTransaction . totalRequestCount ) . to . be . eql ( 1 ) ;
182224 } ) ;
183225
184226 it ( 'stores the "ServerRecieve" events with parent and timing data' , function ( ) {
@@ -282,6 +324,7 @@ describe('The HttpTransaction module', function () {
282324 span : url ,
283325 host : host ,
284326 trace : id ,
327+ isForceSampled : false ,
285328 service : service ,
286329 statusCode : 301 ,
287330 events : [ {
0 commit comments