opentracing
Advanced tools
Comparing version 0.9.13 to 0.9.14
@@ -65,3 +65,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
'use strict'; | ||
/* WEBPACK VAR INJECTION */(function(global) {'use strict'; | ||
@@ -74,3 +74,16 @@ var _singleton = __webpack_require__(2); | ||
module.exports = new _singleton2.default(); | ||
// Due to the various ways packages can be included in JavaScript (e.g. <script> | ||
// tags vs included via webpack), it's possible for a single application to | ||
// have multiple copies of the OpenTracing code. Try to ensure there's only one | ||
// singleton even in such scenarios. | ||
var singleton; | ||
if (typeof window !== 'undefined' && window.__opentracing_singleton) { | ||
singleton = window.__opentracing_singleton; | ||
} else if (typeof global !== 'undefined' && global.__opentracing_singleton) { | ||
singleton = global.__opentracing_singleton; | ||
} else { | ||
singleton = new _singleton2.default(); | ||
} | ||
module.exports = singleton; | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
@@ -93,14 +106,10 @@ /***/ }, | ||
var _binary_carrier = __webpack_require__(7); | ||
var _constants = __webpack_require__(5); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_carrier); | ||
var Constants = _interopRequireWildcard(_constants); | ||
var _split_text_carrier = __webpack_require__(6); | ||
var _binary_carrier = __webpack_require__(6); | ||
var _split_text_carrier2 = _interopRequireDefault(_split_text_carrier); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_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; } } | ||
@@ -185,4 +194,3 @@ | ||
// Include the carriers objects | ||
_this.SplitTextCarrier = _split_text_carrier2.default; | ||
// Carrier objects to be exposed at the package level | ||
_this.BinaryCarrier = _binary_carrier2.default; | ||
@@ -208,4 +216,2 @@ return _this; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -221,10 +227,2 @@ | ||
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 }; } | ||
@@ -281,3 +279,3 @@ | ||
} | ||
if (typeof nameOrFields !== 'string' && (typeof nameOrFields === 'undefined' ? 'undefined' : _typeof(nameOrFields)) !== 'object') { | ||
if (typeof nameOrFields !== 'string' && typeof nameOrFields !== 'object') { | ||
throw new Error('argument expected to be a string or object'); | ||
@@ -288,3 +286,3 @@ } | ||
} | ||
if ((typeof nameOrFields === 'undefined' ? 'undefined' : _typeof(nameOrFields)) === 'object') { | ||
if (typeof nameOrFields === 'object') { | ||
if (arguments.length !== 1) { | ||
@@ -326,2 +324,21 @@ throw new Error('Unexpected number of arguments'); | ||
* | ||
* See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers. | ||
* | ||
* Consider this pseudocode example: | ||
* | ||
* var clientSpan = ...; | ||
* ... | ||
* // Inject clientSpan into a text carrier. | ||
* var textCarrier = {}; | ||
* Tracer.inject(clientSpan, Tracer.FORMAT_TEXT_MAP, textCarrier); | ||
* // Incorporate the textCarrier into the outbound HTTP request header | ||
* // map. | ||
* outboundHTTPReq.headers.extend(textCarrier); | ||
* // ... send the httpReq | ||
* | ||
* For FORMAT_BINARY, inject() will set the buffer field to an Array-like | ||
* (Array, ArrayBuffer, or TypedBuffer) object containing the injected | ||
* binary data. Any valid Object can be used as long as the buffer field of | ||
* the object can be set. | ||
* | ||
* @param {Span} span | ||
@@ -332,3 +349,3 @@ * The span whose information should be injected into the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
* See the method description for details on the carrier object. | ||
*/ | ||
@@ -347,9 +364,9 @@ | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string. Found: ' + (typeof format === 'undefined' ? 'undefined' : _typeof(format))); | ||
throw new Error('format expected to be a string. Found: ' + typeof format); | ||
} | ||
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_TEXT_MAP && typeof carrier !== 'object') { | ||
throw new Error('Unexpected carrier object for TEXT_MAP format'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_binary" format'); | ||
if (format === _constants2.default.FORMAT_BINARY && typeof carrier !== 'object') { | ||
throw new Error('Unexpected carrier object for BINARY format'); | ||
} | ||
@@ -367,2 +384,14 @@ } | ||
* | ||
* See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers. | ||
* | ||
* Consider this pseudocode example: | ||
* | ||
* // Use the inbound HTTP request's headers as a text map carrier. | ||
* var textCarrier = inboundHTTPReq.headers; | ||
* var serverSpan = Tracer.join( | ||
* "operation name", Tracer.FORMAT_TEXT_MAP, textCarrier); | ||
* | ||
* For FORMAT_BINARY, `carrier` is expected to have a field named `buffer` | ||
* that contains an Array-like object (Array, ArrayBuffer, or TypedBuffer). | ||
* | ||
* @param {string} operationName | ||
@@ -390,7 +419,9 @@ * Operation name to use on the newly created span. | ||
} | ||
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_TEXT_MAP && !(typeof carrier === 'object')) { | ||
throw new Error('Unexpected carrier object for FORMAT_TEXT_MAP'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_binary" format'); | ||
if (format === _constants2.default.FORMAT_BINARY) { | ||
if (carrier.buffer !== undefined && typeof carrier.buffer !== 'object') { | ||
throw new Error('Unexpected carrier object for FORMAT_BINARY'); | ||
} | ||
} | ||
@@ -484,4 +515,2 @@ } | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -605,3 +634,3 @@ | ||
} | ||
if ((typeof keyValuePairs === 'undefined' ? 'undefined' : _typeof(keyValuePairs)) !== 'object') { | ||
if (typeof keyValuePairs !== 'object') { | ||
throw new Error('Invalid argument type'); | ||
@@ -650,3 +679,3 @@ } | ||
var valueType = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
var valueType = typeof value; | ||
if (value !== null && valueType !== 'boolean' && valueType !== 'number' && valueType !== 'string') { | ||
@@ -720,3 +749,3 @@ throw new Error('Trace attribute values can only be basic types'); | ||
} | ||
if ((typeof fields === 'undefined' ? 'undefined' : _typeof(fields)) !== 'object') { | ||
if (typeof fields !== 'object') { | ||
throw new Error('Expected fields to be an object'); | ||
@@ -827,10 +856,22 @@ } | ||
/** | ||
* Used to inject/join a span with using a BinaryCarrier. | ||
* Used to inject/join a span using a binary format. | ||
* | ||
* A valid binary carrier is any Object with a field named 'buffer' that | ||
* contains or will contain the binary data. | ||
*/ | ||
FORMAT_SPLIT_BINARY: 'split_binary', | ||
FORMAT_BINARY: 'binary', | ||
/** | ||
* Used to inject/join a span with using a SplitTextCarrier. | ||
* Used to inject/join a span using a string->string map as a carrier. | ||
* | ||
* NOTE: Since HTTP headers are a particularly important use case for the | ||
* TEXT_MAP carrier, map keys identify their respective values in a | ||
* case-insensitive manner. | ||
* | ||
* NOTE: The TEXT_MAP carrier map may contain unrelated data (e.g., | ||
* arbitrary HTTP headers). As such, the Tracer implementation should use a | ||
* prefix or other convention to distinguish Tracer-specific key:value | ||
* pairs. | ||
*/ | ||
FORMAT_SPLIT_TEXT: 'split_text' | ||
FORMAT_TEXT_MAP: 'text_map' | ||
}; | ||
@@ -845,4 +886,6 @@ | ||
/** | ||
* A SplitTextCarrier is intended to hold string-string pairs in its two | ||
* associative arrays. | ||
* Convenience class to use as a binary carrier. | ||
* | ||
* Any valid Object with a field named `buffer` may be used as a binary carrier; | ||
* this class is only one such type of object that can be used. | ||
*/ | ||
@@ -856,29 +899,6 @@ | ||
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() { | ||
var BinaryCarrier = function BinaryCarrier(binaryData) { | ||
_classCallCheck(this, BinaryCarrier); | ||
this.tracerState = new Uint8Array(0); | ||
this.baggage = new Uint8Array(0); | ||
this.buffer = binaryData; | ||
}; | ||
@@ -885,0 +905,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Tracer=t():e.Tracer=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}var i=n(2),o=r(i);e.exports=new o["default"]},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function i(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=i(l),s=n(7),p=i(s),y=n(6),d=i(y),h=n(5),m=r(h),_=function(e){function t(){o(this,t);var e=u(this,Object.getPrototypeOf(t).call(this));for(var n in m)e[n]=m[n];return e.SplitTextCarrier=d["default"],e.BinaryCarrier=p["default"],e}return a(t,e),f(t,[{key:"initGlobalTracer",value:function(e){this._imp=e}},{key:"initNewTracer",value:function(e){return new c["default"](e)}}]),t}(c["default"]);t["default"]=_,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()),u=n(4),a=r(u),f=n(5),l=(r(f),n(6)),c=(r(l),n(7)),s=(r(c),function(){function e(t){i(this,e),this._imp=t||null}return o(e,[{key:"startSpan",value:function(e,t){var n=null;return this._imp&&(1===arguments.length?t="string"==typeof e?{operationName:e}:e:t.operationName=e,n=this._imp.startSpan(t)),new a["default"](n)}},{key:"inject",value:function(e,t,n){this._imp&&this._imp.inject(e._imp,t,n)}},{key:"join",value:function(e,t,n){var r=null;return this._imp&&(r=this._imp.join(e,t,n)),new a["default"](r)}},{key:"flush",value:function(e){return this._imp?void this._imp.flush(e):void e(null)}}]),o(e,[{key:"imp",value:function(){return this._imp}}]),e}());t["default"]=s,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var u=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()),a=n(3),f=r(a),l=n(1),c=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function e(t){o(this,e),this._imp=t}return u(e,[{key:"tracer",value:function(){return this._imp?new f["default"](this._imp.tracer()):l}},{key:"setOperationName",value:function(e){return this._imp&&this._imp.setOperationName(e),this}},{key:"setTag",value:function(e,t){return this.addTags(i({},e,t)),this}},{key:"addTags",value:function(e){return this._imp?(this._imp.addTags(e),this):void 0}},{key:"setBaggageItem",value:function(e,t){return this._imp&&this._imp.setBaggageItem(e,t),this}},{key:"getBaggageItem",value:function(e){return this._imp?this._imp.getBaggageItem(e):void 0}},{key:"log",value:function(e){return this._imp?(this._imp.log(e),this):void 0}},{key:"logEvent",value:function(e,t){return this.log({event:e,payload:t})}},{key:"finish",value:function(e){this._imp&&this._imp.finish(e)}}]),u(e,[{key:"imp",value:function(){return this._imp}}]),e}());t["default"]=c,e.exports=t["default"]},function(e,t){"use strict";e.exports={FORMAT_SPLIT_BINARY:"split_binary",FORMAT_SPLIT_TEXT:"split_text"}},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function i(){n(this,i),this.tracerState={},this.baggage={}};t["default"]=r,e.exports=t["default"]},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function i(){n(this,i),this.tracerState=new Uint8Array(0),this.baggage=new Uint8Array(0)};t["default"]=r,e.exports=t["default"]}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Tracer=t():e.Tracer=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(1)},function(e,t,n){(function(t){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var r,o=n(2),u=i(o);r="undefined"!=typeof window&&window.__opentracing_singleton?window.__opentracing_singleton:"undefined"!=typeof t&&t.__opentracing_singleton?t.__opentracing_singleton:new u["default"],e.exports=r}).call(t,function(){return this}())},function(e,t,n){"use strict";function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var f=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(3),c=r(l),s=n(5),p=i(s),d=n(6),_=r(d),h=function(e){function t(){o(this,t);var e=u(this,Object.getPrototypeOf(t).call(this));for(var n in p)e[n]=p[n];return e.BinaryCarrier=_["default"],e}return a(t,e),f(t,[{key:"initGlobalTracer",value:function(e){this._imp=e}},{key:"initNewTracer",value:function(e){return new c["default"](e)}}]),t}(c["default"]);t["default"]=h,e.exports=t["default"]},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=n(4),a=i(u),f=n(5),l=(i(f),function(){function e(t){r(this,e),this._imp=t||null}return o(e,[{key:"startSpan",value:function(e,t){var n=null;return this._imp&&(1===arguments.length?t="string"==typeof e?{operationName:e}:e:t.operationName=e,n=this._imp.startSpan(t)),new a["default"](n)}},{key:"inject",value:function(e,t,n){this._imp&&this._imp.inject(e._imp,t,n)}},{key:"join",value:function(e,t,n){var i=null;return this._imp&&(i=this._imp.join(e,t,n)),new a["default"](i)}},{key:"flush",value:function(e){return this._imp?void this._imp.flush(e):void e(null)}}]),o(e,[{key:"imp",value:function(){return this._imp}}]),e}());t["default"]=l,e.exports=t["default"]},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(3),f=i(a),l=n(1),c=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function e(t){o(this,e),this._imp=t}return u(e,[{key:"tracer",value:function(){return this._imp?new f["default"](this._imp.tracer()):l}},{key:"setOperationName",value:function(e){return this._imp&&this._imp.setOperationName(e),this}},{key:"setTag",value:function(e,t){return this.addTags(r({},e,t)),this}},{key:"addTags",value:function(e){return this._imp?(this._imp.addTags(e),this):void 0}},{key:"setBaggageItem",value:function(e,t){return this._imp&&this._imp.setBaggageItem(e,t),this}},{key:"getBaggageItem",value:function(e){return this._imp?this._imp.getBaggageItem(e):void 0}},{key:"log",value:function(e){return this._imp?(this._imp.log(e),this):void 0}},{key:"logEvent",value:function(e,t){return this.log({event:e,payload:t})}},{key:"finish",value:function(e){this._imp&&this._imp.finish(e)}}]),u(e,[{key:"imp",value:function(){return this._imp}}]),e}());t["default"]=c,e.exports=t["default"]},function(e,t){"use strict";e.exports={FORMAT_BINARY:"binary",FORMAT_TEXT_MAP:"text_map"}},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function r(e){n(this,r),this.buffer=e};t["default"]=i,e.exports=t["default"]}])}); |
@@ -65,3 +65,15 @@ require("source-map-support").install(); | ||
module.exports = new _singleton2.default(); | ||
// Due to the various ways packages can be included in JavaScript (e.g. <script> | ||
// tags vs included via webpack), it's possible for a single application to | ||
// have multiple copies of the OpenTracing code. Try to ensure there's only one | ||
// singleton even in such scenarios. | ||
var singleton; | ||
if (typeof window !== 'undefined' && window.__opentracing_singleton) { | ||
singleton = window.__opentracing_singleton; | ||
} else if (typeof global !== 'undefined' && global.__opentracing_singleton) { | ||
singleton = global.__opentracing_singleton; | ||
} else { | ||
singleton = new _singleton2.default(); | ||
} | ||
module.exports = singleton; | ||
@@ -84,14 +96,10 @@ /***/ }, | ||
var _binary_carrier = __webpack_require__(7); | ||
var _constants = __webpack_require__(5); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_carrier); | ||
var Constants = _interopRequireWildcard(_constants); | ||
var _split_text_carrier = __webpack_require__(6); | ||
var _binary_carrier = __webpack_require__(6); | ||
var _split_text_carrier2 = _interopRequireDefault(_split_text_carrier); | ||
var _binary_carrier2 = _interopRequireDefault(_binary_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; } } | ||
@@ -176,4 +184,3 @@ | ||
// Include the carriers objects | ||
_this.SplitTextCarrier = _split_text_carrier2.default; | ||
// Carrier objects to be exposed at the package level | ||
_this.BinaryCarrier = _binary_carrier2.default; | ||
@@ -199,4 +206,2 @@ return _this; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -212,10 +217,2 @@ | ||
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 }; } | ||
@@ -272,3 +269,3 @@ | ||
} | ||
if (typeof nameOrFields !== 'string' && (typeof nameOrFields === 'undefined' ? 'undefined' : _typeof(nameOrFields)) !== 'object') { | ||
if (typeof nameOrFields !== 'string' && typeof nameOrFields !== 'object') { | ||
throw new Error('argument expected to be a string or object'); | ||
@@ -279,3 +276,3 @@ } | ||
} | ||
if ((typeof nameOrFields === 'undefined' ? 'undefined' : _typeof(nameOrFields)) === 'object') { | ||
if (typeof nameOrFields === 'object') { | ||
if (arguments.length !== 1) { | ||
@@ -317,2 +314,21 @@ throw new Error('Unexpected number of arguments'); | ||
* | ||
* See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers. | ||
* | ||
* Consider this pseudocode example: | ||
* | ||
* var clientSpan = ...; | ||
* ... | ||
* // Inject clientSpan into a text carrier. | ||
* var textCarrier = {}; | ||
* Tracer.inject(clientSpan, Tracer.FORMAT_TEXT_MAP, textCarrier); | ||
* // Incorporate the textCarrier into the outbound HTTP request header | ||
* // map. | ||
* outboundHTTPReq.headers.extend(textCarrier); | ||
* // ... send the httpReq | ||
* | ||
* For FORMAT_BINARY, inject() will set the buffer field to an Array-like | ||
* (Array, ArrayBuffer, or TypedBuffer) object containing the injected | ||
* binary data. Any valid Object can be used as long as the buffer field of | ||
* the object can be set. | ||
* | ||
* @param {Span} span | ||
@@ -323,3 +339,3 @@ * The span whose information should be injected into the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
* See the method description for details on the carrier object. | ||
*/ | ||
@@ -338,9 +354,9 @@ | ||
if (typeof format !== 'string') { | ||
throw new Error('format expected to be a string. Found: ' + (typeof format === 'undefined' ? 'undefined' : _typeof(format))); | ||
throw new Error('format expected to be a string. Found: ' + typeof format); | ||
} | ||
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_TEXT_MAP && typeof carrier !== 'object') { | ||
throw new Error('Unexpected carrier object for TEXT_MAP format'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_binary" format'); | ||
if (format === _constants2.default.FORMAT_BINARY && typeof carrier !== 'object') { | ||
throw new Error('Unexpected carrier object for BINARY format'); | ||
} | ||
@@ -358,2 +374,14 @@ } | ||
* | ||
* See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers. | ||
* | ||
* Consider this pseudocode example: | ||
* | ||
* // Use the inbound HTTP request's headers as a text map carrier. | ||
* var textCarrier = inboundHTTPReq.headers; | ||
* var serverSpan = Tracer.join( | ||
* "operation name", Tracer.FORMAT_TEXT_MAP, textCarrier); | ||
* | ||
* For FORMAT_BINARY, `carrier` is expected to have a field named `buffer` | ||
* that contains an Array-like object (Array, ArrayBuffer, or TypedBuffer). | ||
* | ||
* @param {string} operationName | ||
@@ -381,7 +409,9 @@ * Operation name to use on the newly created span. | ||
} | ||
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_TEXT_MAP && !(typeof carrier === 'object')) { | ||
throw new Error('Unexpected carrier object for FORMAT_TEXT_MAP'); | ||
} | ||
if (format === _constants2.default.FORMAT_SPLIT_BINARY && !(carrier instanceof _binary_carrier2.default)) { | ||
throw new Error('Unexpected carrier object for "split_binary" format'); | ||
if (format === _constants2.default.FORMAT_BINARY) { | ||
if (carrier.buffer !== undefined && typeof carrier.buffer !== 'object') { | ||
throw new Error('Unexpected carrier object for FORMAT_BINARY'); | ||
} | ||
} | ||
@@ -475,4 +505,2 @@ } | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -596,3 +624,3 @@ | ||
} | ||
if ((typeof keyValuePairs === 'undefined' ? 'undefined' : _typeof(keyValuePairs)) !== 'object') { | ||
if (typeof keyValuePairs !== 'object') { | ||
throw new Error('Invalid argument type'); | ||
@@ -641,3 +669,3 @@ } | ||
var valueType = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
var valueType = typeof value; | ||
if (value !== null && valueType !== 'boolean' && valueType !== 'number' && valueType !== 'string') { | ||
@@ -711,3 +739,3 @@ throw new Error('Trace attribute values can only be basic types'); | ||
} | ||
if ((typeof fields === 'undefined' ? 'undefined' : _typeof(fields)) !== 'object') { | ||
if (typeof fields !== 'object') { | ||
throw new Error('Expected fields to be an object'); | ||
@@ -818,10 +846,22 @@ } | ||
/** | ||
* Used to inject/join a span with using a BinaryCarrier. | ||
* Used to inject/join a span using a binary format. | ||
* | ||
* A valid binary carrier is any Object with a field named 'buffer' that | ||
* contains or will contain the binary data. | ||
*/ | ||
FORMAT_SPLIT_BINARY: 'split_binary', | ||
FORMAT_BINARY: 'binary', | ||
/** | ||
* Used to inject/join a span with using a SplitTextCarrier. | ||
* Used to inject/join a span using a string->string map as a carrier. | ||
* | ||
* NOTE: Since HTTP headers are a particularly important use case for the | ||
* TEXT_MAP carrier, map keys identify their respective values in a | ||
* case-insensitive manner. | ||
* | ||
* NOTE: The TEXT_MAP carrier map may contain unrelated data (e.g., | ||
* arbitrary HTTP headers). As such, the Tracer implementation should use a | ||
* prefix or other convention to distinguish Tracer-specific key:value | ||
* pairs. | ||
*/ | ||
FORMAT_SPLIT_TEXT: 'split_text' | ||
FORMAT_TEXT_MAP: 'text_map' | ||
}; | ||
@@ -836,4 +876,6 @@ | ||
/** | ||
* A SplitTextCarrier is intended to hold string-string pairs in its two | ||
* associative arrays. | ||
* Convenience class to use as a binary carrier. | ||
* | ||
* Any valid Object with a field named `buffer` may be used as a binary carrier; | ||
* this class is only one such type of object that can be used. | ||
*/ | ||
@@ -847,29 +889,6 @@ | ||
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() { | ||
var BinaryCarrier = function BinaryCarrier(binaryData) { | ||
_classCallCheck(this, BinaryCarrier); | ||
this.tracerState = new Uint8Array(0); | ||
this.baggage = new Uint8Array(0); | ||
this.buffer = binaryData; | ||
}; | ||
@@ -876,0 +895,0 @@ |
@@ -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";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),_=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}},{key:"initNewTracer",value:function(t){return new s["default"](t)}}]),e}(s["default"]);e["default"]=_,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,e){var n=null;return this._imp&&(1===arguments.length?e="string"==typeof t?{operationName:t}:t:e.operationName=t,n=this._imp.startSpan(e)),new a["default"](n)}},{key:"inject",value:function(t,e,n){this._imp&&this._imp.inject(t._imp,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){return t&&t.__esModule?t:{"default":t}}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var u=("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}}()),a=n(3),f=r(a),l=n(1),s=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function t(e){o(this,t),this._imp=e}return u(t,[{key:"tracer",value:function(){return this._imp?new f["default"](this._imp.tracer()):l}},{key:"setOperationName",value:function(t){return this._imp&&this._imp.setOperationName(t),this}},{key:"setTag",value:function(t,e){return this.addTags(i({},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.setBaggageItem(t,e),this}},{key:"getBaggageItem",value:function(t){return this._imp?this._imp.getBaggageItem(t):void 0}},{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)}}]),u(t,[{key:"imp",value:function(){return this._imp}}]),t}());e["default"]=s,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(0),this.baggage=new Uint8Array(0)};e["default"]=r,t.exports=e["default"]}]); | ||
module.exports=function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(1)},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var r,o=n(2),u=i(o);r="undefined"!=typeof window&&window.__opentracing_singleton?window.__opentracing_singleton:"undefined"!=typeof global&&global.__opentracing_singleton?global.__opentracing_singleton:new u["default"],e.exports=r},function(e,t,n){"use strict";function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),f=n(3),s=r(f),c=n(5),p=i(c),_=n(6),d=r(_),h=function(e){function t(){o(this,t);var e=u(this,Object.getPrototypeOf(t).call(this));for(var n in p)e[n]=p[n];return e.BinaryCarrier=d["default"],e}return a(t,e),l(t,[{key:"initGlobalTracer",value:function(e){this._imp=e}},{key:"initNewTracer",value:function(e){return new s["default"](e)}}]),t}(s["default"]);t["default"]=h,e.exports=t["default"]},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=n(4),a=i(u),l=n(5),f=(i(l),function(){function e(t){r(this,e),this._imp=t||null}return o(e,[{key:"startSpan",value:function(e,t){var n=null;return this._imp&&(1===arguments.length?t="string"==typeof e?{operationName:e}:e:t.operationName=e,n=this._imp.startSpan(t)),new a["default"](n)}},{key:"inject",value:function(e,t,n){this._imp&&this._imp.inject(e._imp,t,n)}},{key:"join",value:function(e,t,n){var i=null;return this._imp&&(i=this._imp.join(e,t,n)),new a["default"](i)}},{key:"flush",value:function(e){return this._imp?void this._imp.flush(e):void e(null)}}]),o(e,[{key:"imp",value:function(){return this._imp}}]),e}());t["default"]=f,e.exports=t["default"]},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(3),l=i(a),f=n(1),s=(new RegExp(/^[a-z0-9][-a-z0-9]*/),function(){function e(t){o(this,e),this._imp=t}return u(e,[{key:"tracer",value:function(){return this._imp?new l["default"](this._imp.tracer()):f}},{key:"setOperationName",value:function(e){return this._imp&&this._imp.setOperationName(e),this}},{key:"setTag",value:function(e,t){return this.addTags(r({},e,t)),this}},{key:"addTags",value:function(e){return this._imp?(this._imp.addTags(e),this):void 0}},{key:"setBaggageItem",value:function(e,t){return this._imp&&this._imp.setBaggageItem(e,t),this}},{key:"getBaggageItem",value:function(e){return this._imp?this._imp.getBaggageItem(e):void 0}},{key:"log",value:function(e){return this._imp?(this._imp.log(e),this):void 0}},{key:"logEvent",value:function(e,t){return this.log({event:e,payload:t})}},{key:"finish",value:function(e){this._imp&&this._imp.finish(e)}}]),u(e,[{key:"imp",value:function(){return this._imp}}]),e}());t["default"]=s,e.exports=t["default"]},function(e,t){"use strict";e.exports={FORMAT_BINARY:"binary",FORMAT_TEXT_MAP:"text_map"}},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function r(e){n(this,r),this.buffer=e};t["default"]=i,e.exports=t["default"]}]); |
{ | ||
"name": "opentracing", | ||
"version": "0.9.13", | ||
"version": "0.9.14", | ||
"main": "dist/opentracing-node.js", | ||
@@ -23,2 +23,18 @@ "scripts": { | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-plugin-check-es2015-constants": "^6.7.2", | ||
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2", | ||
"babel-plugin-transform-es2015-block-scoped-functions": "^6.6.5", | ||
"babel-plugin-transform-es2015-block-scoping": "^6.7.1", | ||
"babel-plugin-transform-es2015-classes": "^6.6.5", | ||
"babel-plugin-transform-es2015-computed-properties": "^6.6.5", | ||
"babel-plugin-transform-es2015-destructuring": "^6.6.5", | ||
"babel-plugin-transform-es2015-duplicate-keys": "^6.6.4", | ||
"babel-plugin-transform-es2015-literals": "^6.5.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.7.4", | ||
"babel-plugin-transform-es2015-object-super": "^6.6.5", | ||
"babel-plugin-transform-es2015-parameters": "^6.7.0", | ||
"babel-plugin-transform-es2015-spread": "^6.6.5", | ||
"babel-plugin-transform-es2015-sticky-regex": "^6.5.0", | ||
"babel-plugin-transform-es2015-template-literals": "^6.6.5", | ||
"babel-plugin-transform-es2015-unicode-regex": "^6.5.0", | ||
"babel-polyfill": "^6.3.14", | ||
@@ -25,0 +41,0 @@ "babel-preset-es2015": "^6.3.13", |
@@ -60,9 +60,10 @@ # OpenTracing API for JavaScript | ||
## API | ||
## Development Information | ||
Coming soon! | ||
*I.e. information for developers working on this package.* | ||
## Usage Examples | ||
#### Building the library | ||
Coming soon! | ||
* `make build` creates the compiled, distributable code | ||
* `make test` runs the tests | ||
@@ -77,20 +78,2 @@ ## JavaScript OpenTracing Implementations | ||
For truly implementation-dependent methods, the JavaScript API layer does expose `imp()` methods on each major type to allow the implementations to be accessed directly. Use of implementation-dependent methods is discouraged as it immediately makes instrumented code no longer portable. However, the `imp()` call does at least call attention to deviations from the standard API without making implementation-dependent calls impossible. | ||
## Development Information | ||
*I.e. information for developers working on this package.* | ||
#### Building the library | ||
``` | ||
npm run webpack | ||
``` | ||
This builds both a production and debug version of the library. The production version is intended to introduce minimal overhead, whereas the debug version does more aggressive checks for correct API usage. | ||
#### Unit tests | ||
``` | ||
npm test | ||
``` | ||
For truly implementation-dependent methods, the JavaScript API layer *does* expose `imp()` methods on each major type to allow the implementations to be accessed directly. Use of implementation-dependent methods is discouraged as it immediately makes instrumented code no longer portable. However, the `imp()` call does at least call attention to deviations from the standard API without making implementation-dependent calls impossible. |
@@ -5,10 +5,22 @@ 'use strict'; | ||
/** | ||
* Used to inject/join a span with using a BinaryCarrier. | ||
* Used to inject/join a span using a binary format. | ||
* | ||
* A valid binary carrier is any Object with a field named 'buffer' that | ||
* contains or will contain the binary data. | ||
*/ | ||
FORMAT_SPLIT_BINARY : 'split_binary', | ||
FORMAT_BINARY : 'binary', | ||
/** | ||
* Used to inject/join a span with using a SplitTextCarrier. | ||
* Used to inject/join a span using a string->string map as a carrier. | ||
* | ||
* NOTE: Since HTTP headers are a particularly important use case for the | ||
* TEXT_MAP carrier, map keys identify their respective values in a | ||
* case-insensitive manner. | ||
* | ||
* NOTE: The TEXT_MAP carrier map may contain unrelated data (e.g., | ||
* arbitrary HTTP headers). As such, the Tracer implementation should use a | ||
* prefix or other convention to distinguish Tracer-specific key:value | ||
* pairs. | ||
*/ | ||
FORMAT_SPLIT_TEXT : 'split_text', | ||
FORMAT_TEXT_MAP : 'text_map', | ||
}; |
@@ -5,2 +5,14 @@ 'use strict'; | ||
module.exports = new Singleton(); | ||
// Due to the various ways packages can be included in JavaScript (e.g. <script> | ||
// tags vs included via webpack), it's possible for a single application to | ||
// have multiple copies of the OpenTracing code. Try to ensure there's only one | ||
// singleton even in such scenarios. | ||
var singleton; | ||
if (typeof window !== 'undefined' && window.__opentracing_singleton) { | ||
singleton = window.__opentracing_singleton; | ||
} else if (typeof global !== 'undefined' && global.__opentracing_singleton) { | ||
singleton = global.__opentracing_singleton; | ||
} else { | ||
singleton = new Singleton(); | ||
} | ||
module.exports = singleton; |
'use strict'; | ||
import Tracer from './tracer'; | ||
import BinaryCarrier from './carriers/binary_carrier'; | ||
import SplitTextCarrier from './carriers/split_text_carrier'; | ||
import * as Constants from './constants'; | ||
import BinaryCarrier from './binary_carrier'; | ||
@@ -62,6 +61,5 @@ /** | ||
// Include the carriers objects | ||
this.SplitTextCarrier = SplitTextCarrier; | ||
// Carrier objects to be exposed at the package level | ||
this.BinaryCarrier = BinaryCarrier; | ||
} | ||
} |
@@ -5,4 +5,2 @@ 'use strict'; | ||
import Constants from './constants'; | ||
import SplitTextCarrier from './carriers/split_text_carrier'; | ||
import BinaryCarrier from './carriers/binary_carrier'; | ||
@@ -95,2 +93,21 @@ /** | ||
* | ||
* See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers. | ||
* | ||
* Consider this pseudocode example: | ||
* | ||
* var clientSpan = ...; | ||
* ... | ||
* // Inject clientSpan into a text carrier. | ||
* var textCarrier = {}; | ||
* Tracer.inject(clientSpan, Tracer.FORMAT_TEXT_MAP, textCarrier); | ||
* // Incorporate the textCarrier into the outbound HTTP request header | ||
* // map. | ||
* outboundHTTPReq.headers.extend(textCarrier); | ||
* // ... send the httpReq | ||
* | ||
* For FORMAT_BINARY, inject() will set the buffer field to an Array-like | ||
* (Array, ArrayBuffer, or TypedBuffer) object containing the injected | ||
* binary data. Any valid Object can be used as long as the buffer field of | ||
* the object can be set. | ||
* | ||
* @param {Span} span | ||
@@ -101,3 +118,3 @@ * The span whose information should be injected into the carrier. | ||
* @param {any} carrier | ||
* The type of the carrier object is determined by the format. | ||
* See the method description for details on the carrier object. | ||
*/ | ||
@@ -115,7 +132,7 @@ inject(span, format, carrier) { | ||
} | ||
if (format === Constants.FORMAT_SPLIT_TEXT && !(carrier instanceof SplitTextCarrier)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
if (format === Constants.FORMAT_TEXT_MAP && typeof carrier !== 'object') { | ||
throw new Error('Unexpected carrier object for TEXT_MAP format'); | ||
} | ||
if (format === Constants.FORMAT_SPLIT_BINARY && !(carrier instanceof BinaryCarrier)) { | ||
throw new Error('Unexpected carrier object for "split_binary" format'); | ||
if (format === Constants.FORMAT_BINARY && typeof carrier !== 'object') { | ||
throw new Error('Unexpected carrier object for BINARY format'); | ||
} | ||
@@ -133,2 +150,14 @@ } | ||
* | ||
* See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers. | ||
* | ||
* Consider this pseudocode example: | ||
* | ||
* // Use the inbound HTTP request's headers as a text map carrier. | ||
* var textCarrier = inboundHTTPReq.headers; | ||
* var serverSpan = Tracer.join( | ||
* "operation name", Tracer.FORMAT_TEXT_MAP, textCarrier); | ||
* | ||
* For FORMAT_BINARY, `carrier` is expected to have a field named `buffer` | ||
* that contains an Array-like object (Array, ArrayBuffer, or TypedBuffer). | ||
* | ||
* @param {string} operationName | ||
@@ -153,7 +182,9 @@ * Operation name to use on the newly created span. | ||
} | ||
if (format === Constants.FORMAT_SPLIT_TEXT && !(carrier instanceof SplitTextCarrier)) { | ||
throw new Error('Unexpected carrier object for "split_text" format'); | ||
if (format === Constants.FORMAT_TEXT_MAP && !(typeof carrier === 'object')) { | ||
throw new Error('Unexpected carrier object for FORMAT_TEXT_MAP'); | ||
} | ||
if (format === Constants.FORMAT_SPLIT_BINARY && !(carrier instanceof BinaryCarrier)) { | ||
throw new Error('Unexpected carrier object for "split_binary" format'); | ||
if (format === Constants.FORMAT_BINARY) { | ||
if (carrier.buffer !== undefined && typeof carrier.buffer !== 'object') { | ||
throw new Error('Unexpected carrier object for FORMAT_BINARY'); | ||
} | ||
} | ||
@@ -160,0 +191,0 @@ } |
@@ -24,4 +24,4 @@ // 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'); | ||
expect(Tracer.FORMAT_TEXT_MAP).to.be.a('string'); | ||
expect(Tracer.FORMAT_BINARY).to.be.a('string'); | ||
}); | ||
@@ -48,8 +48,21 @@ | ||
it('should have the required carrier objects', function() { | ||
expect(Tracer.SplitTextCarrier).to.be.a('function'); | ||
expect(Tracer.BinaryCarrier).to.be.a('function'); | ||
it('should enforce the required carrier types', function() { | ||
var span = Tracer.startSpan('test_operation'); | ||
expect(new Tracer.SplitTextCarrier()).to.be.a('object'); | ||
expect(new Tracer.BinaryCarrier()).to.be.a('object'); | ||
var textCarrier = {}; | ||
expect(function() { Tracer.inject(span, Tracer.FORMAT_TEXT_MAP, textCarrier); }).to.not.throw(Error); | ||
expect(function() { Tracer.inject(span, Tracer.FORMAT_TEXT_MAP, ''); }).to.throw(Error); | ||
expect(function() { Tracer.inject(span, Tracer.FORMAT_TEXT_MAP, 5); }).to.throw(Error); | ||
var binCarrier = new Tracer.BinaryCarrier(); | ||
expect(function() { Tracer.inject(span, Tracer.FORMAT_BINARY, binCarrier); }).to.not.throw(Error); | ||
expect(function() { Tracer.inject(span, Tracer.FORMAT_BINARY, new Object); }).to.not.throw(Error); | ||
expect(function() { Tracer.inject(span, Tracer.FORMAT_BINARY, {}); }).to.not.throw(Error); | ||
expect(function() { Tracer.inject(span, Tracer.FORMAT_BINARY, { buffer : null }); }).to.not.throw(Error); | ||
expect(function() { Tracer.join('test_op2', Tracer.FORMAT_BINARY, binCarrier); }).to.not.throw(Error); | ||
expect(function() { Tracer.join('test_op2', Tracer.FORMAT_BINARY, {}); }).to.not.throw(Error); | ||
expect(function() { Tracer.join('test_op2', Tracer.FORMAT_BINARY, { buffer : null }); }).to.not.throw(Error); | ||
expect(function() { Tracer.join('test_op2', Tracer.FORMAT_BINARY, { buffer : '' }); }).to.throw(Error); | ||
expect(function() { Tracer.join('test_op2', Tracer.FORMAT_BINARY, { buffer : 5 }); }).to.throw(Error); | ||
}); | ||
@@ -56,0 +69,0 @@ }); |
@@ -105,4 +105,30 @@ var webpack = require("webpack"); | ||
cacheDirectory : true, | ||
presets : [ "es2015" ], | ||
plugins : [ "add-module-exports" ], | ||
presets : [ ], | ||
plugins : [ | ||
"add-module-exports", | ||
// Manually specify the *subset* of the ES2015 preset | ||
// to use. This reduces the output file size and improves | ||
// interoperability (e.g. Symbol on IE). | ||
'babel-plugin-transform-es2015-template-literals', | ||
'babel-plugin-transform-es2015-literals', | ||
//'babel-plugin-transform-es2015-function-name', | ||
'babel-plugin-transform-es2015-arrow-functions', | ||
'babel-plugin-transform-es2015-block-scoped-functions', | ||
'babel-plugin-transform-es2015-classes', | ||
'babel-plugin-transform-es2015-object-super', | ||
// 'babel-plugin-transform-es2015-shorthand-properties', | ||
'babel-plugin-transform-es2015-duplicate-keys', | ||
'babel-plugin-transform-es2015-computed-properties', | ||
// 'babel-plugin-transform-es2015-for-of', | ||
'babel-plugin-transform-es2015-sticky-regex', | ||
'babel-plugin-transform-es2015-unicode-regex', | ||
'babel-plugin-check-es2015-constants', | ||
'babel-plugin-transform-es2015-spread', | ||
'babel-plugin-transform-es2015-parameters', | ||
'babel-plugin-transform-es2015-destructuring', | ||
'babel-plugin-transform-es2015-block-scoping', | ||
//'babel-plugin-transform-es2015-typeof-symbol', | ||
'babel-plugin-transform-es2015-modules-commonjs', | ||
], | ||
} | ||
@@ -109,0 +135,0 @@ }, |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
181808
2289
30
78
1