@@ -56,6 +56,10 @@ describe('Trace', function () {
5656 report : sinon . spy ( ) ,
5757 reportError : sinon . spy ( ) ,
5858 getRequestId : sinon . spy ( ) ,
59+ customMetrics : {
60+ increment : sinon . spy ( ) ,
61+ record : sinon . spy ( )
62+ } ,
5963 memoryProfiler : { }
6064 }
6165
@@ -64,6 +68,8 @@ describe('Trace', function () {
6468 fakeAgent . report . reset ( )
6569 fakeAgent . reportError . reset ( )
6670 fakeAgent . getRequestId . reset ( )
71+ fakeAgent . customMetrics . increment . reset ( )
72+ fakeAgent . customMetrics . record . reset ( )
6773 } )
6874
6975 it ( 'is a constructor' , function ( ) {
@@ -147,6 +153,25 @@ describe('Trace', function () {
147153 expect ( fakeAgent . getRequestId ) . to . have . been . called
148154 } )
149155 } )
156+
157+ describe ( 'customMetrics' , function ( ) {
158+ it ( 'is a function' , function ( ) {
159+ this . sandbox . stub ( Agent , 'create' ) . returns ( fakeAgent )
160+ this . sandbox . stub ( Instrumentation , 'create' ) . returns ( { } )
161+ var instance = new trace . Trace ( fakeConfig )
162+ expect ( instance . incrementMetric ) . to . be . a ( 'function' )
163+ expect ( instance . recordMetric ) . to . be . a ( 'function' )
164+ } )
165+ it ( 'calls agent.customMetrics' , function ( ) {
166+ this . sandbox . stub ( Agent , 'create' ) . returns ( fakeAgent )
167+ this . sandbox . stub ( Instrumentation , 'create' ) . returns ( { } )
168+ var instance = new trace . Trace ( fakeConfig )
169+ instance . incrementMetric ( )
170+ instance . recordMetric ( )
171+ expect ( fakeAgent . customMetrics . record ) . to . have . been . called
172+ expect ( fakeAgent . customMetrics . increment ) . to . have . been . called
173+ } )
174+ } )
150175 } )
151176 } )
152177
0 commit comments