glutenfree
Version:
A profiler/loganalyzer for nginx/Cetrea Aw.
31 lines (21 loc) • 835 B
text/coffeescript
_ = require("underscore")
traverse = require("./../Utilities").traverse
class GlutenFreeProfilerTargeting
constructor: ->
@name = "glutenfree"
generate: (stats) ->
# we're only interested in GETs and we do some cleanup along the way
gets = _.filter(stats.uniques, (info) -> info.method is "GET")
gets = _.sortBy(gets, "percent").reverse()
accumulated = 0
# convert stats to lookup
targeting = for get in gets
do (get) ->
accumulated += get.percent
# replace args w newArgs
path: [get.action, get.component, get.componentVersion, get.endpoint, get.fun].filter((c) -> c?).concat(get.newArgs or get.args).join("/")
percentage: get.percent
acc_percentage: accumulated
# return
targeting
exports.targeting = new GlutenFreeProfilerTargeting()