diff --git a/libraries/metrics/http.coffee b/libraries/metrics/http.coffee index 1abaede902..45f72b7642 100644 --- a/libraries/metrics/http.coffee +++ b/libraries/metrics/http.coffee @@ -12,7 +12,7 @@ module.exports.monitor = (logger) -> routePath = req.route.path.toString().replace(/\//g, '_').replace(/\:/g, '').slice(1) key = "http-requests.#{routePath}.#{req.method}.#{res.statusCode}" - Metrics.timing("http_request", responseTime, null, {method:req.method, status_code:res.status_code, path:routePath}) + Metrics.timing("http_request", responseTime, null, {method:req.method, status_code: res.statusCode, path:routePath}) logger.log req: url: req.originalUrl || req.url diff --git a/libraries/metrics/metrics.coffee b/libraries/metrics/metrics.coffee index 60624e4ac2..7e2927e7ae 100644 --- a/libraries/metrics/metrics.coffee +++ b/libraries/metrics/metrics.coffee @@ -87,22 +87,22 @@ module.exports = Metrics = help: key, maxAgeSeconds: 600, ageBuckets: 10, - labelNames: ['app', 'path', 'status_code', 'method'] + labelNames: ['app', 'path', 'status_code', 'method', 'collection', 'query'] }) opts.app = name - console.log(key, opts, "timing key") promMetrics[key].observe(opts, timeSpan) Timer : class - constructor :(key, sampleRate = 1)-> + constructor :(key, sampleRate = 1, opts)-> this.start = new Date() key = Metrics.sanitizeKey(key) this.key = key this.sampleRate = sampleRate + this.opts = opts done:-> timeSpan = new Date - this.start - Metrics.timing(this.key, timeSpan, this.sampleRate) + Metrics.timing(this.key, timeSpan, this.sampleRate, this.opts) return timeSpan gauge : (key, value, sampleRate = 1)-> diff --git a/libraries/metrics/mongodb.coffee b/libraries/metrics/mongodb.coffee index ce1ca71385..1f54cdde9a 100644 --- a/libraries/metrics/mongodb.coffee +++ b/libraries/metrics/mongodb.coffee @@ -34,7 +34,7 @@ module.exports = query = Object.keys(db_command.query).sort().join("_") key += "." + query - timer = new Metrics.Timer(key) + timer = new Metrics.Timer("mongo", {collection: collection, query:query}) start = new Date() _method.call this, db_command, options, () -> timer.done() diff --git a/libraries/metrics/timeAsyncMethod.coffee b/libraries/metrics/timeAsyncMethod.coffee index 27e21e6e09..6986299390 100644 --- a/libraries/metrics/timeAsyncMethod.coffee +++ b/libraries/metrics/timeAsyncMethod.coffee @@ -17,7 +17,7 @@ module.exports = (obj, methodName, prefix, logger) -> logger.log "[Metrics] expected wrapped method '#{methodName}' to be invoked with a callback" return realMethod.apply this, originalArgs - timer = new metrics.Timer(key) + timer = new metrics.Timer(prefix, null, {method: methodName}) realMethod.call this, firstArgs..., (callbackArgs...) -> elapsedTime = timer.done()