Skip to content

Commit 3cdb41f

Browse files
committed
fix(agent): debug log typeerror
1 parent b80acae commit 3cdb41f

4 files changed

Lines changed: 15 additions & 17 deletions

File tree

lib/agent/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Agent.prototype.start = function () {
9898
var self = this
9999
this._api.getService(function (err, serviceKey) {
100100
if (err) {
101-
return debug(err.message)
101+
return debug.error('start', 'Error starting service: ' + err.stack)
102102
}
103103
debug.info('start', 'ServiceKey is set to: ' + serviceKey)
104104
self.serviceKey = serviceKey

lib/agent/security/security.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ Security.prototype.collectSnykFlags = function collectSnykFlags (callback) {
3131
try {
3232
patch = yaml.safeLoad(data).patch
3333
} catch (ex) {
34-
debug.error('collectSnykFlags', format('error collecting snyk flags: %s', ex))
35-
debug.error(ex)
34+
debug.error('collectSnykFlags', format('error collecting snyk flags: %s', ex.stack))
3635
callback(null, [])
3736
return
3837
}
@@ -53,7 +52,7 @@ Security.prototype.collectSnykFlags = function collectSnykFlags (callback) {
5352
if (_error) {
5453
// ignore
5554
debug.error('collectSnykFlags',
56-
format('`npm ls <package_names> --long --parseable` returned error: %s', _error))
55+
format('`npm ls <package_names> --long --parseable` returned error: %s', _error.stack))
5756
}
5857

5958
var pkgs = stdout.split('\n')
@@ -140,13 +139,13 @@ Security.prototype.sendDependencies = function sendDependencies () {
140139
var _this = this
141140
this.collectDependencies(function (error, dependencies) {
142141
if (error) {
143-
debug.error('sendDependencies', format('error collecting dependencies: %s', error))
142+
debug.error('sendDependencies', format('error collecting dependencies: %s', error.stack))
144143
return
145144
}
146145

147146
_this.collectSnykFlags(function (_error, flags) {
148147
if (_error) {
149-
debug.error('sendDependencies', format('error collecting snyk flags: %s', _error))
148+
debug.error('sendDependencies', format('error collecting snyk flags: %s', _error.stack))
150149
// send dependencies without patches
151150
_this.collectorApi.sendDependencies(dependencies)
152151
return

lib/instrumentations/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ function loadInstrumentationsForTarget (name, path) {
1313
} catch (err) {
1414
debug.warn('loadInstrumentationsForTarget',
1515
format('instrumentation failed for `%s`. Could not load `%s`. Reason: %s',
16-
name, path, err))
17-
debug.warn(err)
16+
name, path, err.stack))
1817
}
1918
if (!instrumentations) {
2019
return
@@ -62,7 +61,7 @@ function instrumentModule (target, instrumentation, agent, load) {
6261
} catch (err) {
6362
debug.warn('instrumentModule', format('[Warning] cannot load `[%s] package.json`, ' +
6463
'although it was requested by the instrumentation group. Instrumentation might not work properly. ' +
65-
'Err: %s', target.name, err.message))
64+
'Err: %s', target.name, err.stack))
6665
}
6766
}
6867
if (instrumentation.pre) {
@@ -73,7 +72,7 @@ function instrumentModule (target, instrumentation, agent, load) {
7372
} catch (err) {
7473
debug.error('instrumentModule', format(
7574
'[Error] Failed applying preload hook to module `[%s] %s`: %s. Instrumentation may not work properly',
76-
target.name, instrumentation.path, err.message
75+
target.name, instrumentation.path, err.stack
7776
))
7877
}
7978
}
@@ -86,7 +85,7 @@ function instrumentModule (target, instrumentation, agent, load) {
8685
} catch (err) {
8786
debug.error('instrumentModule', format(
8887
'Failed applying postload hook to module `[%s] %s`: %s. Instrumentation may not work properly',
89-
target.name, instrumentation.path, err.message
88+
target.name, instrumentation.path, err.stack
9089
))
9190
}
9291
}
@@ -100,8 +99,8 @@ function loadTargetsEagerly (targets) {
10099
try {
101100
require(instrumentation.path)
102101
} catch (err) {
103-
debug.error('loadTargetsEagerly', format('Could not load module `[%s] %s`: `%s`',
104-
target.name, instrumentation.path, err.message))
102+
debug.error('loadTargetsEagerly', format('Could not load module `[%s] %s`: %s',
103+
target.name, instrumentation.path, err.stack))
105104
}
106105
}
107106
})

lib/utils/configReader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ConfigReader.prototype._getEnvVarConfig = function () {
8282
defaults(envVarConfig, { ignoreHeaders: ignoreHeaders })
8383
} catch (err) {
8484
debug.error('getEnvVarConfig',
85-
format('[Error] Cannot parse TRACE_IGNORE_HEADERS. Error: %s', err.message))
85+
format('[Error] Cannot parse TRACE_IGNORE_HEADERS. %s', err.stack))
8686
}
8787
}
8888

@@ -92,7 +92,7 @@ ConfigReader.prototype._getEnvVarConfig = function () {
9292
defaults(envVarConfig, { ignoreOutgoingHosts: ignoreOutgoingHosts })
9393
} catch (err) {
9494
debug.error('getEnvVarConfig',
95-
format('Cannot parse TRACE_IGNORE_OUTGOING_HOSTS. Error: %s', err.message))
95+
format('Cannot parse TRACE_IGNORE_OUTGOING_HOSTS. %s', err.stack))
9696
}
9797
}
9898

@@ -183,9 +183,9 @@ ConfigReader.prototype._readProcFile = function (name) {
183183
var procFileContent
184184
try {
185185
procFileContent = fs.readFileSync('/proc' + name, 'utf-8')
186-
} catch (ex) {
186+
} catch (err) {
187187
debug.info('_readProcFile',
188-
format('Cannot read procfile %s: Error: %s', name, ex))
188+
format('Cannot read procfile %s: %s', name, err))
189189
}
190190
return procFileContent
191191
}

0 commit comments

Comments
 (0)