lightstep-tracer
Advanced tools
Comparing version 0.25.2 to 0.27.0
@@ -7,4 +7,11 @@ # CHANGELOG | ||
## 0.26.0 | ||
* Require node >= v8 | ||
* New option to empty span buffer on max error streak `clear_span_buffer_consecutive_errors` | ||
* Upgrade eslint | ||
## 0.25.2 | ||
* fix for fetch plugin: 'method' was always GET | ||
* Fix missing clock offsets over proto transport | ||
@@ -11,0 +18,0 @@ * Fix timestamp conversion for protobuf transport |
@@ -11,2 +11,3 @@ "use strict"; | ||
// iterated with for-in. | ||
// TODO: remove this function and replace with Object.keys, Object.values, ... (spread) or other. | ||
function _each(obj, cb) { | ||
@@ -16,2 +17,3 @@ if (!obj) { | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var key in obj) { | ||
@@ -18,0 +20,0 @@ if (hasOwnProperty.call(obj, key)) { |
@@ -7,4 +7,5 @@ 'use strict'; | ||
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 _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; }; }(); // eslint-disable-next-line camelcase | ||
var _platform_abstraction_layer = require('../platform_abstraction_layer'); | ||
@@ -14,3 +15,2 @@ | ||
// eslint-disable-line camelcase | ||
var proto = require('./generated_proto/collector_pb.js'); | ||
@@ -17,0 +17,0 @@ |
'use strict'; | ||
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 _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; }; }(); // eslint-disable-next-line camelcase | ||
var _platform_abstraction_layer = require('../platform_abstraction_layer'); | ||
@@ -9,3 +10,2 @@ | ||
// eslint-disable-line camelcase | ||
var constants = require('../constants'); | ||
@@ -12,0 +12,0 @@ var coerce = require('./coerce'); |
@@ -27,4 +27,4 @@ 'use strict'; | ||
// eslint-disable-line camelcase | ||
var googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb.js'); | ||
var proto = require('./generated_proto/collector_pb.js'); | ||
var googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb.js'); | ||
@@ -31,0 +31,0 @@ var LogRecordImp = function () { |
@@ -10,2 +10,3 @@ 'use strict'; | ||
// check to see if we're in a webworker | ||
// eslint-disable-next-line no-restricted-globals | ||
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { | ||
@@ -55,2 +56,3 @@ return null; | ||
var accessToken = dataset.access_token; | ||
@@ -84,2 +86,3 @@ if (typeof accessToken === 'string' && accessToken.length > 0) { | ||
var enable = dataset.enable; | ||
if (typeof enable === 'string') { | ||
@@ -93,2 +96,3 @@ if (enable === 'true') { | ||
var verbosity = dataset.verbosity; | ||
if (typeof verbosity === 'string') { | ||
@@ -95,0 +99,0 @@ opts.verbosity = parseInt(verbosity, 10); |
@@ -75,5 +75,7 @@ 'use strict'; | ||
value: function _generateLongUUID() { | ||
/* eslint-disable no-bitwise */ | ||
var p0 = ('00000000' + Math.abs(Math.random() * 0xFFFFFFFF | 0).toString(16)).substr(-8); | ||
var p1 = ('00000000' + Math.abs(Math.random() * 0xFFFFFFFF | 0).toString(16)).substr(-8); | ||
return '' + p0 + p1; | ||
/* eslint-enable no-bitwise */ | ||
} | ||
@@ -80,0 +82,0 @@ }, { |
@@ -65,7 +65,7 @@ 'use strict'; | ||
if (actual[0] > required[0]) { | ||
return; | ||
// eslint-disable-next-line no-empty | ||
} else if (actual[0] < required[0]) { | ||
this.fatal(err); | ||
} else if (actual[1] > required[1]) { | ||
return; | ||
// eslint-disable-next-line no-empty | ||
} else if (actual[1] < required[1]) { | ||
@@ -86,4 +86,10 @@ this.fatal(err); | ||
} | ||
/* eslint-disable no-empty */ | ||
}, { | ||
key: 'nowMicros', | ||
/* eslint-enable no-empty */ | ||
value: function nowMicros() { | ||
@@ -101,5 +107,7 @@ var hrTime = process.hrtime(); | ||
value: function generateUUID() { | ||
/* eslint-disable no-bitwise */ | ||
var p0 = ('00000000' + Math.abs(Math.random() * 0xFFFFFFFF | 0).toString(16)).substr(-8); | ||
var p1 = ('00000000' + Math.abs(Math.random() * 0xFFFFFFFF | 0).toString(16)).substr(-8); | ||
return '' + p0 + p1; | ||
/* eslint-enable no-bitwise */ | ||
} | ||
@@ -106,0 +114,0 @@ }, { |
@@ -17,3 +17,3 @@ 'use strict'; | ||
var _coerce = require('./coerce.js'); | ||
var _coerce = require('./coerce'); | ||
@@ -28,3 +28,3 @@ var coerce = _interopRequireWildcard(_coerce); | ||
var proto = require('./generated_proto/collector_pb.js'); | ||
var proto = require('./generated_proto/collector_pb'); | ||
@@ -31,0 +31,0 @@ var ReportImp = function () { |
@@ -17,3 +17,3 @@ 'use strict'; | ||
var _coerce = require('./coerce.js'); | ||
var _coerce = require('./coerce'); | ||
@@ -28,4 +28,4 @@ var coerce = _interopRequireWildcard(_coerce); | ||
var proto = require('./generated_proto/collector_pb.js'); | ||
var converter = require('hex2dec'); | ||
var proto = require('./generated_proto/collector_pb'); | ||
var packageObject = require('../../package.json'); | ||
@@ -32,0 +32,0 @@ |
@@ -21,3 +21,2 @@ 'use strict'; | ||
// ---------------------------------------------------------------------- // | ||
@@ -24,0 +23,0 @@ // OpenTracing Implementation |
@@ -11,4 +11,8 @@ 'use strict'; | ||
var _coerce = require('./coerce.js'); | ||
var _opentracing = require('opentracing'); | ||
var opentracing = _interopRequireWildcard(_opentracing); | ||
var _coerce = require('./coerce'); | ||
var coerce = _interopRequireWildcard(_coerce); | ||
@@ -24,6 +28,2 @@ | ||
var _opentracing = require('opentracing'); | ||
var opentracing = _interopRequireWildcard(_opentracing); | ||
var _platform_abstraction_layer = require('../platform_abstraction_layer'); | ||
@@ -35,3 +35,3 @@ | ||
var _util = require('./util/util.js'); | ||
var _util = require('./util/util'); | ||
@@ -55,4 +55,4 @@ var _util2 = _interopRequireDefault(_util); | ||
var converter = require('hex2dec'); | ||
var proto = require('./generated_proto/collector_pb.js'); | ||
var googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb.js'); | ||
var googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb'); | ||
var proto = require('./generated_proto/collector_pb'); | ||
@@ -65,3 +65,2 @@ var SpanImp = function (_opentracing$Span) { | ||
// ---------------------------------------------------------------------- // | ||
@@ -230,4 +229,4 @@ // opentracing.Span SPI | ||
* @param {Number} finishTime | ||
* Optional Unix timestamp in milliseconds setting an explicit | ||
* finish time for the span. | ||
* Optional Unix timestamp in milliseconds setting an explicit | ||
* finish time for the span. | ||
*/ | ||
@@ -330,3 +329,3 @@ | ||
var parentSpanGUID = undefined; | ||
var parentSpanGUID = void 0; | ||
var tags = []; | ||
@@ -333,0 +332,0 @@ (0, _each3.default)(this._tags, function (value, key) { |
@@ -144,3 +144,3 @@ 'use strict'; | ||
if (opts && opts.propagators) { | ||
_this._propagators = Object.assign({}, _this._propagators, opts.propagators); | ||
_this._propagators = { ..._this._propagators, ...opts.propagators }; | ||
} | ||
@@ -256,2 +256,3 @@ | ||
if (self._ee[methodName]) { | ||
// eslint-disable-next-line prefer-spread | ||
self._ee[methodName].apply(self._ee, arguments); | ||
@@ -269,3 +270,5 @@ } | ||
// options changes and takes effect as soon as possible. | ||
this.addOption('verbosity', { type: 'int', min: 0, max: 9, defaultValue: 1 }); | ||
this.addOption('verbosity', { | ||
type: 'int', min: 0, max: 9, defaultValue: 1 | ||
}); | ||
@@ -295,2 +298,3 @@ // Core options | ||
this.addOption('logger', { type: 'function', defaultValue: this._printToConsole.bind(this) }); | ||
this.addOption('clear_span_buffer_consecutive_errors', { type: 'int', defaultValue: null }); | ||
@@ -339,2 +343,3 @@ // Debugging options | ||
this._error('Span reference has an invalid context', context); | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
@@ -546,7 +551,7 @@ } | ||
// that didn't result either in a change or a reset to the existing value? | ||
for (var key in opts) { | ||
Object.keys(opts).forEach(function (key) { | ||
if (modified[key] === undefined && unchanged[key] === undefined) { | ||
this._warn('Invalid option ' + key + ' with value ' + opts[key]); | ||
_this3._warn('Invalid option ' + key + ' with value ' + opts[key]); | ||
} | ||
} | ||
}); | ||
@@ -579,2 +584,3 @@ // | ||
var name = desc.name; | ||
var value = opts[name]; | ||
@@ -588,3 +594,2 @@ var valueType = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
switch (desc.type) { | ||
case 'any': | ||
@@ -977,2 +982,32 @@ break; | ||
/** | ||
* clearSpanRecordsIfMaxErrors checks to see if the tracer was configured to | ||
* empty the span buffer after a fixed amount of errors. If it is configured, | ||
* and there has been an error streak equal to the configured value, | ||
* it will empty spanRecords and record that the spans were dropped. | ||
* | ||
* @private | ||
*/ | ||
}, { | ||
key: '_clearSpanRecordsIfMaxErrors', | ||
value: function _clearSpanRecordsIfMaxErrors() { | ||
var maxErrorsToEmpty = this.options().clear_span_buffer_consecutive_errors; | ||
if (maxErrorsToEmpty === null || this._reportErrorStreak < maxErrorsToEmpty) { | ||
return; | ||
} | ||
// spanRecords is configured to be emptied | ||
// the number of dropped spans and reporting errors should still be maintained since | ||
// the loop may still in the process of a report. | ||
var numSpansToDrop = this._spanRecords.length; | ||
this._counters['spans.dropped'] += numSpansToDrop; | ||
this._spanRecords = []; | ||
this._warn('Span buffer flushed, max consecutive errors reached', { | ||
max_consecutive_errors: maxErrorsToEmpty, | ||
spans_dropped: numSpansToDrop | ||
}); | ||
} | ||
//-----------------------------------------------------------------------// | ||
@@ -1213,2 +1248,4 @@ // Reporting loop | ||
_this12._clearSpanRecordsIfMaxErrors(); | ||
_this12.emit('report_error', err, { | ||
@@ -1215,0 +1252,0 @@ error: err, |
@@ -124,2 +124,3 @@ 'use strict'; | ||
(0, _each3.default)(this._samples, function (sample) { | ||
// eslint-disable-next-line no-restricted-properties | ||
jitter += Math.pow(bestOffsetMicros - sample.offsetMicros, 2); | ||
@@ -126,0 +127,0 @@ }); |
@@ -71,3 +71,3 @@ 'use strict'; | ||
var state = document.readyState; | ||
var payload = undefined; | ||
var payload = void 0; | ||
if (state === 'complete') { | ||
@@ -95,7 +95,6 @@ payload = {}; | ||
for (var key in nav) { | ||
// eslint-disable-line guard-for-in | ||
// eslint-disable-line guard-for-in, no-restricted-syntax | ||
try { | ||
var value = nav[key]; | ||
switch (key) { | ||
case 'plugins': | ||
@@ -159,3 +158,3 @@ { | ||
var payload = undefined; | ||
var payload = void 0; | ||
@@ -162,0 +161,0 @@ if (key === 'navigationStart' && (typeof navigator === 'undefined' ? 'undefined' : _typeof(navigator)) === 'object') { |
@@ -5,2 +5,4 @@ 'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
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; }; | ||
@@ -53,3 +55,9 @@ | ||
var pair = entries[i]; | ||
result[pair[0]] = pair[1]; | ||
var _pair = _slicedToArray(pair, 2); | ||
var key = _pair[0]; | ||
var val = _pair[1]; | ||
result[key] = val; | ||
} | ||
@@ -73,6 +81,2 @@ return result; | ||
this._handleOptions = this._handleOptions.bind(this); | ||
if (!this._enabled) { | ||
return; | ||
} | ||
} | ||
@@ -154,3 +158,3 @@ | ||
function escapeRegExp(str) { | ||
return ('' + str).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
return ('' + str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
@@ -193,10 +197,9 @@ | ||
return function (request) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
request = new Request(request, options); | ||
return function (input, init) { | ||
var request = new Request(input, init); | ||
var opts = tracer.options(); | ||
if (!self._shouldTrace(tracer, request.url)) { | ||
return proxiedFetch.apply(null, arguments); | ||
// eslint-disable-next-line prefer-spread | ||
return proxiedFetch(request); | ||
} | ||
@@ -203,0 +206,0 @@ |
@@ -81,5 +81,2 @@ 'use strict'; | ||
this._handleOptions = this._handleOptions.bind(this); | ||
if (!this._enabled) { | ||
return; | ||
} | ||
} | ||
@@ -165,3 +162,3 @@ | ||
function escapeRegExp(str) { | ||
return ('' + str).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
return ('' + str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
@@ -205,2 +202,3 @@ | ||
var urlObject = void 0; | ||
/* eslint-disable prefer-destructuring */ | ||
@@ -215,3 +213,3 @@ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
if (_typeof(args[1]) === 'object') { | ||
options = Object.assign({}, options, args[1]); | ||
options = { ...options, ...args[1] }; | ||
callback = args[2]; | ||
@@ -225,2 +223,3 @@ } else if (typeof args[1] === 'function') { | ||
} | ||
/* eslint-enable prefer-destructuring */ | ||
@@ -231,3 +230,5 @@ // check if there are headers stated, and if not create them on the first arg | ||
var headers = options.headers; | ||
var _options = options; | ||
var headers = _options.headers; | ||
var method = options.method || 'GET'; | ||
@@ -249,2 +250,3 @@ var url = options.href || _url2.default.format(options); | ||
if (url) { | ||
// eslint-disable-next-line prefer-destructuring | ||
tags.url_pathname = url.split('?')[0]; | ||
@@ -318,3 +320,3 @@ } | ||
// This shouldn't be possible, but let's be paranoid | ||
if (!tracer) { | ||
if (!tracer || !url) { | ||
return false; | ||
@@ -324,44 +326,24 @@ } | ||
var opts = tracer.options(); | ||
if (opts.disabled) { | ||
if (opts.disabled || !opts.nodejs_instrumentation) { | ||
return false; | ||
} | ||
if (!opts.nodejs_instrumentation) { | ||
if (this._internalExclusions.some(function (ex) { | ||
return ex.test(url); | ||
})) { | ||
return false; | ||
} | ||
if (!url) { | ||
return false; | ||
} | ||
for (var key in this._internalExclusions) { | ||
if (!this._internalExclusions.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
var ex = this._internalExclusions[key]; | ||
if (ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
var include = false; | ||
for (var _key2 in opts.nodejs_inclusion_patterns) { | ||
if (!opts.nodejs_inclusion_patterns.hasOwnProperty(_key2)) { | ||
continue; | ||
} | ||
var inc = opts.nodejs_inclusion_patterns[_key2]; | ||
if (inc.test(url)) { | ||
include = true; | ||
break; | ||
} | ||
if (opts.nodejs_url_inclusion_patterns.some(function (inc) { | ||
return inc.test(url); | ||
})) { | ||
include = true; | ||
} | ||
if (!include) { | ||
return false; | ||
if (opts.nodejs_url_exclusion_patterns.some(function (ex) { | ||
return ex.test(url); | ||
})) { | ||
include = false; | ||
} | ||
for (var _key3 in opts.nodejs_exclusion_patterns) { | ||
if (!opts.nodejs_exclusion_patterns.hasOwnProperty(_key3)) { | ||
continue; | ||
} | ||
var _ex = opts.nodejs_exclusion_patterns[_key3]; | ||
if (_ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
return include; | ||
} | ||
@@ -368,0 +350,0 @@ }]); |
@@ -7,6 +7,2 @@ 'use strict'; | ||
var _each2 = require('../_each'); | ||
var _each3 = _interopRequireDefault(_each2); | ||
var _opentracing = require('opentracing'); | ||
@@ -18,4 +14,2 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -83,6 +77,2 @@ | ||
this._handleOptions = this._handleOptions.bind(this); | ||
if (!this._enabled) { | ||
return; | ||
} | ||
} | ||
@@ -169,3 +159,3 @@ | ||
function escapeRegExp(str) { | ||
return ('' + str).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
return ('' + str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
@@ -238,9 +228,7 @@ | ||
if (url) { | ||
// eslint-disable-next-line prefer-destructuring | ||
tags.url_pathname = url.split('?')[0]; | ||
} | ||
var openPayload = {}; | ||
(0, _each3.default)(tags, function (val, key) { | ||
openPayload[key] = val; | ||
}); | ||
var openPayload = { ...tags }; | ||
if (opts.include_cookies) { | ||
@@ -281,2 +269,3 @@ openPayload.cookies = getCookies(); | ||
var responseType = this.responseType; | ||
span.log({ | ||
@@ -327,3 +316,3 @@ readyState: 4, | ||
var data = Array.prototype.slice.call(arguments); | ||
var len = undefined; | ||
var len = void 0; | ||
if (data.length === 1) { | ||
@@ -360,3 +349,3 @@ if (data[0] && data[0].length) { | ||
// This shouldn't be possible, but let's be paranoid | ||
if (!tracer) { | ||
if (!tracer || !url) { | ||
return false; | ||
@@ -369,38 +358,21 @@ } | ||
} | ||
if (!url) { | ||
if (this._internalExclusions.some(function (ex) { | ||
return ex.test(url); | ||
})) { | ||
return false; | ||
} | ||
for (var key in this._internalExclusions) { | ||
if (!this._internalExclusions.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
var ex = this._internalExclusions[key]; | ||
if (ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
var include = false; | ||
for (var _key in opts.xhr_url_inclusion_patterns) { | ||
if (!opts.xhr_url_inclusion_patterns.hasOwnProperty(_key)) { | ||
continue; | ||
} | ||
var inc = opts.xhr_url_inclusion_patterns[_key]; | ||
if (inc.test(url)) { | ||
include = true; | ||
break; | ||
} | ||
if (opts.xhr_url_inclusion_patterns.some(function (inc) { | ||
return inc.test(url); | ||
})) { | ||
include = true; | ||
} | ||
if (!include) { | ||
return false; | ||
if (opts.xhr_url_exclusion_patterns.some(function (ex) { | ||
return ex.test(url); | ||
})) { | ||
include = false; | ||
} | ||
for (var _key2 in opts.xhr_url_exclusion_patterns) { | ||
if (!opts.xhr_url_exclusion_patterns.hasOwnProperty(_key2)) { | ||
continue; | ||
} | ||
var _ex = opts.xhr_url_exclusion_patterns[_key2]; | ||
if (_ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
return include; | ||
} | ||
@@ -407,0 +379,0 @@ }]); |
@@ -64,2 +64,3 @@ 'use strict'; | ||
// Ignore records without a message (e.g. a stable_name log record) | ||
if (!message) { | ||
@@ -66,0 +67,0 @@ return; |
{ | ||
"name": "lightstep-tracer", | ||
"version": "0.25.2", | ||
"version": "0.27.0", | ||
"main": "index.js", | ||
@@ -8,3 +8,3 @@ "types": "index.d.ts", | ||
"engines": { | ||
"node": ">=0.12.0" | ||
"node": ">=8.0.0" | ||
}, | ||
@@ -25,2 +25,3 @@ "scripts": { | ||
"hex2dec": "1.0.1", | ||
"opentracing": "^0.14.4", | ||
"source-map-support": "0.3.3", | ||
@@ -35,2 +36,3 @@ "thrift": "0.13.0" | ||
"babel-plugin-check-es2015-constants": "6.7.2", | ||
"babel-plugin-syntax-object-rest-spread": "^6.13.0", | ||
"babel-plugin-transform-es2015-arrow-functions": "6.5.2", | ||
@@ -47,3 +49,3 @@ "babel-plugin-transform-es2015-block-scoped-functions": "6.6.5", | ||
"babel-plugin-transform-es2015-parameters": "6.7.0", | ||
"babel-plugin-transform-es2015-spread": "6.6.5", | ||
"babel-plugin-transform-es2015-spread": "^6.6.5", | ||
"babel-plugin-transform-es2015-sticky-regex": "6.5.0", | ||
@@ -57,9 +59,10 @@ "babel-plugin-transform-es2015-template-literals": "6.6.5", | ||
"colors": "1.1.2", | ||
"eslint": "2.4.0", | ||
"eslint-config-airbnb": "6.2.0", | ||
"eslint-plugin-react": "4.2.3", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb": "^18.0.1", | ||
"eslint-plugin-import": "^2.20.0", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-react": "^7.18.0", | ||
"express": "^4.16.3", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^5.2.0", | ||
"opentracing": "^0.14.4", | ||
"shelljs": "0.5.3", | ||
@@ -66,0 +69,0 @@ "sprintf-js": "1.0.3", |
@@ -15,3 +15,3 @@ # lightstep-tracer | ||
All modern browsers and Node versions >= 0.12 are supported. | ||
All modern browsers and Node versions >= 8 are supported. | ||
@@ -126,2 +126,3 @@ ## Getting started | ||
* `propagators` `dictionary` *optional*, *defaults=*`{ [opentracing.FORMAT_HTTP_HEADERS]: new lightstep.LightStepPropagator(), [opentracing.FORMAT_TEXT_MAP]: new lightstep.LightStepPropagator(), [opentracing.FORMAT_BINARY]: new lightstep.UnsupportedPropagator() }`: Allows inject/extract to use custom propagators for different formats. This package includes `B3Propagator` that supports B3 headers on text maps and http headers. `DDPropagator` supports DataDog trace headers. | ||
* `clear_span_buffer_consecutive_errors` `number` *optional*, *default=null* - each consecutive buffer flush error will check to see if `clear_span_buffer_consecutive_errors` has been reached. If reached, the span buffer will be emptied. This is useful for auto-recovering from errors based on request size constraints, particularly max payload size on intermediate load balancers. | ||
@@ -128,0 +129,0 @@ An example configuration using custom propagators might look like: |
@@ -5,2 +5,3 @@ // Underscore.js-like wrapper to iterate object key-values. Note that even for completely | ||
// iterated with for-in. | ||
// TODO: remove this function and replace with Object.keys, Object.values, ... (spread) or other. | ||
export default function _each(obj, cb) { | ||
@@ -10,2 +11,3 @@ if (!obj) { | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (let key in obj) { | ||
@@ -12,0 +14,0 @@ if (hasOwnProperty.call(obj, key)) { |
@@ -1,2 +0,4 @@ | ||
import { crouton_thrift } from '../platform_abstraction_layer'; // eslint-disable-line camelcase | ||
// eslint-disable-next-line camelcase | ||
import { crouton_thrift } from '../platform_abstraction_layer'; | ||
let proto = require('./generated_proto/collector_pb.js'); | ||
@@ -3,0 +5,0 @@ |
export function toString(value) { | ||
return '' + value; // eslint-disable-line prefer-template | ||
return '' + value; // eslint-disable-line prefer-template | ||
} | ||
@@ -5,0 +5,0 @@ |
@@ -1,2 +0,4 @@ | ||
import { crouton_thrift } from '../platform_abstraction_layer'; // eslint-disable-line camelcase | ||
// eslint-disable-next-line camelcase | ||
import { crouton_thrift } from '../platform_abstraction_layer'; | ||
const constants = require('../constants'); | ||
@@ -8,3 +10,2 @@ const coerce = require('./coerce'); | ||
class LogBuilder { | ||
constructor(runtime) { | ||
@@ -11,0 +12,0 @@ this._runtime = runtime; |
import { crouton_thrift } from '../platform_abstraction_layer'; // eslint-disable-line camelcase | ||
import _each from '../_each'; | ||
import * as coerce from './coerce'; // eslint-disable-line camelcase | ||
import * as coerce from './coerce'; | ||
// eslint-disable-line camelcase | ||
let googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb.js'); | ||
let proto = require('./generated_proto/collector_pb.js'); | ||
let googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb.js'); | ||
@@ -7,0 +8,0 @@ export default class LogRecordImp { |
@@ -8,2 +8,3 @@ /* global WorkerGlobalScope */ | ||
// check to see if we're in a webworker | ||
// eslint-disable-next-line no-restricted-globals | ||
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { | ||
@@ -51,3 +52,3 @@ return null; | ||
let dataset = hostScriptElement.dataset; | ||
let { dataset } = hostScriptElement; | ||
@@ -81,3 +82,3 @@ let accessToken = dataset.access_token; | ||
let enable = dataset.enable; | ||
let { enable } = dataset; | ||
if (typeof enable === 'string') { | ||
@@ -90,3 +91,3 @@ if (enable === 'true') { | ||
} | ||
let verbosity = dataset.verbosity; | ||
let { verbosity } = dataset; | ||
if (typeof verbosity === 'string') { | ||
@@ -93,0 +94,0 @@ opts.verbosity = parseInt(verbosity, 10); |
@@ -10,6 +10,6 @@ const optionsParser = require('./options_parser.js'); | ||
// Is a hi-res timer available? | ||
if (window.performance && | ||
window.performance.now && | ||
window.performance.timing && | ||
window.performance.timing.navigationStart) { | ||
if (window.performance | ||
&& window.performance.now | ||
&& window.performance.timing | ||
&& window.performance.timing.navigationStart) { | ||
let start = performance.timing.navigationStart; | ||
@@ -27,3 +27,2 @@ return function () { | ||
class PlatformBrowser { | ||
name() { | ||
@@ -61,5 +60,7 @@ return 'browser'; | ||
_generateLongUUID() { | ||
/* eslint-disable no-bitwise */ | ||
let p0 = `00000000${Math.abs((Math.random() * 0xFFFFFFFF) | 0).toString(16)}`.substr(-8); | ||
let p1 = `00000000${Math.abs((Math.random() * 0xFFFFFFFF) | 0).toString(16)}`.substr(-8); | ||
return `${p0}${p1}`; | ||
/* eslint-enable no-bitwise */ | ||
} | ||
@@ -98,2 +99,3 @@ | ||
} | ||
static initGlobalTracer(lib, opts) { | ||
@@ -106,3 +108,3 @@ if (typeof window !== 'object') { | ||
} | ||
opentracing.initGlobalTracer(new lib.Tracer(opts)); // eslint-disable-line no-undef | ||
opentracing.initGlobalTracer(new lib.Tracer(opts)); // eslint-disable-line no-undef | ||
} | ||
@@ -109,0 +111,0 @@ |
let proto = require('../../generated_proto/collector_pb.js'); | ||
export default class TransportBrowser { | ||
constructor() { | ||
@@ -6,0 +5,0 @@ this._host = ''; |
export default class TransportBrowser { | ||
constructor() { | ||
@@ -68,5 +67,5 @@ this._host = ''; | ||
let protocol = (this._encryption === 'none') ? 'http' : 'https'; | ||
let url = `${protocol}://${this._host}:${this._port}${this._path}/_rpc/v1/reports/uri_encoded` + | ||
`?auth=${encodeURIComponent(authJSON)}` + | ||
`&report=${encodeURIComponent(reportJSON)}`; | ||
let url = `${protocol}://${this._host}:${this._port}${this._path}/_rpc/v1/reports/uri_encoded` | ||
+ `?auth=${encodeURIComponent(authJSON)}` | ||
+ `&report=${encodeURIComponent(reportJSON)}`; | ||
@@ -73,0 +72,0 @@ let elem = document.createElement('script'); |
@@ -19,3 +19,2 @@ const os = require('os'); | ||
export default class PlatformNode { | ||
constructor(imp) { | ||
@@ -59,7 +58,7 @@ this._mustMatchVersion(); | ||
if (actual[0] > required[0]) { | ||
return; | ||
// eslint-disable-next-line no-empty | ||
} else if (actual[0] < required[0]) { | ||
this.fatal(err); | ||
} else if (actual[1] > required[1]) { | ||
return; | ||
// eslint-disable-next-line no-empty | ||
} else if (actual[1] < required[1]) { | ||
@@ -80,4 +79,5 @@ this.fatal(err); | ||
static initLibrary(lib) { | ||
} | ||
/* eslint-disable no-empty */ | ||
static initLibrary(lib) {} | ||
/* eslint-enable no-empty */ | ||
@@ -94,5 +94,7 @@ nowMicros() { | ||
generateUUID() { | ||
/* eslint-disable no-bitwise */ | ||
let p0 = `00000000${Math.abs((Math.random() * 0xFFFFFFFF) | 0).toString(16)}`.substr(-8); | ||
let p1 = `00000000${Math.abs((Math.random() * 0xFFFFFFFF) | 0).toString(16)}`.substr(-8); | ||
return `${p0}${p1}`; | ||
/* eslint-enable no-bitwise */ | ||
} | ||
@@ -166,3 +168,3 @@ | ||
fatal(message) { | ||
console.error(message); // eslint-disable-line no-console | ||
console.error(message); // eslint-disable-line no-console | ||
process.exit(1); | ||
@@ -169,0 +171,0 @@ } |
import * as https from 'https'; | ||
import * as http from 'http'; | ||
let proto = require('../../generated_proto/collector_pb.js'); | ||
@@ -4,0 +5,0 @@ |
@@ -6,2 +6,3 @@ export default class UnsupportedPropagator { | ||
} | ||
inject(spanContext, carrier) { | ||
@@ -11,2 +12,3 @@ this._tracer._error(`Unsupported format: ${this._name}`); | ||
} | ||
extract(carrier) { | ||
@@ -16,2 +18,1 @@ this._tracer._error(`Unsupported format: ${this._name}`); | ||
} | ||
import { crouton_thrift } from '../platform_abstraction_layer'; // eslint-disable-line camelcase | ||
import _each from '../_each'; // eslint-disable-line camelcase | ||
import * as coerce from './coerce.js'; | ||
let proto = require('./generated_proto/collector_pb.js'); | ||
import * as coerce from './coerce'; | ||
let proto = require('./generated_proto/collector_pb'); | ||
export default class ReportImp { | ||
@@ -7,0 +8,0 @@ constructor(runtime, oldestMicros, youngestMicros, spanRecords, internalLogs, counters, timestampOffsetMicros) { |
import { crouton_thrift } from '../platform_abstraction_layer'; // eslint-disable-line camelcase | ||
import _each from '../_each'; // eslint-disable-line camelcase | ||
import * as coerce from './coerce.js'; | ||
let proto = require('./generated_proto/collector_pb.js'); | ||
import * as coerce from './coerce'; | ||
let converter = require('hex2dec'); | ||
let proto = require('./generated_proto/collector_pb'); | ||
const packageObject = require('../../package.json'); | ||
@@ -7,0 +8,0 @@ |
import _each from '../_each'; | ||
export default class SpanContextImp { | ||
// ---------------------------------------------------------------------- // | ||
@@ -6,0 +5,0 @@ // OpenTracing Implementation |
@@ -1,14 +0,14 @@ | ||
import * as coerce from './coerce.js'; | ||
import * as opentracing from 'opentracing'; | ||
import * as coerce from './coerce'; | ||
import * as constants from '../constants'; | ||
import _each from '../_each'; | ||
import * as opentracing from 'opentracing'; | ||
import { crouton_thrift } from '../platform_abstraction_layer'; // eslint-disable-line camelcase | ||
import LogRecordImp from './log_record_imp'; // eslint-disable-line camelcase | ||
import util from './util/util.js'; | ||
import util from './util/util'; | ||
let converter = require('hex2dec'); | ||
let proto = require('./generated_proto/collector_pb.js'); | ||
let googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb.js'); | ||
let googleProtobufTimestampPB = require('google-protobuf/google/protobuf/timestamp_pb'); | ||
let proto = require('./generated_proto/collector_pb'); | ||
export default class SpanImp extends opentracing.Span { | ||
// ---------------------------------------------------------------------- // | ||
@@ -45,5 +45,5 @@ // opentracing.Span SPI | ||
let tsMicros = timestamp ? | ||
(timestamp * 1000) : | ||
self._tracerImp._platform.nowMicros(); | ||
let tsMicros = timestamp | ||
? (timestamp * 1000) | ||
: self._tracerImp._platform.nowMicros(); | ||
@@ -54,3 +54,4 @@ let record = new LogRecordImp( | ||
tsMicros, | ||
keyValuePairs); | ||
keyValuePairs, | ||
); | ||
self._log_records = self._log_records || []; | ||
@@ -72,3 +73,3 @@ self._log_records.push(record); | ||
console.assert(typeof tracer === 'object', 'Invalid runtime'); // eslint-disable-line no-console | ||
console.assert(typeof tracer === 'object', 'Invalid runtime'); // eslint-disable-line no-console | ||
@@ -160,4 +161,4 @@ this._tracerImp = tracer; | ||
* @param {Number} finishTime | ||
* Optional Unix timestamp in milliseconds setting an explicit | ||
* finish time for the span. | ||
* Optional Unix timestamp in milliseconds setting an explicit | ||
* finish time for the span. | ||
*/ | ||
@@ -253,3 +254,3 @@ end(finishTime) { | ||
let parentSpanGUID = undefined; | ||
let parentSpanGUID; | ||
let tags = []; | ||
@@ -256,0 +257,0 @@ _each(this._tags, (value, key) => { |
@@ -39,3 +39,2 @@ //============================================================================// | ||
export default class Tracer extends opentracing.Tracer { | ||
constructor(opts) { | ||
@@ -55,3 +54,3 @@ super(); | ||
this._platform = new Platform(this); | ||
this._runtimeGUID = opts.guid || this.override_runtime_guid || null; // Set once the group name is set | ||
this._runtimeGUID = opts.guid || this.override_runtime_guid || null; // Set once the group name is set | ||
this._plugins = {}; | ||
@@ -91,3 +90,3 @@ this._options = {}; | ||
if (opts && opts.propagators) { | ||
this._propagators = Object.assign({}, this._propagators, opts.propagators); | ||
this._propagators = { ...this._propagators, ...opts.propagators }; | ||
} | ||
@@ -100,3 +99,3 @@ | ||
this._reportTimer = null; | ||
this._reportErrorStreak = 0; // Number of consecutive errors | ||
this._reportErrorStreak = 0; // Number of consecutive errors | ||
this._lastVisibleErrorMillis = 0; | ||
@@ -183,5 +182,6 @@ this._skippedVisibleErrors = 0; | ||
this._warn( | ||
`Access token not set - | ||
`Access token not set - | ||
this requires a satellite with access token checking disabled, | ||
such as a developer satellite.`); | ||
such as a developer satellite.`, | ||
); | ||
} | ||
@@ -217,2 +217,3 @@ | ||
if (self._ee[methodName]) { | ||
// eslint-disable-next-line prefer-spread | ||
self._ee[methodName].apply(self._ee, arguments); | ||
@@ -229,3 +230,5 @@ } | ||
// options changes and takes effect as soon as possible. | ||
this.addOption('verbosity', { type : 'int', min: 0, max: 9, defaultValue: 1 }); | ||
this.addOption('verbosity', { | ||
type : 'int', min: 0, max: 9, defaultValue: 1, | ||
}); | ||
@@ -255,2 +258,4 @@ // Core options | ||
this.addOption('logger', { type: 'function', defaultValue: this._printToConsole.bind(this) }); | ||
this.addOption('clear_span_buffer_consecutive_errors', | ||
{ type: 'int', defaultValue: null }); | ||
@@ -291,7 +296,8 @@ // Debugging options | ||
let type = ref.type(); | ||
if (type === this._opentracing.REFERENCE_CHILD_OF || | ||
type === this._opentracing.REFERENCE_FOLLOWS_FROM) { | ||
if (type === this._opentracing.REFERENCE_CHILD_OF | ||
|| type === this._opentracing.REFERENCE_FOLLOWS_FROM) { | ||
let context = ref.referencedContext(); | ||
if (!context) { | ||
this._error('Span reference has an invalid context', context); | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
@@ -403,3 +409,3 @@ } | ||
}) | ||
.finish(); | ||
.finish(); | ||
} | ||
@@ -486,5 +492,5 @@ return sc; | ||
if (opts.collector_encryption !== undefined && opts.collector_port === undefined) { | ||
opts.collector_port = opts.collector_encryption !== 'none' ? | ||
DEFAULT_COLLECTOR_PORT_TLS : | ||
DEFAULT_COLLECTOR_PORT_PLAIN; | ||
opts.collector_port = opts.collector_encryption !== 'none' | ||
? DEFAULT_COLLECTOR_PORT_TLS | ||
: DEFAULT_COLLECTOR_PORT_PLAIN; | ||
} | ||
@@ -503,7 +509,7 @@ // set meta event reporting to false by default, it will be enabled by the satellite | ||
// that didn't result either in a change or a reset to the existing value? | ||
for (let key in opts) { | ||
Object.keys(opts).forEach((key) => { | ||
if (modified[key] === undefined && unchanged[key] === undefined) { | ||
this._warn(`Invalid option ${key} with value ${opts[key]}`); | ||
} | ||
} | ||
}); | ||
@@ -534,3 +540,3 @@ // | ||
_setOptionInternal(modified, unchanged, opts, desc) { | ||
let name = desc.name; | ||
let { name } = desc; | ||
let value = opts[name]; | ||
@@ -544,3 +550,2 @@ let valueType = typeof value; | ||
switch (desc.type) { | ||
case 'any': | ||
@@ -757,4 +762,4 @@ break; | ||
_each(this._activeRootSpanSet, (span) => { | ||
if (!this._activeRootSpan || | ||
span._beginMicros > this._activeRootSpan._beginMicros) { | ||
if (!this._activeRootSpan | ||
|| span._beginMicros > this._activeRootSpan._beginMicros) { | ||
this._activeRootSpan = span; | ||
@@ -900,2 +905,29 @@ } | ||
/** | ||
* clearSpanRecordsIfMaxErrors checks to see if the tracer was configured to | ||
* empty the span buffer after a fixed amount of errors. If it is configured, | ||
* and there has been an error streak equal to the configured value, | ||
* it will empty spanRecords and record that the spans were dropped. | ||
* | ||
* @private | ||
*/ | ||
_clearSpanRecordsIfMaxErrors() { | ||
const maxErrorsToEmpty = this.options().clear_span_buffer_consecutive_errors; | ||
if (maxErrorsToEmpty === null || this._reportErrorStreak < maxErrorsToEmpty) { | ||
return; | ||
} | ||
// spanRecords is configured to be emptied | ||
// the number of dropped spans and reporting errors should still be maintained since | ||
// the loop may still in the process of a report. | ||
const numSpansToDrop = this._spanRecords.length; | ||
this._counters['spans.dropped'] += numSpansToDrop; | ||
this._spanRecords = []; | ||
this._warn('Span buffer flushed, max consecutive errors reached', { | ||
max_consecutive_errors: maxErrorsToEmpty, | ||
spans_dropped: numSpansToDrop, | ||
}); | ||
} | ||
//-----------------------------------------------------------------------// | ||
@@ -998,5 +1030,5 @@ // Reporting loop | ||
let reportInterval = this._options.max_reporting_interval_millis; | ||
if (this._reportErrorStreak === 0 && | ||
this._useClockState && | ||
!this._clockState.isReady()) { | ||
if (this._reportErrorStreak === 0 | ||
&& this._useClockState | ||
&& !this._clockState.isReady()) { | ||
reportInterval = Math.min(constants.CLOCK_STATE_REFRESH_INTERVAL_MS, reportInterval); | ||
@@ -1119,3 +1151,4 @@ } | ||
report.getInternalLogs(), | ||
report.getCounters()); | ||
report.getCounters(), | ||
); | ||
@@ -1125,2 +1158,4 @@ // Increment the counter *after* the counters are restored | ||
this._clearSpanRecordsIfMaxErrors(); | ||
this.emit('report_error', err, { | ||
@@ -1150,3 +1185,4 @@ error : err, | ||
res.timing.transmit_micros, | ||
destinationMicros); | ||
destinationMicros, | ||
); | ||
} else if (res.receiveTimestamp && res.transmitTimestamp) { | ||
@@ -1158,3 +1194,4 @@ // Handle protobuf transport timing response. | ||
res.transmitTimestamp.seconds * 1e6 + res.transmitTimestamp.nanos / 1e3, | ||
destinationMicros); | ||
destinationMicros, | ||
); | ||
} else { | ||
@@ -1161,0 +1198,0 @@ // The response does not have timing information. Disable |
@@ -11,3 +11,2 @@ import _each from '../../_each'; | ||
class ClockState { | ||
constructor(opts) { | ||
@@ -29,5 +28,5 @@ this._nowMicros = opts.nowMicros; | ||
let storedData = this._localStoreGet(); | ||
if (storedData && | ||
storedData.timestamp_micros && | ||
storedData.timestamp_micros > this._nowMicros() - kStoredSamplesTTLMicros) { | ||
if (storedData | ||
&& storedData.timestamp_micros | ||
&& storedData.timestamp_micros > this._nowMicros() - kStoredSamplesTTLMicros) { | ||
// Make sure there are no more than (kMaxOffsetAge+1) elements | ||
@@ -42,6 +41,5 @@ this._samples = storedData.samples.slice(-(kMaxOffsetAge + 1)); | ||
addSample(originMicros, | ||
receiveMicros, | ||
transmitMicros, | ||
destinationMicros | ||
) { | ||
receiveMicros, | ||
transmitMicros, | ||
destinationMicros) { | ||
let latestDelayMicros = Number.MAX_VALUE; | ||
@@ -51,8 +49,8 @@ let latestOffsetMicros = 0; | ||
// not, we'll push a {0, MAX} record into the queue. | ||
if (originMicros > 0 && receiveMicros > 0 && | ||
transmitMicros > 0 && destinationMicros > 0) { | ||
latestDelayMicros = (destinationMicros - originMicros) - | ||
(transmitMicros - receiveMicros); | ||
latestOffsetMicros = ((receiveMicros - originMicros) + | ||
(transmitMicros - destinationMicros)) / 2; | ||
if (originMicros > 0 && receiveMicros > 0 | ||
&& transmitMicros > 0 && destinationMicros > 0) { | ||
latestDelayMicros = (destinationMicros - originMicros) | ||
- (transmitMicros - receiveMicros); | ||
latestOffsetMicros = ((receiveMicros - originMicros) | ||
+ (transmitMicros - destinationMicros)) / 2; | ||
} | ||
@@ -119,2 +117,3 @@ | ||
_each(this._samples, (sample) => { | ||
// eslint-disable-next-line no-restricted-properties | ||
jitter += Math.pow(bestOffsetMicros - sample.offsetMicros, 2); | ||
@@ -129,4 +128,4 @@ }); | ||
const kSGATE = 3; // See RFC 5905 | ||
if (this._currentOffsetAge > kMaxOffsetAge || | ||
Math.abs(this._currentOffsetMicros - bestOffsetMicros) < kSGATE * jitter) { | ||
if (this._currentOffsetAge > kMaxOffsetAge | ||
|| Math.abs(this._currentOffsetMicros - bestOffsetMicros) < kSGATE * jitter) { | ||
this._currentOffsetMicros = bestOffsetMicros; | ||
@@ -133,0 +132,0 @@ this._currentOffsetAge = 0; |
@@ -51,3 +51,3 @@ import _each from '../_each'; | ||
let state = document.readyState; | ||
let payload = undefined; | ||
let payload; | ||
if (state === 'complete') { | ||
@@ -73,7 +73,6 @@ payload = {}; | ||
let dst = {}; | ||
for (let key in nav) { // eslint-disable-line guard-for-in | ||
for (let key in nav) { // eslint-disable-line guard-for-in, no-restricted-syntax | ||
try { | ||
let value = nav[key]; | ||
switch (key) { | ||
case 'plugins': { | ||
@@ -130,3 +129,3 @@ let p = []; | ||
let payload = undefined; | ||
let payload; | ||
@@ -133,0 +132,0 @@ if (key === 'navigationStart' && typeof navigator === 'object') { |
@@ -40,3 +40,4 @@ import * as opentracing from 'opentracing'; | ||
const pair = entries[i]; | ||
result[pair[0]] = pair[1]; | ||
const [key, val] = pair; | ||
result[key] = val; | ||
} | ||
@@ -57,6 +58,2 @@ return result; | ||
this._handleOptions = this._handleOptions.bind(this); | ||
if (!this._enabled) { | ||
return; | ||
} | ||
} | ||
@@ -127,3 +124,3 @@ | ||
function escapeRegExp(str) { | ||
return (`${str}`).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
return (`${str}`).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
@@ -162,8 +159,9 @@ | ||
return function (request, options = {}) { | ||
request = new Request(request, options); | ||
return function (input, init) { | ||
const request = new Request(input, init); | ||
const opts = tracer.options(); | ||
if (!self._shouldTrace(tracer, request.url)) { | ||
return proxiedFetch.apply(null, arguments); | ||
// eslint-disable-next-line prefer-spread | ||
return proxiedFetch(request); | ||
} | ||
@@ -248,3 +246,3 @@ | ||
if (this._internalExclusions.some(ex => ex.test(url))) { | ||
if (this._internalExclusions.some((ex) => ex.test(url))) { | ||
return false; | ||
@@ -254,6 +252,6 @@ } | ||
let include = false; | ||
if (opts.fetch_url_inclusion_patterns.some(inc => inc.test(url))) { | ||
if (opts.fetch_url_inclusion_patterns.some((inc) => inc.test(url))) { | ||
include = true; | ||
} | ||
if (opts.fetch_url_exclusion_patterns.some(ex => ex.test(url))) { | ||
if (opts.fetch_url_exclusion_patterns.some((ex) => ex.test(url))) { | ||
include = false; | ||
@@ -260,0 +258,0 @@ } |
@@ -58,5 +58,2 @@ import * as opentracing from 'opentracing'; | ||
this._handleOptions = this._handleOptions.bind(this); | ||
if (!this._enabled) { | ||
return; | ||
} | ||
} | ||
@@ -131,3 +128,3 @@ | ||
function escapeRegExp(str) { | ||
return (`${str}`).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
return (`${str}`).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
@@ -152,5 +149,5 @@ | ||
_isValidContext() { | ||
const isNode = (typeof process !== 'undefined') && | ||
(typeof process.release !== 'undefined') && | ||
(process.release.name === 'node'); | ||
const isNode = (typeof process !== 'undefined') | ||
&& (typeof process.release !== 'undefined') | ||
&& (process.release.name === 'node'); | ||
return isNode; | ||
@@ -170,2 +167,3 @@ } | ||
let urlObject; | ||
/* eslint-disable prefer-destructuring */ | ||
if (typeof args[0] === 'string' || args[0] instanceof URL) { | ||
@@ -175,3 +173,3 @@ urlObject = args[0] instanceof URL ? args[0] : new URL(args[0]); | ||
if (typeof args[1] === 'object') { | ||
options = Object.assign({}, options, args[1]); | ||
options = { ...options, ...args[1] }; | ||
callback = args[2]; | ||
@@ -185,2 +183,3 @@ } else if (typeof args[1] === 'function') { | ||
} | ||
/* eslint-enable prefer-destructuring */ | ||
@@ -191,3 +190,3 @@ // check if there are headers stated, and if not create them on the first arg | ||
const headers = options.headers; | ||
const { headers } = options; | ||
const method = options.method || 'GET'; | ||
@@ -211,2 +210,3 @@ const url = options.href || urlCreator.format(options); | ||
if (url) { | ||
// eslint-disable-next-line prefer-destructuring | ||
tags.url_pathname = url.split('?')[0]; | ||
@@ -225,3 +225,3 @@ } | ||
// reference https://nodejs.org/api/http.html#http_class_http_clientrequest | ||
keys.forEach(key => { | ||
keys.forEach((key) => { | ||
headers[key] = headersCarrier[key]; | ||
@@ -281,3 +281,3 @@ }); | ||
// This shouldn't be possible, but let's be paranoid | ||
if (!tracer) { | ||
if (!tracer || !url) { | ||
return false; | ||
@@ -287,44 +287,18 @@ } | ||
let opts = tracer.options(); | ||
if (opts.disabled) { | ||
if (opts.disabled || !opts.nodejs_instrumentation) { | ||
return false; | ||
} | ||
if (!opts.nodejs_instrumentation) { | ||
if (this._internalExclusions.some((ex) => ex.test(url))) { | ||
return false; | ||
} | ||
if (!url) { | ||
return false; | ||
} | ||
for (let key in this._internalExclusions) { | ||
if (!this._internalExclusions.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
const ex = this._internalExclusions[key]; | ||
if (ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
let include = false; | ||
for (let key in opts.nodejs_inclusion_patterns) { | ||
if (!opts.nodejs_inclusion_patterns.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
const inc = opts.nodejs_inclusion_patterns[key]; | ||
if (inc.test(url)) { | ||
include = true; | ||
break; | ||
} | ||
if (opts.nodejs_url_inclusion_patterns.some((inc) => inc.test(url))) { | ||
include = true; | ||
} | ||
if (!include) { | ||
return false; | ||
if (opts.nodejs_url_exclusion_patterns.some((ex) => ex.test(url))) { | ||
include = false; | ||
} | ||
for (let key in opts.nodejs_exclusion_patterns) { | ||
if (!opts.nodejs_exclusion_patterns.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
const ex = opts.nodejs_exclusion_patterns[key]; | ||
if (ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
return include; | ||
} | ||
@@ -331,0 +305,0 @@ } |
@@ -1,2 +0,1 @@ | ||
import _each from '../_each'; | ||
import * as opentracing from 'opentracing'; | ||
@@ -61,6 +60,2 @@ | ||
this._handleOptions = this._handleOptions.bind(this); | ||
if (!this._enabled) { | ||
return; | ||
} | ||
} | ||
@@ -136,3 +131,3 @@ | ||
function escapeRegExp(str) { | ||
return (`${str}`).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
return (`${str}`).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
@@ -200,9 +195,7 @@ | ||
if (url) { | ||
// eslint-disable-next-line prefer-destructuring | ||
tags.url_pathname = url.split('?')[0]; | ||
} | ||
let openPayload = {}; | ||
_each(tags, (val, key) => { | ||
openPayload[key] = val; | ||
}); | ||
let openPayload = { ...tags }; | ||
if (opts.include_cookies) { | ||
@@ -242,3 +235,3 @@ openPayload.cookies = getCookies(); | ||
} else if (this.readyState === 4) { | ||
let responseType = this.responseType; | ||
let { responseType } = this; | ||
span.log({ | ||
@@ -286,3 +279,3 @@ readyState : 4, | ||
let data = Array.prototype.slice.call(arguments); | ||
let len = undefined; | ||
let len; | ||
if (data.length === 1) { | ||
@@ -318,3 +311,3 @@ if (data[0] && data[0].length) { | ||
// This shouldn't be possible, but let's be paranoid | ||
if (!tracer) { | ||
if (!tracer || !url) { | ||
return false; | ||
@@ -327,38 +320,15 @@ } | ||
} | ||
if (!url) { | ||
if (this._internalExclusions.some((ex) => ex.test(url))) { | ||
return false; | ||
} | ||
for (let key in this._internalExclusions) { | ||
if (!this._internalExclusions.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
const ex = this._internalExclusions[key]; | ||
if (ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
let include = false; | ||
for (let key in opts.xhr_url_inclusion_patterns) { | ||
if (!opts.xhr_url_inclusion_patterns.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
const inc = opts.xhr_url_inclusion_patterns[key]; | ||
if (inc.test(url)) { | ||
include = true; | ||
break; | ||
} | ||
if (opts.xhr_url_inclusion_patterns.some((inc) => inc.test(url))) { | ||
include = true; | ||
} | ||
if (!include) { | ||
return false; | ||
if (opts.xhr_url_exclusion_patterns.some((ex) => ex.test(url))) { | ||
include = false; | ||
} | ||
for (let key in opts.xhr_url_exclusion_patterns) { | ||
if (!opts.xhr_url_exclusion_patterns.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
const ex = opts.xhr_url_exclusion_patterns[key]; | ||
if (ex.test(url)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
return include; | ||
} | ||
@@ -365,0 +335,0 @@ } |
@@ -46,3 +46,3 @@ const constants = require('../constants'); | ||
let level = constants.LOG_STRING_TO_LEVEL[record.level]; | ||
let message = record.message; | ||
let { message } = record; | ||
@@ -49,0 +49,0 @@ // Ignore records without a message (e.g. a stable_name log record) |
@@ -152,2 +152,6 @@ function makeLSTracer(extraOpts) { | ||
}); | ||
it('should default to not empty spans on errors', function() { | ||
expect(makeLSTracer().options().clear_span_buffer_consecutive_errors).to.equal(null); | ||
}); | ||
}); | ||
@@ -193,2 +197,23 @@ | ||
}); | ||
describe("TracerImp#clearSpanRecordsIfMaxErrors", function() { | ||
it('should leave spanRecords if not configured', function() { | ||
const tracer = makeLSTracer(); | ||
const s = tracer.startSpan("test"); | ||
s.finish(); | ||
tracer._clearSpanRecordsIfMaxErrors(); | ||
expect(tracer._spanRecords.length).to.equal(1); | ||
}); | ||
it('should drop spanRecords when threshold his reached', function() { | ||
const tracer = makeLSTracer({ | ||
clear_span_buffer_consecutive_errors : 0, | ||
}); | ||
const s = tracer.startSpan("test"); | ||
s.finish(); | ||
tracer._clearSpanRecordsIfMaxErrors(); | ||
expect(tracer._spanRecords.length).to.equal(0); | ||
expect(tracer._counters['spans.dropped']).to.equal(1); | ||
}); | ||
}); | ||
}); |
@@ -76,2 +76,3 @@ const path = require('path'); | ||
'babel-plugin-transform-es2015-spread', | ||
'babel-plugin-syntax-object-rest-spread', | ||
'babel-plugin-transform-es2015-parameters', | ||
@@ -81,3 +82,3 @@ 'babel-plugin-transform-es2015-destructuring', | ||
//'babel-plugin-transform-es2015-typeof-symbol', | ||
'babel-plugin-transform-es2015-modules-commonjs', | ||
'babel-plugin-transform-es2015-modules-commonjs' | ||
], | ||
@@ -84,0 +85,0 @@ }, |
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
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 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 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 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 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 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
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
5106931
158
7
40
200
67468
+ Addedopentracing@^0.14.4
+ Addedopentracing@0.14.7(transitive)