lightstep-tracer
Advanced tools
Comparing version 0.21.0 to 0.21.1
# CHANGELOG | ||
*Log of significant changes, especially those affecting the supported API.* | ||
## 0.20.15 | ||
## 0.21.1 | ||
* Passing fractional timestamps to span start/finish are now properly handled. | ||
* Several bugs were fixed with the `proto` transport option around span duration and span ids. | ||
* We now support a custom logger function (thanks @Rowno), see README for more details. | ||
## 0.21.0 | ||
* Update `thrift` to `0.11.0`. This breaks support for node.js versions <= 5.8. | ||
@@ -7,0 +14,0 @@ |
@@ -21,4 +21,4 @@ "use strict"; | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=_each.js.map |
@@ -48,4 +48,4 @@ 'use strict'; | ||
exports.default = AuthImp; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=auth_imp.js.map |
@@ -149,4 +149,4 @@ 'use strict'; | ||
exports.default = LogRecordImp; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=log_record_imp.js.map |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -19,12 +19,6 @@ | ||
if (window.performance && window.performance.now && window.performance.timing && window.performance.timing.navigationStart) { | ||
var _ret = function () { | ||
var start = performance.timing.navigationStart; | ||
return { | ||
v: function v() { | ||
return Math.floor((start + performance.now()) * 1000.0); | ||
} | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
var start = performance.timing.navigationStart; | ||
return function () { | ||
return Math.floor((start + performance.now()) * 1000.0); | ||
}; | ||
} | ||
@@ -31,0 +25,0 @@ // The low-res timer is the best we can do |
@@ -89,4 +89,4 @@ 'use strict'; | ||
exports.default = TransportBrowser; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=transport_httpproto.js.map |
@@ -106,4 +106,4 @@ 'use strict'; | ||
exports.default = TransportBrowser; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=transport_httpthrift.js.map |
@@ -201,4 +201,4 @@ 'use strict'; | ||
exports.default = PlatformNode; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=platform_node.js.map |
@@ -140,3 +140,3 @@ 'use strict'; | ||
} | ||
return done(err, resp); | ||
return done(err, resp.toObject()); | ||
}); | ||
@@ -203,4 +203,4 @@ }); | ||
exports.default = TransportHTTPProto; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=transport_httpproto.js.map |
@@ -206,4 +206,4 @@ 'use strict'; | ||
exports.default = TransportHTTPThrift; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=transport_httpthrift.js.map |
@@ -128,4 +128,4 @@ 'use strict'; | ||
exports.default = ReportImp; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=report_imp.js.map |
@@ -89,4 +89,4 @@ 'use strict'; | ||
exports.default = RuntimeImp; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=runtime_imp.js.map |
@@ -70,4 +70,4 @@ 'use strict'; | ||
exports.default = SpanContextImp; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=span_context_imp.js.map |
@@ -233,3 +233,3 @@ 'use strict'; | ||
if (finishTime !== undefined) { | ||
this._endMicros = finishTime * 1000; | ||
this.setEndMicros(Math.floor(finishTime * 1000)); | ||
} | ||
@@ -242,3 +242,3 @@ | ||
if (this._endMicros === 0) { | ||
this._endMicros = this._tracerImp._platform.nowMicros(); | ||
this.setEndMicros(this._tracerImp._platform.nowMicros()); | ||
} | ||
@@ -301,3 +301,3 @@ this._tracerImp._addSpanRecord(this); | ||
spanProto.setStartTimestamp(startTimestamp); | ||
spanProto.setDurationMicros(this._endMicros - this._beginMicros); | ||
spanProto.setDurationMicros((this._endMicros - this._beginMicros).toString()); | ||
@@ -345,4 +345,4 @@ var logs = []; | ||
exports.default = SpanImp; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=span_imp.js.map |
@@ -261,2 +261,3 @@ 'use strict'; | ||
this.addOption('error_throttle_millis', { type: 'int', defaultValue: 60000 }); | ||
this.addOption('logger', { type: 'function', defaultValue: this._printToConsole.bind(this) }); | ||
@@ -321,3 +322,3 @@ // Debugging options | ||
// startTime is in milliseconds | ||
spanImp.setBeginMicros(value * 1000); | ||
spanImp.setBeginMicros(Math.floor(value * 1000)); | ||
break; | ||
@@ -575,13 +576,11 @@ case 'tags': | ||
if (this.verbosity() >= 3) { | ||
(function () { | ||
var optionsString = ''; | ||
var count = 0; | ||
(0, _each3.default)(modified, function (val, key) { | ||
optionsString += '\t' + JSON.stringify(key) + ': ' + JSON.stringify(val.newValue) + '\n'; | ||
count++; | ||
}); | ||
if (count > 0) { | ||
_this4._debug('Options modified:\n' + optionsString); | ||
} | ||
})(); | ||
var optionsString = ''; | ||
var count = 0; | ||
(0, _each3.default)(modified, function (val, key) { | ||
optionsString += '\t' + JSON.stringify(key) + ': ' + JSON.stringify(val.newValue) + '\n'; | ||
count++; | ||
}); | ||
if (count > 0) { | ||
this._debug('Options modified:\n' + optionsString); | ||
} | ||
} | ||
@@ -613,2 +612,9 @@ this.emit('options', modified, this._options, this); | ||
case 'function': | ||
if (typeof value !== 'function') { | ||
this._error('Invalid function option \'' + name + '\' \'' + value + '\''); | ||
return; | ||
} | ||
break; | ||
case 'int': | ||
@@ -711,33 +717,31 @@ if (valueType !== 'number' || Math.floor(value) !== value) { | ||
if (this._options.access_token.length > 0 && this._options.component_name.length > 0) { | ||
(function () { | ||
_this5._runtimeGUID = _this5._platform.runtimeGUID(_this5._options.component_name); | ||
this._runtimeGUID = this._platform.runtimeGUID(this._options.component_name); | ||
_this5._auth = new _auth_imp2.default(_this5._options.access_token); | ||
this._auth = new _auth_imp2.default(this._options.access_token); | ||
// | ||
// Assemble the tracer tags from the user-specified and automatic, | ||
// internal tags. | ||
// | ||
var tags = {}; | ||
(0, _each3.default)(_this5._options.tags, function (value, key) { | ||
if (typeof value !== 'string') { | ||
_this5._error('Tracer tag value is not a string: key=' + key); | ||
return; | ||
} | ||
tags[key] = value; | ||
}); | ||
tags['lightstep.tracer_version'] = packageObject.version; | ||
var platformTags = _this5._platform.tracerTags(); | ||
(0, _each3.default)(platformTags, function (val, key) { | ||
tags[key] = val; | ||
}); | ||
// | ||
// Assemble the tracer tags from the user-specified and automatic, | ||
// internal tags. | ||
// | ||
var tags = {}; | ||
(0, _each3.default)(this._options.tags, function (value, key) { | ||
if (typeof value !== 'string') { | ||
_this5._error('Tracer tag value is not a string: key=' + key); | ||
return; | ||
} | ||
tags[key] = value; | ||
}); | ||
tags['lightstep.tracer_version'] = packageObject.version; | ||
var platformTags = this._platform.tracerTags(); | ||
(0, _each3.default)(platformTags, function (val, key) { | ||
tags[key] = val; | ||
}); | ||
_this5._runtime = new _runtime_imp2.default(_this5._runtimeGUID, _this5._startMicros, _this5._options.component_name, tags); | ||
this._runtime = new _runtime_imp2.default(this._runtimeGUID, this._startMicros, this._options.component_name, tags); | ||
_this5._info('Initializing thrift reporting data', { | ||
component_name: _this5._options.component_name, | ||
access_token: _this5._auth.getAccessToken() | ||
}); | ||
_this5.emit('reporting_initialized'); | ||
})(); | ||
this._info('Initializing thrift reporting data', { | ||
component_name: this._options.component_name, | ||
access_token: this._auth.getAccessToken() | ||
}); | ||
this.emit('reporting_initialized'); | ||
} | ||
@@ -1290,3 +1294,3 @@ } | ||
} | ||
this._printToConsole('log', '[LightStep:DEBUG] ' + msg, payload); | ||
this._options.logger('debug', msg, payload); | ||
} | ||
@@ -1299,3 +1303,3 @@ }, { | ||
} | ||
this._printToConsole('log', '[LightStep:INFO] ' + msg, payload); | ||
this._options.logger('info', msg, payload); | ||
} | ||
@@ -1310,3 +1314,3 @@ }, { | ||
} | ||
this._printToConsole('warn', '[LightStep:WARN] ' + msg, payload); | ||
this._options.logger('warn', msg, payload); | ||
} | ||
@@ -1341,7 +1345,7 @@ }, { | ||
/* eslint-enable max-len */ | ||
this._printToConsole('error', '[LightStep:ERROR] ' + s, payload); | ||
this._options.logger('error', s, payload); | ||
} | ||
} | ||
this._printToConsole('error', '[LightStep:ERROR] ' + msg, payload); | ||
this._options.logger('error', msg, payload); | ||
this._lastVisibleErrorMillis = now; | ||
@@ -1352,3 +1356,19 @@ this._skippedVisibleErrors = 0; | ||
key: '_printToConsole', | ||
value: function _printToConsole(type, msg, payload) { | ||
value: function _printToConsole(level, msg, payload) { | ||
var method = 'log'; | ||
var message = '[LightStep:INFO] ' + msg; | ||
if (level === 'debug') { | ||
method = 'log'; | ||
message = '[LightStep:DEBUG] ' + msg; | ||
} else if (level === 'info') { | ||
method = 'log'; | ||
message = '[LightStep:INFO] ' + msg; | ||
} else if (level === 'warn') { | ||
method = 'warn'; | ||
message = '[LightStep:WARN] ' + msg; | ||
} else if (level === 'error') { | ||
method = 'error'; | ||
message = '[LightStep:ERROR] ' + msg; | ||
} | ||
// Internal option to silence intentional errors generated by the unit | ||
@@ -1361,5 +1381,5 @@ // tests. | ||
if (payload !== undefined) { | ||
console[type](msg, payload); // eslint-disable-line no-console | ||
console[method](message, payload); // eslint-disable-line no-console | ||
} else { | ||
console[type](msg); // eslint-disable-line no-console | ||
console[method](message); // eslint-disable-line no-console | ||
} | ||
@@ -1386,4 +1406,4 @@ } | ||
exports.default = Tracer; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=tracer_imp.js.map |
@@ -35,4 +35,4 @@ "use strict"; | ||
exports.default = new Util(); | ||
module.exports = exports['default']; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "lightstep-tracer", | ||
"version": "0.21.0", | ||
"version": "0.21.1", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -78,3 +78,3 @@ # lightstep-tracer | ||
* `xhr_instrumentation` `bool` - if false, disables automatic instrumentation of XMLHttpRequests (XHRs). This must be set at initialization; changes after initialization will have no effect. Defaults to false. | ||
* `xhr_instrumentation` `bool` - if false, disables automatic instrumentation of XMLHttpRequests (XHRs). This must be set at initialization; changes after initialization will have no effect. Defaults to false. | ||
@@ -97,2 +97,3 @@ * `xhr_url_inclusion_patterns` `RegExp[]` - an array of regular expressions used to whitelist URLs for `XMLHttpRequest` auto-instrumentation. The default value is wildcard matching all strings. For a given URL to be instrumented, it must match at least one regular expression in `xhr_url_inclusion_patterns` and not match any regular expressions in `xhr_url_exclusion_patterns`. | ||
* `transport` `string` *optional*, *default=thrift* - when `transport` is set to `proto`, the Tracer will use Proto over HTTP as a transport rather than Thrift. | ||
* `logger` `function(level: string, message: string, payload: any): void` *optional* - specify a custom logger function. Possible `level` values are `debug`, `info`, `warn` and `error`. By default messages will be logged to the console. | ||
@@ -99,0 +100,0 @@ ### SpanImp |
@@ -114,3 +114,3 @@ import * as https from 'https'; | ||
} | ||
return done(err, resp); | ||
return done(err, resp.toObject()); | ||
}); | ||
@@ -117,0 +117,0 @@ }); |
@@ -167,3 +167,3 @@ import * as coerce from './coerce.js'; | ||
if (finishTime !== undefined) { | ||
this._endMicros = finishTime * 1000; | ||
this.setEndMicros(Math.floor(finishTime * 1000)); | ||
} | ||
@@ -176,3 +176,3 @@ | ||
if (this._endMicros === 0) { | ||
this._endMicros = this._tracerImp._platform.nowMicros(); | ||
this.setEndMicros(this._tracerImp._platform.nowMicros()); | ||
} | ||
@@ -229,3 +229,3 @@ this._tracerImp._addSpanRecord(this); | ||
spanProto.setStartTimestamp(startTimestamp); | ||
spanProto.setDurationMicros(this._endMicros - this._beginMicros); | ||
spanProto.setDurationMicros((this._endMicros - this._beginMicros).toString()); | ||
@@ -232,0 +232,0 @@ let logs = []; |
@@ -219,2 +219,3 @@ //============================================================================// | ||
this.addOption('error_throttle_millis', { type: 'int', defaultValue: 60000 }); | ||
this.addOption('logger', { type: 'function', defaultValue: this._printToConsole.bind(this) }); | ||
@@ -276,3 +277,3 @@ // Debugging options | ||
// startTime is in milliseconds | ||
spanImp.setBeginMicros(value * 1000); | ||
spanImp.setBeginMicros(Math.floor(value * 1000)); | ||
break; | ||
@@ -545,2 +546,9 @@ case 'tags': | ||
case 'function': | ||
if (typeof value !== 'function') { | ||
this._error(`Invalid function option '${name}' '${value}'`); | ||
return; | ||
} | ||
break; | ||
case 'int': | ||
@@ -1169,3 +1177,3 @@ if (valueType !== 'number' || Math.floor(value) !== value) { | ||
} | ||
this._printToConsole('log', `[LightStep:DEBUG] ${msg}`, payload); | ||
this._options.logger('debug', msg, payload); | ||
} | ||
@@ -1177,3 +1185,3 @@ | ||
} | ||
this._printToConsole('log', `[LightStep:INFO] ${msg}`, payload); | ||
this._options.logger('info', msg, payload); | ||
} | ||
@@ -1187,3 +1195,3 @@ | ||
} | ||
this._printToConsole('warn', `[LightStep:WARN] ${msg}`, payload); | ||
this._options.logger('warn', msg, payload); | ||
} | ||
@@ -1221,7 +1229,7 @@ | ||
/* eslint-enable max-len */ | ||
this._printToConsole('error', `[LightStep:ERROR] ${s}`, payload); | ||
this._options.logger('error', s, payload); | ||
} | ||
} | ||
this._printToConsole('error', `[LightStep:ERROR] ${msg}`, payload); | ||
this._options.logger('error', msg, payload); | ||
this._lastVisibleErrorMillis = now; | ||
@@ -1231,3 +1239,19 @@ this._skippedVisibleErrors = 0; | ||
_printToConsole(type, msg, payload) { | ||
_printToConsole(level, msg, payload) { | ||
let method = 'log'; | ||
let message = `[LightStep:INFO] ${msg}`; | ||
if (level === 'debug') { | ||
method = 'log'; | ||
message = `[LightStep:DEBUG] ${msg}`; | ||
} else if (level === 'info') { | ||
method = 'log'; | ||
message = `[LightStep:INFO] ${msg}`; | ||
} else if (level === 'warn') { | ||
method = 'warn'; | ||
message = `[LightStep:WARN] ${msg}`; | ||
} else if (level === 'error') { | ||
method = 'error'; | ||
message = `[LightStep:ERROR] ${msg}`; | ||
} | ||
// Internal option to silence intentional errors generated by the unit | ||
@@ -1240,5 +1264,5 @@ // tests. | ||
if (payload !== undefined) { | ||
console[type](msg, payload); // eslint-disable-line no-console | ||
console[method](message, payload); // eslint-disable-line no-console | ||
} else { | ||
console[type](msg); // eslint-disable-line no-console | ||
console[method](message); // eslint-disable-line no-console | ||
} | ||
@@ -1245,0 +1269,0 @@ } |
@@ -27,2 +27,10 @@ describe("SpanImp", function() { | ||
describe("SpanImp#beginMicrosWithNanos", function() { | ||
it("handles fractional timestamps", function() { | ||
var span = Tracer.startSpan('test', {startTime: 1550584089648.123456789}) | ||
expect(span.beginMicros() % 1).to.be.eq(0) | ||
span.finish(); | ||
}); | ||
}); | ||
// Used by the browser to create spans retroactively | ||
@@ -29,0 +37,0 @@ describe("SpanImp#setEndMicros", function() { |
@@ -133,2 +133,11 @@ function makeLSTracer(extraOpts) { | ||
it('should allow setting a custom logger', function () { | ||
let hasLogged = false; | ||
makeLSTracer({ | ||
logger : function () { hasLogged = true; }, | ||
silent : false, | ||
verbosity : 4, | ||
}); | ||
expect(hasLogged).to.equal(true); | ||
}); | ||
}); | ||
@@ -135,0 +144,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64627
119
4844563
179