Skip to content

Commit ea43a8a

Browse files
committed
fix(collector): correctly read severity during SS
1 parent 8a3fafc commit ea43a8a

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

lib/agent/tracer/collector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@ Collector.prototype.serverSend = function (payload, briefcase, options) {
285285
}, payload.severity != null ? payload.severity : this.defaultSeverity)
286286
}
287287

288+
var severity = this._getSeverityHintFromCache(communicationId)
289+
288290
this._removeLockFromCache(communicationId)
289291
this._flushUnlockedCache(communicationId)
290292

291-
var severity = this._getSeverityHintFromCache(communicationId)
292-
293293
var duffelBag = {
294294
timestamp: timestamp,
295295
severity: severity,
@@ -407,7 +407,7 @@ Collector.prototype._getSeverityHintFromCache = function (cacheId) {
407407
if (this._eventBuffers[cacheId]) {
408408
return this._eventBuffers[cacheId].severityBuf.elements().reduce(function (acc, x) {
409409
return levels.gte(acc, x) ? acc : x
410-
})
410+
}, this.defaultSeverity)
411411
} else {
412412
return this.defaultSeverity
413413
}

lib/agent/tracer/collector.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,35 @@ describe('Collector', function () {
283283
expect(tracer.collect().length).to.be.equal(2)
284284
})
285285

286+
it('SS duffelBag contains mustCollect', function () {
287+
var tracer = new Collector(options)
288+
var sr = {
289+
payload: { },
290+
duffelBag: {
291+
communicationId: 'commId',
292+
transactionId: 'trId',
293+
severity: tracer.mustCollectSeverity
294+
}
295+
}
296+
var ss = {
297+
payload: { },
298+
briefcase: {
299+
communication: {
300+
id: sr.duffelBag.communicationId,
301+
transactionId: sr.duffelBag.transactionId
302+
}
303+
}
304+
}
305+
306+
this.sandbox.stub(microtime, 'now', function () {
307+
return 2
308+
})
309+
310+
tracer.serverRecv(sr.payload, sr.duffelBag)
311+
var ssResult = tracer.serverSend(ss.payload, ss.briefcase)
312+
expect(ssResult.duffelBag.severity).to.equal(tracer.mustCollectSeverity)
313+
})
314+
286315
it('both is dropped when SS is skipped', function () {
287316
var tracer = new Collector(options)
288317
var sr = {

0 commit comments

Comments
 (0)