Skip to content

Commit

Permalink
fix(collector): collect all traces with errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gergelyke committed Sep 14, 2015
1 parent 78115c7 commit 0f7682c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Collector.prototype.onClientReceive = function (data) {
spanId = data.headers['x-span-id'];
}

if (data.err) {
trace.isSampled = true;
}

trace.events.push({
id: spanId,
time: data.time,
Expand All @@ -128,8 +132,6 @@ Collector.prototype.onServerSend = function (data) {
var headers = data.headers;
var spanId = headers['x-span-id'];

var isSampled = this.sampleRate > Math.random();

var trace = this._initTrace(data);
trace.statusCode = data.statusCode;
trace.events.push({
Expand All @@ -138,7 +140,10 @@ Collector.prototype.onServerSend = function (data) {
type: Collector.SERVER_SEND
});

var isSampled = trace.isSampled || this.sampleRate > Math.random();

if (trace.statusCode > 399 || isSampled) {
delete trace.isSampled;
this.traces.push(trace);
}

Expand Down

0 comments on commit 0f7682c

Please sign in to comment.