From d54d45127f8e19e89bb5e13b95dacbbf477ad2c3 Mon Sep 17 00:00:00 2001 From: rochdev Date: Tue, 12 Nov 2019 13:18:09 -0500 Subject: [PATCH 1/9] move prefix to individual metrics --- .../dd-trace/src/platform/node/metrics.js | 66 ++++----- packages/dd-trace/src/scope/async_hooks.js | 8 +- .../dd-trace/test/platform/node/index.spec.js | 134 +++++++++--------- .../dd-trace/test/scope/async_hooks.spec.js | 12 +- 4 files changed, 110 insertions(+), 110 deletions(-) diff --git a/packages/dd-trace/src/platform/node/metrics.js b/packages/dd-trace/src/platform/node/metrics.js index b618d6ea63b..41d7041bbba 100644 --- a/packages/dd-trace/src/platform/node/metrics.js +++ b/packages/dd-trace/src/platform/node/metrics.js @@ -144,36 +144,36 @@ function captureCpuUsage () { const systemPercent = 100 * elapsedUsage.system / 1000 / elapsedMs const totalPercent = userPercent + systemPercent - client.gauge('cpu.system', systemPercent.toFixed(2)) - client.gauge('cpu.user', userPercent.toFixed(2)) - client.gauge('cpu.total', totalPercent.toFixed(2)) + client.gauge('runtime.node.cpu.system', systemPercent.toFixed(2)) + client.gauge('runtime.node.cpu.user', userPercent.toFixed(2)) + client.gauge('runtime.node.cpu.total', totalPercent.toFixed(2)) } function captureMemoryUsage () { const stats = process.memoryUsage() - client.gauge('mem.heap_total', stats.heapTotal) - client.gauge('mem.heap_used', stats.heapUsed) - client.gauge('mem.rss', stats.rss) + client.gauge('runtime.node.mem.heap_total', stats.heapTotal) + client.gauge('runtime.node.mem.heap_used', stats.heapUsed) + client.gauge('runtime.node.mem.rss', stats.rss) - stats.external && client.gauge('mem.external', stats.external) + stats.external && client.gauge('runtime.node.mem.external', stats.external) } function captureProcess () { - client.gauge('process.uptime', Math.round(process.uptime())) + client.gauge('runtime.node.process.uptime', Math.round(process.uptime())) } function captureHeapStats () { const stats = v8.getHeapStatistics() - client.gauge('heap.total_heap_size', stats.total_heap_size) - client.gauge('heap.total_heap_size_executable', stats.total_heap_size_executable) - client.gauge('heap.total_physical_size', stats.total_physical_size) - client.gauge('heap.total_available_size', stats.total_available_size) - client.gauge('heap.heap_size_limit', stats.heap_size_limit) + client.gauge('runtime.node.heap.total_heap_size', stats.total_heap_size) + client.gauge('runtime.node.heap.total_heap_size_executable', stats.total_heap_size_executable) + client.gauge('runtime.node.heap.total_physical_size', stats.total_physical_size) + client.gauge('runtime.node.heap.total_available_size', stats.total_available_size) + client.gauge('runtime.node.heap.heap_size_limit', stats.heap_size_limit) - stats.malloced_memory && client.gauge('heap.malloced_memory', stats.malloced_memory) - stats.peak_malloced_memory && client.gauge('heap.peak_malloced_memory', stats.peak_malloced_memory) + stats.malloced_memory && client.gauge('runtime.node.heap.malloced_memory', stats.malloced_memory) + stats.peak_malloced_memory && client.gauge('runtime.node.heap.peak_malloced_memory', stats.peak_malloced_memory) } function captureHeapSpace () { @@ -184,10 +184,10 @@ function captureHeapSpace () { for (let i = 0, l = stats.length; i < l; i++) { const tags = [`space:${stats[i].space_name}`] - client.gauge('heap.size.by.space', stats[i].space_size, tags) - client.gauge('heap.used_size.by.space', stats[i].space_used_size, tags) - client.gauge('heap.available_size.by.space', stats[i].space_available_size, tags) - client.gauge('heap.physical_size.by.space', stats[i].physical_space_size, tags) + client.gauge('runtime.node.heap.size.by.space', stats[i].space_size, tags) + client.gauge('runtime.node.heap.used_size.by.space', stats[i].space_used_size, tags) + client.gauge('runtime.node.heap.available_size.by.space', stats[i].space_available_size, tags) + client.gauge('runtime.node.heap.physical_size.by.space', stats[i].physical_space_size, tags) } } @@ -222,41 +222,41 @@ function captureNativeMetrics () { const systemPercent = 100 * stats.cpu.system / elapsedUs const totalPercent = userPercent + systemPercent - client.gauge('cpu.system', systemPercent.toFixed(2)) - client.gauge('cpu.user', userPercent.toFixed(2)) - client.gauge('cpu.total', totalPercent.toFixed(2)) + client.gauge('runtime.node.cpu.system', systemPercent.toFixed(2)) + client.gauge('runtime.node.cpu.user', userPercent.toFixed(2)) + client.gauge('runtime.node.cpu.total', totalPercent.toFixed(2)) - histogram('event_loop.delay', stats.eventLoop) + histogram('runtime.node.event_loop.delay', stats.eventLoop) Object.keys(stats.gc).forEach(type => { if (type === 'all') { - histogram('gc.pause', stats.gc[type]) + histogram('runtime.node.gc.pause', stats.gc[type]) } else { - histogram('gc.pause.by.type', stats.gc[type], [`gc_type:${type}`]) + histogram('runtime.node.gc.pause.by.type', stats.gc[type], [`gc_type:${type}`]) } }) - client.gauge('spans.finished', stats.spans.total.finished) - client.gauge('spans.unfinished', stats.spans.total.unfinished) + client.gauge('runtime.node.spans.finished', stats.spans.total.finished) + client.gauge('runtime.node.spans.unfinished', stats.spans.total.unfinished) for (let i = 0, l = spaces.length; i < l; i++) { const tags = [`heap_space:${spaces[i].space_name}`] - client.gauge('heap.size.by.space', spaces[i].space_size, tags) - client.gauge('heap.used_size.by.space', spaces[i].space_used_size, tags) - client.gauge('heap.available_size.by.space', spaces[i].space_available_size, tags) - client.gauge('heap.physical_size.by.space', spaces[i].physical_space_size, tags) + client.gauge('runtime.node.heap.size.by.space', spaces[i].space_size, tags) + client.gauge('runtime.node.heap.used_size.by.space', spaces[i].space_used_size, tags) + client.gauge('runtime.node.heap.available_size.by.space', spaces[i].space_available_size, tags) + client.gauge('runtime.node.heap.physical_size.by.space', spaces[i].physical_space_size, tags) } if (stats.spans.operations) { const operations = stats.spans.operations Object.keys(operations.finished).forEach(name => { - client.gauge('spans.finished.by.name', operations.finished[name], [`span_name:${name}`]) + client.gauge('runtime.node.spans.finished.by.name', operations.finished[name], [`span_name:${name}`]) }) Object.keys(operations.unfinished).forEach(name => { - client.gauge('spans.unfinished.by.name', operations.unfinished[name], [`span_name:${name}`]) + client.gauge('runtime.node.spans.unfinished.by.name', operations.unfinished[name], [`span_name:${name}`]) }) } } diff --git a/packages/dd-trace/src/scope/async_hooks.js b/packages/dd-trace/src/scope/async_hooks.js index 9dadf40551e..5771da38863 100644 --- a/packages/dd-trace/src/scope/async_hooks.js +++ b/packages/dd-trace/src/scope/async_hooks.js @@ -108,8 +108,8 @@ class Scope extends Base { this._weaks.set(resource, asyncId) } - platform.metrics().increment('async.resources') - platform.metrics().increment('async.resources.by.type', `resource_type:${type}`) + platform.metrics().increment('runtime.node.async.resources') + platform.metrics().increment('runtime.node.async.resources.by.type', `resource_type:${type}`) if (this._trackAsyncScope && type === 'PROMISE') { this._initPromise() @@ -129,8 +129,8 @@ class Scope extends Base { const type = this._types[asyncId] if (type) { - platform.metrics().decrement('async.resources') - platform.metrics().decrement('async.resources.by.type', `resource_type:${type}`) + platform.metrics().decrement('runtime.node.async.resources') + platform.metrics().decrement('runtime.node.async.resources.by.type', `resource_type:${type}`) } delete this._spans[asyncId] diff --git a/packages/dd-trace/test/platform/node/index.spec.js b/packages/dd-trace/test/platform/node/index.spec.js index 7b37a53130d..a146d83b2f1 100644 --- a/packages/dd-trace/test/platform/node/index.spec.js +++ b/packages/dd-trace/test/platform/node/index.spec.js @@ -436,59 +436,59 @@ describe('Platform', () => { clock.tick(10000) - expect(client.gauge).to.have.been.calledWith('cpu.user') - expect(client.gauge).to.have.been.calledWith('cpu.system') - expect(client.gauge).to.have.been.calledWith('cpu.total') - - expect(client.gauge).to.have.been.calledWith('mem.rss') - expect(client.gauge).to.have.been.calledWith('mem.heap_total') - expect(client.gauge).to.have.been.calledWith('mem.heap_used') - - expect(client.gauge).to.have.been.calledWith('process.uptime') - - expect(client.gauge).to.have.been.calledWith('heap.total_heap_size') - expect(client.gauge).to.have.been.calledWith('heap.total_heap_size_executable') - expect(client.gauge).to.have.been.calledWith('heap.total_physical_size') - expect(client.gauge).to.have.been.calledWith('heap.total_available_size') - expect(client.gauge).to.have.been.calledWith('heap.total_heap_size') - expect(client.gauge).to.have.been.calledWith('heap.heap_size_limit') - - expect(client.gauge).to.have.been.calledWith('heap.malloced_memory') - expect(client.gauge).to.have.been.calledWith('heap.peak_malloced_memory') - - expect(client.gauge).to.have.been.calledWith('event_loop.delay.max') - expect(client.gauge).to.have.been.calledWith('event_loop.delay.min') - expect(client.increment).to.have.been.calledWith('event_loop.delay.sum') - expect(client.gauge).to.have.been.calledWith('event_loop.delay.avg') - expect(client.gauge).to.have.been.calledWith('event_loop.delay.median') - expect(client.gauge).to.have.been.calledWith('event_loop.delay.95percentile') - expect(client.increment).to.have.been.calledWith('event_loop.delay.count') - - expect(client.gauge).to.have.been.calledWith('gc.pause.max') - expect(client.gauge).to.have.been.calledWith('gc.pause.min') - expect(client.increment).to.have.been.calledWith('gc.pause.sum') - expect(client.gauge).to.have.been.calledWith('gc.pause.avg') - expect(client.gauge).to.have.been.calledWith('gc.pause.median') - expect(client.gauge).to.have.been.calledWith('gc.pause.95percentile') - expect(client.increment).to.have.been.calledWith('gc.pause.count') - - expect(client.gauge).to.have.been.calledWith('gc.pause.by.type.max') - expect(client.gauge).to.have.been.calledWith('gc.pause.by.type.min') - expect(client.increment).to.have.been.calledWith('gc.pause.by.type.sum') - expect(client.gauge).to.have.been.calledWith('gc.pause.by.type.avg') - expect(client.gauge).to.have.been.calledWith('gc.pause.by.type.median') - expect(client.gauge).to.have.been.calledWith('gc.pause.by.type.95percentile') - expect(client.increment).to.have.been.calledWith('gc.pause.by.type.count') + expect(client.gauge).to.have.been.calledWith('runtime.node.cpu.user') + expect(client.gauge).to.have.been.calledWith('runtime.node.cpu.system') + expect(client.gauge).to.have.been.calledWith('runtime.node.cpu.total') + + expect(client.gauge).to.have.been.calledWith('runtime.node.mem.rss') + expect(client.gauge).to.have.been.calledWith('runtime.node.mem.heap_total') + expect(client.gauge).to.have.been.calledWith('runtime.node.mem.heap_used') + + expect(client.gauge).to.have.been.calledWith('runtime.node.process.uptime') + + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_heap_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_heap_size_executable') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_physical_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_available_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_heap_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.heap_size_limit') + + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.malloced_memory') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.peak_malloced_memory') + + expect(client.gauge).to.have.been.calledWith('runtime.node.event_loop.delay.max') + expect(client.gauge).to.have.been.calledWith('runtime.node.event_loop.delay.min') + expect(client.increment).to.have.been.calledWith('runtime.node.event_loop.delay.sum') + expect(client.gauge).to.have.been.calledWith('runtime.node.event_loop.delay.avg') + expect(client.gauge).to.have.been.calledWith('runtime.node.event_loop.delay.median') + expect(client.gauge).to.have.been.calledWith('runtime.node.event_loop.delay.95percentile') + expect(client.increment).to.have.been.calledWith('runtime.node.event_loop.delay.count') + + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.max') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.min') + expect(client.increment).to.have.been.calledWith('runtime.node.gc.pause.sum') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.avg') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.median') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.95percentile') + expect(client.increment).to.have.been.calledWith('runtime.node.gc.pause.count') + + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.by.type.max') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.by.type.min') + expect(client.increment).to.have.been.calledWith('runtime.node.gc.pause.by.type.sum') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.by.type.avg') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.by.type.median') + expect(client.gauge).to.have.been.calledWith('runtime.node.gc.pause.by.type.95percentile') + expect(client.increment).to.have.been.calledWith('runtime.node.gc.pause.by.type.count') expect(client.increment).to.have.been.calledWith( - 'gc.pause.by.type.count', sinon.match.any, sinon.match(val => { + 'runtime.node.gc.pause.by.type.count', sinon.match.any, sinon.match(val => { return val && /^gc_type:[a-z_]+$/.test(val[0]) }) ) - expect(client.gauge).to.have.been.calledWith('heap.size.by.space') - expect(client.gauge).to.have.been.calledWith('heap.used_size.by.space') - expect(client.gauge).to.have.been.calledWith('heap.available_size.by.space') - expect(client.gauge).to.have.been.calledWith('heap.physical_size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.used_size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.available_size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.physical_size.by.space') expect(client.flush).to.have.been.called }) @@ -558,30 +558,30 @@ describe('Platform', () => { clock.tick(10000) - expect(client.gauge).to.have.been.calledWith('cpu.user') - expect(client.gauge).to.have.been.calledWith('cpu.system') - expect(client.gauge).to.have.been.calledWith('cpu.total') + expect(client.gauge).to.have.been.calledWith('runtime.node.cpu.user') + expect(client.gauge).to.have.been.calledWith('runtime.node.cpu.system') + expect(client.gauge).to.have.been.calledWith('runtime.node.cpu.total') - expect(client.gauge).to.have.been.calledWith('mem.rss') - expect(client.gauge).to.have.been.calledWith('mem.heap_total') - expect(client.gauge).to.have.been.calledWith('mem.heap_used') + expect(client.gauge).to.have.been.calledWith('runtime.node.mem.rss') + expect(client.gauge).to.have.been.calledWith('runtime.node.mem.heap_total') + expect(client.gauge).to.have.been.calledWith('runtime.node.mem.heap_used') - expect(client.gauge).to.have.been.calledWith('process.uptime') + expect(client.gauge).to.have.been.calledWith('runtime.node.process.uptime') - expect(client.gauge).to.have.been.calledWith('heap.total_heap_size') - expect(client.gauge).to.have.been.calledWith('heap.total_heap_size_executable') - expect(client.gauge).to.have.been.calledWith('heap.total_physical_size') - expect(client.gauge).to.have.been.calledWith('heap.total_available_size') - expect(client.gauge).to.have.been.calledWith('heap.total_heap_size') - expect(client.gauge).to.have.been.calledWith('heap.heap_size_limit') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_heap_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_heap_size_executable') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_physical_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_available_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.total_heap_size') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.heap_size_limit') - expect(client.gauge).to.have.been.calledWith('heap.malloced_memory') - expect(client.gauge).to.have.been.calledWith('heap.peak_malloced_memory') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.malloced_memory') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.peak_malloced_memory') - expect(client.gauge).to.have.been.calledWith('heap.size.by.space') - expect(client.gauge).to.have.been.calledWith('heap.used_size.by.space') - expect(client.gauge).to.have.been.calledWith('heap.available_size.by.space') - expect(client.gauge).to.have.been.calledWith('heap.physical_size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.used_size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.available_size.by.space') + expect(client.gauge).to.have.been.calledWith('runtime.node.heap.physical_size.by.space') expect(client.flush).to.have.been.called }) diff --git a/packages/dd-trace/test/scope/async_hooks.spec.js b/packages/dd-trace/test/scope/async_hooks.spec.js index f5ebca9cc5b..aa49cae26c0 100644 --- a/packages/dd-trace/test/scope/async_hooks.spec.js +++ b/packages/dd-trace/test/scope/async_hooks.spec.js @@ -36,16 +36,16 @@ describe('Scope (async_hooks)', () => { scope._init(0, 'TEST') scope._destroy(0) - expect(metrics.increment).to.have.been.calledWith('async.resources') - expect(metrics.decrement).to.have.been.calledWith('async.resources') + expect(metrics.increment).to.have.been.calledWith('runtime.node.async.resources') + expect(metrics.decrement).to.have.been.calledWith('runtime.node.async.resources') }) it('should keep track of asynchronous resource count by type', () => { scope._init(0, 'TEST') scope._destroy(0) - expect(metrics.increment).to.have.been.calledWith('async.resources.by.type', 'resource_type:TEST') - expect(metrics.decrement).to.have.been.calledWith('async.resources.by.type', 'resource_type:TEST') + expect(metrics.increment).to.have.been.calledWith('runtime.node.async.resources.by.type', 'resource_type:TEST') + expect(metrics.decrement).to.have.been.calledWith('runtime.node.async.resources.by.type', 'resource_type:TEST') }) it('should only track destroys once', () => { @@ -54,8 +54,8 @@ describe('Scope (async_hooks)', () => { scope._destroy(0) expect(metrics.decrement).to.have.been.calledTwice - expect(metrics.decrement).to.have.been.calledWith('async.resources') - expect(metrics.decrement).to.have.been.calledWith('async.resources.by.type') + expect(metrics.decrement).to.have.been.calledWith('runtime.node.async.resources') + expect(metrics.decrement).to.have.been.calledWith('runtime.node.async.resources.by.type') }) it('should not break propagation for nested resources', done => { From 9af2d2b360f86d39541036875edb76fbaa406ec6 Mon Sep 17 00:00:00 2001 From: rochdev Date: Tue, 12 Nov 2019 16:23:35 -0500 Subject: [PATCH 2/9] wip --- .../dd-trace/src/exporters/agent/writer.js | 18 +++++++++++++++++- packages/dd-trace/src/platform/node/metrics.js | 3 +++ packages/dd-trace/src/platform/node/request.js | 6 +++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/dd-trace/src/exporters/agent/writer.js b/packages/dd-trace/src/exporters/agent/writer.js index 45c01a7ee84..95c102f2a6d 100644 --- a/packages/dd-trace/src/exporters/agent/writer.js +++ b/packages/dd-trace/src/exporters/agent/writer.js @@ -4,6 +4,7 @@ const platform = require('../../platform') const log = require('../../log') const encode = require('../../encode') const tracerVersion = require('../../../lib/version') +const metrics = platform.metrics() const MAX_SIZE = 8 * 1024 * 1024 // 8MB @@ -26,6 +27,8 @@ class Writer { log.debug(() => `Adding encoded trace to buffer: ${buffer.toString('hex').match(/../g).join(' ')}`) + metrics.histogram('tracer.node.agent.trace_size', buffer.length) + if (buffer.length + this._size > MAX_SIZE) { this.flush() } @@ -37,9 +40,12 @@ class Writer { flush () { if (this._queue.length > 0) { const data = platform.msgpack.prefix(this._queue) + const size = data.reduce((prev, next) => prev + next.length, 0) this._request(data, this._queue.length) + metrics.histogram('tracer.node.agent.payload_size', size) + this._queue = [] this._size = 0 } @@ -70,7 +76,17 @@ class Writer { log.debug(() => `Request to the agent: ${JSON.stringify(options)}`) - platform.request(Object.assign({ data }, options), (err, res) => { + metrics.increment('tracer.node.agent.requests') + + platform.request(Object.assign({ data }, options), (err, res, status) => { + if (status) { + metrics.increment('tracer.node.agent.responses') + metrics.increment('tracer.node.agent.responses', [`status:${status}`]) + } else { + metrics.increment('tracer.node.agent.errors') + metrics.increment('tracer.node.agent.errors.by.code', err.code && [`code:${err.code}`]) + } + if (err) return log.error(err) log.debug(`Response from the agent: ${res}`) diff --git a/packages/dd-trace/src/platform/node/metrics.js b/packages/dd-trace/src/platform/node/metrics.js index 41d7041bbba..4c0c9172c80 100644 --- a/packages/dd-trace/src/platform/node/metrics.js +++ b/packages/dd-trace/src/platform/node/metrics.js @@ -4,6 +4,7 @@ const v8 = require('v8') const path = require('path') +const os = require('os') const Client = require('./dogstatsd') const log = require('../../log') @@ -155,6 +156,8 @@ function captureMemoryUsage () { client.gauge('runtime.node.mem.heap_total', stats.heapTotal) client.gauge('runtime.node.mem.heap_used', stats.heapUsed) client.gauge('runtime.node.mem.rss', stats.rss) + client.gauge('runtime.node.mem.total', os.totalmem()) + client.gauge('runtime.node.mem.free', os.freemem()) stats.external && client.gauge('runtime.node.mem.external', stats.external) } diff --git a/packages/dd-trace/src/platform/node/request.js b/packages/dd-trace/src/platform/node/request.js index 7880bfde9c6..de7353bd1cd 100644 --- a/packages/dd-trace/src/platform/node/request.js +++ b/packages/dd-trace/src/platform/node/request.js @@ -30,12 +30,12 @@ function request (options, callback) { res.on('data', chunk => { data += chunk }) res.on('end', () => { if (res.statusCode >= 200 && res.statusCode <= 299) { - callback(null, data) + callback(null, data, res.statusCode) } else { - const error = new Error(http.STATUS_CODES[res.statusCode]) + const error = new Error(`Error from the agent: ${res.statusCode} ${http.STATUS_CODES[res.statusCode]}`) error.status = res.statusCode - callback(new Error(`Error from the agent: ${res.statusCode} ${http.STATUS_CODES[res.statusCode]}`)) + callback(error, null, res.statusCode) } }) }) From fcf6daa584a61c736d6fc465e7bd6e7964f8464d Mon Sep 17 00:00:00 2001 From: rochdev Date: Thu, 14 Nov 2019 11:35:51 -0500 Subject: [PATCH 3/9] wip --- LICENSE-3rdparty.csv | 1 + benchmark/core.js | 7 ++ package.json | 1 + .../dd-trace/src/exporters/agent/writer.js | 15 ++-- packages/dd-trace/src/histogram.js | 52 ++++++++++++++ packages/dd-trace/src/opentracing/tracer.js | 7 +- .../dd-trace/src/platform/browser/metrics.js | 2 + .../dd-trace/src/platform/node/metrics.js | 69 ++++++++++++++++--- packages/dd-trace/src/span_processor.js | 2 + packages/dd-trace/test/histogram.spec.js | 43 ++++++++++++ .../dd-trace/test/platform/node/index.spec.js | 1 + 11 files changed, 181 insertions(+), 19 deletions(-) create mode 100644 packages/dd-trace/src/histogram.js create mode 100644 packages/dd-trace/test/histogram.spec.js diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 8bc2127968a..9f4d306134e 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -3,6 +3,7 @@ require,@types/node,MIT,Copyright Authors require,bowser,MIT,Copyright 2015 Dustin Diaz require,container-info,MIT,Copyright 2018 Stephen Belanger require,core-js,MIT,Copyright 2014-2019 Denis Pushkarev +require,hdr-histogram-js,BSD-2-Clause,Copyright 2016 Alexandre Victoor require,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki require,koalas,MIT,Copyright 2013-2017 Brian Woodward require,limiter,MIT,Copyright 2011 John Hurliman diff --git a/benchmark/core.js b/benchmark/core.js index 46c7cb7c5a1..e0caafb33ce 100644 --- a/benchmark/core.js +++ b/benchmark/core.js @@ -19,6 +19,8 @@ const format = require('../packages/dd-trace/src/format') const encode = require('../packages/dd-trace/src/encode') const config = new Config('benchmark', { service: 'benchmark' }) const id = require('../packages/dd-trace/src/id') +const Histogram = require('../packages/dd-trace/src/histogram') +const histogram = new Histogram() const suite = benchmark('core') @@ -99,5 +101,10 @@ suite id() } }) + .add('Histogram', { + fn () { + histogram.record(Math.round(Math.random() * 3e12)) + } + }) suite.run() diff --git a/package.json b/package.json index 4de182219e4..0c30f4a3100 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "bowser": "^2.5.3", "container-info": "^1.0.1", "core-js": "^3.3.4", + "hdr-histogram-js": "^1.1.4", "int64-buffer": "^0.1.9", "koalas": "^1.0.2", "limiter": "^1.1.4", diff --git a/packages/dd-trace/src/exporters/agent/writer.js b/packages/dd-trace/src/exporters/agent/writer.js index 95c102f2a6d..00e8add53bd 100644 --- a/packages/dd-trace/src/exporters/agent/writer.js +++ b/packages/dd-trace/src/exporters/agent/writer.js @@ -4,7 +4,6 @@ const platform = require('../../platform') const log = require('../../log') const encode = require('../../encode') const tracerVersion = require('../../../lib/version') -const metrics = platform.metrics() const MAX_SIZE = 8 * 1024 * 1024 // 8MB @@ -27,7 +26,7 @@ class Writer { log.debug(() => `Adding encoded trace to buffer: ${buffer.toString('hex').match(/../g).join(' ')}`) - metrics.histogram('tracer.node.agent.trace_size', buffer.length) + platform.metrics().histogram('datadog.tracer.node.exporter.agent.trace_size', buffer.length) if (buffer.length + this._size > MAX_SIZE) { this.flush() @@ -44,7 +43,7 @@ class Writer { this._request(data, this._queue.length) - metrics.histogram('tracer.node.agent.payload_size', size) + platform.metrics().histogram('datadog.tracer.node.exporter.agent.payload_size', size) this._queue = [] this._size = 0 @@ -76,15 +75,15 @@ class Writer { log.debug(() => `Request to the agent: ${JSON.stringify(options)}`) - metrics.increment('tracer.node.agent.requests') + platform.metrics().increment('datadog.tracer.node.exporter.agent.requests') platform.request(Object.assign({ data }, options), (err, res, status) => { if (status) { - metrics.increment('tracer.node.agent.responses') - metrics.increment('tracer.node.agent.responses', [`status:${status}`]) + platform.metrics().increment('datadog.tracer.node.exporter.agent.responses') + platform.metrics().increment('datadog.tracer.node.exporter.agent.responses', [`status:${status}`]) } else { - metrics.increment('tracer.node.agent.errors') - metrics.increment('tracer.node.agent.errors.by.code', err.code && [`code:${err.code}`]) + platform.metrics().increment('datadog.tracer.node.exporter.agent.errors') + platform.metrics().increment('datadog.tracer.node.exporter.agent.errors.by.code', err.code && [`code:${err.code}`]) } if (err) return log.error(err) diff --git a/packages/dd-trace/src/histogram.js b/packages/dd-trace/src/histogram.js new file mode 100644 index 00000000000..95cfc0974fc --- /dev/null +++ b/packages/dd-trace/src/histogram.js @@ -0,0 +1,52 @@ +'use strict' + +const hdr = require('hdr-histogram-js') + +const highestTrackableValue = 3.6e12 // 1 hour + +class Histogram { + constructor () { + this._histogram = hdr.build({ + highestTrackableValue + }) + + this.reset() + } + + get min () { return this._min } + get max () { return this._max } + get avg () { return this._count === 0 ? 0 : this._sum / this._count } + get sum () { return this._sum } + get count () { return this._count } + get median () { return this.percentile(50) } + get p95 () { return this.percentile(95) } + + percentile (percentile) { + return this._histogram.getValueAtPercentile(percentile) + } + + record (value) { + if (this._count === 0) { + this._min = this._max = value + } else { + this._min = Math.min(this._min, value) + this._max = Math.max(this._max, value) + } + + this._count++ + this._sum += value + + this._histogram.recordValue(value) + } + + reset () { + this._min = 0 + this._max = 0 + this._sum = 0 + this._count = 0 + + this._histogram.reset() + } +} + +module.exports = Histogram diff --git a/packages/dd-trace/src/opentracing/tracer.js b/packages/dd-trace/src/opentracing/tracer.js index 7b47a7bf5d7..2ef6e19a2f1 100644 --- a/packages/dd-trace/src/opentracing/tracer.js +++ b/packages/dd-trace/src/opentracing/tracer.js @@ -60,8 +60,13 @@ class DatadogTracer extends Tracer { const type = reference && reference.type() const parent = reference && reference.referencedContext() + platform.metrics().increment('datadog.tracer.node.traces', true) + if (parent && parent._noop) return parent._noop - if (!isSampled(this._sampler, parent, type)) return new NoopSpan(this, parent) + if (!isSampled(this._sampler, parent, type)) { + platform.metrics().increment('datadog.tracer.node.traces.dropped', true) + return new NoopSpan(this, parent) + } const tags = { 'service.name': this._service diff --git a/packages/dd-trace/src/platform/browser/metrics.js b/packages/dd-trace/src/platform/browser/metrics.js index 518cdd21c3e..25836e66dda 100644 --- a/packages/dd-trace/src/platform/browser/metrics.js +++ b/packages/dd-trace/src/platform/browser/metrics.js @@ -16,6 +16,8 @@ module.exports = function () { } }, + histogram () {}, + count () {}, increment () {}, diff --git a/packages/dd-trace/src/platform/node/metrics.js b/packages/dd-trace/src/platform/node/metrics.js index 4c0c9172c80..a9481313b33 100644 --- a/packages/dd-trace/src/platform/node/metrics.js +++ b/packages/dd-trace/src/platform/node/metrics.js @@ -7,6 +7,7 @@ const path = require('path') const os = require('os') const Client = require('./dogstatsd') const log = require('../../log') +const Histogram = require('../../histogram') const INTERVAL = 10 * 1000 @@ -17,7 +18,9 @@ let interval let client let time let cpuUsage +let gauges let counters +let histograms reset() @@ -100,25 +103,44 @@ module.exports = function () { return { finish: () => {} } }, - count (name, count, tag) { + histogram (name, value, tag) { if (!client) return - if (!counters[name]) { - counters[name] = tag ? Object.create(null) : 0 + + histograms[name] = histograms[name] || new Map() + + if (!histograms[name].has(tag)) { + histograms[name].set(tag, new Histogram()) + } + + histograms[name].get(tag).record(value) + }, + + count (name, count, tag, monotonic) { + if (!client) return + if (typeof tag === 'boolean') { + monotonic = tag + tag = undefined + } + + const map = monotonic ? counters : gauges + + if (!map[name]) { + map[name] = tag ? Object.create(null) : 0 } if (tag) { - counters[name][tag] = (counters[name][tag] || 0) + count + map[name][tag] = (map[name][tag] || 0) + count } else { - counters[name] = (counters[name] || 0) + count + map[name] = (map[name] || 0) + count } }, - increment (name, tag) { - this.count(name, 1, tag) + increment (name, tag, monotonic = false) { + this.count(name, 1, tag, monotonic) }, decrement (name, tag) { - this.count(name, -1, tag) + this.count(name, -1, tag, false) } }) } @@ -128,7 +150,9 @@ function reset () { client = null time = null cpuUsage = null + gauges = {} counters = {} + histograms = {} } function captureCpuUsage () { @@ -194,23 +218,46 @@ function captureHeapSpace () { } } +function captureGauges () { + Object.keys(gauges).forEach(name => { + if (typeof gauges[name] === 'object') { + Object.keys(gauges[name]).forEach(tag => { + client.gauge(name, gauges[name][tag], [tag]) + }) + } else { + client.gauge(name, gauges[name]) + } + }) +} + function captureCounters () { Object.keys(counters).forEach(name => { if (typeof counters[name] === 'object') { Object.keys(counters[name]).forEach(tag => { - client.gauge(name, counters[name][tag], [tag]) + client.count(name, counters[name][tag], [tag]) }) } else { - client.gauge(name, counters[name]) + client.count(name, counters[name]) } }) } +function captureHistograms () { + Object.keys(histograms).forEach(name => { + histograms[name].forEach((stats, tag) => { + histogram(name, stats, tag) + stats.reset() + }) + }) +} + function captureCommonMetrics () { captureMemoryUsage() captureProcess() captureHeapStats() + captureGauges() captureCounters() + captureHistograms() } function captureNativeMetrics () { @@ -265,6 +312,8 @@ function captureNativeMetrics () { } function histogram (name, stats, tags) { + tags = [].concat(tags) + client.gauge(`${name}.min`, stats.min, tags) client.gauge(`${name}.max`, stats.max, tags) client.increment(`${name}.sum`, stats.sum, tags) diff --git a/packages/dd-trace/src/span_processor.js b/packages/dd-trace/src/span_processor.js index 8ed8a866641..dc988f7b908 100644 --- a/packages/dd-trace/src/span_processor.js +++ b/packages/dd-trace/src/span_processor.js @@ -1,5 +1,6 @@ const log = require('./log') const format = require('./format') +const platform = require('./platform') class SpanProcessor { constructor (exporter, prioritySampler) { @@ -15,6 +16,7 @@ class SpanProcessor { this._prioritySampler.sample(spanContext) if (spanContext._traceFlags.sampled === false) { + platform.metrics().increment('datadog.tracer.node.traces.dropped', true) log.debug(() => `Dropping trace due to user configured filtering: ${trace}`) this._erase(trace) return diff --git a/packages/dd-trace/test/histogram.spec.js b/packages/dd-trace/test/histogram.spec.js new file mode 100644 index 00000000000..ed4517e95d4 --- /dev/null +++ b/packages/dd-trace/test/histogram.spec.js @@ -0,0 +1,43 @@ +'use strict' + +const Histogram = require('../src/histogram') + +describe('Histogram', () => { + let histogram + + beforeEach(() => { + histogram = new Histogram() + }) + + it('should record values', () => { + histogram.record(1) + histogram.record(2) + histogram.record(3) + + expect(histogram).to.have.property('min', 1) + expect(histogram).to.have.property('max', 3) + expect(histogram).to.have.property('sum', 6) + expect(histogram).to.have.property('avg', 2) + expect(histogram).to.have.property('median', 2) + expect(histogram).to.have.property('count', 3) + expect(histogram).to.have.property('p95', 3) + expect(histogram.percentile(50)).to.equal(2) + }) + + it('should reset all stats', () => { + histogram.record(1) + histogram.record(2) + histogram.record(3) + + histogram.reset() + + expect(histogram).to.have.property('min', 0) + expect(histogram).to.have.property('max', 0) + expect(histogram).to.have.property('sum', 0) + expect(histogram).to.have.property('avg', 0) + expect(histogram).to.have.property('median', 0) + expect(histogram).to.have.property('count', 0) + expect(histogram).to.have.property('p95', 0) + expect(histogram.percentile(50)).to.equal(0) + }) +}) diff --git a/packages/dd-trace/test/platform/node/index.spec.js b/packages/dd-trace/test/platform/node/index.spec.js index a146d83b2f1..5cc1f9992b6 100644 --- a/packages/dd-trace/test/platform/node/index.spec.js +++ b/packages/dd-trace/test/platform/node/index.spec.js @@ -378,6 +378,7 @@ describe('Platform', () => { client = { gauge: sinon.spy(), increment: sinon.spy(), + histogram: sinon.spy(), flush: sinon.spy() } From b47093d587cbd67f09b0ec57b003a5bd767e9e70 Mon Sep 17 00:00:00 2001 From: rochdev Date: Thu, 14 Nov 2019 11:46:34 -0500 Subject: [PATCH 4/9] fix tests --- packages/dd-trace/src/exporters/agent/writer.js | 7 +++++-- packages/dd-trace/test/exporters/agent/writer.spec.js | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/dd-trace/src/exporters/agent/writer.js b/packages/dd-trace/src/exporters/agent/writer.js index 00e8add53bd..611b356ce9c 100644 --- a/packages/dd-trace/src/exporters/agent/writer.js +++ b/packages/dd-trace/src/exporters/agent/writer.js @@ -80,10 +80,13 @@ class Writer { platform.request(Object.assign({ data }, options), (err, res, status) => { if (status) { platform.metrics().increment('datadog.tracer.node.exporter.agent.responses') - platform.metrics().increment('datadog.tracer.node.exporter.agent.responses', [`status:${status}`]) + platform.metrics().increment('datadog.tracer.node.exporter.agent.responses', `status:${status}`) } else { platform.metrics().increment('datadog.tracer.node.exporter.agent.errors') - platform.metrics().increment('datadog.tracer.node.exporter.agent.errors.by.code', err.code && [`code:${err.code}`]) + + if (err && err.code) { + platform.metrics().increment('datadog.tracer.node.exporter.agent.errors.by.code', `code:${err.code}`) + } } if (err) return log.error(err) diff --git a/packages/dd-trace/test/exporters/agent/writer.spec.js b/packages/dd-trace/test/exporters/agent/writer.spec.js index a7b18ea9d22..c1c549d8fba 100644 --- a/packages/dd-trace/test/exporters/agent/writer.spec.js +++ b/packages/dd-trace/test/exporters/agent/writer.spec.js @@ -53,7 +53,7 @@ describe('Writer', () => { engine: sinon.stub(), request: sinon.stub().yields(null, response), msgpack: { - prefix: sinon.stub() + prefix: sinon.stub().returns([]) } } @@ -125,7 +125,7 @@ describe('Writer', () => { }) it('should flush its traces to the agent', () => { - platform.msgpack.prefix.withArgs(['encoded', 'encoded']).returns('prefixed') + platform.msgpack.prefix.withArgs(['encoded', 'encoded']).returns(['prefixed']) platform.name.returns('lang') platform.version.returns('version') platform.engine.returns('interpreter') @@ -148,7 +148,7 @@ describe('Writer', () => { 'Datadog-Meta-Tracer-Version': 'tracerVersion', 'X-Datadog-Trace-Count': '2' }, - data: 'prefixed' + data: ['prefixed'] }) }) From ee755637972d8a1e305a3cfe9189925c49089c51 Mon Sep 17 00:00:00 2001 From: rochdev Date: Thu, 14 Nov 2019 11:52:02 -0500 Subject: [PATCH 5/9] code cleanup --- packages/dd-trace/src/platform/node/metrics.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/dd-trace/src/platform/node/metrics.js b/packages/dd-trace/src/platform/node/metrics.js index a9481313b33..b4336b3a492 100644 --- a/packages/dd-trace/src/platform/node/metrics.js +++ b/packages/dd-trace/src/platform/node/metrics.js @@ -115,7 +115,7 @@ module.exports = function () { histograms[name].get(tag).record(value) }, - count (name, count, tag, monotonic) { + count (name, count, tag, monotonic = false) { if (!client) return if (typeof tag === 'boolean') { monotonic = tag @@ -135,12 +135,12 @@ module.exports = function () { } }, - increment (name, tag, monotonic = false) { + increment (name, tag, monotonic) { this.count(name, 1, tag, monotonic) }, decrement (name, tag) { - this.count(name, -1, tag, false) + this.count(name, -1, tag) } }) } From eaee5baca541afecfcb4a3cc28766ce1ccb718da Mon Sep 17 00:00:00 2001 From: rochdev Date: Fri, 15 Nov 2019 12:04:39 -0500 Subject: [PATCH 6/9] add tests and total alias --- .../dd-trace/src/platform/node/metrics.js | 5 +- .../dd-trace/test/platform/node/index.spec.js | 46 +++++++++++++++++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/packages/dd-trace/src/platform/node/metrics.js b/packages/dd-trace/src/platform/node/metrics.js index b4336b3a492..c56d22039e6 100644 --- a/packages/dd-trace/src/platform/node/metrics.js +++ b/packages/dd-trace/src/platform/node/metrics.js @@ -234,10 +234,10 @@ function captureCounters () { Object.keys(counters).forEach(name => { if (typeof counters[name] === 'object') { Object.keys(counters[name]).forEach(tag => { - client.count(name, counters[name][tag], [tag]) + client.increment(name, counters[name][tag], [tag]) }) } else { - client.count(name, counters[name]) + client.increment(name, counters[name]) } }) } @@ -317,6 +317,7 @@ function histogram (name, stats, tags) { client.gauge(`${name}.min`, stats.min, tags) client.gauge(`${name}.max`, stats.max, tags) client.increment(`${name}.sum`, stats.sum, tags) + client.increment(`${name}.total`, stats.sum, tags) client.gauge(`${name}.avg`, stats.avg, tags) client.increment(`${name}.count`, stats.count, tags) client.gauge(`${name}.median`, stats.median, tags) diff --git a/packages/dd-trace/test/platform/node/index.spec.js b/packages/dd-trace/test/platform/node/index.spec.js index 5cc1f9992b6..b5945000fce 100644 --- a/packages/dd-trace/test/platform/node/index.spec.js +++ b/packages/dd-trace/test/platform/node/index.spec.js @@ -506,8 +506,28 @@ describe('Platform', () => { }) }) + describe('histogram', () => { + it('should add a record to a histogram', () => { + metrics.apply(platform).start() + metrics.apply(platform).histogram('test', 1) + metrics.apply(platform).histogram('test', 2) + metrics.apply(platform).histogram('test', 3) + + clock.tick(10000) + + expect(client.gauge).to.have.been.calledWith('test.max', 3) + expect(client.gauge).to.have.been.calledWith('test.min', 1) + expect(client.increment).to.have.been.calledWith('test.sum', 6) + expect(client.increment).to.have.been.calledWith('test.total', 6) + expect(client.gauge).to.have.been.calledWith('test.avg', 2) + expect(client.gauge).to.have.been.calledWith('test.median', 2) + expect(client.gauge).to.have.been.calledWith('test.95percentile', 3) + expect(client.increment).to.have.been.calledWith('test.count', 3) + }) + }) + describe('increment', () => { - it('should increment a counter', () => { + it('should increment a gauge', () => { metrics.apply(platform).start() metrics.apply(platform).increment('test') @@ -516,7 +536,7 @@ describe('Platform', () => { expect(client.gauge).to.have.been.calledWith('test', 1) }) - it('should increment a counter with a tag', () => { + it('should increment a gauge with a tag', () => { metrics.apply(platform).start() metrics.apply(platform).increment('test', 'foo:bar') @@ -524,10 +544,28 @@ describe('Platform', () => { expect(client.gauge).to.have.been.calledWith('test', 1, ['foo:bar']) }) + + it('should increment a monotonic counter', () => { + metrics.apply(platform).start() + metrics.apply(platform).increment('test', true) + + clock.tick(10000) + + expect(client.increment).to.have.been.calledWith('test', 1) + }) + + it('should increment a monotonic counter with a tag', () => { + metrics.apply(platform).start() + metrics.apply(platform).increment('test', 'foo:bar', true) + + clock.tick(10000) + + expect(client.increment).to.have.been.calledWith('test', 1, ['foo:bar']) + }) }) describe('decrement', () => { - it('should increment a counter', () => { + it('should increment a gauge', () => { metrics.apply(platform).start() metrics.apply(platform).decrement('test') @@ -536,7 +574,7 @@ describe('Platform', () => { expect(client.gauge).to.have.been.calledWith('test', -1) }) - it('should decrement a counter with a tag', () => { + it('should decrement a gauge with a tag', () => { metrics.apply(platform).start() metrics.apply(platform).decrement('test', 'foo:bar') From 16ddc409fe078d04419fcbbfcb3754e6ef51f111 Mon Sep 17 00:00:00 2001 From: rochdev Date: Fri, 15 Nov 2019 12:22:37 -0500 Subject: [PATCH 7/9] code cleanup --- packages/dd-trace/src/opentracing/tracer.js | 7 +------ packages/dd-trace/src/span_processor.js | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/dd-trace/src/opentracing/tracer.js b/packages/dd-trace/src/opentracing/tracer.js index 2ef6e19a2f1..7b47a7bf5d7 100644 --- a/packages/dd-trace/src/opentracing/tracer.js +++ b/packages/dd-trace/src/opentracing/tracer.js @@ -60,13 +60,8 @@ class DatadogTracer extends Tracer { const type = reference && reference.type() const parent = reference && reference.referencedContext() - platform.metrics().increment('datadog.tracer.node.traces', true) - if (parent && parent._noop) return parent._noop - if (!isSampled(this._sampler, parent, type)) { - platform.metrics().increment('datadog.tracer.node.traces.dropped', true) - return new NoopSpan(this, parent) - } + if (!isSampled(this._sampler, parent, type)) return new NoopSpan(this, parent) const tags = { 'service.name': this._service diff --git a/packages/dd-trace/src/span_processor.js b/packages/dd-trace/src/span_processor.js index dc988f7b908..019f1e58caf 100644 --- a/packages/dd-trace/src/span_processor.js +++ b/packages/dd-trace/src/span_processor.js @@ -16,7 +16,6 @@ class SpanProcessor { this._prioritySampler.sample(spanContext) if (spanContext._traceFlags.sampled === false) { - platform.metrics().increment('datadog.tracer.node.traces.dropped', true) log.debug(() => `Dropping trace due to user configured filtering: ${trace}`) this._erase(trace) return From 36ec6aef562472886881303c7fc0f3acec9129ef Mon Sep 17 00:00:00 2001 From: rochdev Date: Fri, 15 Nov 2019 12:25:06 -0500 Subject: [PATCH 8/9] code cleanup --- packages/dd-trace/src/span_processor.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/dd-trace/src/span_processor.js b/packages/dd-trace/src/span_processor.js index 019f1e58caf..8ed8a866641 100644 --- a/packages/dd-trace/src/span_processor.js +++ b/packages/dd-trace/src/span_processor.js @@ -1,6 +1,5 @@ const log = require('./log') const format = require('./format') -const platform = require('./platform') class SpanProcessor { constructor (exporter, prioritySampler) { From 10ef862a231390943e4782e5a554b7e27a46b763 Mon Sep 17 00:00:00 2001 From: rochdev Date: Fri, 15 Nov 2019 15:53:15 -0500 Subject: [PATCH 9/9] fix metric name --- packages/dd-trace/src/exporters/agent/writer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dd-trace/src/exporters/agent/writer.js b/packages/dd-trace/src/exporters/agent/writer.js index 611b356ce9c..46a2a725400 100644 --- a/packages/dd-trace/src/exporters/agent/writer.js +++ b/packages/dd-trace/src/exporters/agent/writer.js @@ -80,7 +80,7 @@ class Writer { platform.request(Object.assign({ data }, options), (err, res, status) => { if (status) { platform.metrics().increment('datadog.tracer.node.exporter.agent.responses') - platform.metrics().increment('datadog.tracer.node.exporter.agent.responses', `status:${status}`) + platform.metrics().increment('datadog.tracer.node.exporter.agent.responses.by.status', `status:${status}`) } else { platform.metrics().increment('datadog.tracer.node.exporter.agent.errors')