Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: domain handling #11

Merged
merged 6 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions .jshintrc

This file was deleted.

5 changes: 2 additions & 3 deletions bin/spm-client-diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ var zip = new ZipZipTop()
var config = require('spm-agent').Config
var util = require('util')
var os = require('os')
var path = require ('path')
var path = require('path')

var systemInfo = {
operatingSystem: os.type() + ', ' + os.platform() + ', ' + os.release() + ', ' + os.arch(),
processVersions: process.versions,
processEnvironment: process.env
}

var cfgDumpFileName = path.join (os.tmpdir(), 'spm-cfg-dump.txt')
var cfgDumpFileName = path.join(os.tmpdir(), 'spm-cfg-dump.txt')
fs.writeFileSync(cfgDumpFileName, util.inspect(config).toString() + '\nSystem-Info:\n' + util.inspect(systemInfo))
zip.folder(config.logger.dir)
var archFileName = path.join(os.tmpdir(), 'spm-diagnose.zip')
zip.writeToFile(archFileName)
console.log('SPM diagnostics info is in ' + archFileName)
console.log('Please e-mail the file to [email protected]')
fs.unlink(cfgDumpFileName, function () {})

12 changes: 5 additions & 7 deletions bin/spmconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ var fs = require('fs')
var os = require('os')
var path = require('path')

var spm_token = ''
var spmToken = ''
if (process.argv.length === 3) {
spm_token = process.argv[2]
spmToken = process.argv[2]
}
if (process.env.SPM_TOKEN)
spm_token = process.env.SPM_TOKEN
if (process.env.SPM_TOKEN) { spmToken = process.env.SPM_TOKEN }
var useLinuxAgent = 'false'
if (os.platform() === 'linux')
{
if (os.platform() === 'linux') {
useLinuxAgent = 'true'
}
var cfgLines = [
Expand All @@ -32,7 +30,7 @@ var cfgLines = [
'# SPM_MONITOR_TAGS=project:frontend,environment:test,role:testserver',
'# Application Token for SPM',
'tokens:',
' spm: ' + spm_token,
' spm: ' + spmToken,
' ',
'logger:',
' # log file directory default is __dirname / spmlogs',
Expand Down
18 changes: 9 additions & 9 deletions bin/spmmonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
// "use strict"
var fs = require('fs')
var path = require('path')

try {
var script = fs.readFileSync(process.argv[2]).toString()
Expand All @@ -19,19 +18,20 @@ try {
console.log('e.g. spmmonitor ./server/app.js')
}
var scriptName = process.argv[2]
var agent = require('spm-agent-nodejs')

require('spm-agent-nodejs')
// Remove Arguments for Runner Script, to give started process a clean ENV
process.argv.splice(1, 1)
process.argv.splice(2, 1)
var script = fs.readFileSync(scriptName).toString()

script = fs.readFileSync(scriptName).toString()
var lines = script.split('\n')
if (lines[0] && /\#!/.test(lines[0])) {
if (lines[0] && /^#!/.test(lines[0])) {
console.log('removed shebang line:' + lines[0])
lines [0] = '\n'
lines[0] = '\n'
}
eval(lines.join('\n'))

eval(lines.join('\n')) // eslint-disable-line
} catch (err) {
console.error(err)
process.exit(1)
console.error(err)
process.exit(1)
}
16 changes: 8 additions & 8 deletions example/simple-server.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var spmAgent = require ('../lib/index.js') // or 'spm-agent-nodejs'
spmAgent.on ('stats', function (stats) {
console.log (stats)
var spmAgent = require('../lib/index.js') // or 'spm-agent-nodejs'
spmAgent.on('stats', function (stats) {
console.log(stats)
})
spmAgent.on ('metric', function (metric) {
spmAgent.on('metric', function (metric) {
// if (metric.name === 'http')
// console.log (metric)
})

var http = require ('http')
http.createServer (function (req, res) {
res.end ('Hello World')
}).listen (8080)
var http = require('http')
http.createServer(function (req, res) {
res.end('Hello World')
}).listen(8080)
2 changes: 1 addition & 1 deletion lib/eventLoopAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function () {
start: function (agent) {
this.elListener = function (stats) {
var metric = {
ts: new Date().getTime(),
ts: Date.now(),
name: 'eventloop',
value: [stats.count, stats.time, stats.min, stats.max, stats.avg]
}
Expand Down
2 changes: 1 addition & 1 deletion lib/eventLoopStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ EventLoopStats.prototype.start = function () {
stats.min = Math.min(parseInt(key, 10), stats.min)
}
stats.avg = Math.floor(stats.time / stats.count)
//console.log (stats)
// console.log (stats)
this.emit('data', stats)
measures[0] = measures.pop()
measures.length = 1
Expand Down
12 changes: 6 additions & 6 deletions lib/gcAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ function getGcStats () {
var timerId = setInterval(function () {
var now = new Date().getTime()
var heapInfo = lastHeapInfo
var heap_compactions = heapCompactions.toJSON()
// gc.num_gc_inc (int), gc.num_gc_full(int), gc.duration(float), heap_compactions (int), gc.heap_diff (float), processHeapUsed (long), processHeapTotal, processMemoryRss (long)
var heapCompactionsJSON = heapCompactions.toJSON()
// gc.num_gc_inc (int), gc.num_gc_full(int), gc.duration(float), heapCompactionsJSON (int), gc.heap_diff (float), processHeapUsed (long), processHeapTotal, processMemoryRss (long)
var metricValues = [
incGc.toJSON() || 0,
fullGc.toJSON() || 0,
gcTimes.toJSON().sum || 0,
heap_compactions || 0,
heapCompactionsJSON || 0,
heapDiff.toJSON().sum || 0,
heapInfo ['processHeapUsed'] || 0,
heapInfo ['processHeapTotal'] || 0,
heapInfo ['processMemoryRss'] || 0
heapInfo['processHeapUsed'] || 0,
heapInfo['processHeapTotal'] || 0,
heapInfo['processMemoryRss'] || 0
]
agent.addMetrics({ts: now, name: 'gc', value: metricValues})
fullGc.reset(0)
Expand Down
Loading