opentracing
Advanced tools
Comparing version 0.9.7 to 0.9.9
@@ -50,4 +50,12 @@ var Tracer = | ||
var _singleton = __webpack_require__(1); | ||
module.exports = __webpack_require__(1); | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var _singleton = __webpack_require__(2); | ||
var _singleton2 = _interopRequireDefault(_singleton); | ||
@@ -57,12 +65,6 @@ | ||
var singleton = new _singleton2.default(); | ||
// Add in constants to the singleton object | ||
singleton.FORMAT_SPLIT_BINARY = 'split_binary'; | ||
singleton.FORMAT_SPLIT_TEXT = 'split_text'; | ||
module.exports = singleton; | ||
module.exports = new _singleton2.default(); | ||
/***/ }, | ||
/* 1 */ | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -73,3 +75,3 @@ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -79,6 +81,20 @@ | ||
var _tracer = __webpack_require__(2); | ||
var _tracer = __webpack_require__(3); | ||
var _tracer2 = _interopRequireDefault(_tracer); | ||
var _binary_carrier = __webpack_require__(7); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_carrier); | ||
var _split_text_carrier = __webpack_require__(6); | ||
var _split_text_carrier2 = _interopRequireDefault(_split_text_carrier); | ||
var _constants = __webpack_require__(5); | ||
var Constants = _interopRequireWildcard(_constants); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -99,53 +115,69 @@ | ||
var Singleton = function (_Tracer) { | ||
_inherits(Singleton, _Tracer); | ||
_inherits(Singleton, _Tracer); | ||
_createClass(Singleton, [{ | ||
key: 'initGlobalTracer', | ||
_createClass(Singleton, [{ | ||
key: 'initGlobalTracer', | ||
// ---------------------------------------------------------------------- // | ||
// OpenTracing API methods | ||
// ---------------------------------------------------------------------- // | ||
// ---------------------------------------------------------------------- // | ||
// OpenTracing API methods | ||
// ---------------------------------------------------------------------- // | ||
/** | ||
* Set the global Tracer's underlying implementation. | ||
* | ||
* The behavior is undefined if this function is called more than once. | ||
*/ | ||
value: function initGlobalTracer(tracingImp) { | ||
this._imp = tracingImp.newTracer(); | ||
} | ||
/** | ||
* Set the global Tracer's underlying implementation. | ||
* | ||
* The behavior is undefined if this function is called more than once. | ||
*/ | ||
value: function initGlobalTracer(tracingImp) { | ||
this._imp = tracingImp.newTracer(); | ||
} | ||
/** | ||
* Create a new Tracer object with the given underlying implementation. | ||
* | ||
* @return {Tracer} a new Tracer object | ||
*/ | ||
/** | ||
* Create a new Tracer object with the given underlying implementation. | ||
* | ||
* @return {Tracer} a new Tracer object | ||
*/ | ||
}, { | ||
key: 'initNewTracer', | ||
value: function initNewTracer(tracingImp) { | ||
return new _tracer2.default(tracingImp); | ||
} | ||
}, { | ||
key: 'initNewTracer', | ||
value: function initNewTracer(tracingImp) { | ||
return new _tracer2.default(tracingImp); | ||
} | ||
// ---------------------------------------------------------------------- // | ||
// Private and non-standard methods | ||
// ---------------------------------------------------------------------- // | ||
// ---------------------------------------------------------------------- // | ||
// Private and non-standard methods | ||
// ---------------------------------------------------------------------- // | ||
/** | ||
* Creates the Singleton with no underlying implementation (i.e. defaults | ||
* to no-op behavior for all functions). | ||
* | ||
* Note: this should never be called directly by consumers of the library. | ||
*/ | ||
/** | ||
* Creates the Singleton with no underlying implementation (i.e. defaults | ||
* to no-op behavior for all functions). | ||
* | ||
* The OpenTracing package-level object acts both at the singleton and the | ||
* package interface itself, so this Singleton is both a the Tracer and | ||
* also includes all the global library symbols. | ||
* | ||
* Note: this should never be called directly by consumers of the library. | ||
*/ | ||
}]); | ||
}]); | ||
function Singleton() { | ||
_classCallCheck(this, Singleton); | ||
function Singleton() { | ||
_classCallCheck(this, Singleton); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Singleton).call(this)); | ||
} | ||
// Merge the constants into the singleton object so they are accessible at the | ||
// package level. | ||
return Singleton; | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Singleton).call(this)); | ||
for (var key in Constants) { | ||
_this[key] = Constants[key]; | ||
} | ||
// Include the carriers objects | ||
_this.SplitTextCarrier = _split_text_carrier2.default; | ||
_this.BinaryCarrier = _binary_carrier2.default; | ||
return _this; | ||
} | ||
return Singleton; | ||
}(_tracer2.default); | ||
@@ -157,3 +189,3 @@ | ||
/***/ }, | ||
/* 2 */ | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -171,6 +203,18 @@ | ||
var _span = __webpack_require__(3); | ||
var _span = __webpack_require__(4); | ||
var _span2 = _interopRequireDefault(_span); | ||
var _constants = __webpack_require__(5); | ||
var _constants2 = _interopRequireDefault(_constants); | ||
var _split_text_carrier = __webpack_require__(6); | ||
var _split_text_carrier2 = _interopRequireDefault(_split_text_carrier); | ||
var _binary_carrier = __webpack_require__(7); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_carrier); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -258,19 +302,32 @@ | ||
/** | ||
* Returns an Injector object that handles the given `format`. | ||
* Injects the information about the given span into the carrier | ||
* so that the span can propogate across inter-process barriers. | ||
* | ||
* @param {Span} span | ||
* The span whose information should be injected into the carrier. | ||
* @param {string} format | ||
* See the Injector documentation for valid formats. | ||
* @return {Injector} | ||
* The format of the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
*/ | ||
}, { | ||
key: 'injector', | ||
value: function injector(format) { | ||
key: 'inject', | ||
value: function inject(span, format, carrier) { | ||
if (true) { | ||
if (arguments.length !== 1) { | ||
if (arguments.length !== 3) { | ||
throw new Error('Invalid number of arguments.'); | ||
} | ||
if (!(span instanceof _span2.default)) { | ||
throw new Error('Expected span object as first argument'); | ||
} | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_TEXT && !(carrier instanceof _split_text_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
} | ||
if (format === _constants2.default.FORMAT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "binary" format'); | ||
} | ||
} | ||
@@ -280,31 +337,44 @@ | ||
if (this._imp) { | ||
imp = this._imp.injector(format); | ||
imp = this._imp.inject(span, format, carrier); | ||
} | ||
return new Injector(imp); | ||
} | ||
/** | ||
* Returns an Extractor object that handles the given `format`. | ||
* Returns a new Span object with the given operation name using the trace | ||
* information from the carrier. | ||
* | ||
* @param {string} operationName | ||
* Operation name to use on the newly created span. | ||
* @param {string} format | ||
* See the Extractor documentation for valid formats. | ||
* @return {Injector} | ||
* The format of the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
* @return {Span} | ||
*/ | ||
}, { | ||
key: 'extractor', | ||
value: function extractor(format) { | ||
key: 'join', | ||
value: function join(operationName, format, carrier) { | ||
if (true) { | ||
if (arguments.length !== 1) { | ||
if (arguments.length !== 3) { | ||
throw new Error('Invalid number of arguments.'); | ||
} | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string'); | ||
if (typeof operationName !== 'string' || !operationName.length) { | ||
throw new Error('operationName is expected to be a string of non-zero length'); | ||
} | ||
if (typeof format !== 'string' || !format.length) { | ||
throw new Error('format is expected to be a string of non-zero length'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_TEXT && !(carrier instanceof _split_text_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
} | ||
if (format === _constants2.default.FORMAT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "binary" format'); | ||
} | ||
} | ||
var imp = null; | ||
var spanImp = null; | ||
if (this._imp) { | ||
imp = this._imp.extractor(format); | ||
spanImp = this._imp.join(operationName, format, carrier); | ||
} | ||
return new Extractor(imp); | ||
return new _span2.default(spanImp); | ||
} | ||
@@ -332,3 +402,2 @@ | ||
} | ||
if (!this._imp) { | ||
@@ -384,3 +453,3 @@ done(null); | ||
/***/ }, | ||
/* 3 */ | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -402,2 +471,4 @@ | ||
var defaultTracer = __webpack_require__(1); | ||
var kKeyRegExp = new RegExp(/^[a-z0-9][-a-z0-9]*/); | ||
@@ -414,3 +485,3 @@ | ||
_createClass(Span, [{ | ||
key: 'setTag', | ||
key: 'tracer', | ||
@@ -422,2 +493,30 @@ | ||
value: function tracer() { | ||
if (true) { | ||
if (arguments.length !== 0) { | ||
throw new Error('Invalid number of arguments'); | ||
} | ||
} | ||
if (this._imp) { | ||
return this._imp.tracer(); | ||
} | ||
return defaultTracer; | ||
} | ||
}, { | ||
key: 'setOperationName', | ||
value: function setOperationName(name) { | ||
if (true) { | ||
if (arguments.length !== 1) { | ||
throw new Error('Invalid number of arguments'); | ||
} | ||
if (typeof name !== 'string' || name.length > 0) { | ||
throw new Error('Name must be a string of length > 0'); | ||
} | ||
} | ||
if (this._imp) { | ||
this._imp.setOperationName(name); | ||
} | ||
return this; | ||
} | ||
/** | ||
@@ -429,2 +528,5 @@ * Adds a single tag to the span. See `AddTags()` for details. | ||
*/ | ||
}, { | ||
key: 'setTag', | ||
value: function setTag(key, value) { | ||
@@ -440,2 +542,3 @@ if (true) { | ||
this.addTags(_defineProperty({}, key, value)); | ||
return this; | ||
} | ||
@@ -476,2 +579,3 @@ | ||
this._imp.addTags(keyValuePairs); | ||
return this; | ||
} | ||
@@ -483,10 +587,10 @@ | ||
* | ||
* All spans created as children of this span will inherit the set of trace | ||
* attributes of this span. | ||
* All spans created as children of this span will inherit the baggage items | ||
* of this span. | ||
* | ||
* Trace attributes are copied between all spans, both in-process and across | ||
* distributed requets, therefore this feature should be used with care to | ||
* Baggage items are copied between all spans, both in-process and across | ||
* distributed requests, therefore this feature should be used with care to | ||
* ensure undue overhead is not incurred. | ||
* | ||
* Trace keys are case insensitive, must match the regular expresssion | ||
* Keys are case insensitive and must match the regular expresssion | ||
* `[a-z0-9][-a-z0-9]*`. | ||
@@ -499,5 +603,4 @@ * | ||
}, { | ||
key: 'setTraceAttribute', | ||
value: function setTraceAttribute(key, value) { | ||
key: 'setBaggageItem', | ||
value: function setBaggageItem(key, value) { | ||
if (true) { | ||
@@ -523,7 +626,7 @@ if (arguments.length !== 2) { | ||
} | ||
return; | ||
return this; | ||
} | ||
/** | ||
* Returns the value for the given trace attribute key. | ||
* Returns the value for the given baggage item key. | ||
* | ||
@@ -538,4 +641,4 @@ * @param {string} key | ||
}, { | ||
key: 'getTraceAttribute', | ||
value: function getTraceAttribute(key) { | ||
key: 'getBaggageItem', | ||
value: function getBaggageItem(key) { | ||
if (true) { | ||
@@ -633,2 +736,3 @@ if (arguments.length !== 1) { | ||
this._imp.log(fields); | ||
return this; | ||
} | ||
@@ -723,4 +827,71 @@ | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
module.exports = { | ||
/** | ||
* Used to inject/join a span with using a BinaryCarrier. | ||
*/ | ||
FORMAT_SPLIT_BINARY: 'split_binary', | ||
/** | ||
* Used to inject/join a span with using a SplitTextCarrier. | ||
*/ | ||
FORMAT_SPLIT_TEXT: 'split_text' | ||
}; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
/** | ||
* A SplitTextCarrier is intended to hold string-string pairs in its two | ||
* associative arrays. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var SplitTextCarrier = function SplitTextCarrier() { | ||
_classCallCheck(this, SplitTextCarrier); | ||
this.tracerState = {}; | ||
this.baggage = {}; | ||
}; | ||
exports.default = SplitTextCarrier; | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var BinaryCarrier = function BinaryCarrier() { | ||
_classCallCheck(this, BinaryCarrier); | ||
this.tracerState = new Uint8Array(); | ||
this.baggage = new Uint8Array(); | ||
}; | ||
exports.default = BinaryCarrier; | ||
module.exports = exports['default']; | ||
/***/ } | ||
/******/ ]); | ||
//# sourceMappingURL=opentracing-browser.js.map |
@@ -1,1 +0,1 @@ | ||
var Tracer=function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(1),o=r(i),u=new o["default"];u.FORMAT_SPLIT_BINARY="split_binary",u.FORMAT_SPLIT_TEXT="split_text",t.exports=u},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),l=n(2),f=r(l),c=function(t){function e(){return i(this,e),o(this,Object.getPrototypeOf(e).call(this))}return u(e,t),a(e,[{key:"initGlobalTracer",value:function(t){this._imp=t.newTracer()}},{key:"initNewTracer",value:function(t){return new f["default"](t)}}]),e}(f["default"]);e["default"]=c,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=n(3),a=r(u),l=function(){function t(e){i(this,t),this._imp=e||null}return o(t,[{key:"startSpan",value:function(t){var e=null;return this._imp&&("string"==typeof t&&(t={operationName:t}),e=this._imp.startSpan(t)),new a["default"](e)}},{key:"injector",value:function(t){var e=null;return this._imp&&(e=this._imp.injector(t)),new Injector(e)}},{key:"extractor",value:function(t){var e=null;return this._imp&&(e=this._imp.extractor(t)),new Extractor(e)}},{key:"flush",value:function(t){return this._imp?void this._imp.flush(t):void t(null)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}();e["default"]=l,t.exports=e["default"]},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function t(e){i(this,t),this._imp=e}return o(t,[{key:"setTag",value:function(t,e){this.addTags(r({},t,e))}},{key:"addTags",value:function(t){this._imp&&this._imp.addTags(t)}},{key:"setTraceAttribute",value:function(t,e){this._imp&&this._imp.setTraceAttribute(t,e)}},{key:"getTraceAttribute",value:function(t){return this._imp?this._imp.getTraceAttribute(t):void 0}},{key:"startChildSpan",value:function(e){var n=null;return this._imp&&("string"==typeof e&&(e={operationName:e}),n=this._imp.startChildSpan(e)),new t(n)}},{key:"log",value:function(t){this._imp&&this._imp.log(t)}},{key:"logEvent",value:function(t,e){return this.log({event:t,payload:e})}},{key:"finish",value:function(t){this._imp&&this._imp.finish(t)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}());e["default"]=u,t.exports=e["default"]}]); | ||
var Tracer=function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";t.exports=n(1)},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(2),o=r(i);t.exports=new o["default"]},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}function i(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var f=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),l=n(3),s=i(l),c=n(7),p=i(c),y=n(6),h=i(y),d=n(5),m=r(d),v=function(t){function e(){o(this,e);var t=u(this,Object.getPrototypeOf(e).call(this));for(var n in m)t[n]=m[n];return t.SplitTextCarrier=h["default"],t.BinaryCarrier=p["default"],t}return a(e,t),f(e,[{key:"initGlobalTracer",value:function(t){this._imp=t.newTracer()}},{key:"initNewTracer",value:function(t){return new s["default"](t)}}]),e}(s["default"]);e["default"]=v,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=n(4),a=r(u),f=n(5),l=(r(f),n(6)),s=(r(l),n(7)),c=(r(s),function(){function t(e){i(this,t),this._imp=e||null}return o(t,[{key:"startSpan",value:function(t){var e=null;return this._imp&&("string"==typeof t&&(t={operationName:t}),e=this._imp.startSpan(t)),new a["default"](e)}},{key:"inject",value:function(t,e,n){var r=null;this._imp&&(r=this._imp.inject(t,e,n))}},{key:"join",value:function(t,e,n){var r=null;return this._imp&&(r=this._imp.join(t,e,n)),new a["default"](r)}},{key:"flush",value:function(t){return this._imp?void this._imp.flush(t):void t(null)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}());e["default"]=c,t.exports=e["default"]},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=n(1),a=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function t(e){i(this,t),this._imp=e}return o(t,[{key:"tracer",value:function(){return this._imp?this._imp.tracer():u}},{key:"setOperationName",value:function(t){return this._imp&&this._imp.setOperationName(t),this}},{key:"setTag",value:function(t,e){return this.addTags(r({},t,e)),this}},{key:"addTags",value:function(t){return this._imp?(this._imp.addTags(t),this):void 0}},{key:"setBaggageItem",value:function(t,e){return this._imp&&this._imp.setTraceAttribute(t,e),this}},{key:"getBaggageItem",value:function(t){return this._imp?this._imp.getTraceAttribute(t):void 0}},{key:"startChildSpan",value:function(e){var n=null;return this._imp&&("string"==typeof e&&(e={operationName:e}),n=this._imp.startChildSpan(e)),new t(n)}},{key:"log",value:function(t){return this._imp?(this._imp.log(t),this):void 0}},{key:"logEvent",value:function(t,e){return this.log({event:t,payload:e})}},{key:"finish",value:function(t){this._imp&&this._imp.finish(t)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}());e["default"]=a,t.exports=e["default"]},function(t,e){"use strict";t.exports={FORMAT_SPLIT_BINARY:"split_binary",FORMAT_SPLIT_TEXT:"split_text"}},function(t,e){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function i(){n(this,i),this.tracerState={},this.baggage={}};e["default"]=r,t.exports=e["default"]},function(t,e){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function i(){n(this,i),this.tracerState=new Uint8Array,this.baggage=new Uint8Array};e["default"]=r,t.exports=e["default"]}]); |
@@ -51,4 +51,12 @@ require("source-map-support").install(); | ||
var _singleton = __webpack_require__(1); | ||
module.exports = __webpack_require__(1); | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var _singleton = __webpack_require__(2); | ||
var _singleton2 = _interopRequireDefault(_singleton); | ||
@@ -58,12 +66,6 @@ | ||
var singleton = new _singleton2.default(); | ||
// Add in constants to the singleton object | ||
singleton.FORMAT_SPLIT_BINARY = 'split_binary'; | ||
singleton.FORMAT_SPLIT_TEXT = 'split_text'; | ||
module.exports = singleton; | ||
module.exports = new _singleton2.default(); | ||
/***/ }, | ||
/* 1 */ | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -74,3 +76,3 @@ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -80,6 +82,20 @@ | ||
var _tracer = __webpack_require__(2); | ||
var _tracer = __webpack_require__(3); | ||
var _tracer2 = _interopRequireDefault(_tracer); | ||
var _binary_carrier = __webpack_require__(7); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_carrier); | ||
var _split_text_carrier = __webpack_require__(6); | ||
var _split_text_carrier2 = _interopRequireDefault(_split_text_carrier); | ||
var _constants = __webpack_require__(5); | ||
var Constants = _interopRequireWildcard(_constants); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -100,53 +116,69 @@ | ||
var Singleton = function (_Tracer) { | ||
_inherits(Singleton, _Tracer); | ||
_inherits(Singleton, _Tracer); | ||
_createClass(Singleton, [{ | ||
key: 'initGlobalTracer', | ||
_createClass(Singleton, [{ | ||
key: 'initGlobalTracer', | ||
// ---------------------------------------------------------------------- // | ||
// OpenTracing API methods | ||
// ---------------------------------------------------------------------- // | ||
// ---------------------------------------------------------------------- // | ||
// OpenTracing API methods | ||
// ---------------------------------------------------------------------- // | ||
/** | ||
* Set the global Tracer's underlying implementation. | ||
* | ||
* The behavior is undefined if this function is called more than once. | ||
*/ | ||
value: function initGlobalTracer(tracingImp) { | ||
this._imp = tracingImp.newTracer(); | ||
} | ||
/** | ||
* Set the global Tracer's underlying implementation. | ||
* | ||
* The behavior is undefined if this function is called more than once. | ||
*/ | ||
value: function initGlobalTracer(tracingImp) { | ||
this._imp = tracingImp.newTracer(); | ||
} | ||
/** | ||
* Create a new Tracer object with the given underlying implementation. | ||
* | ||
* @return {Tracer} a new Tracer object | ||
*/ | ||
/** | ||
* Create a new Tracer object with the given underlying implementation. | ||
* | ||
* @return {Tracer} a new Tracer object | ||
*/ | ||
}, { | ||
key: 'initNewTracer', | ||
value: function initNewTracer(tracingImp) { | ||
return new _tracer2.default(tracingImp); | ||
} | ||
}, { | ||
key: 'initNewTracer', | ||
value: function initNewTracer(tracingImp) { | ||
return new _tracer2.default(tracingImp); | ||
} | ||
// ---------------------------------------------------------------------- // | ||
// Private and non-standard methods | ||
// ---------------------------------------------------------------------- // | ||
// ---------------------------------------------------------------------- // | ||
// Private and non-standard methods | ||
// ---------------------------------------------------------------------- // | ||
/** | ||
* Creates the Singleton with no underlying implementation (i.e. defaults | ||
* to no-op behavior for all functions). | ||
* | ||
* Note: this should never be called directly by consumers of the library. | ||
*/ | ||
/** | ||
* Creates the Singleton with no underlying implementation (i.e. defaults | ||
* to no-op behavior for all functions). | ||
* | ||
* The OpenTracing package-level object acts both at the singleton and the | ||
* package interface itself, so this Singleton is both a the Tracer and | ||
* also includes all the global library symbols. | ||
* | ||
* Note: this should never be called directly by consumers of the library. | ||
*/ | ||
}]); | ||
}]); | ||
function Singleton() { | ||
_classCallCheck(this, Singleton); | ||
function Singleton() { | ||
_classCallCheck(this, Singleton); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Singleton).call(this)); | ||
} | ||
// Merge the constants into the singleton object so they are accessible at the | ||
// package level. | ||
return Singleton; | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Singleton).call(this)); | ||
for (var key in Constants) { | ||
_this[key] = Constants[key]; | ||
} | ||
// Include the carriers objects | ||
_this.SplitTextCarrier = _split_text_carrier2.default; | ||
_this.BinaryCarrier = _binary_carrier2.default; | ||
return _this; | ||
} | ||
return Singleton; | ||
}(_tracer2.default); | ||
@@ -158,3 +190,3 @@ | ||
/***/ }, | ||
/* 2 */ | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -172,6 +204,18 @@ | ||
var _span = __webpack_require__(3); | ||
var _span = __webpack_require__(4); | ||
var _span2 = _interopRequireDefault(_span); | ||
var _constants = __webpack_require__(5); | ||
var _constants2 = _interopRequireDefault(_constants); | ||
var _split_text_carrier = __webpack_require__(6); | ||
var _split_text_carrier2 = _interopRequireDefault(_split_text_carrier); | ||
var _binary_carrier = __webpack_require__(7); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_carrier); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -259,19 +303,32 @@ | ||
/** | ||
* Returns an Injector object that handles the given `format`. | ||
* Injects the information about the given span into the carrier | ||
* so that the span can propogate across inter-process barriers. | ||
* | ||
* @param {Span} span | ||
* The span whose information should be injected into the carrier. | ||
* @param {string} format | ||
* See the Injector documentation for valid formats. | ||
* @return {Injector} | ||
* The format of the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
*/ | ||
}, { | ||
key: 'injector', | ||
value: function injector(format) { | ||
key: 'inject', | ||
value: function inject(span, format, carrier) { | ||
if (true) { | ||
if (arguments.length !== 1) { | ||
if (arguments.length !== 3) { | ||
throw new Error('Invalid number of arguments.'); | ||
} | ||
if (!(span instanceof _span2.default)) { | ||
throw new Error('Expected span object as first argument'); | ||
} | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_TEXT && !(carrier instanceof _split_text_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
} | ||
if (format === _constants2.default.FORMAT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "binary" format'); | ||
} | ||
} | ||
@@ -281,31 +338,44 @@ | ||
if (this._imp) { | ||
imp = this._imp.injector(format); | ||
imp = this._imp.inject(span, format, carrier); | ||
} | ||
return new Injector(imp); | ||
} | ||
/** | ||
* Returns an Extractor object that handles the given `format`. | ||
* Returns a new Span object with the given operation name using the trace | ||
* information from the carrier. | ||
* | ||
* @param {string} operationName | ||
* Operation name to use on the newly created span. | ||
* @param {string} format | ||
* See the Extractor documentation for valid formats. | ||
* @return {Injector} | ||
* The format of the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
* @return {Span} | ||
*/ | ||
}, { | ||
key: 'extractor', | ||
value: function extractor(format) { | ||
key: 'join', | ||
value: function join(operationName, format, carrier) { | ||
if (true) { | ||
if (arguments.length !== 1) { | ||
if (arguments.length !== 3) { | ||
throw new Error('Invalid number of arguments.'); | ||
} | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string'); | ||
if (typeof operationName !== 'string' || !operationName.length) { | ||
throw new Error('operationName is expected to be a string of non-zero length'); | ||
} | ||
if (typeof format !== 'string' || !format.length) { | ||
throw new Error('format is expected to be a string of non-zero length'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_TEXT && !(carrier instanceof _split_text_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
} | ||
if (format === _constants2.default.FORMAT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "binary" format'); | ||
} | ||
} | ||
var imp = null; | ||
var spanImp = null; | ||
if (this._imp) { | ||
imp = this._imp.extractor(format); | ||
spanImp = this._imp.join(operationName, format, carrier); | ||
} | ||
return new Extractor(imp); | ||
return new _span2.default(spanImp); | ||
} | ||
@@ -333,3 +403,2 @@ | ||
} | ||
if (!this._imp) { | ||
@@ -385,3 +454,3 @@ done(null); | ||
/***/ }, | ||
/* 3 */ | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -403,2 +472,4 @@ | ||
var defaultTracer = __webpack_require__(1); | ||
var kKeyRegExp = new RegExp(/^[a-z0-9][-a-z0-9]*/); | ||
@@ -415,3 +486,3 @@ | ||
_createClass(Span, [{ | ||
key: 'setTag', | ||
key: 'tracer', | ||
@@ -423,2 +494,30 @@ | ||
value: function tracer() { | ||
if (true) { | ||
if (arguments.length !== 0) { | ||
throw new Error('Invalid number of arguments'); | ||
} | ||
} | ||
if (this._imp) { | ||
return this._imp.tracer(); | ||
} | ||
return defaultTracer; | ||
} | ||
}, { | ||
key: 'setOperationName', | ||
value: function setOperationName(name) { | ||
if (true) { | ||
if (arguments.length !== 1) { | ||
throw new Error('Invalid number of arguments'); | ||
} | ||
if (typeof name !== 'string' || name.length > 0) { | ||
throw new Error('Name must be a string of length > 0'); | ||
} | ||
} | ||
if (this._imp) { | ||
this._imp.setOperationName(name); | ||
} | ||
return this; | ||
} | ||
/** | ||
@@ -430,2 +529,5 @@ * Adds a single tag to the span. See `AddTags()` for details. | ||
*/ | ||
}, { | ||
key: 'setTag', | ||
value: function setTag(key, value) { | ||
@@ -441,2 +543,3 @@ if (true) { | ||
this.addTags(_defineProperty({}, key, value)); | ||
return this; | ||
} | ||
@@ -477,2 +580,3 @@ | ||
this._imp.addTags(keyValuePairs); | ||
return this; | ||
} | ||
@@ -484,10 +588,10 @@ | ||
* | ||
* All spans created as children of this span will inherit the set of trace | ||
* attributes of this span. | ||
* All spans created as children of this span will inherit the baggage items | ||
* of this span. | ||
* | ||
* Trace attributes are copied between all spans, both in-process and across | ||
* distributed requets, therefore this feature should be used with care to | ||
* Baggage items are copied between all spans, both in-process and across | ||
* distributed requests, therefore this feature should be used with care to | ||
* ensure undue overhead is not incurred. | ||
* | ||
* Trace keys are case insensitive, must match the regular expresssion | ||
* Keys are case insensitive and must match the regular expresssion | ||
* `[a-z0-9][-a-z0-9]*`. | ||
@@ -500,5 +604,4 @@ * | ||
}, { | ||
key: 'setTraceAttribute', | ||
value: function setTraceAttribute(key, value) { | ||
key: 'setBaggageItem', | ||
value: function setBaggageItem(key, value) { | ||
if (true) { | ||
@@ -524,7 +627,7 @@ if (arguments.length !== 2) { | ||
} | ||
return; | ||
return this; | ||
} | ||
/** | ||
* Returns the value for the given trace attribute key. | ||
* Returns the value for the given baggage item key. | ||
* | ||
@@ -539,4 +642,4 @@ * @param {string} key | ||
}, { | ||
key: 'getTraceAttribute', | ||
value: function getTraceAttribute(key) { | ||
key: 'getBaggageItem', | ||
value: function getBaggageItem(key) { | ||
if (true) { | ||
@@ -634,2 +737,3 @@ if (arguments.length !== 1) { | ||
this._imp.log(fields); | ||
return this; | ||
} | ||
@@ -724,4 +828,71 @@ | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
module.exports = { | ||
/** | ||
* Used to inject/join a span with using a BinaryCarrier. | ||
*/ | ||
FORMAT_SPLIT_BINARY: 'split_binary', | ||
/** | ||
* Used to inject/join a span with using a SplitTextCarrier. | ||
*/ | ||
FORMAT_SPLIT_TEXT: 'split_text' | ||
}; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
/** | ||
* A SplitTextCarrier is intended to hold string-string pairs in its two | ||
* associative arrays. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var SplitTextCarrier = function SplitTextCarrier() { | ||
_classCallCheck(this, SplitTextCarrier); | ||
this.tracerState = {}; | ||
this.baggage = {}; | ||
}; | ||
exports.default = SplitTextCarrier; | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var BinaryCarrier = function BinaryCarrier() { | ||
_classCallCheck(this, BinaryCarrier); | ||
this.tracerState = new Uint8Array(); | ||
this.baggage = new Uint8Array(); | ||
}; | ||
exports.default = BinaryCarrier; | ||
module.exports = exports['default']; | ||
/***/ } | ||
/******/ ]); | ||
//# sourceMappingURL=opentracing-node-debug.js.map |
@@ -1,1 +0,1 @@ | ||
module.exports=function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(1),o=r(i),u=new o["default"];u.FORMAT_SPLIT_BINARY="split_binary",u.FORMAT_SPLIT_TEXT="split_text",t.exports=u},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),l=n(2),f=r(l),c=function(t){function e(){return i(this,e),o(this,Object.getPrototypeOf(e).call(this))}return u(e,t),a(e,[{key:"initGlobalTracer",value:function(t){this._imp=t.newTracer()}},{key:"initNewTracer",value:function(t){return new f["default"](t)}}]),e}(f["default"]);e["default"]=c,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=n(3),a=r(u),l=function(){function t(e){i(this,t),this._imp=e||null}return o(t,[{key:"startSpan",value:function(t){var e=null;return this._imp&&("string"==typeof t&&(t={operationName:t}),e=this._imp.startSpan(t)),new a["default"](e)}},{key:"injector",value:function(t){var e=null;return this._imp&&(e=this._imp.injector(t)),new Injector(e)}},{key:"extractor",value:function(t){var e=null;return this._imp&&(e=this._imp.extractor(t)),new Extractor(e)}},{key:"flush",value:function(t){return this._imp?void this._imp.flush(t):void t(null)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}();e["default"]=l,t.exports=e["default"]},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function t(e){i(this,t),this._imp=e}return o(t,[{key:"setTag",value:function(t,e){this.addTags(r({},t,e))}},{key:"addTags",value:function(t){this._imp&&this._imp.addTags(t)}},{key:"setTraceAttribute",value:function(t,e){this._imp&&this._imp.setTraceAttribute(t,e)}},{key:"getTraceAttribute",value:function(t){return this._imp?this._imp.getTraceAttribute(t):void 0}},{key:"startChildSpan",value:function(e){var n=null;return this._imp&&("string"==typeof e&&(e={operationName:e}),n=this._imp.startChildSpan(e)),new t(n)}},{key:"log",value:function(t){this._imp&&this._imp.log(t)}},{key:"logEvent",value:function(t,e){return this.log({event:t,payload:e})}},{key:"finish",value:function(t){this._imp&&this._imp.finish(t)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}());e["default"]=u,t.exports=e["default"]}]); | ||
module.exports=function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";t.exports=n(1)},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(2),o=r(i);t.exports=new o["default"]},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}function i(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var f=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),l=n(3),s=i(l),c=n(7),p=i(c),y=n(6),h=i(y),d=n(5),m=r(d),v=function(t){function e(){o(this,e);var t=u(this,Object.getPrototypeOf(e).call(this));for(var n in m)t[n]=m[n];return t.SplitTextCarrier=h["default"],t.BinaryCarrier=p["default"],t}return a(e,t),f(e,[{key:"initGlobalTracer",value:function(t){this._imp=t.newTracer()}},{key:"initNewTracer",value:function(t){return new s["default"](t)}}]),e}(s["default"]);e["default"]=v,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=n(4),a=r(u),f=n(5),l=(r(f),n(6)),s=(r(l),n(7)),c=(r(s),function(){function t(e){i(this,t),this._imp=e||null}return o(t,[{key:"startSpan",value:function(t){var e=null;return this._imp&&("string"==typeof t&&(t={operationName:t}),e=this._imp.startSpan(t)),new a["default"](e)}},{key:"inject",value:function(t,e,n){var r=null;this._imp&&(r=this._imp.inject(t,e,n))}},{key:"join",value:function(t,e,n){var r=null;return this._imp&&(r=this._imp.join(t,e,n)),new a["default"](r)}},{key:"flush",value:function(t){return this._imp?void this._imp.flush(t):void t(null)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}());e["default"]=c,t.exports=e["default"]},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()),u=n(1),a=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function t(e){i(this,t),this._imp=e}return o(t,[{key:"tracer",value:function(){return this._imp?this._imp.tracer():u}},{key:"setOperationName",value:function(t){return this._imp&&this._imp.setOperationName(t),this}},{key:"setTag",value:function(t,e){return this.addTags(r({},t,e)),this}},{key:"addTags",value:function(t){return this._imp?(this._imp.addTags(t),this):void 0}},{key:"setBaggageItem",value:function(t,e){return this._imp&&this._imp.setTraceAttribute(t,e),this}},{key:"getBaggageItem",value:function(t){return this._imp?this._imp.getTraceAttribute(t):void 0}},{key:"startChildSpan",value:function(e){var n=null;return this._imp&&("string"==typeof e&&(e={operationName:e}),n=this._imp.startChildSpan(e)),new t(n)}},{key:"log",value:function(t){return this._imp?(this._imp.log(t),this):void 0}},{key:"logEvent",value:function(t,e){return this.log({event:t,payload:e})}},{key:"finish",value:function(t){this._imp&&this._imp.finish(t)}}]),o(t,[{key:"imp",value:function(){return this._imp}}]),t}());e["default"]=a,t.exports=e["default"]},function(t,e){"use strict";t.exports={FORMAT_SPLIT_BINARY:"split_binary",FORMAT_SPLIT_TEXT:"split_text"}},function(t,e){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function i(){n(this,i),this.tracerState={},this.baggage={}};e["default"]=r,t.exports=e["default"]},function(t,e){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function i(){n(this,i),this.tracerState=new Uint8Array,this.baggage=new Uint8Array};e["default"]=r,t.exports=e["default"]}]); |
{ | ||
"name": "opentracing", | ||
"version": "0.9.7", | ||
"version": "0.9.9", | ||
"main": "dist/opentracing-node-debug.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -7,3 +7,3 @@ # OpenTracing API for JavaScript | ||
In order to fully understand this platform API, one must must first be familiar with the [OpenTracing project](http://opentracing.io) and | ||
To fully understand this platform API, it's helpful to be familiar with the [OpenTracing project](http://opentracing.io) and | ||
[terminology](http://opentracing.io/spec/) more generally. | ||
@@ -19,3 +19,3 @@ | ||
In the JS code, add instrumentation to the operations to be tracked. This is composed primarily of using "spans" around operations of interest and adding log statements to capture useful data relevant to those operations. | ||
In your JavaScript code, add instrumentation to the operations to be tracked. This is composed primarily of using "spans" around operations of interest and adding log statements to capture useful data relevant to those operations. | ||
@@ -22,0 +22,0 @@ ```js |
@@ -1,11 +0,1 @@ | ||
'use strict'; | ||
import Singleton from './singleton'; | ||
let singleton = new Singleton(); | ||
// Add in constants to the singleton object | ||
singleton.FORMAT_SPLIT_BINARY = 'split_binary'; | ||
singleton.FORMAT_SPLIT_TEXT = 'split_text'; | ||
module.exports = singleton; | ||
module.exports = require('./default_tracer'); |
'use strict'; | ||
import Tracer from './tracer'; | ||
import BinaryCarrier from './carriers/binary_carrier'; | ||
import SplitTextCarrier from './carriers/split_text_carrier'; | ||
import * as Constants from './constants'; | ||
@@ -42,2 +45,6 @@ /** | ||
* | ||
* The OpenTracing package-level object acts both at the singleton and the | ||
* package interface itself, so this Singleton is both a the Tracer and | ||
* also includes all the global library symbols. | ||
* | ||
* Note: this should never be called directly by consumers of the library. | ||
@@ -47,3 +54,13 @@ */ | ||
super(); | ||
// Merge the constants into the singleton object so they are accessible at the | ||
// package level. | ||
for (let key in Constants) { | ||
this[key] = Constants[key]; | ||
} | ||
// Include the carriers objects | ||
this.SplitTextCarrier = SplitTextCarrier; | ||
this.BinaryCarrier = BinaryCarrier; | ||
} | ||
} |
'use strict'; | ||
let defaultTracer = require('./default_tracer'); | ||
const kKeyRegExp = new RegExp(/^[a-z0-9][-a-z0-9]*/); | ||
@@ -17,3 +19,29 @@ | ||
tracer() { | ||
if (API_CONFORMANCE_CHECKS) { | ||
if (arguments.length !== 0) { | ||
throw new Error('Invalid number of arguments'); | ||
} | ||
} | ||
if (this._imp) { | ||
return this._imp.tracer(); | ||
} | ||
return defaultTracer; | ||
} | ||
setOperationName(name) { | ||
if (API_CONFORMANCE_CHECKS) { | ||
if (arguments.length !== 1) { | ||
throw new Error('Invalid number of arguments'); | ||
} | ||
if (typeof name !== 'string' || name.length > 0) { | ||
throw new Error('Name must be a string of length > 0'); | ||
} | ||
} | ||
if (this._imp) { | ||
this._imp.setOperationName(name); | ||
} | ||
return this; | ||
} | ||
/** | ||
@@ -35,2 +63,3 @@ * Adds a single tag to the span. See `AddTags()` for details. | ||
this.addTags({ [key] : value }); | ||
return this; | ||
} | ||
@@ -68,2 +97,3 @@ | ||
this._imp.addTags(keyValuePairs); | ||
return this; | ||
} | ||
@@ -75,10 +105,10 @@ | ||
* | ||
* All spans created as children of this span will inherit the set of trace | ||
* attributes of this span. | ||
* All spans created as children of this span will inherit the baggage items | ||
* of this span. | ||
* | ||
* Trace attributes are copied between all spans, both in-process and across | ||
* distributed requets, therefore this feature should be used with care to | ||
* Baggage items are copied between all spans, both in-process and across | ||
* distributed requests, therefore this feature should be used with care to | ||
* ensure undue overhead is not incurred. | ||
* | ||
* Trace keys are case insensitive, must match the regular expresssion | ||
* Keys are case insensitive and must match the regular expresssion | ||
* `[a-z0-9][-a-z0-9]*`. | ||
@@ -89,4 +119,3 @@ * | ||
*/ | ||
setTraceAttribute(key, value) { | ||
setBaggageItem(key, value) { | ||
if (API_CONFORMANCE_CHECKS) { | ||
@@ -115,7 +144,7 @@ if (arguments.length !== 2) { | ||
} | ||
return; | ||
return this; | ||
} | ||
/** | ||
* Returns the value for the given trace attribute key. | ||
* Returns the value for the given baggage item key. | ||
* | ||
@@ -128,3 +157,3 @@ * @param {string} key | ||
*/ | ||
getTraceAttribute(key) { | ||
getBaggageItem(key) { | ||
if (API_CONFORMANCE_CHECKS) { | ||
@@ -216,2 +245,3 @@ if (arguments.length !== 1) { | ||
this._imp.log(fields); | ||
return this; | ||
} | ||
@@ -218,0 +248,0 @@ |
'use strict'; | ||
import Span from './span'; | ||
import Constants from './constants'; | ||
import SplitTextCarrier from './carriers/split_text_carrier'; | ||
import BinaryCarrier from './carriers/binary_carrier'; | ||
@@ -79,16 +82,29 @@ /** | ||
/** | ||
* Returns an Injector object that handles the given `format`. | ||
* Injects the information about the given span into the carrier | ||
* so that the span can propogate across inter-process barriers. | ||
* | ||
* @param {Span} span | ||
* The span whose information should be injected into the carrier. | ||
* @param {string} format | ||
* See the Injector documentation for valid formats. | ||
* @return {Injector} | ||
* The format of the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
*/ | ||
injector(format) { | ||
inject(span, format, carrier) { | ||
if (API_CONFORMANCE_CHECKS) { | ||
if (arguments.length !== 1) { | ||
if (arguments.length !== 3) { | ||
throw new Error('Invalid number of arguments.'); | ||
} | ||
if (!(span instanceof Span)) { | ||
throw new Error('Expected span object as first argument'); | ||
} | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string'); | ||
} | ||
if (format === Constants.FORMAT_SPLIT_TEXT && !(carrier instanceof SplitTextCarrier)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
} | ||
if (format === Constants.FORMAT_BINARY && !(carrier instanceof BinaryCarrier)) { | ||
throw new Error('Unexpected carrier object for "binary" format'); | ||
} | ||
} | ||
@@ -98,28 +114,41 @@ | ||
if (this._imp) { | ||
imp = this._imp.injector(format); | ||
imp = this._imp.inject(span, format, carrier); | ||
} | ||
return new Injector(imp); | ||
} | ||
/** | ||
* Returns an Extractor object that handles the given `format`. | ||
* Returns a new Span object with the given operation name using the trace | ||
* information from the carrier. | ||
* | ||
* @param {string} operationName | ||
* Operation name to use on the newly created span. | ||
* @param {string} format | ||
* See the Extractor documentation for valid formats. | ||
* @return {Injector} | ||
* The format of the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
* @return {Span} | ||
*/ | ||
extractor(format) { | ||
join(operationName, format, carrier) { | ||
if (API_CONFORMANCE_CHECKS) { | ||
if (arguments.length !== 1) { | ||
if (arguments.length !== 3) { | ||
throw new Error('Invalid number of arguments.'); | ||
} | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string'); | ||
if (typeof operationName !== 'string' || !operationName.length) { | ||
throw new Error('operationName is expected to be a string of non-zero length'); | ||
} | ||
if (typeof format !== 'string' || !format.length) { | ||
throw new Error('format is expected to be a string of non-zero length'); | ||
} | ||
if (format === Constants.FORMAT_SPLIT_TEXT && !(carrier instanceof SplitTextCarrier)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
} | ||
if (format === Constants.FORMAT_BINARY && !(carrier instanceof BinaryCarrier)) { | ||
throw new Error('Unexpected carrier object for "binary" format'); | ||
} | ||
} | ||
let imp = null; | ||
let spanImp = null; | ||
if (this._imp) { | ||
imp = this._imp.extractor(format); | ||
spanImp = this._imp.join(operationName, format, carrier); | ||
} | ||
return new Extractor(imp); | ||
return new Span(spanImp); | ||
} | ||
@@ -144,3 +173,2 @@ | ||
} | ||
if (!this._imp) { | ||
@@ -147,0 +175,0 @@ done(null); |
@@ -23,6 +23,11 @@ // For the convenience of unit testing, add these to the global namespace | ||
it('should have the required constants', function() { | ||
expect(Tracer.FORMAT_SPLIT_TEXT).to.be.a('string'); | ||
expect(Tracer.FORMAT_SPLIT_BINARY).to.be.a('string'); | ||
}); | ||
it('should have the required Tracer functions', function() { | ||
expect(Tracer.startSpan).to.be.a('function'); | ||
expect(Tracer.injector).to.be.a('function'); | ||
expect(Tracer.extractor).to.be.a('function'); | ||
expect(Tracer.inject).to.be.a('function'); | ||
expect(Tracer.join).to.be.a('function'); | ||
expect(Tracer.flush).to.be.a('function'); | ||
@@ -33,7 +38,7 @@ }); | ||
var span = Tracer.startSpan('test_operation'); | ||
expect(span.tracer).to.be.a('function'); | ||
expect(span.setTag).to.be.a('function'); | ||
expect(span.addTags).to.be.a('function'); | ||
expect(span.setTraceAttribute).to.be.a('function'); | ||
expect(span.getTraceAttribute).to.be.a('function'); | ||
expect(span.setBaggageItem).to.be.a('function'); | ||
expect(span.getBaggageItem).to.be.a('function'); | ||
expect(span.startChildSpan).to.be.a('function'); | ||
@@ -40,0 +45,0 @@ expect(span.log).to.be.a('function'); |
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
172599
22
2163