mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
use modified prefix and method name
This commit is contained in:
parent
2a6839f48c
commit
a8cfa97463
2 changed files with 9 additions and 8 deletions
|
@ -52,16 +52,18 @@ module.exports = Metrics =
|
|||
|
||||
set : (key, value, sampleRate = 1)->
|
||||
|
||||
inc : (key, sampleRate = 1)->
|
||||
inc : (key, sampleRate = 1, opts)->
|
||||
key = Metrics.buildPromKey(key)
|
||||
if !promMetrics[key]?
|
||||
promMetrics[key] = new prom.Counter({
|
||||
name: key,
|
||||
help: key,
|
||||
labelNames: ['app','host']
|
||||
labelNames: ['app','host','status','method']
|
||||
})
|
||||
console.log("doing inc", key, appname)
|
||||
promMetrics[key].inc({app: appname, host: hostname})
|
||||
opts.app = appname
|
||||
opts.host = hostname
|
||||
promMetrics[key].inc(opts)
|
||||
|
||||
count : (key, count, sampleRate = 1)->
|
||||
key = Metrics.buildPromKey(key)
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = (obj, methodName, prefix, logger) ->
|
|||
startPrefix = prefix.split(".")[0]
|
||||
|
||||
endPrefix = prefix.split(".")[1]
|
||||
modifedMethodName = "#{endPrefix}_methodName"
|
||||
modifedMethodName = "#{endPrefix}_#{methodName}"
|
||||
console.log "Async method", prefix, key, methodName, modifedMethodName
|
||||
obj[methodName] = (originalArgs...) ->
|
||||
|
||||
|
@ -25,16 +25,15 @@ module.exports = (obj, methodName, prefix, logger) ->
|
|||
console.log("creating timer for async method", prefix, startPrefix, modifedMethodName)
|
||||
|
||||
|
||||
timer = new metrics.Timer(prefix, null, {method: methodName})
|
||||
console.log("changed timer for async method", prefix, methodName, key)
|
||||
timer = new metrics.Timer(startPrefix, null, {method: modifedMethodName})
|
||||
|
||||
realMethod.call this, firstArgs..., (callbackArgs...) ->
|
||||
elapsedTime = timer.done()
|
||||
possibleError = callbackArgs[0]
|
||||
if possibleError?
|
||||
metrics.inc "#{key}.failure"
|
||||
metrics.inc "#{startPrefix}", null, {status:"success", method: modifedMethodName}
|
||||
else
|
||||
metrics.inc "#{key}.success"
|
||||
metrics.inc "#{startPrefix}", null, {status:"failed", method: modifedMethodName}
|
||||
if logger?
|
||||
loggableArgs = {}
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue