File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
lib/agent/metrics/externalEdge Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ var debug = require ( 'debug' ) ( 'risingstack/trace' )
12var flatMap = require ( 'lodash.flatmap' )
23var consts = require ( '../../../consts' )
34
@@ -36,6 +37,12 @@ ExternalEdgeMetrics.prototype.initProtocol = function (data) {
3637}
3738
3839ExternalEdgeMetrics . prototype . report = function ( data ) {
40+ // protect against bad use of the report function: responseTime is required
41+ // TODO: check all instrumentations to be sure they send a responseTime
42+ if ( ! data . responseTime ) {
43+ debug ( 'ExternalEdgeMetrics.report responseTime is undefined, discarding' )
44+ return
45+ }
3946 this . initProtocol ( data )
4047 var edge = this . initHost ( data )
4148
Original file line number Diff line number Diff line change @@ -3,6 +3,32 @@ var expect = require('chai').expect
33var ExternalEdgeMetrics = require ( './' )
44
55describe ( 'The ExternalEdgeMetrics module' , function ( ) {
6+ it ( 'discards undefined responseTime values' , function ( ) {
7+ var ISOString = 'date-string'
8+ var collectorApi = {
9+ sendExternalEdgeMetrics : this . sandbox . spy ( )
10+ }
11+
12+ var edgeMetrics = ExternalEdgeMetrics . create ( {
13+ collectorApi : collectorApi ,
14+ config : {
15+ collectInterval : 1
16+ }
17+ } )
18+
19+ this . sandbox . stub ( Date . prototype , 'toISOString' , function ( ) {
20+ return ISOString
21+ } )
22+
23+ edgeMetrics . report ( {
24+ targetHost : 'rstckapp.com' ,
25+ protocol : 'psql' ,
26+ status : 0
27+ } )
28+
29+ expect ( edgeMetrics . metrics ) . to . eql ( { } )
30+ } )
31+
632 it ( 'sends metrics' , function ( ) {
733 var ISOString = 'date-string'
834 var collectorApi = {
You can’t perform that action at this time.
0 commit comments