Skip to content

Commit

Permalink
SC-6766: edited tag/metric names
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanrahic committed Jan 20, 2020
1 parent c951819 commit 404bfc1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 53 deletions.
30 changes: 16 additions & 14 deletions lib/processAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const addMetrics = function (agent, pidToCheck) {
const masterProcess = processes.filter(proc => proc.pid === pidToCheck).pop()
const masterProcessMetric = {
timestamp: timestamp,
measurement: 'nodejs.process',
measurement: 'process',
tags: {
token: infraToken,
'nodejs.process.name': 'master',
'nodejs.process.type': 'master'
'process.name': 'node',
'process.type': 'master'
},
fields: {
'cpu.percent': masterProcess.cpu,
memory: masterProcess.memory,
'cpu.usage': masterProcess.cpu,
rss: masterProcess.memory,
uptime: masterProcess.elapsed
}
}
Expand All @@ -45,15 +45,15 @@ const addMetrics = function (agent, pidToCheck) {
childProcesses.forEach((proc, counter) => {
const childProcessMetric = {
timestamp: timestamp,
measurement: 'nodejs.process',
measurement: 'process',
tags: {
token: infraToken,
'nodejs.process.name': `child-${counter + 1}`,
'nodejs.process.type': 'child'
'process.name': 'node',
'process.type': 'child'
},
fields: {
'cpu.percent': proc.cpu,
memory: proc.memory,
'cpu.usage': proc.cpu,
rss: proc.memory,
uptime: proc.elapsed
}
}
Expand All @@ -63,10 +63,11 @@ const addMetrics = function (agent, pidToCheck) {

const processCountMetric = {
timestamp: timestamp,
measurement: 'nodejs.process',
measurement: 'process',
tags: {
token: infraToken,
'nodejs.process.type': 'master'
'process.type': 'master',
'process.name': 'node'
},
fields: {
count: 1
Expand All @@ -75,10 +76,11 @@ const addMetrics = function (agent, pidToCheck) {
agent.addMetrics(processCountMetric)
const processChildCountMetric = {
timestamp: timestamp,
measurement: 'nodejs.process',
measurement: 'process',
tags: {
token: infraToken,
'nodejs.process.type': 'child'
'process.type': 'child',
'process.name': 'node'
},
fields: {
count: Math.max(processes.length - 1, 0) || 0
Expand Down
57 changes: 19 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('SPM for Node.js tests', function () {
if (metric.measurement && metric.measurement.indexOf('process') > -1 &&
metric.fields.uptime &&
metric.fields.memory &&
metric.fields['cpu.percent']) {
metric.fields['cpu.usage']) {
if (metric.tags.token !== config.tokens.infra) {
console.log(metric)
done(new Error(`No infra token set ${metric.tags.token} != ${config.tokens.infra}`))
Expand Down

0 comments on commit 404bfc1

Please sign in to comment.