|
@@ -1,8 +1,10 @@
|
|
|
StatsD = require('lynx')
|
|
StatsD = require('lynx')
|
|
|
statsd = new StatsD(process.env["STATSD_HOST"] or "localhost", 8125, {on_error:->})
|
|
statsd = new StatsD(process.env["STATSD_HOST"] or "localhost", 8125, {on_error:->})
|
|
|
|
|
|
|
|
|
|
+traceAgent = require('@google-cloud/trace-agent')
|
|
|
|
|
+debugAgent = require('@google-cloud/debug-agent')
|
|
|
|
|
+
|
|
|
prom = require('prom-client')
|
|
prom = require('prom-client')
|
|
|
-collectDefaultMetrics = client.collectDefaultMetrics
|
|
|
|
|
|
|
|
|
|
name = "unknown"
|
|
name = "unknown"
|
|
|
hostname = require('os').hostname()
|
|
hostname = require('os').hostname()
|
|
@@ -15,21 +17,10 @@ destructors = []
|
|
|
require "./uv_threadpool_size"
|
|
require "./uv_threadpool_size"
|
|
|
|
|
|
|
|
|
|
|
|
|
-traceAgent = require('@google-cloud/trace-agent')
|
|
|
|
|
-debugAgent = require('@google-cloud/debug-agent')
|
|
|
|
|
-
|
|
|
|
|
-.start({
|
|
|
|
|
- serviceContext: {
|
|
|
|
|
- allowExpressions: true,
|
|
|
|
|
- service: 'filestore-readonly',
|
|
|
|
|
- version: '0.0.1'
|
|
|
|
|
- }
|
|
|
|
|
-});
|
|
|
|
|
|
|
|
|
|
module.exports = Metrics =
|
|
module.exports = Metrics =
|
|
|
initialize: (_name) ->
|
|
initialize: (_name) ->
|
|
|
name = _name
|
|
name = _name
|
|
|
- collectDefaultMetrics({ timeout: 5000, prefix: name })
|
|
|
|
|
traceAgent.start()
|
|
traceAgent.start()
|
|
|
debugAgent.start({
|
|
debugAgent.start({
|
|
|
serviceContext: {
|
|
serviceContext: {
|
|
@@ -47,19 +38,9 @@ module.exports = Metrics =
|
|
|
|
|
|
|
|
inc : (key, sampleRate = 1)->
|
|
inc : (key, sampleRate = 1)->
|
|
|
statsd.increment buildKey(key), sampleRate
|
|
statsd.increment buildKey(key), sampleRate
|
|
|
- counter = new prom.Counter({
|
|
|
|
|
- name: key,
|
|
|
|
|
- help: key #https://prometheus.io/docs/instrumenting/writing_exporters/#help-strings this is probably wrong
|
|
|
|
|
- });
|
|
|
|
|
- counter.inc()
|
|
|
|
|
|
|
|
|
|
count : (key, count, sampleRate = 1)->
|
|
count : (key, count, sampleRate = 1)->
|
|
|
statsd.count buildKey(key), count, sampleRate
|
|
statsd.count buildKey(key), count, sampleRate
|
|
|
- counter = new prom.Counter({
|
|
|
|
|
- name: key,
|
|
|
|
|
- help: key #https://prometheus.io/docs/instrumenting/writing_exporters/#help-strings this is probably wrong
|
|
|
|
|
- });
|
|
|
|
|
- counter.inc(count)
|
|
|
|
|
|
|
|
|
|
timing: (key, timeSpan, sampleRate)->
|
|
timing: (key, timeSpan, sampleRate)->
|
|
|
statsd.timing(buildKey(key), timeSpan, sampleRate)
|
|
statsd.timing(buildKey(key), timeSpan, sampleRate)
|