Skip to content

Commit

Permalink
feat(logging): add data logging to reporters
Browse files Browse the repository at this point in the history
  • Loading branch information
peteyycz committed Sep 1, 2015
1 parent 9a3f2ea commit cefc26d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var getNamespace = require('continuation-local-storage').getNamespace;
* @extends events.EventEmitter
*/
function Collector(options) {
debug('collector is initializing...');
events.EventEmitter.call(this);

this.collectInterval = options.collectInterval;
Expand All @@ -32,11 +33,13 @@ function Collector(options) {
this.formattableLogFile = config.logFilePath + config.logFilePrefix + '%s.log';

this._updateLogFile();
debug('collector initialized');
}

util.inherits(Collector, events.EventEmitter);

Collector.prototype.startCollecting = function () {
debug('collector started collecting');
var _this = this;
this.intervalId = setInterval(function () {
if (_this.isSampled && (typeof _this.service !== 'undefined')) {
Expand All @@ -47,10 +50,12 @@ Collector.prototype.startCollecting = function () {
};

Collector.prototype.stopCollecting = function () {
debug('collector stopped collecting');
clearInterval(this.intervalId);
};

Collector.prototype.setService = function (serviceId) {
debug('collector service is set to: ', serviceId);
this.service = serviceId;
};

Expand Down
4 changes: 3 additions & 1 deletion lib/reporters/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ TraceReporter.prototype.send = function (data, callback) {
return callback(err);
});

req.write(JSON.stringify(data));
var payload = JSON.stringify(data);
debug('sending data to trace servers: ', payload);
req.write(payload);
req.end();
};

Expand Down

0 comments on commit cefc26d

Please sign in to comment.