Skip to content

Commit 1c4b043

Browse files
committed
fix: propagate serviceKey to tracer
1 parent 02a4e1d commit 1c4b043

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

lib/agent/metrics/incomingEdge/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ IncomingEdgeMetrics.prototype.report = function (data) {
3838
if (data.transportDelay < 0) {
3939
return
4040
}
41-
var serviceKey = data.serviceKey === undefined
41+
var serviceKey = data.serviceKey == null
4242
? 'root' : data.serviceKey
4343
var edge = this._getEdge(data.protocol, serviceKey)
4444

lib/agent/tracer/collector.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ Collector.prototype.flush = function () {
155155
return result
156156
}
157157

158+
Collector.prototype.setServiceKey = function (serviceKey) {
159+
this.serviceKey = serviceKey
160+
this.tracer.setServiceKey(serviceKey)
161+
}
162+
158163
// Purely for cache management
159164
Collector.prototype.end = function (briefcase) {
160165
if (!briefcase) {

lib/agent/tracer/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ inherits(Tracer, Agent)
3131

3232
Tracer.prototype.initialize = function (opts) {
3333
Agent.prototype.initialize.call(this, opts)
34-
this.collector.serviceKey = this.serviceKey = opts.serviceKey
34+
this.serviceKey = opts.serviceKey
35+
this.collector.setServiceKey(opts.serviceKey)
3536
}
3637

3738
Tracer.prototype.start = function () {

lib/agent/tracer/tracer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ Tracer.prototype.getTransactionId = function (briefcase) {
303303
return history[0][1].r
304304
}
305305

306+
Tracer.prototype.setServiceKey = function (serviceKey) {
307+
this.serviceKey = serviceKey
308+
}
309+
306310
module.exports = Tracer
307311
module.exports.create = function (options) {
308312
return new Tracer(options)

test/e2e/apiCalls.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ apiCalls.forEach(function (name) {
6565
t.pass('collector sends ' + name)
6666
if (typeof requestBody === 'object') {
6767
t.pass('requestBody is valid JSON')
68-
console.log(requestBody)
68+
console.log(JSON.stringify(requestBody))
6969
ok()
7070
} else {
7171
var buffer = new Buffer(requestBody, 'hex')

0 commit comments

Comments
 (0)