Socket
Socket
Sign inDemoInstall

jaeger-client

Package Overview
Dependencies
14
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.14.4 to 3.15.0

dist/src/jaeger-idl/.gitignore

7

CHANGELOG.md
# Changes by Version
## 3.15.0 (2019-05-10)
* Avoid mutation of user's tags (#348) - Thanks @fapspirit
* Support false values for the B3 Sampled header (#346) - Thanks @sebnow
* Fix HTTP sender, consume response data to free up memory (#343) - Thanks @baldmaster
* Transform IP for int32 representation to dot representation (#340) - Thanks @Etienne-Carriere
## 3.14.4 (2019-01-24)

@@ -4,0 +11,0 @@

6

dist/src/_flow/baggage_restriction_manager.js

@@ -7,3 +7,5 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=baggage_restriction_manager.js.map
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
//# sourceMappingURL=baggage_restriction_manager.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=bufrw.js.map
'use strict';
//# sourceMappingURL=bufrw.js.map

@@ -7,3 +7,5 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=context.js.map
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
//# sourceMappingURL=context.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=crossdock.js.map
'use strict';
//# sourceMappingURL=crossdock.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=extractor.js.map
'use strict';
//# sourceMappingURL=extractor.js.map

@@ -7,3 +7,5 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=injector.js.map
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
//# sourceMappingURL=injector.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=jaeger-thrift.js.map
'use strict';
//# sourceMappingURL=jaeger-thrift.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=logger.js.map
'use strict';
//# sourceMappingURL=logger.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=metrics.js.map
'use strict';
//# sourceMappingURL=metrics.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=process_setter.js.map
'use strict';
//# sourceMappingURL=process_setter.js.map

@@ -7,3 +7,5 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=reporter.js.map
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
//# sourceMappingURL=reporter.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=sampler-thrift.js.map
'use strict';
//# sourceMappingURL=sampler-thrift.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=sampler.js.map
'use strict';
//# sourceMappingURL=sampler.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=socket.js.map
'use strict';
//# sourceMappingURL=socket.js.map

@@ -1,2 +0,2 @@

"use strict";
//# sourceMappingURL=throttler.js.map
'use strict';
//# sourceMappingURL=throttler.js.map

@@ -7,3 +7,5 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=tracer.js.map
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
//# sourceMappingURL=tracer.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2017 Uber Technologies, Inc.

@@ -32,5 +47,11 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -41,3 +62,3 @@ /**

*/
var BaggageSetter = function () {
var BaggageSetter = (function() {
function BaggageSetter(restrictionManager, metrics) {

@@ -60,53 +81,55 @@ _classCallCheck(this, BaggageSetter);

_createClass(BaggageSetter, [{
key: 'setBaggage',
value: function setBaggage(span, key, baggageValue) {
var value = baggageValue;
var truncated = false;
var prevItem = '';
var restriction = this._restrictionManager.getRestriction(span.serviceName, key);
if (!restriction.keyAllowed) {
_createClass(BaggageSetter, [
{
key: 'setBaggage',
value: function setBaggage(span, key, baggageValue) {
var value = baggageValue;
var truncated = false;
var prevItem = '';
var restriction = this._restrictionManager.getRestriction(span.serviceName, key);
if (!restriction.keyAllowed) {
this._logFields(span, key, value, prevItem, truncated, restriction.keyAllowed);
this._metrics.baggageUpdateFailure.increment(1);
return span.context();
}
if (value.length > restriction.maxValueLength) {
truncated = true;
value = value.substring(0, restriction.maxValueLength);
this._metrics.baggageTruncate.increment(1);
}
prevItem = span.getBaggageItem(key);
this._logFields(span, key, value, prevItem, truncated, restriction.keyAllowed);
this._metrics.baggageUpdateFailure.increment(1);
return span.context();
}
if (value.length > restriction.maxValueLength) {
truncated = true;
value = value.substring(0, restriction.maxValueLength);
this._metrics.baggageTruncate.increment(1);
}
prevItem = span.getBaggageItem(key);
this._logFields(span, key, value, prevItem, truncated, restriction.keyAllowed);
this._metrics.baggageUpdateSuccess.increment(1);
return span.context().withBaggageItem(key, value);
}
}, {
key: '_logFields',
value: function _logFields(span, key, value, prevItem, truncated, valid) {
if (!span.context().isSampled()) {
return;
}
var fields = {
event: 'baggage',
key: key,
value: value
};
if (prevItem) {
fields.override = 'true';
}
if (truncated) {
fields.truncated = 'true';
}
if (!valid) {
fields.invalid = 'true';
}
span.log(fields);
}
}]);
this._metrics.baggageUpdateSuccess.increment(1);
return span.context().withBaggageItem(key, value);
},
},
{
key: '_logFields',
value: function _logFields(span, key, value, prevItem, truncated, valid) {
if (!span.context().isSampled()) {
return;
}
var fields = {
event: 'baggage',
key: key,
value: value,
};
if (prevItem) {
fields.override = 'true';
}
if (truncated) {
fields.truncated = 'true';
}
if (!valid) {
fields.invalid = 'true';
}
span.log(fields);
},
},
]);
return BaggageSetter;
}();
})();
exports.default = BaggageSetter;
//# sourceMappingURL=baggage_setter.js.map
//# sourceMappingURL=baggage_setter.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports.DEFAULT_MAX_VALUE_LENGTH = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2017 Uber Technologies, Inc.

@@ -25,7 +40,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var DEFAULT_MAX_VALUE_LENGTH = exports.DEFAULT_MAX_VALUE_LENGTH = 2048;
var DEFAULT_MAX_VALUE_LENGTH = (exports.DEFAULT_MAX_VALUE_LENGTH = 2048);

@@ -36,3 +57,3 @@ /**

var DefaultBaggageRestrictionManager = function () {
var DefaultBaggageRestrictionManager = (function() {
function DefaultBaggageRestrictionManager(maxValueLength) {

@@ -45,13 +66,15 @@ _classCallCheck(this, DefaultBaggageRestrictionManager);

_createClass(DefaultBaggageRestrictionManager, [{
key: 'getRestriction',
value: function getRestriction(service, key) {
return this._restriction;
}
}]);
_createClass(DefaultBaggageRestrictionManager, [
{
key: 'getRestriction',
value: function getRestriction(service, key) {
return this._restriction;
},
},
]);
return DefaultBaggageRestrictionManager;
}();
})();
exports.default = DefaultBaggageRestrictionManager;
//# sourceMappingURL=default_baggage_restriction_manager.js.map
//# sourceMappingURL=default_baggage_restriction_manager.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -27,3 +46,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

*/
var Restriction = function () {
var Restriction = (function() {
function Restriction(keyAllowed, maxValueLength) {

@@ -36,18 +55,21 @@ _classCallCheck(this, Restriction);

_createClass(Restriction, [{
key: "keyAllowed",
get: function get() {
return this._keyAllowed;
}
}, {
key: "maxValueLength",
get: function get() {
return this._maxValueLength;
}
}]);
_createClass(Restriction, [
{
key: 'keyAllowed',
get: function get() {
return this._keyAllowed;
},
},
{
key: 'maxValueLength',
get: function get() {
return this._maxValueLength;
},
},
]);
return Restriction;
}();
})();
exports.default = Restriction;
//# sourceMappingURL=restriction.js.map
//# sourceMappingURL=restriction.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
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; }; }(); // Copyright (c) 2018 Jaeger Author.
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;
};
})(); // Copyright (c) 2018 Jaeger Author.
//

@@ -27,5 +42,11 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -40,6 +61,6 @@ var deprecatedEnvVars = {

JAEGER_REPORTER_AGENT_PORT: 'JAEGER_AGENT_PORT',
JAEGER_DISABLE: 'JAEGER_DISABLED'
JAEGER_DISABLE: 'JAEGER_DISABLED',
};
var ConfigurationEnv = function () {
var ConfigurationEnv = (function() {
function ConfigurationEnv() {

@@ -49,161 +70,210 @@ _classCallCheck(this, ConfigurationEnv);

_createClass(ConfigurationEnv, null, [{
key: '_validateEnv',
value: function _validateEnv() {
Object.keys(deprecatedEnvVars).forEach(function (env) {
if (process.env[env]) {
console.warn('You are using deprecated env variable ' + env + '. Use ' + deprecatedEnvVars[env] + ' instead. \nDeprecated env variable will be removed in the next major release (4.x.x)');
_createClass(ConfigurationEnv, null, [
{
key: '_validateEnv',
value: function _validateEnv() {
Object.keys(deprecatedEnvVars).forEach(function(env) {
if (process.env[env]) {
console.warn(
'You are using deprecated env variable ' +
env +
'. Use ' +
deprecatedEnvVars[env] +
' instead. \nDeprecated env variable will be removed in the next major release (4.x.x)'
);
}
});
},
},
{
key: '_getConfigValue',
value: function _getConfigValue(obj, key, defaultValue) {
return (obj && obj[key]) || defaultValue;
},
},
{
key: '_getSamplerFromEnv',
value: function _getSamplerFromEnv(config) {
var samplerConfig = {};
var value = ConfigurationEnv._getConfigValue(config.sampler, 'type', process.env.JAEGER_SAMPLER_TYPE);
if (value) {
samplerConfig.type = value;
}
});
}
}, {
key: '_getConfigValue',
value: function _getConfigValue(obj, key, defaultValue) {
return obj && obj[key] || defaultValue;
}
}, {
key: '_getSamplerFromEnv',
value: function _getSamplerFromEnv(config) {
var samplerConfig = {};
var value = ConfigurationEnv._getConfigValue(config.sampler, 'type', process.env.JAEGER_SAMPLER_TYPE);
if (value) {
samplerConfig.type = value;
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'param', process.env.JAEGER_SAMPLER_PARAM);
if (value) {
samplerConfig.param = parseFloat(value);
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'param', process.env.JAEGER_SAMPLER_PARAM);
if (value) {
samplerConfig.param = parseFloat(value);
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'hostPort', process.env.JAEGER_SAMPLER_MANAGER_HOST_PORT);
if (value) {
samplerConfig.hostPort = value;
}
value = ConfigurationEnv._getConfigValue(
config.sampler,
'hostPort',
process.env.JAEGER_SAMPLER_MANAGER_HOST_PORT
);
if (value) {
samplerConfig.hostPort = value;
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'host', process.env.JAEGER_SAMPLER_HOST);
if (value) {
samplerConfig.host = value;
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'host', process.env.JAEGER_SAMPLER_HOST);
if (value) {
samplerConfig.host = value;
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'port', process.env.JAEGER_SAMPLER_PORT);
if (value) {
samplerConfig.port = parseInt(value);
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'port', process.env.JAEGER_SAMPLER_PORT);
if (value) {
samplerConfig.port = parseInt(value);
}
value = ConfigurationEnv._getConfigValue(config.sampler, 'refreshIntervalMs', process.env.JAEGER_SAMPLER_REFRESH_INTERVAL);
if (value) {
samplerConfig.refreshIntervalMs = parseInt(value);
}
value = ConfigurationEnv._getConfigValue(
config.sampler,
'refreshIntervalMs',
process.env.JAEGER_SAMPLER_REFRESH_INTERVAL
);
if (value) {
samplerConfig.refreshIntervalMs = parseInt(value);
}
return samplerConfig;
}
}, {
key: '_getReporterFromEnv',
value: function _getReporterFromEnv(config) {
var reporterConfig = {};
var value = ConfigurationEnv._getConfigValue(config.reporter, 'logSpans', process.env.JAEGER_REPORTER_LOG_SPANS);
if (value) {
reporterConfig.logSpans = Boolean(value);
}
return samplerConfig;
},
},
{
key: '_getReporterFromEnv',
value: function _getReporterFromEnv(config) {
var reporterConfig = {};
var value = ConfigurationEnv._getConfigValue(
config.reporter,
'logSpans',
process.env.JAEGER_REPORTER_LOG_SPANS
);
if (value) {
reporterConfig.logSpans = Boolean(value);
}
value = ConfigurationEnv._getConfigValue(config.reporter, 'flushIntervalMs', process.env.JAEGER_REPORTER_FLUSH_INTERVAL);
if (value) {
reporterConfig.flushIntervalMs = parseInt(value);
}
value = ConfigurationEnv._getConfigValue(
config.reporter,
'flushIntervalMs',
process.env.JAEGER_REPORTER_FLUSH_INTERVAL
);
if (value) {
reporterConfig.flushIntervalMs = parseInt(value);
}
value = ConfigurationEnv._getConfigValue(config.reporter, 'collectorEndpoint', process.env.JAEGER_ENDPOINT || process.env.JAEGER_REPORTER_ENDPOINT);
if (value) {
reporterConfig.collectorEndpoint = value;
}
value = ConfigurationEnv._getConfigValue(
config.reporter,
'collectorEndpoint',
process.env.JAEGER_ENDPOINT || process.env.JAEGER_REPORTER_ENDPOINT
);
if (value) {
reporterConfig.collectorEndpoint = value;
}
value = ConfigurationEnv._getConfigValue(config.reporter, 'username', process.env.JAEGER_USER || process.env.JAEGER_REPORTER_USER);
if (value) {
reporterConfig.username = value;
}
value = ConfigurationEnv._getConfigValue(
config.reporter,
'username',
process.env.JAEGER_USER || process.env.JAEGER_REPORTER_USER
);
if (value) {
reporterConfig.username = value;
}
value = ConfigurationEnv._getConfigValue(config.reporter, 'password', process.env.JAEGER_PASSWORD || process.env.JAEGER_REPORTER_PASSWORD);
if (value) {
reporterConfig.password = value;
}
value = ConfigurationEnv._getConfigValue(
config.reporter,
'password',
process.env.JAEGER_PASSWORD || process.env.JAEGER_REPORTER_PASSWORD
);
if (value) {
reporterConfig.password = value;
}
value = ConfigurationEnv._getConfigValue(config.reporter, 'agentHost', process.env.JAEGER_AGENT_HOST || process.env.JAEGER_REPORTER_AGENT_HOST);
if (value) {
reporterConfig.agentHost = value;
}
value = ConfigurationEnv._getConfigValue(
config.reporter,
'agentHost',
process.env.JAEGER_AGENT_HOST || process.env.JAEGER_REPORTER_AGENT_HOST
);
if (value) {
reporterConfig.agentHost = value;
}
value = ConfigurationEnv._getConfigValue(config.reporter, 'agentPort', process.env.JAEGER_AGENT_PORT || process.env.JAEGER_REPORTER_AGENT_PORT);
if (value) {
reporterConfig.agentPort = parseInt(value);
}
value = ConfigurationEnv._getConfigValue(
config.reporter,
'agentPort',
process.env.JAEGER_AGENT_PORT || process.env.JAEGER_REPORTER_AGENT_PORT
);
if (value) {
reporterConfig.agentPort = parseInt(value);
}
return reporterConfig;
}
}, {
key: '_parseTagsFromEnv',
value: function _parseTagsFromEnv(options) {
if (options.tags) {
return options.tags;
}
var tags = {};
if (process.env.JAEGER_TAGS) {
var tagsList = process.env.JAEGER_TAGS.split(',');
var len = tagsList.length;
var idx = 0;
while (idx < len) {
var kv = tagsList[idx].split('=');
var k = kv[0].trim();
var v = kv[1].trim();
if (_util2.default.startsWith(v, '${') && _util2.default.endsWith(v, '}')) {
var ed = v.substring(2, v.length - 1).split(':');
v = process.env[ed[0]];
if (!v && ed[1] !== '') {
v = ed[1];
return reporterConfig;
},
},
{
key: '_parseTagsFromEnv',
value: function _parseTagsFromEnv(options) {
if (options.tags) {
return options.tags;
}
var tags = {};
if (process.env.JAEGER_TAGS) {
var tagsList = process.env.JAEGER_TAGS.split(',');
var len = tagsList.length;
var idx = 0;
while (idx < len) {
var kv = tagsList[idx].split('=');
var k = kv[0].trim();
var v = kv[1].trim();
if (_util2.default.startsWith(v, '${') && _util2.default.endsWith(v, '}')) {
var ed = v.substring(2, v.length - 1).split(':');
v = process.env[ed[0]];
if (!v && ed[1] !== '') {
v = ed[1];
}
}
tags[k] = v;
idx += 1;
}
tags[k] = v;
idx += 1;
}
}
return tags;
}
return tags;
},
/**
* Initialize and return a new instance of Jaeger Tracer from environment variables.
* config or options can be passed to override environment variables.
*
* @param {Object} config - configuration, see Configuration.initTracer
* @param {Object} options - options, see Configuration.initTracer
*/
/**
* Initialize and return a new instance of Jaeger Tracer from environment variables.
* config or options can be passed to override environment variables.
*
* @param {Object} config - configuration, see Configuration.initTracer
* @param {Object} options - options, see Configuration.initTracer
*/
},
{
key: 'initTracer',
value: function initTracer() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
}, {
key: 'initTracer',
value: function initTracer() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
ConfigurationEnv._validateEnv();
ConfigurationEnv._validateEnv();
config.disable =
config.disable || process.env.JAEGER_DISABLED === 'true' || process.env.JAEGER_DISABLE === 'true';
config.serviceName = config.serviceName || process.env.JAEGER_SERVICE_NAME;
config.disable = config.disable || process.env.JAEGER_DISABLED === 'true' || process.env.JAEGER_DISABLE === 'true';
config.serviceName = config.serviceName || process.env.JAEGER_SERVICE_NAME;
options.tags = ConfigurationEnv._parseTagsFromEnv(options);
var samplerConfig = ConfigurationEnv._getSamplerFromEnv(config);
if (Object.keys(samplerConfig).length > 0) {
config.sampler = samplerConfig;
}
options.tags = ConfigurationEnv._parseTagsFromEnv(options);
var samplerConfig = ConfigurationEnv._getSamplerFromEnv(config);
if (Object.keys(samplerConfig).length > 0) {
config.sampler = samplerConfig;
}
if (!options.reporter) {
var reporterConfig = ConfigurationEnv._getReporterFromEnv(config, options);
if (Object.keys(reporterConfig).length > 0) {
config.reporter = reporterConfig;
if (!options.reporter) {
var reporterConfig = ConfigurationEnv._getReporterFromEnv(config, options);
if (Object.keys(reporterConfig).length > 0) {
config.reporter = reporterConfig;
}
}
}
return _configuration2.default.initTracer(config, options);
}
}]);
return _configuration2.default.initTracer(config, options);
},
},
]);
return ConfigurationEnv;
}();
})();
exports.default = ConfigurationEnv;
//# sourceMappingURL=configuration_env.js.map
//# sourceMappingURL=configuration_env.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
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; }; }(); // Copyright (c) 2016 Uber Technologies, Inc.
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;
};
})(); // Copyright (c) 2016 Uber Technologies, Inc.
//

@@ -79,7 +94,26 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

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 _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 }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -99,6 +133,6 @@ var jaegerSchema = {

port: { type: 'number' },
refreshIntervalMs: { type: 'number' }
refreshIntervalMs: { type: 'number' },
},
required: ['type', 'param'],
additionalProperties: false
additionalProperties: false,
},

@@ -113,5 +147,5 @@ reporter: {

password: { type: 'string' },
flushIntervalMs: { type: 'number' }
flushIntervalMs: { type: 'number' },
},
additionalProperties: false
additionalProperties: false,
},

@@ -122,10 +156,10 @@ throttler: {

port: { type: 'number' },
refreshIntervalMs: { type: 'number' }
refreshIntervalMs: { type: 'number' },
},
additionalProperties: false
}
}
additionalProperties: false,
},
},
};
var Configuration = function () {
var Configuration = (function() {
function Configuration() {

@@ -135,185 +169,193 @@ _classCallCheck(this, Configuration);

_createClass(Configuration, null, [{
key: '_getSampler',
value: function _getSampler(config, options) {
var type = config.sampler.type;
var param = config.sampler.param;
var hostPort = config.sampler.hostPort;
var host = config.sampler.host;
var port = config.sampler.port;
var refreshIntervalMs = config.sampler.refreshIntervalMs;
_createClass(Configuration, null, [
{
key: '_getSampler',
value: function _getSampler(config, options) {
var type = config.sampler.type;
var param = config.sampler.param;
var hostPort = config.sampler.hostPort;
var host = config.sampler.host;
var port = config.sampler.port;
var refreshIntervalMs = config.sampler.refreshIntervalMs;
if (typeof param !== 'number') {
throw new Error('Expecting sampler.param to be a number. Received ' + param);
}
if (typeof param !== 'number') {
throw new Error('Expecting sampler.param to be a number. Received ' + param);
}
var sampler = void 0;
if (type === constants.SAMPLER_TYPE_PROBABILISTIC) {
sampler = new _probabilistic_sampler2.default(param);
}
var sampler = void 0;
if (type === constants.SAMPLER_TYPE_PROBABILISTIC) {
sampler = new _probabilistic_sampler2.default(param);
}
if (type === constants.SAMPLER_TYPE_RATE_LIMITING) {
sampler = new _ratelimiting_sampler2.default(param);
}
if (type === constants.SAMPLER_TYPE_RATE_LIMITING) {
sampler = new _ratelimiting_sampler2.default(param);
}
if (type === constants.SAMPLER_TYPE_CONST) {
sampler = new _const_sampler2.default(param === 1);
}
if (type === constants.SAMPLER_TYPE_REMOTE) {
sampler = new _remote_sampler2.default(config.serviceName, {
sampler: new _probabilistic_sampler2.default(param),
hostPort: hostPort,
host: host,
port: port,
refreshInterval: refreshIntervalMs,
metrics: options.metrics,
logger: options.logger
});
}
return sampler;
}
}, {
key: '_getReporter',
value: function _getReporter(config, options) {
var reporterConfig = {};
var reporters = [];
var isHTTPSender = false;
var senderConfig = {
logger: options.logger
};
if (config.reporter) {
if (config.reporter.logSpans) {
reporters.push(new _logging_reporter2.default(options.logger));
if (type === constants.SAMPLER_TYPE_CONST) {
sampler = new _const_sampler2.default(param === 1);
}
if (config.reporter.flushIntervalMs) {
reporterConfig['bufferFlushInterval'] = config.reporter.flushIntervalMs;
if (type === constants.SAMPLER_TYPE_REMOTE) {
sampler = new _remote_sampler2.default(config.serviceName, {
sampler: new _probabilistic_sampler2.default(param),
hostPort: hostPort,
host: host,
port: port,
refreshInterval: refreshIntervalMs,
metrics: options.metrics,
logger: options.logger,
});
}
if (config.reporter.collectorEndpoint) {
isHTTPSender = true;
return sampler;
},
},
{
key: '_getReporter',
value: function _getReporter(config, options) {
var reporterConfig = {};
var reporters = [];
var isHTTPSender = false;
var senderConfig = {
logger: options.logger,
};
if (config.reporter) {
if (config.reporter.logSpans) {
reporters.push(new _logging_reporter2.default(options.logger));
}
senderConfig['endpoint'] = config.reporter.collectorEndpoint;
if (config.reporter.flushIntervalMs) {
reporterConfig['bufferFlushInterval'] = config.reporter.flushIntervalMs;
}
if (config.reporter.username) {
senderConfig['username'] = config.reporter.username;
if (config.reporter.collectorEndpoint) {
isHTTPSender = true;
senderConfig['endpoint'] = config.reporter.collectorEndpoint;
if (config.reporter.username) {
senderConfig['username'] = config.reporter.username;
}
if (config.reporter.password) {
senderConfig['password'] = config.reporter.password;
}
}
if (config.reporter.password) {
senderConfig['password'] = config.reporter.password;
if (config.reporter.agentHost) {
senderConfig['host'] = config.reporter.agentHost;
}
if (config.reporter.agentPort) {
senderConfig['port'] = config.reporter.agentPort;
}
}
if (config.reporter.agentHost) {
senderConfig['host'] = config.reporter.agentHost;
reporterConfig['metrics'] = options.metrics;
reporterConfig['logger'] = options.logger;
var sender = isHTTPSender
? new _http_sender2.default(senderConfig)
: new _udp_sender2.default(senderConfig);
var remoteReporter = new _remote_reporter2.default(sender, reporterConfig);
if (reporters.length == 0) {
return remoteReporter;
}
if (config.reporter.agentPort) {
senderConfig['port'] = config.reporter.agentPort;
reporters.push(remoteReporter);
return new _composite_reporter2.default(reporters);
},
},
{
key: '_getThrottler',
value: function _getThrottler(config, options) {
var throttlerOptions = _util2.default.clone(config.throttler);
if (options.logger) {
throttlerOptions.logger = options.logger;
}
}
reporterConfig['metrics'] = options.metrics;
reporterConfig['logger'] = options.logger;
var sender = isHTTPSender ? new _http_sender2.default(senderConfig) : new _udp_sender2.default(senderConfig);
var remoteReporter = new _remote_reporter2.default(sender, reporterConfig);
if (reporters.length == 0) {
return remoteReporter;
}
reporters.push(remoteReporter);
return new _composite_reporter2.default(reporters);
}
}, {
key: '_getThrottler',
value: function _getThrottler(config, options) {
var throttlerOptions = _util2.default.clone(config.throttler);
if (options.logger) {
throttlerOptions.logger = options.logger;
}
if (options.metrics) {
throttlerOptions.metrics = options.metrics;
}
return new _remote_throttler2.default(config.serviceName, throttlerOptions);
}
if (options.metrics) {
throttlerOptions.metrics = options.metrics;
}
return new _remote_throttler2.default(config.serviceName, throttlerOptions);
},
/**
* Initialize and return a new instance of Jaeger Tracer.
*
* The config dictionary is not validated for adherence to the schema above.
* Such validation can be performed like this:
*
* import {Validator} from 'jsonschema';
*
* let v = new Validator();
* v.validate(config, jaegerSchema, {
* throwError: true
* });
*
* @param {Object} config - configuration matching the jaegerSchema definition.
* @param {Object} options - options
* @param {Object} [options.reporter] - if provided, this reporter will be used.
* Otherwise a new reporter will be created according to the description
* in the config.
* @param {Object} [options.throttler] - if provided, this throttler will be used.
* Otherwise a new throttler will be created according to the description
* in the config.
* @param {Object} [options.metrics] - a metrics factory (see ./_flow/metrics.js)
* @param {Object} [options.logger] - a logger (see ./_flow/logger.js)
* @param {Object} [options.tags] - set of key-value pairs which will be set
* as process-level tags on the Tracer itself.
*/
/**
* Initialize and return a new instance of Jaeger Tracer.
*
* The config dictionary is not validated for adherence to the schema above.
* Such validation can be performed like this:
*
* import {Validator} from 'jsonschema';
*
* let v = new Validator();
* v.validate(config, jaegerSchema, {
* throwError: true
* });
*
* @param {Object} config - configuration matching the jaegerSchema definition.
* @param {Object} options - options
* @param {Object} [options.reporter] - if provided, this reporter will be used.
* Otherwise a new reporter will be created according to the description
* in the config.
* @param {Object} [options.throttler] - if provided, this throttler will be used.
* Otherwise a new throttler will be created according to the description
* in the config.
* @param {Object} [options.metrics] - a metrics factory (see ./_flow/metrics.js)
* @param {Object} [options.logger] - a logger (see ./_flow/logger.js)
* @param {Object} [options.tags] - set of key-value pairs which will be set
* as process-level tags on the Tracer itself.
*/
},
{
key: 'initTracer',
value: function initTracer(config) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
}, {
key: 'initTracer',
value: function initTracer(config) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var reporter = void 0;
var sampler = void 0;
var throttler = void 0;
if (options.metrics) {
options.metrics = new _metrics2.default(options.metrics);
}
if (config.disable) {
return new _opentracing2.default.Tracer();
}
if (!config.serviceName) {
throw new Error('config.serviceName must be provided');
}
if (config.sampler) {
sampler = Configuration._getSampler(config, options);
} else {
sampler = new _remote_sampler2.default(config.serviceName, options);
}
if (!options.reporter) {
reporter = Configuration._getReporter(config, options);
} else {
reporter = options.reporter;
}
if (!options.throttler) {
if (config.throttler) {
throttler = Configuration._getThrottler(config, options);
}
} else {
throttler = options.throttler;
}
var reporter = void 0;
var sampler = void 0;
var throttler = void 0;
if (options.metrics) {
options.metrics = new _metrics2.default(options.metrics);
}
if (config.disable) {
return new _opentracing2.default.Tracer();
}
if (!config.serviceName) {
throw new Error('config.serviceName must be provided');
}
if (config.sampler) {
sampler = Configuration._getSampler(config, options);
} else {
sampler = new _remote_sampler2.default(config.serviceName, options);
}
if (!options.reporter) {
reporter = Configuration._getReporter(config, options);
} else {
reporter = options.reporter;
}
if (!options.throttler) {
if (config.throttler) {
throttler = Configuration._getThrottler(config, options);
if (options.logger) {
options.logger.info(
'Initializing Jaeger Tracer with ' + reporter.name() + ' and ' + sampler.name()
);
}
} else {
throttler = options.throttler;
}
if (options.logger) {
options.logger.info('Initializing Jaeger Tracer with ' + reporter.name() + ' and ' + sampler.name());
}
return new _tracer2.default(config.serviceName, reporter, sampler, {
contextKey: options.contextKey,
baggagePrefix: options.baggagePrefix,
metrics: options.metrics,
logger: options.logger,
tags: options.tags,
debugThrottler: throttler,
});
},
},
]);
return new _tracer2.default(config.serviceName, reporter, sampler, {
contextKey: options.contextKey,
baggagePrefix: options.baggagePrefix,
metrics: options.metrics,
logger: options.logger,
tags: options.tags,
debugThrottler: throttler
});
}
}]);
return Configuration;
}();
})();
exports.default = Configuration;
//# sourceMappingURL=configuration.js.map
//# sourceMappingURL=configuration.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});

@@ -19,42 +19,42 @@ // Copyright (c) 2016 Uber Technologies, Inc.

// SAMPLED_MASK is the bit mask indicating that a span has been sampled.
var SAMPLED_MASK = exports.SAMPLED_MASK = 0x1;
var SAMPLED_MASK = (exports.SAMPLED_MASK = 0x1);
// DEBUG_MASK is the bit mask indicationg that a span has been marked for debug.
var DEBUG_MASK = exports.DEBUG_MASK = 0x2;
var DEBUG_MASK = (exports.DEBUG_MASK = 0x2);
// JAEGER_CLIENT_VERSION_TAG_KEY is the name of the tag used to report client version.
var JAEGER_CLIENT_VERSION_TAG_KEY = exports.JAEGER_CLIENT_VERSION_TAG_KEY = 'jaeger.version';
var JAEGER_CLIENT_VERSION_TAG_KEY = (exports.JAEGER_CLIENT_VERSION_TAG_KEY = 'jaeger.version');
// TRACER_HOSTNAME_TAG_KEY is used to report host name of the process.
var TRACER_HOSTNAME_TAG_KEY = exports.TRACER_HOSTNAME_TAG_KEY = 'hostname';
var TRACER_HOSTNAME_TAG_KEY = (exports.TRACER_HOSTNAME_TAG_KEY = 'hostname');
// TRACER_CLIENT_ID_TAG_KEY is used to report client ID of the process.
var TRACER_CLIENT_ID_TAG_KEY = exports.TRACER_CLIENT_ID_TAG_KEY = 'client-uuid';
var TRACER_CLIENT_ID_TAG_KEY = (exports.TRACER_CLIENT_ID_TAG_KEY = 'client-uuid');
// PROCESS_IP used to report ip of the process.
var PROCESS_IP = exports.PROCESS_IP = 'ip';
var PROCESS_IP = (exports.PROCESS_IP = 'ip');
// SAMPLER_TYPE_TAG_KEY reports which sampler was used on the root span.
var SAMPLER_TYPE_TAG_KEY = exports.SAMPLER_TYPE_TAG_KEY = 'sampler.type';
var SAMPLER_TYPE_TAG_KEY = (exports.SAMPLER_TYPE_TAG_KEY = 'sampler.type');
// SAMPLER_PARAM_TAG_KEY reports which sampler was used on the root span.
var SAMPLER_PARAM_TAG_KEY = exports.SAMPLER_PARAM_TAG_KEY = 'sampler.param';
var SAMPLER_PARAM_TAG_KEY = (exports.SAMPLER_PARAM_TAG_KEY = 'sampler.param');
// SAMPLER_TYPE_CONST is the type of the sampler that always makes the same decision.
var SAMPLER_TYPE_CONST = exports.SAMPLER_TYPE_CONST = 'const';
var SAMPLER_TYPE_CONST = (exports.SAMPLER_TYPE_CONST = 'const');
// SAMPLER_TYPE_PROBABILISTIC is the type of sampler that samples traces
// with a certain fixed probability.
var SAMPLER_TYPE_PROBABILISTIC = exports.SAMPLER_TYPE_PROBABILISTIC = 'probabilistic';
var SAMPLER_TYPE_PROBABILISTIC = (exports.SAMPLER_TYPE_PROBABILISTIC = 'probabilistic');
// SAMPLER_TYPE_RATE_LIMITING is the type of sampler that samples
// only up to a fixed number of traces per second.
var SAMPLER_TYPE_RATE_LIMITING = exports.SAMPLER_TYPE_RATE_LIMITING = 'ratelimiting';
var SAMPLER_TYPE_RATE_LIMITING = (exports.SAMPLER_TYPE_RATE_LIMITING = 'ratelimiting');
// SAMPLER_TYPE_LOWER_BOUND is the type of sampler that samples
// only up to a fixed number of traces per second.
var SAMPLER_TYPE_LOWER_BOUND = exports.SAMPLER_TYPE_LOWER_BOUND = 'lowerbound';
var SAMPLER_TYPE_LOWER_BOUND = (exports.SAMPLER_TYPE_LOWER_BOUND = 'lowerbound');
// SAMPLER_TYPE_REMOTE is the type of sampler that polls Jaeger agent for sampling strategy.
var SAMPLER_TYPE_REMOTE = exports.SAMPLER_TYPE_REMOTE = 'remote';
var SAMPLER_TYPE_REMOTE = (exports.SAMPLER_TYPE_REMOTE = 'remote');

@@ -65,3 +65,3 @@ // JAEGER_DEBUG_HEADER is the name of an HTTP header or a TextMap carrier key which,

// trace can be found in the UI using this value as a correlation ID.
var JAEGER_DEBUG_HEADER = exports.JAEGER_DEBUG_HEADER = 'jaeger-debug-id';
var JAEGER_DEBUG_HEADER = (exports.JAEGER_DEBUG_HEADER = 'jaeger-debug-id');

@@ -71,9 +71,9 @@ // JaegerBaggageHeader is the name of the HTTP header that is used to submit baggage.

// a root span does not exist.
var JAEGER_BAGGAGE_HEADER = exports.JAEGER_BAGGAGE_HEADER = 'jaeger-baggage';
var JAEGER_BAGGAGE_HEADER = (exports.JAEGER_BAGGAGE_HEADER = 'jaeger-baggage');
// TRACER_BAGGAGE_HEADER_PREFIX is the default prefix used for saving baggage to a carrier.
var TRACER_BAGGAGE_HEADER_PREFIX = exports.TRACER_BAGGAGE_HEADER_PREFIX = 'uberctx-';
var TRACER_BAGGAGE_HEADER_PREFIX = (exports.TRACER_BAGGAGE_HEADER_PREFIX = 'uberctx-');
// TRACER_STATE_HEADER_NAME is the header key used for a span's serialized context.
var TRACER_STATE_HEADER_NAME = exports.TRACER_STATE_HEADER_NAME = 'uber-trace-id';
//# sourceMappingURL=constants.js.map
var TRACER_STATE_HEADER_NAME = (exports.TRACER_STATE_HEADER_NAME = 'uber-trace-id');
//# sourceMappingURL=constants.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

var DefaultContext = function () {
var DefaultContext = (function() {
function DefaultContext() {

@@ -29,18 +48,21 @@ _classCallCheck(this, DefaultContext);

_createClass(DefaultContext, [{
key: "setSpan",
value: function setSpan(span) {
this._span = span;
}
}, {
key: "getSpan",
value: function getSpan() {
return this._span;
}
}]);
_createClass(DefaultContext, [
{
key: 'setSpan',
value: function setSpan(span) {
this._span = span;
},
},
{
key: 'getSpan',
value: function getSpan() {
return this._span;
},
},
]);
return DefaultContext;
}();
})();
exports.default = DefaultContext;
//# sourceMappingURL=default_context.js.map
//# sourceMappingURL=default_context.js.map

@@ -83,5 +83,20 @@ 'use strict';

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 _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 }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}

@@ -125,4 +140,4 @@ // Copyright (c) 2016 Uber Technologies, Inc.

PrometheusMetricsFactory: _prometheus2.default,
opentracing: opentracing
opentracing: opentracing,
};
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

@@ -7,2 +7,1 @@ # jaeger-idl [![Build Status][ci-img]][ci]

[ci]: https://travis-ci.org/uber/jaeger-idl

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

var NullLogger = function () {
var NullLogger = (function() {
function NullLogger() {

@@ -29,14 +48,17 @@ _classCallCheck(this, NullLogger);

_createClass(NullLogger, [{
key: "info",
value: function info(msg) {}
}, {
key: "error",
value: function error(msg) {}
}]);
_createClass(NullLogger, [
{
key: 'info',
value: function info(msg) {},
},
{
key: 'error',
value: function error(msg) {},
},
]);
return NullLogger;
}();
})();
exports.default = NullLogger;
//# sourceMappingURL=logger.js.map
//# sourceMappingURL=logger.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -28,3 +32,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

state: 'started',
sampled: 'y'
sampled: 'y',
});

@@ -34,3 +38,3 @@

state: 'started',
sampled: 'n'
sampled: 'n',
});

@@ -40,3 +44,3 @@

state: 'joined',
sampled: 'y'
sampled: 'y',
});

@@ -46,3 +50,3 @@

state: 'joined',
sampled: 'n'
sampled: 'n',
});

@@ -53,7 +57,7 @@

this.spansStartedSampled = this._factory.createCounter('jaeger:started_spans', {
sampled: 'y'
sampled: 'y',
});
this.spansStartedNotSampled = this._factory.createCounter('jaeger:started_spans', {
sampled: 'n'
sampled: 'n',
});

@@ -64,11 +68,11 @@

this.reporterSuccess = this._factory.createCounter('jaeger:reporter_spans', {
result: 'ok'
result: 'ok',
});
this.reporterFailure = this._factory.createCounter('jaeger:reporter_spans', {
result: 'err'
result: 'err',
});
this.reporterDropped = this._factory.createCounter('jaeger:reporter_spans', {
result: 'dropped'
result: 'dropped',
});

@@ -79,23 +83,23 @@

this.samplerRetrieved = this._factory.createCounter('jaeger:sampler_queries', {
result: 'ok'
result: 'ok',
});
this.samplerQueryFailure = this._factory.createCounter('jaeger:sampler_queries', {
result: 'err'
result: 'err',
});
this.samplerUpdated = this._factory.createCounter('jaeger:sampler_updates', {
result: 'ok'
result: 'ok',
});
this.samplerUpdateFailure = this._factory.createCounter('jaeger:sampler_updates', {
result: 'err'
result: 'err',
});
this.baggageUpdateSuccess = this._factory.createCounter('jaeger:baggage_updates', {
result: 'ok'
result: 'ok',
});
this.baggageUpdateFailure = this._factory.createCounter('jaeger:baggage_updates', {
result: 'err'
result: 'err',
});

@@ -108,7 +112,7 @@

this.throttlerUpdateSuccess = this._factory.createCounter('jaeger:throttler_updates', {
result: 'ok'
result: 'ok',
});
this.throttlerUpdateFailure = this._factory.createCounter('jaeger:throttler_updates', {
result: 'err'
result: 'err',
});

@@ -118,2 +122,2 @@ };

exports.default = Metrics;
//# sourceMappingURL=metrics.js.map
//# sourceMappingURL=metrics.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

var NoopCounter = function () {
var NoopCounter = (function() {
function NoopCounter() {

@@ -29,11 +48,13 @@ _classCallCheck(this, NoopCounter);

_createClass(NoopCounter, [{
key: "increment",
value: function increment(delta) {}
}]);
_createClass(NoopCounter, [
{
key: 'increment',
value: function increment(delta) {},
},
]);
return NoopCounter;
}();
})();
exports.default = NoopCounter;
//# sourceMappingURL=counter.js.map
//# sourceMappingURL=counter.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

var NoopGauge = function () {
var NoopGauge = (function() {
function NoopGauge() {

@@ -29,11 +48,13 @@ _classCallCheck(this, NoopGauge);

_createClass(NoopGauge, [{
key: "update",
value: function update(value) {}
}]);
_createClass(NoopGauge, [
{
key: 'update',
value: function update(value) {},
},
]);
return NoopGauge;
}();
})();
exports.default = NoopGauge;
//# sourceMappingURL=gauge.js.map
//# sourceMappingURL=gauge.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -32,7 +47,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var NoopMetricFactory = function () {
var NoopMetricFactory = (function() {
function NoopMetricFactory() {

@@ -42,23 +63,27 @@ _classCallCheck(this, NoopMetricFactory);

_createClass(NoopMetricFactory, [{
key: 'createCounter',
value: function createCounter(name, tags) {
return new _counter2.default();
}
}, {
key: 'createTimer',
value: function createTimer(name, tags) {
return new _timer2.default();
}
}, {
key: 'createGauge',
value: function createGauge(name, tags) {
return new _gauge2.default();
}
}]);
_createClass(NoopMetricFactory, [
{
key: 'createCounter',
value: function createCounter(name, tags) {
return new _counter2.default();
},
},
{
key: 'createTimer',
value: function createTimer(name, tags) {
return new _timer2.default();
},
},
{
key: 'createGauge',
value: function createGauge(name, tags) {
return new _gauge2.default();
},
},
]);
return NoopMetricFactory;
}();
})();
exports.default = NoopMetricFactory;
//# sourceMappingURL=metric_factory.js.map
//# sourceMappingURL=metric_factory.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

var NoopTimer = function () {
var NoopTimer = (function() {
function NoopTimer() {

@@ -29,11 +48,13 @@ _classCallCheck(this, NoopTimer);

_createClass(NoopTimer, [{
key: "record",
value: function record(value) {}
}]);
_createClass(NoopTimer, [
{
key: 'record',
value: function record(value) {},
},
]);
return NoopTimer;
}();
})();
exports.default = NoopTimer;
//# sourceMappingURL=timer.js.map
//# sourceMappingURL=timer.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2018 Jaeger Author.

var CounterPromWrapper = function () {
var CounterPromWrapper = (function() {
function CounterPromWrapper(counter) {

@@ -31,13 +50,15 @@ _classCallCheck(this, CounterPromWrapper);

_createClass(CounterPromWrapper, [{
key: 'increment',
value: function increment(delta) {
this._counter.inc(delta);
}
}]);
_createClass(CounterPromWrapper, [
{
key: 'increment',
value: function increment(delta) {
this._counter.inc(delta);
},
},
]);
return CounterPromWrapper;
}();
})();
var GaugePromWrapper = function () {
var GaugePromWrapper = (function() {
function GaugePromWrapper(gauge) {

@@ -49,14 +70,15 @@ _classCallCheck(this, GaugePromWrapper);

_createClass(GaugePromWrapper, [{
key: 'update',
value: function update(value) {
this._gauge.set(value);
}
}]);
_createClass(GaugePromWrapper, [
{
key: 'update',
value: function update(value) {
this._gauge.set(value);
},
},
]);
return GaugePromWrapper;
}();
})();
var PrometheusMetricsFactory = function () {
var PrometheusMetricsFactory = (function() {
/**

@@ -88,55 +110,59 @@ * Construct metrics factory for Prometheus

_createClass(PrometheusMetricsFactory, [{
key: '_createMetric',
value: function _createMetric(metric, name, labels) {
var _cache$key;
_createClass(PrometheusMetricsFactory, [
{
key: '_createMetric',
value: function _createMetric(metric, name, labels) {
var _cache$key;
var labelNames = [];
var labelValues = [];
for (var _key in labels) {
labelNames.push(_key);
labelValues.push(labels[_key]);
}
var key = name + ',' + labelNames.toString();
var help = name;
if (this._namespace) {
name = this._namespace + '_' + name;
}
if (!(key in this._cache)) {
this._cache[key] = new metric({ name: name, help: help, labelNames: labelNames });
}
return labelValues.length > 0 ? (_cache$key = this._cache[key]).labels.apply(_cache$key, labelValues) : this._cache[key];
}
var labelNames = [];
var labelValues = [];
for (var _key in labels) {
labelNames.push(_key);
labelValues.push(labels[_key]);
}
var key = name + ',' + labelNames.toString();
var help = name;
if (this._namespace) {
name = this._namespace + '_' + name;
}
if (!(key in this._cache)) {
this._cache[key] = new metric({ name: name, help: help, labelNames: labelNames });
}
return labelValues.length > 0
? (_cache$key = this._cache[key]).labels.apply(_cache$key, labelValues)
: this._cache[key];
},
/**
* Create a counter metric
* @param {string} name - metric name
* @param {any} tags - labels
* @returns {Counter} - created counter metric
*/
/**
* Create a counter metric
* @param {string} name - metric name
* @param {any} tags - labels
* @returns {Counter} - created counter metric
*/
},
{
key: 'createCounter',
value: function createCounter(name, tags) {
return new CounterPromWrapper(this._createMetric(this._promClient.Counter, name, tags));
},
}, {
key: 'createCounter',
value: function createCounter(name, tags) {
return new CounterPromWrapper(this._createMetric(this._promClient.Counter, name, tags));
}
/**
* Create a gauge metric
* @param {string} name - metric name
* @param {any} tags - labels
* @returns {Gauge} - created gauge metric
*/
},
{
key: 'createGauge',
value: function createGauge(name, tags) {
return new GaugePromWrapper(this._createMetric(this._promClient.Gauge, name, tags));
},
},
]);
/**
* Create a gauge metric
* @param {string} name - metric name
* @param {any} tags - labels
* @returns {Gauge} - created gauge metric
*/
}, {
key: 'createGauge',
value: function createGauge(name, tags) {
return new GaugePromWrapper(this._createMetric(this._promClient.Gauge, name, tags));
}
}]);
return PrometheusMetricsFactory;
}();
})();
exports.default = PrometheusMetricsFactory;
//# sourceMappingURL=prometheus.js.map
//# sourceMappingURL=prometheus.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});

@@ -32,3 +32,3 @@ exports.parseCommaSeparatedBaggage = parseCommaSeparatedBaggage;

function parseCommaSeparatedBaggage(baggage, values) {
values.split(',').forEach(function (keyVal) {
values.split(',').forEach(function(keyVal) {
var splitKeyVal = keyVal.trim().split('=');

@@ -40,2 +40,2 @@ if (splitKeyVal.length == 2) {

}
//# sourceMappingURL=baggage.js.map
//# sourceMappingURL=baggage.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

var BinaryCodec = function () {
var BinaryCodec = (function() {
function BinaryCodec() {

@@ -29,16 +48,19 @@ _classCallCheck(this, BinaryCodec);

_createClass(BinaryCodec, [{
key: "extract",
value: function extract(carrier) {
return null;
}
}, {
key: "inject",
value: function inject(spanContext, carrier) {}
}]);
_createClass(BinaryCodec, [
{
key: 'extract',
value: function extract(carrier) {
return null;
},
},
{
key: 'inject',
value: function inject(spanContext, carrier) {},
},
]);
return BinaryCodec;
}();
})();
exports.default = BinaryCodec;
//# sourceMappingURL=binary_codec.js.map
//# sourceMappingURL=binary_codec.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -42,9 +57,28 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var TextMapCodec = function () {
var TextMapCodec = (function() {
function TextMapCodec() {

@@ -63,83 +97,89 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

_createClass(TextMapCodec, [{
key: '_encodeValue',
value: function _encodeValue(value) {
if (this._urlEncoding) {
return encodeURIComponent(value);
}
_createClass(TextMapCodec, [
{
key: '_encodeValue',
value: function _encodeValue(value) {
if (this._urlEncoding) {
return encodeURIComponent(value);
}
return value;
}
}, {
key: '_decodeValue',
value: function _decodeValue(value) {
// only use url-decoding if there are meta-characters '%'
if (this._urlEncoding && value.indexOf('%') > -1) {
return this._decodeURIValue(value);
}
return value;
},
},
{
key: '_decodeValue',
value: function _decodeValue(value) {
// only use url-decoding if there are meta-characters '%'
if (this._urlEncoding && value.indexOf('%') > -1) {
return this._decodeURIValue(value);
}
return value;
}
}, {
key: '_decodeURIValue',
value: function _decodeURIValue(value) {
// unfortunately, decodeURIComponent() can throw 'URIError: URI malformed' on bad strings
try {
return decodeURIComponent(value);
} catch (e) {
return value;
}
}
}, {
key: 'extract',
value: function extract(carrier) {
var spanContext = new _span_context2.default();
var baggage = {};
var debugId = '';
},
},
{
key: '_decodeURIValue',
value: function _decodeURIValue(value) {
// unfortunately, decodeURIComponent() can throw 'URIError: URI malformed' on bad strings
try {
return decodeURIComponent(value);
} catch (e) {
return value;
}
},
},
{
key: 'extract',
value: function extract(carrier) {
var spanContext = new _span_context2.default();
var baggage = {};
var debugId = '';
for (var key in carrier) {
if (Object.prototype.hasOwnProperty.call(carrier, key)) {
var lowerKey = key.toLowerCase();
if (lowerKey === this._contextKey) {
var decodedContext = _span_context2.default.fromString(this._decodeValue(carrier[key]));
if (decodedContext === null) {
this._metrics.decodingErrors.increment(1);
} else {
spanContext = decodedContext;
for (var key in carrier) {
if (Object.prototype.hasOwnProperty.call(carrier, key)) {
var lowerKey = key.toLowerCase();
if (lowerKey === this._contextKey) {
var decodedContext = _span_context2.default.fromString(this._decodeValue(carrier[key]));
if (decodedContext === null) {
this._metrics.decodingErrors.increment(1);
} else {
spanContext = decodedContext;
}
} else if (lowerKey === constants.JAEGER_DEBUG_HEADER) {
debugId = this._decodeValue(carrier[key]);
} else if (lowerKey === constants.JAEGER_BAGGAGE_HEADER) {
(0, _baggage.parseCommaSeparatedBaggage)(baggage, this._decodeValue(carrier[key]));
} else if (_util2.default.startsWith(lowerKey, this._baggagePrefix)) {
var keyWithoutPrefix = key.substring(this._baggagePrefix.length);
baggage[keyWithoutPrefix] = this._decodeValue(carrier[key]);
}
} else if (lowerKey === constants.JAEGER_DEBUG_HEADER) {
debugId = this._decodeValue(carrier[key]);
} else if (lowerKey === constants.JAEGER_BAGGAGE_HEADER) {
(0, _baggage.parseCommaSeparatedBaggage)(baggage, this._decodeValue(carrier[key]));
} else if (_util2.default.startsWith(lowerKey, this._baggagePrefix)) {
var keyWithoutPrefix = key.substring(this._baggagePrefix.length);
baggage[keyWithoutPrefix] = this._decodeValue(carrier[key]);
}
}
}
spanContext.debugId = debugId;
spanContext.baggage = baggage;
return spanContext;
}
}, {
key: 'inject',
value: function inject(spanContext, carrier) {
var stringSpanContext = spanContext.toString();
carrier[this._contextKey] = stringSpanContext; // no need to encode this
spanContext.debugId = debugId;
spanContext.baggage = baggage;
return spanContext;
},
},
{
key: 'inject',
value: function inject(spanContext, carrier) {
var stringSpanContext = spanContext.toString();
carrier[this._contextKey] = stringSpanContext; // no need to encode this
var baggage = spanContext.baggage;
for (var key in baggage) {
if (Object.prototype.hasOwnProperty.call(baggage, key)) {
var value = this._encodeValue(spanContext.baggage[key]);
carrier['' + this._baggagePrefix + key] = value;
var baggage = spanContext.baggage;
for (var key in baggage) {
if (Object.prototype.hasOwnProperty.call(baggage, key)) {
var value = this._encodeValue(spanContext.baggage[key]);
carrier['' + this._baggagePrefix + key] = value;
}
}
}
}
}]);
},
},
]);
return TextMapCodec;
}();
})();
exports.default = TextMapCodec;
//# sourceMappingURL=text_map_codec.js.map
//# sourceMappingURL=text_map_codec.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2017 The Jaeger Authors

@@ -42,7 +57,26 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -55,3 +89,3 @@ var ZIPKIN_PARENTSPAN_HEADER = 'x-b3-parentspanid';

var ZipkinB3TextMapCodec = function () {
var ZipkinB3TextMapCodec = (function() {
function ZipkinB3TextMapCodec() {

@@ -68,152 +102,165 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

_createClass(ZipkinB3TextMapCodec, [{
key: '_encodeValue',
value: function _encodeValue(value) {
if (this._urlEncoding) {
return encodeURIComponent(value);
}
_createClass(ZipkinB3TextMapCodec, [
{
key: '_encodeValue',
value: function _encodeValue(value) {
if (this._urlEncoding) {
return encodeURIComponent(value);
}
return value;
}
}, {
key: '_decodeValue',
value: function _decodeValue(value) {
// only use url-decoding if there are meta-characters '%'
if (this._urlEncoding && value.indexOf('%') > -1) {
return this._decodeURIValue(value);
}
return value;
},
},
{
key: '_decodeValue',
value: function _decodeValue(value) {
// only use url-decoding if there are meta-characters '%'
if (this._urlEncoding && value.indexOf('%') > -1) {
return this._decodeURIValue(value);
}
return value;
}
}, {
key: '_isValidZipkinId',
value: function _isValidZipkinId(value) {
// Validates a zipkin trace/spanID by attempting to parse it as a
// string of hex digits. This "validation" is not entirely rigorous,
// but equivalent to what is performed in the TextMapCodec.
//
// Note: due to the way parseInt works, this does not guarantee that
// the string is composed *entirely* of hex digits.
//
// > If parseInt encounters a character that is not a numeral in the
// > specified radix, it ignores it and all succeeding characters and
// > returns the integer value parsed up to that point.
//
// Note: The Number type in JS cannot represent the full range of 64bit
// unsigned ints, so using parseInt() on strings representing 64bit hex
// numbers only returns an approximation of the actual value.
// Fortunately, we do not depend on the returned value, we are only
// using it to validate that the string is a valid hex number (which is
// faster than doing it manually). We cannot use
// Int64(numberValue).toBuffer() because it throws exceptions on bad
// strings.
if (!value) {
return true;
}
return !isNaN(parseInt(value, 16));
}
}, {
key: '_decodeURIValue',
value: function _decodeURIValue(value) {
// unfortunately, decodeURIComponent() can throw 'URIError: URI malformed' on bad strings
try {
return decodeURIComponent(value);
} catch (e) {
return value;
}
}
}, {
key: 'extract',
value: function extract(carrier) {
var baggage = {};
var flags = 0;
var debugId = '';
var parentId = '';
var spanId = '';
var traceId = '';
},
},
{
key: '_isValidZipkinId',
value: function _isValidZipkinId(value) {
// Validates a zipkin trace/spanID by attempting to parse it as a
// string of hex digits. This "validation" is not entirely rigorous,
// but equivalent to what is performed in the TextMapCodec.
//
// Note: due to the way parseInt works, this does not guarantee that
// the string is composed *entirely* of hex digits.
//
// > If parseInt encounters a character that is not a numeral in the
// > specified radix, it ignores it and all succeeding characters and
// > returns the integer value parsed up to that point.
//
// Note: The Number type in JS cannot represent the full range of 64bit
// unsigned ints, so using parseInt() on strings representing 64bit hex
// numbers only returns an approximation of the actual value.
// Fortunately, we do not depend on the returned value, we are only
// using it to validate that the string is a valid hex number (which is
// faster than doing it manually). We cannot use
// Int64(numberValue).toBuffer() because it throws exceptions on bad
// strings.
if (!value) {
return true;
}
for (var key in carrier) {
if (Object.prototype.hasOwnProperty.call(carrier, key)) {
var lowerKey = key.toLowerCase();
return !isNaN(parseInt(value, 16));
},
},
{
key: '_decodeURIValue',
value: function _decodeURIValue(value) {
// unfortunately, decodeURIComponent() can throw 'URIError: URI malformed' on bad strings
try {
return decodeURIComponent(value);
} catch (e) {
return value;
}
},
},
{
key: 'extract',
value: function extract(carrier) {
var baggage = {};
var flags = 0;
var debugId = '';
var parentId = '';
var spanId = '';
var traceId = '';
switch (lowerKey) {
case ZIPKIN_PARENTSPAN_HEADER:
parentId = this._decodeValue(carrier[key]);
break;
case ZIPKIN_SPAN_HEADER:
spanId = this._decodeValue(carrier[key]);
break;
case ZIPKIN_TRACE_HEADER:
traceId = this._decodeValue(carrier[key]);
break;
case ZIPKIN_SAMPLED_HEADER:
flags = flags | constants.SAMPLED_MASK;
break;
case ZIPKIN_FLAGS_HEADER:
// Per https://github.com/openzipkin/b3-propagation
// "Debug is encoded as X-B3-Flags: 1"
// and
// "Debug implies Sampled."
if (carrier[key] === '1') {
flags = flags | constants.SAMPLED_MASK | constants.DEBUG_MASK;
}
break;
case constants.JAEGER_DEBUG_HEADER:
debugId = this._decodeValue(carrier[key]);
break;
case constants.JAEGER_BAGGAGE_HEADER:
(0, _baggage.parseCommaSeparatedBaggage)(baggage, this._decodeValue(carrier[key]));
break;
default:
if (_util2.default.startsWith(lowerKey, this._baggagePrefix)) {
var keyWithoutPrefix = key.substring(this._baggagePrefix.length);
baggage[keyWithoutPrefix] = this._decodeValue(carrier[key]);
}
for (var key in carrier) {
if (Object.prototype.hasOwnProperty.call(carrier, key)) {
var lowerKey = key.toLowerCase();
switch (lowerKey) {
case ZIPKIN_PARENTSPAN_HEADER:
parentId = this._decodeValue(carrier[key]);
break;
case ZIPKIN_SPAN_HEADER:
spanId = this._decodeValue(carrier[key]);
break;
case ZIPKIN_TRACE_HEADER:
traceId = this._decodeValue(carrier[key]);
break;
case ZIPKIN_SAMPLED_HEADER:
if (carrier[key] === '1' || carrier[key] === 'true') {
flags = flags | constants.SAMPLED_MASK;
}
break;
case ZIPKIN_FLAGS_HEADER:
// Per https://github.com/openzipkin/b3-propagation
// "Debug is encoded as X-B3-Flags: 1"
// and
// "Debug implies Sampled."
if (carrier[key] === '1') {
flags = flags | constants.SAMPLED_MASK | constants.DEBUG_MASK;
}
break;
case constants.JAEGER_DEBUG_HEADER:
debugId = this._decodeValue(carrier[key]);
break;
case constants.JAEGER_BAGGAGE_HEADER:
(0, _baggage.parseCommaSeparatedBaggage)(baggage, this._decodeValue(carrier[key]));
break;
default:
if (_util2.default.startsWith(lowerKey, this._baggagePrefix)) {
var keyWithoutPrefix = key.substring(this._baggagePrefix.length);
baggage[keyWithoutPrefix] = this._decodeValue(carrier[key]);
}
}
}
}
}
if (!this._isValidZipkinId(traceId) || !this._isValidZipkinId(spanId) || !this._isValidZipkinId(parentId)) {
// Use a context devoid of trace/span/parentSpan IDs (to be
// consistent with the default codec behavior), and increment a
// metric
traceId = spanId = parentId = '';
this._metrics.decodingErrors.increment(1);
}
if (
!this._isValidZipkinId(traceId) ||
!this._isValidZipkinId(spanId) ||
!this._isValidZipkinId(parentId)
) {
// Use a context devoid of trace/span/parentSpan IDs (to be
// consistent with the default codec behavior), and increment a
// metric
traceId = spanId = parentId = '';
this._metrics.decodingErrors.increment(1);
}
return _span_context2.default.withStringIds(traceId, spanId, parentId, flags, baggage, debugId);
}
}, {
key: 'inject',
value: function inject(spanContext, carrier) {
carrier[ZIPKIN_TRACE_HEADER] = spanContext.traceIdStr;
if (spanContext.parentIdStr) {
carrier[ZIPKIN_PARENTSPAN_HEADER] = spanContext.parentIdStr;
}
carrier[ZIPKIN_SPAN_HEADER] = spanContext.spanIdStr;
return _span_context2.default.withStringIds(traceId, spanId, parentId, flags, baggage, debugId);
},
},
{
key: 'inject',
value: function inject(spanContext, carrier) {
carrier[ZIPKIN_TRACE_HEADER] = spanContext.traceIdStr;
if (spanContext.parentIdStr) {
carrier[ZIPKIN_PARENTSPAN_HEADER] = spanContext.parentIdStr;
}
carrier[ZIPKIN_SPAN_HEADER] = spanContext.spanIdStr;
if (spanContext.isDebug()) {
carrier[ZIPKIN_FLAGS_HEADER] = '1';
} else {
// Only set the zipkin sampled header if we're NOT using debug.
// Per https://github.com/openzipkin/b3-propagation
// "Since Debug implies Sampled, so don't also send "X-B3-Sampled: 1"
carrier[ZIPKIN_SAMPLED_HEADER] = spanContext.isSampled() ? '1' : '0';
}
if (spanContext.isDebug()) {
carrier[ZIPKIN_FLAGS_HEADER] = '1';
} else {
// Only set the zipkin sampled header if we're NOT using debug.
// Per https://github.com/openzipkin/b3-propagation
// "Since Debug implies Sampled, so don't also send "X-B3-Sampled: 1"
carrier[ZIPKIN_SAMPLED_HEADER] = spanContext.isSampled() ? '1' : '0';
}
var baggage = spanContext.baggage;
for (var key in baggage) {
if (Object.prototype.hasOwnProperty.call(baggage, key)) {
var value = this._encodeValue(spanContext.baggage[key]);
carrier['' + this._baggagePrefix + key] = value;
var baggage = spanContext.baggage;
for (var key in baggage) {
if (Object.prototype.hasOwnProperty.call(baggage, key)) {
var value = this._encodeValue(spanContext.baggage[key]);
carrier['' + this._baggagePrefix + key] = value;
}
}
}
}
}]);
},
},
]);
return ZipkinB3TextMapCodec;
}();
})();
exports.default = ZipkinB3TextMapCodec;
//# sourceMappingURL=zipkin_b3_text_map_codec.js.map
//# sourceMappingURL=zipkin_b3_text_map_codec.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -23,3 +42,3 @@ // Copyright (c) 2016 Uber Technologies, Inc.

var RateLimiter = function () {
var RateLimiter = (function() {
function RateLimiter(creditsPerSecond, maxBalance, initBalance) {

@@ -34,39 +53,43 @@ _classCallCheck(this, RateLimiter);

_createClass(RateLimiter, [{
key: "update",
value: function update(creditsPerSecond, maxBalance) {
this._updateBalance();
this._creditsPerSecond = creditsPerSecond;
// The new balance should be proportional to the old balance.
this._balance = maxBalance * this._balance / this._maxBalance;
this._maxBalance = maxBalance;
}
}, {
key: "checkCredit",
value: function checkCredit(itemCost) {
this._updateBalance();
if (this._balance >= itemCost) {
this._balance -= itemCost;
return true;
}
return false;
}
}, {
key: "_updateBalance",
value: function _updateBalance() {
var currentTime = new Date().getTime();
var elapsedTime = (currentTime - this._lastTick) / 1000;
this._lastTick = currentTime;
_createClass(RateLimiter, [
{
key: 'update',
value: function update(creditsPerSecond, maxBalance) {
this._updateBalance();
this._creditsPerSecond = creditsPerSecond;
// The new balance should be proportional to the old balance.
this._balance = maxBalance * this._balance / this._maxBalance;
this._maxBalance = maxBalance;
},
},
{
key: 'checkCredit',
value: function checkCredit(itemCost) {
this._updateBalance();
if (this._balance >= itemCost) {
this._balance -= itemCost;
return true;
}
return false;
},
},
{
key: '_updateBalance',
value: function _updateBalance() {
var currentTime = new Date().getTime();
var elapsedTime = (currentTime - this._lastTick) / 1000;
this._lastTick = currentTime;
this._balance += elapsedTime * this._creditsPerSecond;
if (this._balance > this._maxBalance) {
this._balance = this._maxBalance;
}
}
}]);
this._balance += elapsedTime * this._creditsPerSecond;
if (this._balance > this._maxBalance) {
this._balance = this._maxBalance;
}
},
},
]);
return RateLimiter;
}();
})();
exports.default = RateLimiter;
//# sourceMappingURL=rate_limiter.js.map
//# sourceMappingURL=rate_limiter.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -24,7 +39,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var CompositeReporter = function () {
var CompositeReporter = (function() {
function CompositeReporter(reporters) {

@@ -36,48 +57,56 @@ _classCallCheck(this, CompositeReporter);

_createClass(CompositeReporter, [{
key: 'name',
value: function name() {
return 'CompositeReporter';
}
}, {
key: 'report',
value: function report(span) {
this._reporters.forEach(function (r) {
r.report(span);
});
}
}, {
key: '_compositeCallback',
value: function _compositeCallback(limit, callback) {
var count = 0;
return function () {
count++;
if (count >= limit) {
callback();
}
};
}
}, {
key: 'close',
value: function close(callback) {
var modifiedCallback = callback ? this._compositeCallback(this._reporters.length, callback) : function () {};
this._reporters.forEach(function (r) {
r.close(modifiedCallback);
});
}
}, {
key: 'setProcess',
value: function setProcess(serviceName, tags) {
this._reporters.forEach(function (r) {
if (r.setProcess) {
r.setProcess(serviceName, tags);
}
});
}
}]);
_createClass(CompositeReporter, [
{
key: 'name',
value: function name() {
return 'CompositeReporter';
},
},
{
key: 'report',
value: function report(span) {
this._reporters.forEach(function(r) {
r.report(span);
});
},
},
{
key: '_compositeCallback',
value: function _compositeCallback(limit, callback) {
var count = 0;
return function() {
count++;
if (count >= limit) {
callback();
}
};
},
},
{
key: 'close',
value: function close(callback) {
var modifiedCallback = callback
? this._compositeCallback(this._reporters.length, callback)
: function() {};
this._reporters.forEach(function(r) {
r.close(modifiedCallback);
});
},
},
{
key: 'setProcess',
value: function setProcess(serviceName, tags) {
this._reporters.forEach(function(r) {
if (r.setProcess) {
r.setProcess(serviceName, tags);
}
});
},
},
]);
return CompositeReporter;
}();
})();
exports.default = CompositeReporter;
//# sourceMappingURL=composite_reporter.js.map
//# sourceMappingURL=composite_reporter.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2018 Uber Technologies, Inc.

@@ -50,7 +65,26 @@ //

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 _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 }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -62,3 +96,3 @@ var DEFAULT_PATH = '/api/traces';

var HTTPSender = function () {
var HTTPSender = (function() {
function HTTPSender() {

@@ -73,3 +107,6 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

this._timeoutMS = options.timeoutMS || DEFAULT_TIMEOUT_MS;
this._httpAgent = this._url.protocol === 'https:' ? new _https2.default.Agent({ keepAlive: true }) : new _http2.default.Agent({ keepAlive: true });
this._httpAgent =
this._url.protocol === 'https:'
? new _https2.default.Agent({ keepAlive: true })
: new _http2.default.Agent({ keepAlive: true });

@@ -80,4 +117,7 @@ this._maxSpanBatchSize = options.maxSpanBatchSize || DEFAULT_MAX_SPAN_BATCH_SIZE;

this._jaegerThrift = new _thriftrw.Thrift({
source: _fs2.default.readFileSync(_path2.default.join(__dirname, '../jaeger-idl/thrift/jaeger.thrift'), 'ascii'),
allowOptionalArguments: true
source: _fs2.default.readFileSync(
_path2.default.join(__dirname, '../jaeger-idl/thrift/jaeger.thrift'),
'ascii'
),
allowOptionalArguments: true,
});

@@ -94,82 +134,94 @@

'Content-Type': 'application/x-thrift',
Connection: 'keep-alive'
Connection: 'keep-alive',
},
agent: this._httpAgent,
timeout: this._timeoutMS
timeout: this._timeoutMS,
};
}
_createClass(HTTPSender, [{
key: 'setProcess',
value: function setProcess(process) {
// Go ahead and initialize the Thrift batch that we will reuse for each
// flush.
this._batch = new this._jaegerThrift.Batch({
process: _sender_utils2.default.convertProcessToThrift(this._jaegerThrift, process),
spans: []
});
}
}, {
key: 'append',
value: function append(span, callback) {
this._batch.spans.push(new this._jaegerThrift.Span(span));
_createClass(HTTPSender, [
{
key: 'setProcess',
value: function setProcess(process) {
// Go ahead and initialize the Thrift batch that we will reuse for each
// flush.
this._batch = new this._jaegerThrift.Batch({
process: _sender_utils2.default.convertProcessToThrift(this._jaegerThrift, process),
spans: [],
});
},
},
{
key: 'append',
value: function append(span, callback) {
this._batch.spans.push(new this._jaegerThrift.Span(span));
if (this._batch.spans.length >= this._maxSpanBatchSize) {
this.flush(callback);
return;
}
_sender_utils2.default.invokeCallback(callback, 0);
}
}, {
key: 'flush',
value: function flush(callback) {
var _this = this;
var numSpans = this._batch.spans.length;
if (!numSpans) {
if (this._batch.spans.length >= this._maxSpanBatchSize) {
this.flush(callback);
return;
}
_sender_utils2.default.invokeCallback(callback, 0);
return;
}
},
},
{
key: 'flush',
value: function flush(callback) {
var _this = this;
var result = this._jaegerThrift.Batch.rw.toBuffer(this._batch);
if (result.err) {
_sender_utils2.default.invokeCallback(callback, numSpans, 'Error encoding Thrift batch: ' + result.err);
return;
}
var numSpans = this._batch.spans.length;
if (!numSpans) {
_sender_utils2.default.invokeCallback(callback, 0);
return;
}
this._reset();
var result = this._jaegerThrift.Batch.rw.toBuffer(this._batch);
if (result.err) {
_sender_utils2.default.invokeCallback(
callback,
numSpans,
'Error encoding Thrift batch: ' + result.err
);
return;
}
var requester = this._url.protocol === 'https:' ? _https2.default.request : _http2.default.request;
this._reset();
var req = requester(this._httpOptions, function (resp) {
_sender_utils2.default.invokeCallback(callback, numSpans);
});
var requester = this._url.protocol === 'https:' ? _https2.default.request : _http2.default.request;
req.on('error', function (err) {
var error = 'error sending spans over HTTP: ' + err;
_this._logger.error(error);
_sender_utils2.default.invokeCallback(callback, numSpans, error);
});
req.write(result.value);
req.end();
}
}, {
key: '_reset',
value: function _reset() {
this._batch.spans = [];
}
}, {
key: 'close',
value: function close() {
// Older node versions don't have this.
if (this._httpAgent.destroy) {
this._httpAgent.destroy();
}
}
}]);
var req = requester(this._httpOptions, function(resp) {
// consume response data to free up memory
resp.resume();
_sender_utils2.default.invokeCallback(callback, numSpans);
});
req.on('error', function(err) {
var error = 'error sending spans over HTTP: ' + err;
_this._logger.error(error);
_sender_utils2.default.invokeCallback(callback, numSpans, error);
});
req.write(result.value);
req.end();
},
},
{
key: '_reset',
value: function _reset() {
this._batch.spans = [];
},
},
{
key: 'close',
value: function close() {
// Older node versions don't have this.
if (this._httpAgent.destroy) {
this._httpAgent.destroy();
}
},
},
]);
return HTTPSender;
}();
})();
exports.default = HTTPSender;
//# sourceMappingURL=http_sender.js.map
//# sourceMappingURL=http_sender.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -28,7 +43,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var InMemoryReporter = function () {
var InMemoryReporter = (function() {
function InMemoryReporter() {

@@ -40,43 +61,50 @@ _classCallCheck(this, InMemoryReporter);

_createClass(InMemoryReporter, [{
key: 'name',
value: function name() {
return 'InMemoryReporter';
}
}, {
key: 'report',
value: function report(span) {
this._spans.push(span);
}
}, {
key: 'clear',
value: function clear() {
this._spans = [];
}
}, {
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
}
}, {
key: 'setProcess',
value: function setProcess(serviceName, tags) {
this._process = {
serviceName: serviceName,
tags: _thrift2.default.getThriftTags(tags)
};
}
}, {
key: 'spans',
get: function get() {
return this._spans;
}
}]);
_createClass(InMemoryReporter, [
{
key: 'name',
value: function name() {
return 'InMemoryReporter';
},
},
{
key: 'report',
value: function report(span) {
this._spans.push(span);
},
},
{
key: 'clear',
value: function clear() {
this._spans = [];
},
},
{
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
},
},
{
key: 'setProcess',
value: function setProcess(serviceName, tags) {
this._process = {
serviceName: serviceName,
tags: _thrift2.default.getThriftTags(tags),
};
},
},
{
key: 'spans',
get: function get() {
return this._spans;
},
},
]);
return InMemoryReporter;
}();
})();
exports.default = InMemoryReporter;
//# sourceMappingURL=in_memory_reporter.js.map
//# sourceMappingURL=in_memory_reporter.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -28,7 +43,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var LoggingReporter = function () {
var LoggingReporter = (function() {
function LoggingReporter(logger) {

@@ -40,28 +61,33 @@ _classCallCheck(this, LoggingReporter);

_createClass(LoggingReporter, [{
key: 'report',
value: function report(span) {
this._logger.info('Reporting span ' + span.context().toString());
}
}, {
key: 'name',
value: function name() {
return 'LoggingReporter';
}
}, {
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
}
}, {
key: 'setProcess',
value: function setProcess(serviceName, tags) {}
}]);
_createClass(LoggingReporter, [
{
key: 'report',
value: function report(span) {
this._logger.info('Reporting span ' + span.context().toString());
},
},
{
key: 'name',
value: function name() {
return 'LoggingReporter';
},
},
{
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
},
},
{
key: 'setProcess',
value: function setProcess(serviceName, tags) {},
},
]);
return LoggingReporter;
}();
})();
exports.default = LoggingReporter;
//# sourceMappingURL=logging_reporter.js.map
//# sourceMappingURL=logging_reporter.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -24,7 +39,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var NoopReporter = function () {
var NoopReporter = (function() {
function NoopReporter() {

@@ -34,26 +55,31 @@ _classCallCheck(this, NoopReporter);

_createClass(NoopReporter, [{
key: 'name',
value: function name() {
return 'NoopReporter';
}
}, {
key: 'report',
value: function report(span) {}
}, {
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
}
}, {
key: 'setProcess',
value: function setProcess(serviceName, tags) {}
}]);
_createClass(NoopReporter, [
{
key: 'name',
value: function name() {
return 'NoopReporter';
},
},
{
key: 'report',
value: function report(span) {},
},
{
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
},
},
{
key: 'setProcess',
value: function setProcess(serviceName, tags) {},
},
]);
return NoopReporter;
}();
})();
exports.default = NoopReporter;
//# sourceMappingURL=noop_reporter.js.map
//# sourceMappingURL=noop_reporter.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -36,9 +51,15 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var DEFAULT_BUFFER_FLUSH_INTERVAL_MILLIS = 1000;
var RemoteReporter = function () {
var RemoteReporter = (function() {
function RemoteReporter(sender) {

@@ -51,3 +72,3 @@ var _this = this;

this._appendCallback = function (numSpans, err) {
this._appendCallback = function(numSpans, err) {
if (err) {

@@ -68,3 +89,3 @@ _this._logger.error('Failed to append spans in reporter: ' + err);

this._sender = sender;
this._intervalHandle = setInterval(function () {
this._intervalHandle = setInterval(function() {
_this.flush();

@@ -75,67 +96,74 @@ }, this._bufferFlushInterval);

_createClass(RemoteReporter, [{
key: 'name',
value: function name() {
return 'RemoteReporter';
}
}, {
key: 'report',
value: function report(span) {
var thriftSpan = _thrift2.default.spanToThrift(span);
this._sender.append(thriftSpan, this._appendCallback);
}
}, {
key: '_invokeCallback',
value: function _invokeCallback(callback) {
if (callback) {
callback();
}
}
}, {
key: 'flush',
value: function flush(callback) {
var _this2 = this;
_createClass(RemoteReporter, [
{
key: 'name',
value: function name() {
return 'RemoteReporter';
},
},
{
key: 'report',
value: function report(span) {
var thriftSpan = _thrift2.default.spanToThrift(span);
this._sender.append(thriftSpan, this._appendCallback);
},
},
{
key: '_invokeCallback',
value: function _invokeCallback(callback) {
if (callback) {
callback();
}
},
},
{
key: 'flush',
value: function flush(callback) {
var _this2 = this;
if (this._process === undefined) {
this._logger.error('Failed to flush since process is not set.');
this._invokeCallback(callback);
return;
}
this._sender.flush(function (numSpans, err) {
if (err) {
_this2._logger.error('Failed to flush spans in reporter: ' + err);
_this2._metrics.reporterFailure.increment(numSpans);
} else {
_this2._metrics.reporterSuccess.increment(numSpans);
if (this._process === undefined) {
this._logger.error('Failed to flush since process is not set.');
this._invokeCallback(callback);
return;
}
_this2._invokeCallback(callback);
});
}
}, {
key: 'close',
value: function close(callback) {
var _this3 = this;
this._sender.flush(function(numSpans, err) {
if (err) {
_this2._logger.error('Failed to flush spans in reporter: ' + err);
_this2._metrics.reporterFailure.increment(numSpans);
} else {
_this2._metrics.reporterSuccess.increment(numSpans);
}
_this2._invokeCallback(callback);
});
},
},
{
key: 'close',
value: function close(callback) {
var _this3 = this;
clearInterval(this._intervalHandle);
this.flush(function () {
_this3._sender.close();
_this3._invokeCallback(callback);
});
}
}, {
key: 'setProcess',
value: function setProcess(serviceName, tags) {
this._process = {
serviceName: serviceName,
tags: _thrift2.default.getThriftTags(tags)
};
clearInterval(this._intervalHandle);
this.flush(function() {
_this3._sender.close();
_this3._invokeCallback(callback);
});
},
},
{
key: 'setProcess',
value: function setProcess(serviceName, tags) {
this._process = {
serviceName: serviceName,
tags: _thrift2.default.getThriftTags(tags),
};
this._sender.setProcess(this._process);
}
}]);
this._sender.setProcess(this._process);
},
},
]);
return RemoteReporter;
}();
})();
exports.default = RemoteReporter;
//# sourceMappingURL=remote_reporter.js.map
//# sourceMappingURL=remote_reporter.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2018 Uber Technologies, Inc.

@@ -22,5 +37,9 @@ //

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var SenderUtils = function () {
var SenderUtils = (function() {
function SenderUtils() {

@@ -30,29 +49,32 @@ _classCallCheck(this, SenderUtils);

_createClass(SenderUtils, null, [{
key: 'invokeCallback',
value: function invokeCallback(callback, numSpans, error) {
if (callback) {
callback(numSpans, error);
}
}
}, {
key: 'convertProcessToThrift',
value: function convertProcessToThrift(t, process) {
var tagMessages = [];
for (var j = 0; j < process.tags.length; j++) {
var tag = process.tags[j];
tagMessages.push(new t.Tag(tag));
}
_createClass(SenderUtils, null, [
{
key: 'invokeCallback',
value: function invokeCallback(callback, numSpans, error) {
if (callback) {
callback(numSpans, error);
}
},
},
{
key: 'convertProcessToThrift',
value: function convertProcessToThrift(t, process) {
var tagMessages = [];
for (var j = 0; j < process.tags.length; j++) {
var tag = process.tags[j];
tagMessages.push(new t.Tag(tag));
}
return new t.Process({
serviceName: process.serviceName,
tags: tagMessages
});
}
}]);
return new t.Process({
serviceName: process.serviceName,
tags: tagMessages,
});
},
},
]);
return SenderUtils;
}();
})();
exports.default = SenderUtils;
//# sourceMappingURL=sender_utils.js.map
//# sourceMappingURL=sender_utils.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -42,5 +57,11 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -51,3 +72,3 @@ var HOST = 'localhost';

var UDPSender = function () {
var UDPSender = (function() {
// size of currently batched spans as Thrift bytes

@@ -67,3 +88,3 @@

this._client = _dgram2.default.createSocket('udp4');
this._client.on('error', function (err) {
this._client.on('error', function(err) {
_this._logger.error('error sending spans over UDP: ' + err);

@@ -74,7 +95,10 @@ });

allowOptionalArguments: true,
allowFilesystemAccess: true
allowFilesystemAccess: true,
});
this._jaegerThrift = new _thriftrw.Thrift({
source: _fs2.default.readFileSync(_path2.default.join(__dirname, '../jaeger-idl/thrift/jaeger.thrift'), 'ascii'),
allowOptionalArguments: true
source: _fs2.default.readFileSync(
_path2.default.join(__dirname, '../jaeger-idl/thrift/jaeger.thrift'),
'ascii'
),
allowOptionalArguments: true,
});

@@ -84,135 +108,167 @@ this._totalSpanBytes = 0;

_createClass(UDPSender, [
{
key: '_calcBatchSize',
value: function _calcBatchSize(batch) {
return this._agentThrift.Agent.emitBatch.argumentsMessageRW.byteLength(
this._convertBatchToThriftMessage()
).length;
},
},
{
key: '_calcSpanSize',
value: function _calcSpanSize(span) {
return this._jaegerThrift.Span.rw.byteLength(new this._jaegerThrift.Span(span));
},
},
{
key: 'setProcess',
value: function setProcess(process) {
// This function is only called once during reporter construction, and thus will
// give us the length of the batch before any spans have been added to the span
// list in batch.
this._process = process;
this._batch = {
process: this._process,
spans: [],
};
_createClass(UDPSender, [{
key: '_calcBatchSize',
value: function _calcBatchSize(batch) {
return this._agentThrift.Agent.emitBatch.argumentsMessageRW.byteLength(this._convertBatchToThriftMessage()).length;
}
}, {
key: '_calcSpanSize',
value: function _calcSpanSize(span) {
return this._jaegerThrift.Span.rw.byteLength(new this._jaegerThrift.Span(span));
}
}, {
key: 'setProcess',
value: function setProcess(process) {
// This function is only called once during reporter construction, and thus will
// give us the length of the batch before any spans have been added to the span
// list in batch.
this._process = process;
this._batch = {
process: this._process,
spans: []
};
this._thriftProcessMessage = _sender_utils2.default.convertProcessToThrift(
this._jaegerThrift,
process
);
this._emitSpanBatchOverhead = this._calcBatchSize(this._batch);
this._maxSpanBytes = this._maxPacketSize - this._emitSpanBatchOverhead;
},
},
{
key: 'append',
value: function append(span, callback) {
var _this2 = this;
this._thriftProcessMessage = _sender_utils2.default.convertProcessToThrift(this._jaegerThrift, process);
this._emitSpanBatchOverhead = this._calcBatchSize(this._batch);
this._maxSpanBytes = this._maxPacketSize - this._emitSpanBatchOverhead;
}
}, {
key: 'append',
value: function append(span, callback) {
var _this2 = this;
var _calcSpanSize2 = this._calcSpanSize(span),
var _calcSpanSize2 = this._calcSpanSize(span),
err = _calcSpanSize2.err,
length = _calcSpanSize2.length;
if (err) {
_sender_utils2.default.invokeCallback(callback, 1, 'error converting span to Thrift: ' + err);
return;
}
var spanSize = length;
if (spanSize > this._maxSpanBytes) {
_sender_utils2.default.invokeCallback(callback, 1, 'span size ' + spanSize + ' is larger than maxSpanSize ' + this._maxSpanBytes);
return;
}
if (err) {
_sender_utils2.default.invokeCallback(callback, 1, 'error converting span to Thrift: ' + err);
return;
}
var spanSize = length;
if (spanSize > this._maxSpanBytes) {
_sender_utils2.default.invokeCallback(
callback,
1,
'span size ' + spanSize + ' is larger than maxSpanSize ' + this._maxSpanBytes
);
return;
}
if (this._totalSpanBytes + spanSize <= this._maxSpanBytes) {
this._batch.spans.push(span);
this._totalSpanBytes += spanSize;
if (this._totalSpanBytes < this._maxSpanBytes) {
// still have space in the buffer, don't flush it yet
if (this._totalSpanBytes + spanSize <= this._maxSpanBytes) {
this._batch.spans.push(span);
this._totalSpanBytes += spanSize;
if (this._totalSpanBytes < this._maxSpanBytes) {
// still have space in the buffer, don't flush it yet
_sender_utils2.default.invokeCallback(callback, 0);
return;
}
// buffer size === this._maxSpanBytes
this.flush(callback);
return;
}
this.flush(function(numSpans, err) {
// TODO theoretically we can have buffer overflow here too, if many spans were appended during flush()
_this2._batch.spans.push(span);
_this2._totalSpanBytes += spanSize;
_sender_utils2.default.invokeCallback(callback, numSpans, err);
});
},
},
{
key: 'flush',
value: function flush(callback) {
var numSpans = this._batch.spans.length;
if (!numSpans) {
_sender_utils2.default.invokeCallback(callback, 0);
return;
}
// buffer size === this._maxSpanBytes
this.flush(callback);
return;
}
this.flush(function (numSpans, err) {
// TODO theoretically we can have buffer overflow here too, if many spans were appended during flush()
_this2._batch.spans.push(span);
_this2._totalSpanBytes += spanSize;
_sender_utils2.default.invokeCallback(callback, numSpans, err);
});
}
}, {
key: 'flush',
value: function flush(callback) {
var numSpans = this._batch.spans.length;
if (!numSpans) {
_sender_utils2.default.invokeCallback(callback, 0);
return;
}
var bufferLen = this._totalSpanBytes + this._emitSpanBatchOverhead;
var thriftBuffer = new Buffer(bufferLen);
var writeResult = this._agentThrift.Agent.emitBatch.argumentsMessageRW.writeInto(
this._convertBatchToThriftMessage(),
thriftBuffer,
0
);
this._reset();
var bufferLen = this._totalSpanBytes + this._emitSpanBatchOverhead;
var thriftBuffer = new Buffer(bufferLen);
var writeResult = this._agentThrift.Agent.emitBatch.argumentsMessageRW.writeInto(this._convertBatchToThriftMessage(), thriftBuffer, 0);
this._reset();
if (writeResult.err) {
_sender_utils2.default.invokeCallback(callback, numSpans, 'error writing Thrift object: ' + writeResult.err);
return;
}
// Having the error callback here does not prevent uncaught exception from being thrown,
// that's why in the constructor we also add a general on('error') handler.
this._client.send(thriftBuffer, 0, thriftBuffer.length, this._port, this._host, function (err, sent) {
if (err) {
var error = err && 'error sending spans over UDP: ' + err + ', packet size: ' + writeResult.offset + ', bytes sent: ' + sent;
_sender_utils2.default.invokeCallback(callback, numSpans, error);
} else {
_sender_utils2.default.invokeCallback(callback, numSpans);
if (writeResult.err) {
_sender_utils2.default.invokeCallback(
callback,
numSpans,
'error writing Thrift object: ' + writeResult.err
);
return;
}
});
}
}, {
key: '_convertBatchToThriftMessage',
value: function _convertBatchToThriftMessage() {
var spanMessages = [];
for (var i = 0; i < this._batch.spans.length; i++) {
var span = this._batch.spans[i];
spanMessages.push(new this._jaegerThrift.Span(span));
}
return new this._agentThrift.Agent.emitBatch.ArgumentsMessage({
version: 1,
id: 0,
body: {
batch: new this._jaegerThrift.Batch({
process: this._thriftProcessMessage,
spans: spanMessages
})
// Having the error callback here does not prevent uncaught exception from being thrown,
// that's why in the constructor we also add a general on('error') handler.
this._client.send(thriftBuffer, 0, thriftBuffer.length, this._port, this._host, function(err, sent) {
if (err) {
var error =
err &&
'error sending spans over UDP: ' +
err +
', packet size: ' +
writeResult.offset +
', bytes sent: ' +
sent;
_sender_utils2.default.invokeCallback(callback, numSpans, error);
} else {
_sender_utils2.default.invokeCallback(callback, numSpans);
}
});
},
},
{
key: '_convertBatchToThriftMessage',
value: function _convertBatchToThriftMessage() {
var spanMessages = [];
for (var i = 0; i < this._batch.spans.length; i++) {
var span = this._batch.spans[i];
spanMessages.push(new this._jaegerThrift.Span(span));
}
});
}
}, {
key: '_reset',
value: function _reset() {
this._batch.spans = [];
this._totalSpanBytes = 0;
}
}, {
key: 'close',
value: function close() {
this._client.close();
}
}]);
return new this._agentThrift.Agent.emitBatch.ArgumentsMessage({
version: 1,
id: 0,
body: {
batch: new this._jaegerThrift.Batch({
process: this._thriftProcessMessage,
spans: spanMessages,
}),
},
});
},
},
{
key: '_reset',
value: function _reset() {
this._batch.spans = [];
this._totalSpanBytes = 0;
},
},
{
key: 'close',
value: function close() {
this._client.close();
},
},
]);
return UDPSender;
}();
})();
exports.default = UDPSender;
//# sourceMappingURL=udp_sender.js.map
//# sourceMappingURL=udp_sender.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -24,7 +39,24 @@ //

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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var ConstSampler = function () {
var ConstSampler = (function() {
function ConstSampler(decision) {

@@ -36,48 +68,55 @@ _classCallCheck(this, ConstSampler);

_createClass(ConstSampler, [{
key: 'name',
value: function name() {
return 'ConstSampler';
}
}, {
key: 'toString',
value: function toString() {
return this.name() + '(' + (this._decision ? 'always' : 'never') + ')';
}
}, {
key: 'isSampled',
value: function isSampled(operation, tags) {
if (this._decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_CONST;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._decision;
}
return this._decision;
}
}, {
key: 'equal',
value: function equal(other) {
if (!(other instanceof ConstSampler)) {
return false;
}
_createClass(ConstSampler, [
{
key: 'name',
value: function name() {
return 'ConstSampler';
},
},
{
key: 'toString',
value: function toString() {
return this.name() + '(' + (this._decision ? 'always' : 'never') + ')';
},
},
{
key: 'isSampled',
value: function isSampled(operation, tags) {
if (this._decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_CONST;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._decision;
}
return this._decision;
},
},
{
key: 'equal',
value: function equal(other) {
if (!(other instanceof ConstSampler)) {
return false;
}
return this.decision === other.decision;
}
}, {
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
}
}, {
key: 'decision',
get: function get() {
return this._decision;
}
}]);
return this.decision === other.decision;
},
},
{
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
},
},
{
key: 'decision',
get: function get() {
return this._decision;
},
},
]);
return ConstSampler;
}();
})();
exports.default = ConstSampler;
//# sourceMappingURL=const_sampler.js.map
//# sourceMappingURL=const_sampler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -32,7 +47,26 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -46,3 +80,3 @@ // GuaranteedThroughputProbabilisticSampler is a sampler that leverages both probabilisticSampler and

// samplers return true, the tags for probabilisticSampler will be used.
var GuaranteedThroughputSampler = function () {
var GuaranteedThroughputSampler = (function() {
function GuaranteedThroughputSampler(lowerBound, samplingRate) {

@@ -58,66 +92,83 @@ _classCallCheck(this, GuaranteedThroughputSampler);

_createClass(GuaranteedThroughputSampler, [{
key: 'name',
value: function name() {
return 'GuaranteedThroughputSampler';
}
}, {
key: 'toString',
value: function toString() {
return this.name() + '(samplingRate=' + this._probabilisticSampler.samplingRate + ', lowerBound=' + this._lowerBoundSampler.maxTracesPerSecond + ')';
}
}, {
key: 'isSampled',
value: function isSampled(operation, tags) {
if (this._probabilisticSampler.isSampled(operation, tags)) {
// make rate limiting sampler update its budget
this._lowerBoundSampler.isSampled(operation, this._tagsPlaceholder);
return true;
}
var decision = this._lowerBoundSampler.isSampled(operation, this._tagsPlaceholder);
if (decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_LOWER_BOUND;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._probabilisticSampler.samplingRate;
}
return decision;
}
}, {
key: 'equal',
value: function equal(other) {
if (!(other instanceof GuaranteedThroughputSampler)) {
return false;
}
return this._probabilisticSampler.equal(other._probabilisticSampler) && this._lowerBoundSampler.equal(other._lowerBoundSampler);
}
}, {
key: 'close',
value: function close(callback) {
// neither probabilistic nor rate limiting samplers allocate resources,
// so their close methods are effectively no-op. We do not need to
// pass the callback to them (if we did we'd need to wrap it).
this._probabilisticSampler.close(function () {});
this._lowerBoundSampler.close(function () {});
if (callback) {
callback();
}
}
}, {
key: 'update',
value: function update(lowerBound, samplingRate) {
var updated = false;
if (this._probabilisticSampler.samplingRate != samplingRate) {
this._probabilisticSampler = new _probabilistic_sampler2.default(samplingRate);
updated = true;
}
if (this._lowerBoundSampler.maxTracesPerSecond != lowerBound) {
updated = this._lowerBoundSampler.update(lowerBound);
}
return updated;
}
}]);
_createClass(GuaranteedThroughputSampler, [
{
key: 'name',
value: function name() {
return 'GuaranteedThroughputSampler';
},
},
{
key: 'toString',
value: function toString() {
return (
this.name() +
'(samplingRate=' +
this._probabilisticSampler.samplingRate +
', lowerBound=' +
this._lowerBoundSampler.maxTracesPerSecond +
')'
);
},
},
{
key: 'isSampled',
value: function isSampled(operation, tags) {
if (this._probabilisticSampler.isSampled(operation, tags)) {
// make rate limiting sampler update its budget
this._lowerBoundSampler.isSampled(operation, this._tagsPlaceholder);
return true;
}
var decision = this._lowerBoundSampler.isSampled(operation, this._tagsPlaceholder);
if (decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_LOWER_BOUND;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._probabilisticSampler.samplingRate;
}
return decision;
},
},
{
key: 'equal',
value: function equal(other) {
if (!(other instanceof GuaranteedThroughputSampler)) {
return false;
}
return (
this._probabilisticSampler.equal(other._probabilisticSampler) &&
this._lowerBoundSampler.equal(other._lowerBoundSampler)
);
},
},
{
key: 'close',
value: function close(callback) {
// neither probabilistic nor rate limiting samplers allocate resources,
// so their close methods are effectively no-op. We do not need to
// pass the callback to them (if we did we'd need to wrap it).
this._probabilisticSampler.close(function() {});
this._lowerBoundSampler.close(function() {});
if (callback) {
callback();
}
},
},
{
key: 'update',
value: function update(lowerBound, samplingRate) {
var updated = false;
if (this._probabilisticSampler.samplingRate != samplingRate) {
this._probabilisticSampler = new _probabilistic_sampler2.default(samplingRate);
updated = true;
}
if (this._lowerBoundSampler.maxTracesPerSecond != lowerBound) {
updated = this._lowerBoundSampler.update(lowerBound);
}
return updated;
},
},
]);
return GuaranteedThroughputSampler;
}();
})();
exports.default = GuaranteedThroughputSampler;
//# sourceMappingURL=guaranteed_throughput_sampler.js.map
//# sourceMappingURL=guaranteed_throughput_sampler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -36,7 +51,26 @@ //

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 _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 }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -48,3 +82,3 @@ // PerOperationSampler keeps track of all operation names it is asked to sample

// sampled with a default probabilistic sampler.
var PerOperationSampler = function () {
var PerOperationSampler = (function() {
function PerOperationSampler(strategies, maxOperations) {

@@ -58,75 +92,91 @@ _classCallCheck(this, PerOperationSampler);

_createClass(PerOperationSampler, [{
key: 'update',
value: function update(strategies) {
var _this = this;
_createClass(PerOperationSampler, [
{
key: 'update',
value: function update(strategies) {
var _this = this;
(0, _assert2.default)(typeof strategies.defaultLowerBoundTracesPerSecond === 'number', 'expected strategies.defaultLowerBoundTracesPerSecond to be number');
(0, _assert2.default)(typeof strategies.defaultSamplingProbability === 'number', 'expected strategies.defaultSamplingProbability to be number');
(0, _assert2.default)(
typeof strategies.defaultLowerBoundTracesPerSecond === 'number',
'expected strategies.defaultLowerBoundTracesPerSecond to be number'
);
(0, _assert2.default)(
typeof strategies.defaultSamplingProbability === 'number',
'expected strategies.defaultSamplingProbability to be number'
);
var updated = this._defaultLowerBound !== strategies.defaultLowerBoundTracesPerSecond;
this._defaultLowerBound = strategies.defaultLowerBoundTracesPerSecond;
strategies.perOperationStrategies.forEach(function (strategy) {
var operation = strategy.operation;
var samplingRate = strategy.probabilisticSampling.samplingRate;
var sampler = _this._samplersByOperation[operation];
if (sampler) {
if (sampler.update(_this._defaultLowerBound, samplingRate)) {
var updated = this._defaultLowerBound !== strategies.defaultLowerBoundTracesPerSecond;
this._defaultLowerBound = strategies.defaultLowerBoundTracesPerSecond;
strategies.perOperationStrategies.forEach(function(strategy) {
var operation = strategy.operation;
var samplingRate = strategy.probabilisticSampling.samplingRate;
var sampler = _this._samplersByOperation[operation];
if (sampler) {
if (sampler.update(_this._defaultLowerBound, samplingRate)) {
updated = true;
}
} else {
sampler = new _guaranteed_throughput_sampler2.default(_this._defaultLowerBound, samplingRate);
_this._samplersByOperation[operation] = sampler;
updated = true;
}
} else {
sampler = new _guaranteed_throughput_sampler2.default(_this._defaultLowerBound, samplingRate);
_this._samplersByOperation[operation] = sampler;
});
var defaultSamplingRate = strategies.defaultSamplingProbability;
if (!this._defaultSampler || this._defaultSampler.samplingRate != defaultSamplingRate) {
this._defaultSampler = new _probabilistic_sampler2.default(defaultSamplingRate);
updated = true;
}
});
var defaultSamplingRate = strategies.defaultSamplingProbability;
if (!this._defaultSampler || this._defaultSampler.samplingRate != defaultSamplingRate) {
this._defaultSampler = new _probabilistic_sampler2.default(defaultSamplingRate);
updated = true;
}
return updated;
}
}, {
key: 'name',
value: function name() {
return 'PerOperationSampler';
}
}, {
key: 'toString',
value: function toString() {
return this.name() + '(maxOperations=' + this._maxOperations + ')';
}
}, {
key: 'isSampled',
value: function isSampled(operation, tags) {
var sampler = this._samplersByOperation[operation];
if (!sampler) {
if (Object.keys(this._samplersByOperation).length >= this._maxOperations) {
return this._defaultSampler.isSampled(operation, tags);
return updated;
},
},
{
key: 'name',
value: function name() {
return 'PerOperationSampler';
},
},
{
key: 'toString',
value: function toString() {
return this.name() + '(maxOperations=' + this._maxOperations + ')';
},
},
{
key: 'isSampled',
value: function isSampled(operation, tags) {
var sampler = this._samplersByOperation[operation];
if (!sampler) {
if (Object.keys(this._samplersByOperation).length >= this._maxOperations) {
return this._defaultSampler.isSampled(operation, tags);
}
sampler = new _guaranteed_throughput_sampler2.default(
this._defaultLowerBound,
this._defaultSampler.samplingRate
);
this._samplersByOperation[operation] = sampler;
}
sampler = new _guaranteed_throughput_sampler2.default(this._defaultLowerBound, this._defaultSampler.samplingRate);
this._samplersByOperation[operation] = sampler;
}
return sampler.isSampled(operation, tags);
}
}, {
key: 'equal',
value: function equal(other) {
return false; // TODO equal should be removed
}
}, {
key: 'close',
value: function close(callback) {
// all nested samplers are of simple types, so we do not need to Close them
if (callback) {
callback();
}
}
}]);
return sampler.isSampled(operation, tags);
},
},
{
key: 'equal',
value: function equal(other) {
return false; // TODO equal should be removed
},
},
{
key: 'close',
value: function close(callback) {
// all nested samplers are of simple types, so we do not need to Close them
if (callback) {
callback();
}
},
},
]);
return PerOperationSampler;
}();
})();
exports.default = PerOperationSampler;
//# sourceMappingURL=per_operation_sampler.js.map
//# sourceMappingURL=per_operation_sampler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -24,7 +39,24 @@ //

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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var ProbabilisticSampler = function () {
var ProbabilisticSampler = (function() {
function ProbabilisticSampler(samplingRate) {

@@ -34,3 +66,5 @@ _classCallCheck(this, ProbabilisticSampler);

if (samplingRate < 0.0 || samplingRate > 1.0) {
throw new Error('The sampling rate must be less than 0.0 and greater than 1.0. Received ' + samplingRate);
throw new Error(
'The sampling rate must be less than 0.0 and greater than 1.0. Received ' + samplingRate
);
}

@@ -41,54 +75,62 @@

_createClass(ProbabilisticSampler, [{
key: 'name',
value: function name() {
return 'ProbabilisticSampler';
}
}, {
key: 'toString',
value: function toString() {
return this.name() + '(samplingRate=' + this._samplingRate + ')';
}
}, {
key: 'isSampled',
value: function isSampled(operation, tags) {
var decision = this.random() < this._samplingRate;
if (decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_PROBABILISTIC;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._samplingRate;
}
return decision;
}
}, {
key: 'random',
value: function random() {
return Math.random();
}
}, {
key: 'equal',
value: function equal(other) {
if (!(other instanceof ProbabilisticSampler)) {
return false;
}
_createClass(ProbabilisticSampler, [
{
key: 'name',
value: function name() {
return 'ProbabilisticSampler';
},
},
{
key: 'toString',
value: function toString() {
return this.name() + '(samplingRate=' + this._samplingRate + ')';
},
},
{
key: 'isSampled',
value: function isSampled(operation, tags) {
var decision = this.random() < this._samplingRate;
if (decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_PROBABILISTIC;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._samplingRate;
}
return decision;
},
},
{
key: 'random',
value: function random() {
return Math.random();
},
},
{
key: 'equal',
value: function equal(other) {
if (!(other instanceof ProbabilisticSampler)) {
return false;
}
return this.samplingRate === other.samplingRate;
}
}, {
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
}
}, {
key: 'samplingRate',
get: function get() {
return this._samplingRate;
}
}]);
return this.samplingRate === other.samplingRate;
},
},
{
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
},
},
{
key: 'samplingRate',
get: function get() {
return this._samplingRate;
},
},
]);
return ProbabilisticSampler;
}();
})();
exports.default = ProbabilisticSampler;
//# sourceMappingURL=probabilistic_sampler.js.map
//# sourceMappingURL=probabilistic_sampler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -28,9 +43,28 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var RateLimitingSampler = function () {
var RateLimitingSampler = (function() {
function RateLimitingSampler(maxTracesPerSecond, initBalance) {

@@ -42,71 +76,80 @@ _classCallCheck(this, RateLimitingSampler);

_createClass(RateLimitingSampler, [{
key: 'update',
value: function update(maxTracesPerSecond) {
var prevMaxTracesPerSecond = this._maxTracesPerSecond;
this._init(maxTracesPerSecond);
return this._maxTracesPerSecond !== prevMaxTracesPerSecond;
}
}, {
key: '_init',
value: function _init(maxTracesPerSecond, initBalance) {
if (maxTracesPerSecond < 0) {
throw new Error('maxTracesPerSecond must be greater than 0.0. Received ' + maxTracesPerSecond);
}
var maxBalance = maxTracesPerSecond < 1.0 ? 1.0 : maxTracesPerSecond;
_createClass(RateLimitingSampler, [
{
key: 'update',
value: function update(maxTracesPerSecond) {
var prevMaxTracesPerSecond = this._maxTracesPerSecond;
this._init(maxTracesPerSecond);
return this._maxTracesPerSecond !== prevMaxTracesPerSecond;
},
},
{
key: '_init',
value: function _init(maxTracesPerSecond, initBalance) {
if (maxTracesPerSecond < 0) {
throw new Error('maxTracesPerSecond must be greater than 0.0. Received ' + maxTracesPerSecond);
}
var maxBalance = maxTracesPerSecond < 1.0 ? 1.0 : maxTracesPerSecond;
this._maxTracesPerSecond = maxTracesPerSecond;
if (this._rateLimiter) {
this._rateLimiter.update(maxTracesPerSecond, maxBalance);
} else {
this._rateLimiter = new _rate_limiter2.default(maxTracesPerSecond, maxBalance, initBalance);
}
}
}, {
key: 'name',
value: function name() {
return 'RateLimitingSampler';
}
}, {
key: 'toString',
value: function toString() {
return this.name() + '(maxTracesPerSecond=' + this._maxTracesPerSecond + ')';
}
}, {
key: 'isSampled',
value: function isSampled(operation, tags) {
var decision = this._rateLimiter.checkCredit(1.0);
if (decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_RATE_LIMITING;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._maxTracesPerSecond;
}
return decision;
}
}, {
key: 'equal',
value: function equal(other) {
if (!(other instanceof RateLimitingSampler)) {
return false;
}
this._maxTracesPerSecond = maxTracesPerSecond;
if (this._rateLimiter) {
this._rateLimiter.update(maxTracesPerSecond, maxBalance);
} else {
this._rateLimiter = new _rate_limiter2.default(maxTracesPerSecond, maxBalance, initBalance);
}
},
},
{
key: 'name',
value: function name() {
return 'RateLimitingSampler';
},
},
{
key: 'toString',
value: function toString() {
return this.name() + '(maxTracesPerSecond=' + this._maxTracesPerSecond + ')';
},
},
{
key: 'isSampled',
value: function isSampled(operation, tags) {
var decision = this._rateLimiter.checkCredit(1.0);
if (decision) {
tags[constants.SAMPLER_TYPE_TAG_KEY] = constants.SAMPLER_TYPE_RATE_LIMITING;
tags[constants.SAMPLER_PARAM_TAG_KEY] = this._maxTracesPerSecond;
}
return decision;
},
},
{
key: 'equal',
value: function equal(other) {
if (!(other instanceof RateLimitingSampler)) {
return false;
}
return this.maxTracesPerSecond === other.maxTracesPerSecond;
}
}, {
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
}
}, {
key: 'maxTracesPerSecond',
get: function get() {
return this._maxTracesPerSecond;
}
}]);
return this.maxTracesPerSecond === other.maxTracesPerSecond;
},
},
{
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
},
},
{
key: 'maxTracesPerSecond',
get: function get() {
return this._maxTracesPerSecond;
},
},
]);
return RateLimitingSampler;
}();
})();
exports.default = RateLimitingSampler;
//# sourceMappingURL=ratelimiting_sampler.js.map
//# sourceMappingURL=ratelimiting_sampler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -52,5 +67,11 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -65,4 +86,3 @@ var DEFAULT_INITIAL_SAMPLING_RATE = 0.001;

var RemoteControlledSampler = function () {
var RemoteControlledSampler = (function() {
/**

@@ -108,124 +128,140 @@ * Creates a sampler remotely controlled by jaeger-agent.

_createClass(RemoteControlledSampler, [{
key: 'name',
value: function name() {
return 'RemoteSampler';
}
}, {
key: 'toString',
value: function toString() {
return this.name() + '(serviceName=' + this._serviceName + ')';
}
}, {
key: '_parseHostPort',
value: function _parseHostPort(hostPort) {
hostPort = /^http/.test(hostPort) ? hostPort : 'http://' + hostPort;
var parsedUrl = _url2.default.parse(hostPort);
_createClass(RemoteControlledSampler, [
{
key: 'name',
value: function name() {
return 'RemoteSampler';
},
},
{
key: 'toString',
value: function toString() {
return this.name() + '(serviceName=' + this._serviceName + ')';
},
},
{
key: '_parseHostPort',
value: function _parseHostPort(hostPort) {
hostPort = /^http/.test(hostPort) ? hostPort : 'http://' + hostPort;
var parsedUrl = _url2.default.parse(hostPort);
this._host = parsedUrl.hostname || DEFAULT_SAMPLING_HOST;
this._port = parsedUrl.port ? parseInt(parsedUrl.port) : DEFAULT_SAMPLING_PORT;
}
}, {
key: '_afterInitialDelay',
value: function _afterInitialDelay() {
this._refreshIntervalHandle = setInterval(this._refreshSamplingStrategy.bind(this), this._refreshInterval);
this._initialDelayTimeoutHandle = null;
}
}, {
key: '_refreshSamplingStrategy',
value: function _refreshSamplingStrategy() {
var _this = this;
this._host = parsedUrl.hostname || DEFAULT_SAMPLING_HOST;
this._port = parsedUrl.port ? parseInt(parsedUrl.port) : DEFAULT_SAMPLING_PORT;
},
},
{
key: '_afterInitialDelay',
value: function _afterInitialDelay() {
this._refreshIntervalHandle = setInterval(
this._refreshSamplingStrategy.bind(this),
this._refreshInterval
);
this._initialDelayTimeoutHandle = null;
},
},
{
key: '_refreshSamplingStrategy',
value: function _refreshSamplingStrategy() {
var _this = this;
var serviceName = encodeURIComponent(this._serviceName);
var success = function success(body) {
_this._parseSamplingServerResponse(body);
};
var error = function error(err) {
_this._logger.error('Error in fetching sampling strategy: ' + err + '.');
_this._metrics.samplerQueryFailure.increment(1);
};
_util2.default.httpGet(this._host, this._port, '/sampling?service=' + serviceName, success, error);
}
}, {
key: '_parseSamplingServerResponse',
value: function _parseSamplingServerResponse(body) {
this._metrics.samplerRetrieved.increment(1);
var strategy = void 0;
try {
strategy = JSON.parse(body);
if (!strategy) {
throw 'Malformed response: ' + body;
var serviceName = encodeURIComponent(this._serviceName);
var success = function success(body) {
_this._parseSamplingServerResponse(body);
};
var error = function error(err) {
_this._logger.error('Error in fetching sampling strategy: ' + err + '.');
_this._metrics.samplerQueryFailure.increment(1);
};
_util2.default.httpGet(this._host, this._port, '/sampling?service=' + serviceName, success, error);
},
},
{
key: '_parseSamplingServerResponse',
value: function _parseSamplingServerResponse(body) {
this._metrics.samplerRetrieved.increment(1);
var strategy = void 0;
try {
strategy = JSON.parse(body);
if (!strategy) {
throw 'Malformed response: ' + body;
}
} catch (error) {
this._logger.error('Error in parsing sampling strategy: ' + error + '.');
this._metrics.samplerUpdateFailure.increment(1);
return;
}
} catch (error) {
this._logger.error('Error in parsing sampling strategy: ' + error + '.');
this._metrics.samplerUpdateFailure.increment(1);
return;
}
try {
if (this._updateSampler(strategy)) {
this._metrics.samplerUpdated.increment(1);
try {
if (this._updateSampler(strategy)) {
this._metrics.samplerUpdated.increment(1);
}
} catch (error) {
this._logger.error('Error in updating sampler: ' + error + '.');
this._metrics.samplerUpdateFailure.increment(1);
return;
}
} catch (error) {
this._logger.error('Error in updating sampler: ' + error + '.');
this._metrics.samplerUpdateFailure.increment(1);
return;
}
if (this._onSamplerUpdate) {
this._onSamplerUpdate(this._sampler);
}
}
}, {
key: '_updateSampler',
value: function _updateSampler(response) {
if (response.operationSampling) {
if (this._sampler instanceof _per_operation_sampler2.default) {
var sampler = this._sampler;
return sampler.update(response.operationSampling);
if (this._onSamplerUpdate) {
this._onSamplerUpdate(this._sampler);
}
this._sampler = new _per_operation_sampler2.default(response.operationSampling, this._maxOperations);
return true;
}
var newSampler = void 0;
if (response.strategyType === PROBABILISTIC_STRATEGY_TYPE && response.probabilisticSampling) {
var samplingRate = response.probabilisticSampling.samplingRate;
newSampler = new _probabilistic_sampler2.default(samplingRate);
} else if (response.strategyType === RATELIMITING_STRATEGY_TYPE && response.rateLimitingSampling) {
var maxTracesPerSecond = response.rateLimitingSampling.maxTracesPerSecond;
if (this._sampler instanceof _ratelimiting_sampler2.default) {
var _sampler = this._sampler;
return _sampler.update(maxTracesPerSecond);
},
},
{
key: '_updateSampler',
value: function _updateSampler(response) {
if (response.operationSampling) {
if (this._sampler instanceof _per_operation_sampler2.default) {
var sampler = this._sampler;
return sampler.update(response.operationSampling);
}
this._sampler = new _per_operation_sampler2.default(
response.operationSampling,
this._maxOperations
);
return true;
}
this._sampler = new _ratelimiting_sampler2.default(maxTracesPerSecond);
var newSampler = void 0;
if (response.strategyType === PROBABILISTIC_STRATEGY_TYPE && response.probabilisticSampling) {
var samplingRate = response.probabilisticSampling.samplingRate;
newSampler = new _probabilistic_sampler2.default(samplingRate);
} else if (response.strategyType === RATELIMITING_STRATEGY_TYPE && response.rateLimitingSampling) {
var maxTracesPerSecond = response.rateLimitingSampling.maxTracesPerSecond;
if (this._sampler instanceof _ratelimiting_sampler2.default) {
var _sampler = this._sampler;
return _sampler.update(maxTracesPerSecond);
}
this._sampler = new _ratelimiting_sampler2.default(maxTracesPerSecond);
return true;
} else {
throw 'Malformed response: ' + JSON.stringify(response);
}
if (this._sampler.equal(newSampler)) {
return false;
}
this._sampler = newSampler;
return true;
} else {
throw 'Malformed response: ' + JSON.stringify(response);
}
},
},
{
key: 'isSampled',
value: function isSampled(operation, tags) {
return this._sampler.isSampled(operation, tags);
},
},
{
key: 'close',
value: function close(callback) {
clearTimeout(this._initialDelayTimeoutHandle);
clearInterval(this._refreshIntervalHandle);
if (this._sampler.equal(newSampler)) {
return false;
}
this._sampler = newSampler;
return true;
}
}, {
key: 'isSampled',
value: function isSampled(operation, tags) {
return this._sampler.isSampled(operation, tags);
}
}, {
key: 'close',
value: function close(callback) {
clearTimeout(this._initialDelayTimeoutHandle);
clearInterval(this._refreshIntervalHandle);
if (callback) {
callback();
}
},
},
]);
if (callback) {
callback();
}
}
}]);
return RemoteControlledSampler;
}();
})();
exports.default = RemoteControlledSampler;
//# sourceMappingURL=remote_sampler.js.map
//# sourceMappingURL=remote_sampler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -28,9 +43,28 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var SpanContext = function () {
var SpanContext = (function() {
function SpanContext(traceId, spanId, parentId, traceIdStr, spanIdStr, parentIdStr) {

@@ -72,206 +106,259 @@ var flags = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;

_createClass(
SpanContext,
[
{
key: 'finalizeSampling',
value: function finalizeSampling() {
this._samplingFinalized = true;
},
},
{
key: 'isDebugIDContainerOnly',
value: function isDebugIDContainerOnly() {
return !this.isValid && this._debugId !== '';
},
_createClass(SpanContext, [{
key: 'finalizeSampling',
value: function finalizeSampling() {
this._samplingFinalized = true;
}
}, {
key: 'isDebugIDContainerOnly',
value: function isDebugIDContainerOnly() {
return !this.isValid && this._debugId !== '';
}
/**
* @return {boolean} - returns whether or not this span context was sampled.
**/
},
{
key: 'isSampled',
value: function isSampled() {
return (this.flags & constants.SAMPLED_MASK) === constants.SAMPLED_MASK;
},
/**
* @return {boolean} - returns whether or not this span context was sampled.
**/
/**
* @return {boolean} - returns whether or not this span context has a debug flag set.
**/
},
{
key: 'isDebug',
value: function isDebug() {
return (this.flags & constants.DEBUG_MASK) === constants.DEBUG_MASK;
},
},
{
key: 'withBaggageItem',
value: function withBaggageItem(key, value) {
var newBaggage = _util2.default.clone(this._baggage);
newBaggage[key] = value;
return new SpanContext(
this._traceId,
this._spanId,
this._parentId,
this._traceIdStr,
this._spanIdStr,
this._parentIdStr,
this._flags,
newBaggage,
this._debugId,
this._samplingFinalized
);
},
}, {
key: 'isSampled',
value: function isSampled() {
return (this.flags & constants.SAMPLED_MASK) === constants.SAMPLED_MASK;
}
/**
* @return {string} - returns a string version of this span context.
**/
},
{
key: 'toString',
value: function toString() {
return [this.traceIdStr, this.spanIdStr, this.parentIdStr || '0', this._flags.toString(16)].join(
':'
);
},
/**
* @return {boolean} - returns whether or not this span context has a debug flag set.
**/
/**
* @param {string} serializedString - a serialized span context.
* @return {SpanContext} - returns a span context represented by the serializedString.
**/
},
{
key: 'traceId',
get: function get() {
if (this._traceId == null && this._traceIdStr != null) {
this._traceId = _util2.default.encodeInt64(this._traceIdStr);
}
return this._traceId;
},
set: function set(traceId) {
this._traceId = traceId;
this._traceIdStr = null;
},
},
{
key: 'spanId',
get: function get() {
if (this._spanId == null && this._spanIdStr != null) {
this._spanId = _util2.default.encodeInt64(this._spanIdStr);
}
return this._spanId;
},
set: function set(spanId) {
this._spanId = spanId;
this._spanIdStr = null;
},
},
{
key: 'parentId',
get: function get() {
if (this._parentId == null && this._parentIdStr != null) {
this._parentId = _util2.default.encodeInt64(this._parentIdStr);
}
return this._parentId;
},
set: function set(parentId) {
this._parentId = parentId;
this._parentIdStr = null;
},
},
{
key: 'traceIdStr',
get: function get() {
if (this._traceIdStr == null && this._traceId != null) {
this._traceIdStr = _util2.default.removeLeadingZeros(this._traceId.toString('hex'));
}
return this._traceIdStr;
},
},
{
key: 'spanIdStr',
get: function get() {
if (this._spanIdStr == null && this._spanId != null) {
this._spanIdStr = _util2.default.removeLeadingZeros(this._spanId.toString('hex'));
}
return this._spanIdStr;
},
},
{
key: 'parentIdStr',
get: function get() {
if (this._parentIdStr == null && this._parentId != null) {
this._parentIdStr = _util2.default.removeLeadingZeros(this._parentId.toString('hex'));
}
return this._parentIdStr;
},
},
{
key: 'flags',
get: function get() {
return this._flags;
},
set: function set(flags) {
this._flags = flags;
},
},
{
key: 'baggage',
get: function get() {
return this._baggage;
},
set: function set(baggage) {
this._baggage = baggage;
},
},
{
key: 'debugId',
get: function get() {
return this._debugId;
},
set: function set(debugId) {
this._debugId = debugId;
},
},
{
key: 'samplingFinalized',
get: function get() {
return this._samplingFinalized;
},
},
{
key: 'isValid',
get: function get() {
return !!((this._traceId || this._traceIdStr) && (this._spanId || this._spanIdStr));
},
},
],
[
{
key: 'fromString',
value: function fromString(serializedString) {
var headers = serializedString.split(':');
if (headers.length !== 4) {
return null;
}
}, {
key: 'isDebug',
value: function isDebug() {
return (this.flags & constants.DEBUG_MASK) === constants.DEBUG_MASK;
}
}, {
key: 'withBaggageItem',
value: function withBaggageItem(key, value) {
var newBaggage = _util2.default.clone(this._baggage);
newBaggage[key] = value;
return new SpanContext(this._traceId, this._spanId, this._parentId, this._traceIdStr, this._spanIdStr, this._parentIdStr, this._flags, newBaggage, this._debugId, this._samplingFinalized);
}
// Note: Number type in JS cannot represent the full range of 64bit unsigned ints,
// so using parseInt() on strings representing 64bit hex numbers only returns
// an approximation of the actual value. Fortunately, we do not depend on the
// returned value, we are only using it to validate that the string is
// a valid hex number (which is faster than doing it manually). We cannot use
// Int64(numberValue).toBuffer() because it throws exceptions on bad strings.
var approxTraceId = parseInt(headers[0], 16);
var NaNDetected =
isNaN(approxTraceId) ||
approxTraceId === 0 ||
isNaN(parseInt(headers[1], 16)) ||
isNaN(parseInt(headers[2], 16)) ||
isNaN(parseInt(headers[3], 16));
/**
* @return {string} - returns a string version of this span context.
**/
if (NaNDetected) {
return null;
}
}, {
key: 'toString',
value: function toString() {
return [this.traceIdStr, this.spanIdStr, this.parentIdStr || '0', this._flags.toString(16)].join(':');
}
var parentId = null;
if (headers[2] !== '0') {
parentId = headers[2];
}
/**
* @param {string} serializedString - a serialized span context.
* @return {SpanContext} - returns a span context represented by the serializedString.
**/
return SpanContext.withStringIds(headers[0], headers[1], parentId, parseInt(headers[3], 16));
},
},
{
key: 'withBinaryIds',
value: function withBinaryIds(traceId, spanId, parentId, flags) {
var baggage = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var debugId = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
}, {
key: 'traceId',
get: function get() {
if (this._traceId == null && this._traceIdStr != null) {
this._traceId = _util2.default.encodeInt64(this._traceIdStr);
}
return this._traceId;
},
set: function set(traceId) {
this._traceId = traceId;
this._traceIdStr = null;
}
}, {
key: 'spanId',
get: function get() {
if (this._spanId == null && this._spanIdStr != null) {
this._spanId = _util2.default.encodeInt64(this._spanIdStr);
}
return this._spanId;
},
set: function set(spanId) {
this._spanId = spanId;
this._spanIdStr = null;
}
}, {
key: 'parentId',
get: function get() {
if (this._parentId == null && this._parentIdStr != null) {
this._parentId = _util2.default.encodeInt64(this._parentIdStr);
}
return this._parentId;
},
set: function set(parentId) {
this._parentId = parentId;
this._parentIdStr = null;
}
}, {
key: 'traceIdStr',
get: function get() {
if (this._traceIdStr == null && this._traceId != null) {
this._traceIdStr = _util2.default.removeLeadingZeros(this._traceId.toString('hex'));
}
return this._traceIdStr;
}
}, {
key: 'spanIdStr',
get: function get() {
if (this._spanIdStr == null && this._spanId != null) {
this._spanIdStr = _util2.default.removeLeadingZeros(this._spanId.toString('hex'));
}
return this._spanIdStr;
}
}, {
key: 'parentIdStr',
get: function get() {
if (this._parentIdStr == null && this._parentId != null) {
this._parentIdStr = _util2.default.removeLeadingZeros(this._parentId.toString('hex'));
}
return this._parentIdStr;
}
}, {
key: 'flags',
get: function get() {
return this._flags;
},
set: function set(flags) {
this._flags = flags;
}
}, {
key: 'baggage',
get: function get() {
return this._baggage;
},
set: function set(baggage) {
this._baggage = baggage;
}
}, {
key: 'debugId',
get: function get() {
return this._debugId;
},
set: function set(debugId) {
this._debugId = debugId;
}
}, {
key: 'samplingFinalized',
get: function get() {
return this._samplingFinalized;
}
}, {
key: 'isValid',
get: function get() {
return !!((this._traceId || this._traceIdStr) && (this._spanId || this._spanIdStr));
}
}], [{
key: 'fromString',
value: function fromString(serializedString) {
var headers = serializedString.split(':');
if (headers.length !== 4) {
return null;
}
return new SpanContext(
traceId,
spanId,
parentId,
null, // traceIdStr: string,
null, // spanIdStr: string,
null, // parentIdStr: string,
flags,
baggage,
debugId
);
},
},
{
key: 'withStringIds',
value: function withStringIds(traceIdStr, spanIdStr, parentIdStr, flags) {
var baggage = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var debugId = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
// Note: Number type in JS cannot represent the full range of 64bit unsigned ints,
// so using parseInt() on strings representing 64bit hex numbers only returns
// an approximation of the actual value. Fortunately, we do not depend on the
// returned value, we are only using it to validate that the string is
// a valid hex number (which is faster than doing it manually). We cannot use
// Int64(numberValue).toBuffer() because it throws exceptions on bad strings.
var approxTraceId = parseInt(headers[0], 16);
var NaNDetected = isNaN(approxTraceId) || approxTraceId === 0 || isNaN(parseInt(headers[1], 16)) || isNaN(parseInt(headers[2], 16)) || isNaN(parseInt(headers[3], 16));
return new SpanContext(
null, // traceId,
null, // spanId,
null, // parentId,
traceIdStr,
spanIdStr,
parentIdStr,
flags,
baggage,
debugId
);
},
},
]
);
if (NaNDetected) {
return null;
}
var parentId = null;
if (headers[2] !== '0') {
parentId = headers[2];
}
return SpanContext.withStringIds(headers[0], headers[1], parentId, parseInt(headers[3], 16));
}
}, {
key: 'withBinaryIds',
value: function withBinaryIds(traceId, spanId, parentId, flags) {
var baggage = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var debugId = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
return new SpanContext(traceId, spanId, parentId, null, // traceIdStr: string,
null, // spanIdStr: string,
null, // parentIdStr: string,
flags, baggage, debugId);
}
}, {
key: 'withStringIds',
value: function withStringIds(traceIdStr, spanIdStr, parentIdStr, flags) {
var baggage = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var debugId = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
return new SpanContext(null, // traceId,
null, // spanId,
null, // parentId,
traceIdStr, spanIdStr, parentIdStr, flags, baggage, debugId);
}
}]);
return SpanContext;
}();
})();
exports.default = SpanContext;
//# sourceMappingURL=span_context.js.map
//# sourceMappingURL=span_context.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -40,9 +55,28 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var Span = function () {
var Span = (function() {
function Span(tracer, operationName, spanContext, startTime, references) {

@@ -62,305 +96,316 @@ _classCallCheck(this, Span);

_createClass(Span, [{
key: '_normalizeBaggageKey',
_createClass(
Span,
[
{
key: '_normalizeBaggageKey',
/**
* Returns a normalize key.
*
* @param {string} key - The key to be normalized for a particular baggage value.
* @return {string} - The normalized key (lower cased and underscores replaced, along with dashes.)
**/
value: function _normalizeBaggageKey(key) {
var baggageHeaderCache = Span._getBaggageHeaderCache();
if (key in baggageHeaderCache) {
return baggageHeaderCache[key];
}
/**
* Returns a normalize key.
*
* @param {string} key - The key to be normalized for a particular baggage value.
* @return {string} - The normalized key (lower cased and underscores replaced, along with dashes.)
**/
value: function _normalizeBaggageKey(key) {
var baggageHeaderCache = Span._getBaggageHeaderCache();
if (key in baggageHeaderCache) {
return baggageHeaderCache[key];
}
var normalizedKey = key.replace(/_/g, '-').toLowerCase();
var normalizedKey = key.replace(/_/g, '-').toLowerCase();
if (Object.keys(baggageHeaderCache).length < 100) {
baggageHeaderCache[key] = normalizedKey;
}
if (Object.keys(baggageHeaderCache).length < 100) {
baggageHeaderCache[key] = normalizedKey;
}
return normalizedKey;
},
return normalizedKey;
}
/**
* Sets a baggage value with an associated key.
*
* @param {string} key - The baggage key.
* @param {string} value - The baggage value.
*
* @return {Span} - returns this span.
**/
},
{
key: 'setBaggageItem',
value: function setBaggageItem(key, value) {
var normalizedKey = this._normalizeBaggageKey(key);
/**
* Sets a baggage value with an associated key.
*
* @param {string} key - The baggage key.
* @param {string} value - The baggage value.
*
* @return {Span} - returns this span.
**/
// We create a new instance of the context here instead of just adding
// another entry to the baggage dictionary. By doing so we keep the
// baggage immutable so that it can be passed to children spans as is.
// If it was mutable, we would have to make a copy of the dictionary
// for every child span, which on average we expect to occur more
// frequently than items being added to the baggage.
this._spanContext = this._baggageSetter.setBaggage(this, normalizedKey, value);
return this;
},
}, {
key: 'setBaggageItem',
value: function setBaggageItem(key, value) {
var normalizedKey = this._normalizeBaggageKey(key);
/**
* Gets a baggage value with an associated key.
*
* @param {string} key - The baggage key.
* @return {string} value - The baggage value.
**/
},
{
key: 'getBaggageItem',
value: function getBaggageItem(key) {
var normalizedKey = this._normalizeBaggageKey(key);
return this._spanContext.baggage[normalizedKey];
},
// We create a new instance of the context here instead of just adding
// another entry to the baggage dictionary. By doing so we keep the
// baggage immutable so that it can be passed to children spans as is.
// If it was mutable, we would have to make a copy of the dictionary
// for every child span, which on average we expect to occur more
// frequently than items being added to the baggage.
this._spanContext = this._baggageSetter.setBaggage(this, normalizedKey, value);
return this;
}
/**
* Returns the span context that represents this span.
*
* @return {SpanContext} - Returns this span's span context.
**/
},
{
key: 'context',
value: function context() {
return this._spanContext;
},
/**
* Gets a baggage value with an associated key.
*
* @param {string} key - The baggage key.
* @return {string} value - The baggage value.
**/
/**
* Returns the tracer associated with this span.
*
* @return {Tracer} - returns the tracer associated with this span.
**/
},
{
key: 'tracer',
value: function tracer() {
return this._tracer;
},
}, {
key: 'getBaggageItem',
value: function getBaggageItem(key) {
var normalizedKey = this._normalizeBaggageKey(key);
return this._spanContext.baggage[normalizedKey];
}
/**
* Checks whether or not a span can be written to.
*
* @return {boolean} - The decision about whether this span can be written to.
**/
},
{
key: '_isWriteable',
value: function _isWriteable() {
return !this._spanContext.samplingFinalized || this._spanContext.isSampled();
},
/**
* Returns the span context that represents this span.
*
* @return {SpanContext} - Returns this span's span context.
**/
/**
* Sets the operation name on this given span.
*
* @param {string} name - The name to use for setting a span's operation name.
* @return {Span} - returns this span.
**/
},
{
key: 'setOperationName',
value: function setOperationName(operationName) {
this._operationName = operationName;
// We re-sample the span if it has not been finalized.
if (this._spanContext.samplingFinalized) {
return this;
}
}, {
key: 'context',
value: function context() {
return this._spanContext;
}
var sampler = this.tracer()._sampler;
var tags = {};
if (sampler.isSampled(operationName, tags)) {
this._spanContext.flags |= constants.SAMPLED_MASK;
this.addTags(tags);
}
this._spanContext.finalizeSampling();
/**
* Returns the tracer associated with this span.
*
* @return {Tracer} - returns the tracer associated with this span.
**/
return this;
},
}, {
key: 'tracer',
value: function tracer() {
return this._tracer;
}
/**
* Sets the end timestamp and finalizes Span state.
*
* With the exception of calls to Span.context() (which are always allowed),
* finish() must be the last call made to any span instance, and to do
* otherwise leads to undefined behavior.
*
* @param {number} finishTime
* Optional finish time in milliseconds as a Unix timestamp. Decimal
* values are supported for timestamps with sub-millisecond accuracy.
* If not specified, the current time (as defined by the
* implementation) will be used.
*/
},
{
key: 'finish',
value: function finish(finishTime) {
if (this._duration !== undefined) {
var spanInfo = 'operation=' + this.operationName + ',context=' + this.context().toString();
this.tracer()._logger.error(spanInfo + '#You can only call finish() on a span once.');
return;
}
/**
* Checks whether or not a span can be written to.
*
* @return {boolean} - The decision about whether this span can be written to.
**/
this._spanContext.finalizeSampling();
if (this._spanContext.isSampled()) {
var endTime = finishTime || this._tracer.now();
this._duration = endTime - this._startTime;
this._tracer._report(this);
}
},
}, {
key: '_isWriteable',
value: function _isWriteable() {
return !this._spanContext.samplingFinalized || this._spanContext.isSampled();
}
/**
* Adds a set of tags to a span.
*
* @param {Object} keyValuePairs - An object with key value pairs
* that represent tags to be added to this span.
* @return {Span} - returns this span.
**/
},
{
key: 'addTags',
value: function addTags(keyValuePairs) {
var samplingKey = opentracing.Tags.SAMPLING_PRIORITY;
var samplingPriority = keyValuePairs[samplingKey];
var samplingPriorityWasSet =
samplingPriority != null && this._setSamplingPriority(samplingPriority);
if (this._isWriteable()) {
for (var key in keyValuePairs) {
if (Object.prototype.hasOwnProperty.call(keyValuePairs, key)) {
if (key === samplingKey && !samplingPriorityWasSet) {
continue;
}
var value = keyValuePairs[key];
this._tags.push({ key: key, value: value });
}
}
}
return this;
},
/**
* Sets the operation name on this given span.
*
* @param {string} name - The name to use for setting a span's operation name.
* @return {Span} - returns this span.
**/
/**
* Adds a single tag to a span
*
* @param {string} key - The key for the tag added to this span.
* @param {string} value - The value corresponding with the key
* for the tag added to this span.
* @return {Span} - returns this span.
* */
},
{
key: 'setTag',
value: function setTag(key, value) {
if (key === opentracing.Tags.SAMPLING_PRIORITY && !this._setSamplingPriority(value)) {
return this;
}
}, {
key: 'setOperationName',
value: function setOperationName(operationName) {
this._operationName = operationName;
// We re-sample the span if it has not been finalized.
if (this._spanContext.samplingFinalized) {
return this;
}
if (this._isWriteable()) {
this._tags.push({ key: key, value: value });
}
return this;
},
var sampler = this.tracer()._sampler;
var tags = {};
if (sampler.isSampled(operationName, tags)) {
this._spanContext.flags |= constants.SAMPLED_MASK;
this.addTags(tags);
}
this._spanContext.finalizeSampling();
/**
* Adds a log event, or payload to a span.
*
* @param {object} keyValuePairs
* An object mapping string keys to arbitrary value types. All
* Tracer implementations should support bool, string, and numeric
* value types, and some may also support Object values.
* @param {number} timestamp
* An optional parameter specifying the timestamp in milliseconds
* since the Unix epoch. Fractional values are allowed so that
* timestamps with sub-millisecond accuracy can be represented. If
* not specified, the implementation is expected to use its notion
* of the current time of the call.
* @return {Span} - returns this span.
*/
},
{
key: 'log',
value: function log(keyValuePairs, timestamp) {
if (this._isWriteable()) {
this._logs.push({
timestamp: timestamp || this._tracer.now(),
fields: _util2.default.convertObjectToTags(keyValuePairs),
});
}
return this;
},
return this;
}
/**
* Logs a event with an optional payload.
*
* @param {string} eventName - string associated with the log record
* @param {object} [payload] - arbitrary payload object associated with the
* log record.
*/
},
{
key: 'logEvent',
value: function logEvent(eventName, payload) {
this.log({
event: eventName,
payload: payload,
});
},
/**
* Sets the end timestamp and finalizes Span state.
*
* With the exception of calls to Span.context() (which are always allowed),
* finish() must be the last call made to any span instance, and to do
* otherwise leads to undefined behavior.
*
* @param {number} finishTime
* Optional finish time in milliseconds as a Unix timestamp. Decimal
* values are supported for timestamps with sub-millisecond accuracy.
* If not specified, the current time (as defined by the
* implementation) will be used.
*/
}, {
key: 'finish',
value: function finish(finishTime) {
if (this._duration !== undefined) {
var spanInfo = 'operation=' + this.operationName + ',context=' + this.context().toString();
this.tracer()._logger.error(spanInfo + '#You can only call finish() on a span once.');
return;
}
this._spanContext.finalizeSampling();
if (this._spanContext.isSampled()) {
var endTime = finishTime || this._tracer.now();
this._duration = endTime - this._startTime;
this._tracer._report(this);
}
}
/**
* Adds a set of tags to a span.
*
* @param {Object} keyValuePairs - An object with key value pairs
* that represent tags to be added to this span.
* @return {Span} - returns this span.
**/
}, {
key: 'addTags',
value: function addTags(keyValuePairs) {
var samplingKey = opentracing.Tags.SAMPLING_PRIORITY;
var samplingPriority = keyValuePairs[samplingKey];
var samplingPriorityWasSet = samplingPriority != null && this._setSamplingPriority(samplingPriority);
if (this._isWriteable()) {
for (var key in keyValuePairs) {
if (Object.prototype.hasOwnProperty.call(keyValuePairs, key)) {
if (key === samplingKey && !samplingPriorityWasSet) {
continue;
/**
* Returns true if the flag was updated successfully, false otherwise
*
* @param priority - 0 to disable sampling, 1 to enable
* @returns {boolean} - true if the flag was updated successfully
* @private
*/
},
{
key: '_setSamplingPriority',
value: function _setSamplingPriority(priority) {
this._spanContext.finalizeSampling();
if (priority > 0) {
if (this._spanContext.isDebug()) {
// If the span is already in debug, no need to set it again
return false;
}
var value = keyValuePairs[key];
this._tags.push({ key: key, value: value });
if (this._tracer._isDebugAllowed(this._operationName)) {
this._spanContext.flags =
this._spanContext.flags | constants.SAMPLED_MASK | constants.DEBUG_MASK;
return true;
}
return false;
}
}
}
return this;
}
/**
* Adds a single tag to a span
*
* @param {string} key - The key for the tag added to this span.
* @param {string} value - The value corresponding with the key
* for the tag added to this span.
* @return {Span} - returns this span.
* */
}, {
key: 'setTag',
value: function setTag(key, value) {
if (key === opentracing.Tags.SAMPLING_PRIORITY && !this._setSamplingPriority(value)) {
return this;
}
if (this._isWriteable()) {
this._tags.push({ key: key, value: value });
}
return this;
}
/**
* Adds a log event, or payload to a span.
*
* @param {object} keyValuePairs
* An object mapping string keys to arbitrary value types. All
* Tracer implementations should support bool, string, and numeric
* value types, and some may also support Object values.
* @param {number} timestamp
* An optional parameter specifying the timestamp in milliseconds
* since the Unix epoch. Fractional values are allowed so that
* timestamps with sub-millisecond accuracy can be represented. If
* not specified, the implementation is expected to use its notion
* of the current time of the call.
* @return {Span} - returns this span.
*/
}, {
key: 'log',
value: function log(keyValuePairs, timestamp) {
if (this._isWriteable()) {
this._logs.push({
timestamp: timestamp || this._tracer.now(),
fields: _util2.default.convertObjectToTags(keyValuePairs)
});
}
return this;
}
/**
* Logs a event with an optional payload.
*
* @param {string} eventName - string associated with the log record
* @param {object} [payload] - arbitrary payload object associated with the
* log record.
*/
}, {
key: 'logEvent',
value: function logEvent(eventName, payload) {
this.log({
event: eventName,
payload: payload
});
}
/**
* Returns true if the flag was updated successfully, false otherwise
*
* @param priority - 0 to disable sampling, 1 to enable
* @returns {boolean} - true if the flag was updated successfully
* @private
*/
}, {
key: '_setSamplingPriority',
value: function _setSamplingPriority(priority) {
this._spanContext.finalizeSampling();
if (priority > 0) {
if (this._spanContext.isDebug()) {
// If the span is already in debug, no need to set it again
return false;
}
if (this._tracer._isDebugAllowed(this._operationName)) {
this._spanContext.flags = this._spanContext.flags | constants.SAMPLED_MASK | constants.DEBUG_MASK;
this._spanContext.flags = this._spanContext.flags & ~constants.SAMPLED_MASK;
return true;
}
return false;
}
this._spanContext.flags = this._spanContext.flags & ~constants.SAMPLED_MASK;
return true;
}
}, {
key: 'operationName',
get: function get() {
return this._operationName;
}
}, {
key: 'serviceName',
get: function get() {
return this._tracer._serviceName;
}
}], [{
key: '_getBaggageHeaderCache',
value: function _getBaggageHeaderCache() {
if (!Span._baggageHeaderCache) {
Span._baggageHeaderCache = {};
}
},
},
{
key: 'operationName',
get: function get() {
return this._operationName;
},
},
{
key: 'serviceName',
get: function get() {
return this._tracer._serviceName;
},
},
],
[
{
key: '_getBaggageHeaderCache',
value: function _getBaggageHeaderCache() {
if (!Span._baggageHeaderCache) {
Span._baggageHeaderCache = {};
}
return Span._baggageHeaderCache;
}
}]);
return Span._baggageHeaderCache;
},
},
]
);
return Span;
}();
})();
exports.default = Span;
//# sourceMappingURL=span.js.map
//# sourceMappingURL=span.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof =
typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'
? function(obj) {
return typeof obj;
}
: function(obj) {
return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype
? 'symbol'
: typeof obj;
};
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _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;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -58,12 +82,30 @@ //

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 _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 }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var TCHANNEL_TRACING_PREFIX = '$tracing$';
var TChannelBridge = function () {
var TChannelBridge = (function() {
/**

@@ -82,174 +124,205 @@ * @param {Object} [tracer] - Jaeger Tracer

this._tracer = tracer;
_assert2.default.equal('object', typeof options === 'undefined' ? 'undefined' : _typeof(options), 'options must be an object');
_assert2.default.equal(
'object',
typeof options === 'undefined' ? 'undefined' : _typeof(options),
'options must be an object'
);
this._codec = new _text_map_codec2.default({
urlEncoding: false,
contextKey: TCHANNEL_TRACING_PREFIX + constants.TRACER_STATE_HEADER_NAME,
baggagePrefix: TCHANNEL_TRACING_PREFIX + constants.TRACER_BAGGAGE_HEADER_PREFIX
baggagePrefix: TCHANNEL_TRACING_PREFIX + constants.TRACER_BAGGAGE_HEADER_PREFIX,
});
this._contextFactory = options.contextFactory || function () {
return new _default_context2.default();
};
this._getSpan = options.getSpan || function (ctx) {
return ctx.getSpan();
};
this._setSpan = options.setSpan || function (ctx, span) {
return ctx.setSpan(span);
};
this._contextFactory =
options.contextFactory ||
function() {
return new _default_context2.default();
};
this._getSpan =
options.getSpan ||
function(ctx) {
return ctx.getSpan();
};
this._setSpan =
options.setSpan ||
function(ctx, span) {
return ctx.setSpan(span);
};
}
_createClass(TChannelBridge, [{
key: '_tchannelCallbackWrapper',
value: function _tchannelCallbackWrapper(span, callback, err, res) {
if (err) {
span.setTag(_opentracing2.default.Tags.ERROR, true);
span.log({
event: 'error',
message: err
});
}
_createClass(
TChannelBridge,
[
{
key: '_tchannelCallbackWrapper',
value: function _tchannelCallbackWrapper(span, callback, err, res) {
if (err) {
span.setTag(_opentracing2.default.Tags.ERROR, true);
span.log({
event: 'error',
message: err,
});
}
span.finish();
return callback(err, res);
}
span.finish();
return callback(err, res);
},
/**
* Wraps a tchannel handler, and takes a context in order to populate the incoming context
* with a span.
*
* @param {Function} [handlerFunc] - a tchannel handler function that responds to an incoming request.
* @param {Object} [options] - options to be passed to a span on creation.
* @returns {Function} - a function that wrapps the handler in order to automatically populate
* a the handler's context with a span.
**/
/**
* Wraps a tchannel handler, and takes a context in order to populate the incoming context
* with a span.
*
* @param {Function} [handlerFunc] - a tchannel handler function that responds to an incoming request.
* @param {Object} [options] - options to be passed to a span on creation.
* @returns {Function} - a function that wrapps the handler in order to automatically populate
* a the handler's context with a span.
**/
},
{
key: 'tracedHandler',
value: function tracedHandler(handlerFunc) {
var _this = this;
}, {
key: 'tracedHandler',
value: function tracedHandler(handlerFunc) {
var _this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return function(perProcessOptions, request, headers, body, callback) {
var context = _this._contextFactory();
var operationName = options.operationName || request.arg1;
var span = _this._extractSpan(operationName, headers);
return function (perProcessOptions, request, headers, body, callback) {
var context = _this._contextFactory();
var operationName = options.operationName || request.arg1;
var span = _this._extractSpan(operationName, headers);
// set tags
span.setTag(_opentracing2.default.Tags.PEER_SERVICE, request.callerName);
var hostPort = request.remoteAddr.split(':');
if (hostPort.length == 2) {
span.setTag(_opentracing2.default.Tags.PEER_PORT, parseInt(hostPort[1]));
}
if (request.headers && request.headers.as) {
span.setTag('as', request.headers.as);
}
// set tags
span.setTag(_opentracing2.default.Tags.PEER_SERVICE, request.callerName);
var hostPort = request.remoteAddr.split(':');
if (hostPort.length == 2) {
span.setTag(_opentracing2.default.Tags.PEER_PORT, parseInt(hostPort[1]));
}
if (request.headers && request.headers.as) {
span.setTag('as', request.headers.as);
}
_this._setSpan(context, span);
_this._setSpan(context, span);
// remove headers prefixed with $tracing$
var headerKeys = Object.keys(headers);
for (var i = 0; i < headerKeys.length; i++) {
var key = headerKeys[i];
if (
Object.prototype.hasOwnProperty.call(headers, key) &&
_util2.default.startsWith(key, TCHANNEL_TRACING_PREFIX)
) {
delete headers[key];
}
}
// remove headers prefixed with $tracing$
var headerKeys = Object.keys(headers);
for (var i = 0; i < headerKeys.length; i++) {
var key = headerKeys[i];
if (Object.prototype.hasOwnProperty.call(headers, key) && _util2.default.startsWith(key, TCHANNEL_TRACING_PREFIX)) {
delete headers[key];
}
}
var wrappingCallback = _this._tchannelCallbackWrapper.bind(null, span, callback);
request.context = context;
handlerFunc(perProcessOptions, request, headers, body, wrappingCallback);
};
},
},
{
key: '_wrapTChannelSend',
value: function _wrapTChannelSend(wrappedSend, channel, req, endpoint, headers, body, callback) {
headers = headers || {};
var context = req.context || this._contextFactory();
var childOf = this._getSpan(context);
var clientSpan = this._tracer.startSpan(endpoint, {
childOf: childOf, // ok if null, will start a new trace
});
clientSpan.setTag(_opentracing2.default.Tags.PEER_SERVICE, req.serviceName);
clientSpan.setTag(
_opentracing2.default.Tags.SPAN_KIND,
_opentracing2.default.Tags.SPAN_KIND_RPC_CLIENT
);
this.inject(clientSpan.context(), headers);
var wrappingCallback = _this._tchannelCallbackWrapper.bind(null, span, callback);
request.context = context;
handlerFunc(perProcessOptions, request, headers, body, wrappingCallback);
};
}
}, {
key: '_wrapTChannelSend',
value: function _wrapTChannelSend(wrappedSend, channel, req, endpoint, headers, body, callback) {
headers = headers || {};
var context = req.context || this._contextFactory();
var childOf = this._getSpan(context);
var clientSpan = this._tracer.startSpan(endpoint, {
childOf: childOf // ok if null, will start a new trace
});
clientSpan.setTag(_opentracing2.default.Tags.PEER_SERVICE, req.serviceName);
clientSpan.setTag(_opentracing2.default.Tags.SPAN_KIND, _opentracing2.default.Tags.SPAN_KIND_RPC_CLIENT);
this.inject(clientSpan.context(), headers);
// wrap callback so that span can be finished as soon as the response is received
var wrappingCallback = this._tchannelCallbackWrapper.bind(null, clientSpan, callback);
// wrap callback so that span can be finished as soon as the response is received
var wrappingCallback = this._tchannelCallbackWrapper.bind(null, clientSpan, callback);
return wrappedSend.call(channel, req, endpoint, headers, body, wrappingCallback);
},
},
{
key: '_wrapTChannelRequest',
value: function _wrapTChannelRequest(channel, wrappedRequestMethod, requestOptions) {
// We set the parent to a span with trace_id zero, so that tchannel's
// outgoing tracing frame also has a trace id of zero.
// This forces other tchannel implementations to rely on the headers for the trace context.
requestOptions.parent = { span: TChannelBridge.makeFakeTChannelParentSpan() };
return wrappedSend.call(channel, req, endpoint, headers, body, wrappingCallback);
}
}, {
key: '_wrapTChannelRequest',
value: function _wrapTChannelRequest(channel, wrappedRequestMethod, requestOptions) {
// We set the parent to a span with trace_id zero, so that tchannel's
// outgoing tracing frame also has a trace id of zero.
// This forces other tchannel implementations to rely on the headers for the trace context.
requestOptions.parent = { span: TChannelBridge.makeFakeTChannelParentSpan() };
var tchannelRequest = wrappedRequestMethod.call(channel, requestOptions);
tchannelRequest.context = requestOptions.context;
return tchannelRequest;
},
var tchannelRequest = wrappedRequestMethod.call(channel, requestOptions);
tchannelRequest.context = requestOptions.context;
return tchannelRequest;
}
/**
* Encode given span context as tchannel headers and store into the headers dictionary.
* @param {Object} spanContext - Jaeger SpanContext.
* @returns {Object} headers - a dictionary with TChannel application headers.
*/
},
{
key: 'inject',
value: function inject(spanContext, headers) {
this._codec.inject(spanContext, headers);
},
/**
* Encode given span context as tchannel headers and store into the headers dictionary.
* @param {Object} spanContext - Jaeger SpanContext.
* @returns {Object} headers - a dictionary with TChannel application headers.
*/
/**
* A function that wraps a json, or thrift encoded channel, in order to populate
* the outgoing headers with trace context, and baggage information.
*
* @param {Object} channel - the encoded channel to be wrapped for tracing.
* @returns {Object} channel - the trace wrapped channel.
* */
},
{
key: 'tracedChannel',
value: function tracedChannel(channel) {
var wrappedSend = channel.send;
var wrappedRequestMethod = channel.channel.request;
}, {
key: 'inject',
value: function inject(spanContext, headers) {
this._codec.inject(spanContext, headers);
}
// We are patching the top level channel request method, not the encoded request method.
channel.channel.request = this._wrapTChannelRequest.bind(
this,
channel.channel,
wrappedRequestMethod
);
/**
* A function that wraps a json, or thrift encoded channel, in order to populate
* the outgoing headers with trace context, and baggage information.
*
* @param {Object} channel - the encoded channel to be wrapped for tracing.
* @returns {Object} channel - the trace wrapped channel.
* */
channel.send = this._wrapTChannelSend.bind(this, wrappedSend, channel);
return channel;
},
},
{
key: '_extractSpan',
value: function _extractSpan(operationName, headers) {
var traceContext = this._codec.extract(headers);
var tags = {};
tags[_opentracing2.default.Tags.SPAN_KIND] = _opentracing2.default.Tags.SPAN_KIND_RPC_SERVER;
var options = {
childOf: traceContext,
tags: tags,
};
var span = this._tracer.startSpan(operationName, options);
return span;
},
},
],
[
{
key: 'makeFakeTChannelParentSpan',
value: function makeFakeTChannelParentSpan() {
return {
id: [0, 0],
traceid: [0, 0],
parentid: [0, 0],
flags: 0,
};
},
},
]
);
}, {
key: 'tracedChannel',
value: function tracedChannel(channel) {
var wrappedSend = channel.send;
var wrappedRequestMethod = channel.channel.request;
// We are patching the top level channel request method, not the encoded request method.
channel.channel.request = this._wrapTChannelRequest.bind(this, channel.channel, wrappedRequestMethod);
channel.send = this._wrapTChannelSend.bind(this, wrappedSend, channel);
return channel;
}
}, {
key: '_extractSpan',
value: function _extractSpan(operationName, headers) {
var traceContext = this._codec.extract(headers);
var tags = {};
tags[_opentracing2.default.Tags.SPAN_KIND] = _opentracing2.default.Tags.SPAN_KIND_RPC_SERVER;
var options = {
childOf: traceContext,
tags: tags
};
var span = this._tracer.startSpan(operationName, options);
return span;
}
}], [{
key: 'makeFakeTChannelParentSpan',
value: function makeFakeTChannelParentSpan() {
return {
id: [0, 0],
traceid: [0, 0],
parentid: [0, 0],
flags: 0
};
}
}]);
return TChannelBridge;
}();
})();
exports.default = TChannelBridge;
//# sourceMappingURL=tchannel_bridge.js.map
//# sourceMappingURL=tchannel_bridge.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -32,7 +47,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var TestUtils = function () {
var TestUtils = (function() {
function TestUtils() {

@@ -42,60 +63,65 @@ _classCallCheck(this, TestUtils);

_createClass(TestUtils, null, [{
key: 'hasTags',
value: function hasTags(span, expectedTags) {
// TODO(oibe) make this work for duplicate tags
var actualTags = {};
for (var i = 0; i < span._tags.length; i++) {
var key = span._tags[i].key;
actualTags[key] = span._tags[i].value;
}
_createClass(TestUtils, null, [
{
key: 'hasTags',
value: function hasTags(span, expectedTags) {
// TODO(oibe) make this work for duplicate tags
var actualTags = {};
for (var i = 0; i < span._tags.length; i++) {
var key = span._tags[i].key;
actualTags[key] = span._tags[i].value;
}
for (var tag in expectedTags) {
if (Object.prototype.hasOwnProperty.call(expectedTags, tag) && Object.prototype.hasOwnProperty.call(actualTags, tag)) {
if (actualTags[tag] !== expectedTags[tag]) {
console.log('expected tag:', expectedTags[tag], ', actual tag: ', actualTags[tag]);
for (var tag in expectedTags) {
if (
Object.prototype.hasOwnProperty.call(expectedTags, tag) &&
Object.prototype.hasOwnProperty.call(actualTags, tag)
) {
if (actualTags[tag] !== expectedTags[tag]) {
console.log('expected tag:', expectedTags[tag], ', actual tag: ', actualTags[tag]);
return false;
}
} else {
// mismatch in tag keys
return false;
}
} else {
// mismatch in tag keys
return false;
}
}
return true;
}
return true;
},
/**
* Returns tags stored in the span. If tags with the same key are present,
* only the last tag is returned.
* @param {Object} span - span from which to read the tags.
* @param {Array} [keys] - if specified, only tags with these keys are returned.
*/
}, {
key: 'getTags',
value: function getTags(span, keys) {
var actualTags = {};
for (var i = 0; i < span._tags.length; i++) {
var key = span._tags[i].key;
actualTags[key] = span._tags[i].value;
}
if (keys) {
var filteredTags = {};
for (var _i = 0; _i < keys.length; _i++) {
var _key = keys[_i];
if (actualTags.hasOwnProperty(_key)) {
filteredTags[_key] = actualTags[_key];
/**
* Returns tags stored in the span. If tags with the same key are present,
* only the last tag is returned.
* @param {Object} span - span from which to read the tags.
* @param {Array} [keys] - if specified, only tags with these keys are returned.
*/
},
{
key: 'getTags',
value: function getTags(span, keys) {
var actualTags = {};
for (var i = 0; i < span._tags.length; i++) {
var key = span._tags[i].key;
actualTags[key] = span._tags[i].value;
}
if (keys) {
var filteredTags = {};
for (var _i = 0; _i < keys.length; _i++) {
var _key = keys[_i];
if (actualTags.hasOwnProperty(_key)) {
filteredTags[_key] = actualTags[_key];
}
}
return filteredTags;
}
return filteredTags;
}
return actualTags;
}
}]);
return actualTags;
},
},
]);
return TestUtils;
}();
})();
exports.default = TestUtils;
//# sourceMappingURL=test_util.js.map
//# sourceMappingURL=test_util.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof =
typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'
? function(obj) {
return typeof obj;
}
: function(obj) {
return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype
? 'symbol'
: typeof obj;
};
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _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;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -40,7 +64,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var ThriftUtils = function () {
var ThriftUtils = (function() {
function ThriftUtils() {

@@ -50,126 +80,134 @@ _classCallCheck(this, ThriftUtils);

_createClass(ThriftUtils, null, [{
key: 'getThriftTags',
value: function getThriftTags(initialTags) {
var thriftTags = [];
for (var i = 0; i < initialTags.length; i++) {
var tag = initialTags[i];
_createClass(ThriftUtils, null, [
{
key: 'getThriftTags',
value: function getThriftTags(initialTags) {
var thriftTags = [];
for (var i = 0; i < initialTags.length; i++) {
var tag = initialTags[i];
var key = tag.key;
var key = tag.key;
var vLong = ThriftUtils.emptyBuffer;
var vBinary = ThriftUtils.emptyBuffer;
var vBool = false;
var vDouble = 0;
var vStr = '';
var vLong = ThriftUtils.emptyBuffer;
var vBinary = ThriftUtils.emptyBuffer;
var vBool = false;
var vDouble = 0;
var vStr = '';
var vType = '';
var valueType = _typeof(tag.value);
if (valueType === 'number') {
vType = ThriftUtils._thrift.TagType.DOUBLE;
vDouble = tag.value;
} else if (valueType === 'boolean') {
vType = ThriftUtils._thrift.TagType.BOOL;
vBool = tag.value;
} else if (tag.value instanceof Buffer) {
vType = ThriftUtils._thrift.TagType.BINARY;
vBinary = tag.value;
} else if (valueType === 'object') {
vType = ThriftUtils._thrift.TagType.STRING;
vStr = JSON.stringify(tag.value);
} else {
vType = ThriftUtils._thrift.TagType.STRING;
if (valueType === 'string') {
vStr = tag.value;
var vType = '';
var valueType = _typeof(tag.value);
if (valueType === 'number') {
vType = ThriftUtils._thrift.TagType.DOUBLE;
vDouble = tag.value;
} else if (valueType === 'boolean') {
vType = ThriftUtils._thrift.TagType.BOOL;
vBool = tag.value;
} else if (tag.value instanceof Buffer) {
vType = ThriftUtils._thrift.TagType.BINARY;
vBinary = tag.value;
} else if (valueType === 'object') {
vType = ThriftUtils._thrift.TagType.STRING;
vStr = JSON.stringify(tag.value);
} else {
vStr = String(tag.value);
vType = ThriftUtils._thrift.TagType.STRING;
if (valueType === 'string') {
vStr = tag.value;
} else {
vStr = String(tag.value);
}
}
thriftTags.push({
key: key,
vType: vType,
vStr: vStr,
vDouble: vDouble,
vBool: vBool,
vLong: vLong,
vBinary: vBinary,
});
}
thriftTags.push({
key: key,
vType: vType,
vStr: vStr,
vDouble: vDouble,
vBool: vBool,
vLong: vLong,
vBinary: vBinary
});
}
return thriftTags;
},
},
{
key: 'getThriftLogs',
value: function getThriftLogs(logs) {
var thriftLogs = [];
for (var i = 0; i < logs.length; i++) {
var log = logs[i];
thriftLogs.push({
timestamp: _util2.default.encodeInt64(log.timestamp * 1000), // to microseconds
fields: ThriftUtils.getThriftTags(log.fields),
});
}
return thriftTags;
}
}, {
key: 'getThriftLogs',
value: function getThriftLogs(logs) {
var thriftLogs = [];
for (var i = 0; i < logs.length; i++) {
var log = logs[i];
thriftLogs.push({
timestamp: _util2.default.encodeInt64(log.timestamp * 1000), // to microseconds
fields: ThriftUtils.getThriftTags(log.fields)
});
}
return thriftLogs;
},
},
{
key: 'spanRefsToThriftRefs',
value: function spanRefsToThriftRefs(refs) {
var thriftRefs = [];
for (var i = 0; i < refs.length; i++) {
var refEnum = void 0;
var ref = refs[i];
var context = refs[i].referencedContext();
return thriftLogs;
}
}, {
key: 'spanRefsToThriftRefs',
value: function spanRefsToThriftRefs(refs) {
var thriftRefs = [];
for (var i = 0; i < refs.length; i++) {
var refEnum = void 0;
var ref = refs[i];
var context = refs[i].referencedContext();
if (ref.type() === _opentracing2.default.REFERENCE_CHILD_OF) {
refEnum = ThriftUtils._thrift.SpanRefType.CHILD_OF;
} else if (ref.type() === _opentracing2.default.REFERENCE_FOLLOWS_FROM) {
refEnum = ThriftUtils._thrift.SpanRefType.FOLLOWS_FROM;
} else {
continue;
}
if (ref.type() === _opentracing2.default.REFERENCE_CHILD_OF) {
refEnum = ThriftUtils._thrift.SpanRefType.CHILD_OF;
} else if (ref.type() === _opentracing2.default.REFERENCE_FOLLOWS_FROM) {
refEnum = ThriftUtils._thrift.SpanRefType.FOLLOWS_FROM;
} else {
continue;
thriftRefs.push({
refType: refEnum,
traceIdLow: context.traceId,
traceIdHigh: ThriftUtils.emptyBuffer,
spanId: context.spanId,
});
}
thriftRefs.push({
refType: refEnum,
traceIdLow: context.traceId,
traceIdHigh: ThriftUtils.emptyBuffer,
spanId: context.spanId
});
}
return thriftRefs;
},
},
{
key: 'spanToThrift',
value: function spanToThrift(span) {
var tags = ThriftUtils.getThriftTags(span._tags);
var logs = ThriftUtils.getThriftLogs(span._logs);
var unsigned = true;
return thriftRefs;
}
}, {
key: 'spanToThrift',
value: function spanToThrift(span) {
var tags = ThriftUtils.getThriftTags(span._tags);
var logs = ThriftUtils.getThriftLogs(span._logs);
var unsigned = true;
return {
traceIdLow: span._spanContext.traceId,
traceIdHigh: ThriftUtils.emptyBuffer, // TODO(oibe) implement 128 bit ids
spanId: span._spanContext.spanId,
parentSpanId: span._spanContext.parentId || ThriftUtils.emptyBuffer,
operationName: span._operationName,
references: ThriftUtils.spanRefsToThriftRefs(span._references),
flags: span._spanContext.flags,
startTime: _util2.default.encodeInt64(span._startTime * 1000), // to microseconds
duration: _util2.default.encodeInt64(span._duration * 1000), // to microseconds
tags: tags,
logs: logs,
};
},
},
]);
return {
traceIdLow: span._spanContext.traceId,
traceIdHigh: ThriftUtils.emptyBuffer, // TODO(oibe) implement 128 bit ids
spanId: span._spanContext.spanId,
parentSpanId: span._spanContext.parentId || ThriftUtils.emptyBuffer,
operationName: span._operationName,
references: ThriftUtils.spanRefsToThriftRefs(span._references),
flags: span._spanContext.flags,
startTime: _util2.default.encodeInt64(span._startTime * 1000), // to microseconds
duration: _util2.default.encodeInt64(span._duration * 1000), // to microseconds
tags: tags,
logs: logs
};
}
}]);
return ThriftUtils;
}();
})();
ThriftUtils._thrift = new _thriftrw.Thrift({
source: _fs2.default.readFileSync(_path2.default.join(__dirname, './jaeger-idl/thrift/jaeger.thrift'), 'ascii'),
allowOptionalArguments: true
source: _fs2.default.readFileSync(
_path2.default.join(__dirname, './jaeger-idl/thrift/jaeger.thrift'),
'ascii'
),
allowOptionalArguments: true,
});
ThriftUtils.emptyBuffer = new Buffer([0, 0, 0, 0, 0, 0, 0, 0]);
exports.default = ThriftUtils;
//# sourceMappingURL=thrift.js.map
//# sourceMappingURL=thrift.js.map

@@ -1,10 +0,29 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -26,3 +45,3 @@ // Copyright (c) 2018 Uber Technologies, Inc.

*/
var DefaultThrottler = function () {
var DefaultThrottler = (function() {
function DefaultThrottler(throttleAll) {

@@ -34,25 +53,29 @@ _classCallCheck(this, DefaultThrottler);

_createClass(DefaultThrottler, [{
key: "isAllowed",
value: function isAllowed(operation) {
return !this._throttleAll;
}
}, {
key: "setProcess",
value: function setProcess(process) {
// NOP
}
}, {
key: "close",
value: function close(callback) {
if (callback) {
callback();
}
}
}]);
_createClass(DefaultThrottler, [
{
key: 'isAllowed',
value: function isAllowed(operation) {
return !this._throttleAll;
},
},
{
key: 'setProcess',
value: function setProcess(process) {
// NOP
},
},
{
key: 'close',
value: function close(callback) {
if (callback) {
callback();
}
},
},
]);
return DefaultThrottler;
}();
})();
exports.default = DefaultThrottler;
//# sourceMappingURL=default_throttler.js.map
//# sourceMappingURL=default_throttler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2018 Uber Technologies, Inc.

@@ -36,5 +51,11 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

@@ -50,4 +71,3 @@ var DEFAULT_REFRESH_INTERVAL_MS = 5000;

var RemoteThrottler = function () {
var RemoteThrottler = (function() {
/**

@@ -83,120 +103,133 @@ * Creates a RemoteThrottler that fetches credits remotely from jaeger-agent.

this._initialDelayTimeoutHandle = setTimeout(this._afterInitialDelay.bind(this), options.initialDelayMs || DEFAULT_INITIAL_DELAY_MS);
this._initialDelayTimeoutHandle = setTimeout(
this._afterInitialDelay.bind(this),
options.initialDelayMs || DEFAULT_INITIAL_DELAY_MS
);
}
_createClass(RemoteThrottler, [{
key: '_afterInitialDelay',
value: function _afterInitialDelay() {
this._refreshCredits();
this._refreshIntervalHandle = setInterval(this._refreshCredits.bind(this), this._refreshIntervalMs);
this._initialDelayTimeoutHandle = null;
}
}, {
key: 'setProcess',
value: function setProcess(process) {
this._uuid = process.uuid || '';
}
}, {
key: 'isAllowed',
value: function isAllowed(operation) {
if (operation in this._credits) {
return this._isAllowed(operation);
}
// Credits for the operation will be asynchronously fetched
this._credits[operation] = 0;
this._metrics.throttledDebugSpans.increment(1);
return false;
}
}, {
key: '_isAllowed',
value: function _isAllowed(operation) {
var credits = this._credits[operation] || 0;
if (credits < UNIT_CREDIT) {
_createClass(RemoteThrottler, [
{
key: '_afterInitialDelay',
value: function _afterInitialDelay() {
this._refreshCredits();
this._refreshIntervalHandle = setInterval(this._refreshCredits.bind(this), this._refreshIntervalMs);
this._initialDelayTimeoutHandle = null;
},
},
{
key: 'setProcess',
value: function setProcess(process) {
this._uuid = process.uuid || '';
},
},
{
key: 'isAllowed',
value: function isAllowed(operation) {
if (operation in this._credits) {
return this._isAllowed(operation);
}
// Credits for the operation will be asynchronously fetched
this._credits[operation] = 0;
this._metrics.throttledDebugSpans.increment(1);
return false;
}
this._credits[operation] = credits - UNIT_CREDIT;
return true;
}
}, {
key: '_refreshCredits',
value: function _refreshCredits() {
if (!this._uuid) {
this._logger.error('UUID must be set to fetch credits');
return;
}
var keys = Object.keys(this._credits);
if (keys.length === 0) {
// No point fetching credits if there's no operations to fetch
return;
}
this._fetchCredits(keys);
}
}, {
key: '_incrementCredits',
value: function _incrementCredits(creditResponses) {
var _this = this;
},
},
{
key: '_isAllowed',
value: function _isAllowed(operation) {
var credits = this._credits[operation] || 0;
if (credits < UNIT_CREDIT) {
this._metrics.throttledDebugSpans.increment(1);
return false;
}
this._credits[operation] = credits - UNIT_CREDIT;
return true;
},
},
{
key: '_refreshCredits',
value: function _refreshCredits() {
if (!this._uuid) {
this._logger.error('UUID must be set to fetch credits');
return;
}
var keys = Object.keys(this._credits);
if (keys.length === 0) {
// No point fetching credits if there's no operations to fetch
return;
}
this._fetchCredits(keys);
},
},
{
key: '_incrementCredits',
value: function _incrementCredits(creditResponses) {
var _this = this;
creditResponses.forEach(function (r) {
_this._credits[r.operation] = _this._credits[r.operation] + r.balance;
});
}
}, {
key: '_fetchCredits',
value: function _fetchCredits(operations) {
var _this2 = this;
creditResponses.forEach(function(r) {
_this._credits[r.operation] = _this._credits[r.operation] + r.balance;
});
},
},
{
key: '_fetchCredits',
value: function _fetchCredits(operations) {
var _this2 = this;
var serviceName = encodeURIComponent(this._serviceName);
var uuid = encodeURIComponent(this._uuid);
var ops = operations.map(encodeURIComponent).join('&operations=');
var url = '/credits?service=' + serviceName + '&uuid=' + uuid + '&operations=' + ops;
var serviceName = encodeURIComponent(this._serviceName);
var uuid = encodeURIComponent(this._uuid);
var ops = operations.map(encodeURIComponent).join('&operations=');
var url = '/credits?service=' + serviceName + '&uuid=' + uuid + '&operations=' + ops;
var success = function success(body) {
_this2._parseCreditResponse(body);
};
var error = function error(err) {
_this2._logger.error('Error in fetching credits: ' + err + '.');
_this2._metrics.throttlerUpdateFailure.increment(1);
};
_util2.default.httpGet(this._host, this._port, url, success, error);
}
}, {
key: '_parseCreditResponse',
value: function _parseCreditResponse(body) {
var creditResponses = void 0;
try {
creditResponses = JSON.parse(body);
} catch (error) {
this._logger.error('Error in parsing credit response: ' + error + '.');
this._metrics.throttlerUpdateFailure.increment(1);
return;
}
try {
this._incrementCredits(creditResponses.balances);
this._metrics.throttlerUpdateSuccess.increment(1);
} catch (error) {
this._logger.error('Error in updating credits: ' + error + '.');
this._metrics.throttlerUpdateFailure.increment(1);
return;
}
if (this._onCreditsUpdate) {
this._onCreditsUpdate(this);
}
}
}, {
key: 'close',
value: function close(callback) {
clearTimeout(this._initialDelayTimeoutHandle);
clearInterval(this._refreshIntervalHandle);
var success = function success(body) {
_this2._parseCreditResponse(body);
};
var error = function error(err) {
_this2._logger.error('Error in fetching credits: ' + err + '.');
_this2._metrics.throttlerUpdateFailure.increment(1);
};
_util2.default.httpGet(this._host, this._port, url, success, error);
},
},
{
key: '_parseCreditResponse',
value: function _parseCreditResponse(body) {
var creditResponses = void 0;
try {
creditResponses = JSON.parse(body);
} catch (error) {
this._logger.error('Error in parsing credit response: ' + error + '.');
this._metrics.throttlerUpdateFailure.increment(1);
return;
}
try {
this._incrementCredits(creditResponses.balances);
this._metrics.throttlerUpdateSuccess.increment(1);
} catch (error) {
this._logger.error('Error in updating credits: ' + error + '.');
this._metrics.throttlerUpdateFailure.increment(1);
return;
}
if (this._onCreditsUpdate) {
this._onCreditsUpdate(this);
}
},
},
{
key: 'close',
value: function close(callback) {
clearTimeout(this._initialDelayTimeoutHandle);
clearInterval(this._refreshIntervalHandle);
if (callback) {
callback();
}
}
}]);
if (callback) {
callback();
}
},
},
]);
return RemoteThrottler;
}();
})();
exports.default = RemoteThrottler;
//# sourceMappingURL=remote_throttler.js.map
//# sourceMappingURL=remote_throttler.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -88,10 +103,32 @@ //

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; } }
var _version = require('./version');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _version2 = _interopRequireDefault(_version);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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;
}
}
var Tracer = function () {
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var Tracer = (function() {
/**

@@ -112,4 +149,6 @@ * @param {String} [serviceName] - name of the current service or application.

function Tracer(serviceName) {
var reporter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _noop_reporter2.default();
var sampler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _const_sampler2.default(false);
var reporter =
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _noop_reporter2.default();
var sampler =
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _const_sampler2.default(false);
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

@@ -119,6 +158,7 @@

this._tags = options.tags || {};
this._tags[constants.JAEGER_CLIENT_VERSION_TAG_KEY] = 'Node-3.14.4';
this._tags[constants.TRACER_HOSTNAME_TAG_KEY] = this._tags[constants.TRACER_HOSTNAME_TAG_KEY] || _os2.default.hostname();
this._tags[constants.PROCESS_IP] = _util2.default.ipToInt(this._tags[constants.PROCESS_IP] || _util2.default.myIp());
this._tags = options.tags ? _util2.default.clone(options.tags) : {};
this._tags[constants.JAEGER_CLIENT_VERSION_TAG_KEY] = 'Node-' + _version2.default;
this._tags[constants.TRACER_HOSTNAME_TAG_KEY] =
this._tags[constants.TRACER_HOSTNAME_TAG_KEY] || _os2.default.hostname();
this._tags[constants.PROCESS_IP] = this._tags[constants.PROCESS_IP] || _util2.default.myIp();

@@ -131,3 +171,6 @@ this._metrics = options.metrics || new _metrics2.default(new _metric_factory2.default());

this._logger = options.logger || new _logger2.default();
this._baggageSetter = new _baggage_setter2.default(options.baggageRestrictionManager || new _default_baggage_restriction_manager2.default(), this._metrics);
this._baggageSetter = new _baggage_setter2.default(
options.baggageRestrictionManager || new _default_baggage_restriction_manager2.default(),
this._metrics
);
this._debugThrottler = options.debugThrottler || new _default_throttler2.default(false);

@@ -141,3 +184,3 @@ this._injectors = {};

urlEncoding: false,
metrics: this._metrics
metrics: this._metrics,
};

@@ -164,3 +207,3 @@

tags: _util2.default.convertObjectToTags(this._tags),
uuid: uuid
uuid: uuid,
};

@@ -172,245 +215,269 @@ this._debugThrottler.setProcess(this._process);

_createClass(Tracer, [{
key: '_startInternalSpan',
value: function _startInternalSpan(spanContext, operationName, startTime, userTags, internalTags, parentContext, rpcServer, references) {
var hadParent = parentContext && !parentContext.isDebugIDContainerOnly();
var span = new _span2.default(this, operationName, spanContext, startTime, references);
_createClass(Tracer, [
{
key: '_startInternalSpan',
value: function _startInternalSpan(
spanContext,
operationName,
startTime,
userTags,
internalTags,
parentContext,
rpcServer,
references
) {
var hadParent = parentContext && !parentContext.isDebugIDContainerOnly();
var span = new _span2.default(this, operationName, spanContext, startTime, references);
span.addTags(userTags);
span.addTags(internalTags);
span.addTags(userTags);
span.addTags(internalTags);
// emit metrics
if (span.context().isSampled()) {
this._metrics.spansStartedSampled.increment(1);
if (!hadParent) {
this._metrics.tracesStartedSampled.increment(1);
} else if (rpcServer) {
this._metrics.tracesJoinedSampled.increment(1);
// emit metrics
if (span.context().isSampled()) {
this._metrics.spansStartedSampled.increment(1);
if (!hadParent) {
this._metrics.tracesStartedSampled.increment(1);
} else if (rpcServer) {
this._metrics.tracesJoinedSampled.increment(1);
}
} else {
this._metrics.spansStartedNotSampled.increment(1);
if (!hadParent) {
this._metrics.tracesStartedNotSampled.increment(1);
} else if (rpcServer) {
this._metrics.tracesJoinedNotSampled.increment(1);
}
}
} else {
this._metrics.spansStartedNotSampled.increment(1);
if (!hadParent) {
this._metrics.tracesStartedNotSampled.increment(1);
} else if (rpcServer) {
this._metrics.tracesJoinedNotSampled.increment(1);
}
}
return span;
}
}, {
key: '_report',
value: function _report(span) {
this._metrics.spansFinished.increment(1);
this._reporter.report(span);
}
}, {
key: 'registerInjector',
value: function registerInjector(format, injector) {
this._injectors[format] = injector;
}
}, {
key: 'registerExtractor',
value: function registerExtractor(format, extractor) {
this._extractors[format] = extractor;
}
return span;
},
},
{
key: '_report',
value: function _report(span) {
this._metrics.spansFinished.increment(1);
this._reporter.report(span);
},
},
{
key: 'registerInjector',
value: function registerInjector(format, injector) {
this._injectors[format] = injector;
},
},
{
key: 'registerExtractor',
value: function registerExtractor(format, extractor) {
this._extractors[format] = extractor;
},
/**
* The method for creating a root or child span.
*
* @param {string} operationName - the name of the operation.
* @param {object} [options] - the fields to set on the newly created span.
* @param {string} options.operationName - the name to use for the newly
* created span. Required if called with a single argument.
* @param {SpanContext} [options.childOf] - a parent SpanContext (or Span,
* for convenience) that the newly-started span will be the child of
* (per REFERENCE_CHILD_OF). If specified, `fields.references` must
* be unspecified.
* @param {array} [options.references] - an array of Reference instances,
* each pointing to a causal parent SpanContext. If specified,
* `fields.childOf` must be unspecified.
* @param {object} [options.tags] - set of key-value pairs which will be set
* as tags on the newly created Span. Ownership of the object is
* passed to the created span for efficiency reasons (the caller
* should not modify this object after calling startSpan).
* @param {number} [options.startTime] - a manually specified start time for
* the created Span object. The time should be specified in
* milliseconds as Unix timestamp. Decimal value are supported
* to represent time values with sub-millisecond accuracy.
* @return {Span} - a new Span object.
**/
/**
* The method for creating a root or child span.
*
* @param {string} operationName - the name of the operation.
* @param {object} [options] - the fields to set on the newly created span.
* @param {string} options.operationName - the name to use for the newly
* created span. Required if called with a single argument.
* @param {SpanContext} [options.childOf] - a parent SpanContext (or Span,
* for convenience) that the newly-started span will be the child of
* (per REFERENCE_CHILD_OF). If specified, `fields.references` must
* be unspecified.
* @param {array} [options.references] - an array of Reference instances,
* each pointing to a causal parent SpanContext. If specified,
* `fields.childOf` must be unspecified.
* @param {object} [options.tags] - set of key-value pairs which will be set
* as tags on the newly created Span. Ownership of the object is
* passed to the created span for efficiency reasons (the caller
* should not modify this object after calling startSpan).
* @param {number} [options.startTime] - a manually specified start time for
* the created Span object. The time should be specified in
* milliseconds as Unix timestamp. Decimal value are supported
* to represent time values with sub-millisecond accuracy.
* @return {Span} - a new Span object.
**/
},
{
key: 'startSpan',
value: function startSpan(operationName, options) {
// Convert options.childOf to options.references as needed.
options = options || {};
var references = options.references || [];
}, {
key: 'startSpan',
value: function startSpan(operationName, options) {
// Convert options.childOf to options.references as needed.
options = options || {};
var references = options.references || [];
var userTags = options.tags || {};
var startTime = options.startTime || this.now();
var userTags = options.tags || {};
var startTime = options.startTime || this.now();
// This flag is used to ensure that CHILD_OF reference is preferred
// as a parent even if it comes after FOLLOWS_FROM reference.
var followsFromIsParent = false;
var parent = options.childOf instanceof _span2.default ? options.childOf.context() : options.childOf;
// If there is no childOf in options, then search list of references
for (var i = 0; i < references.length; i++) {
var ref = references[i];
if (ref.type() === opentracing.REFERENCE_CHILD_OF) {
if (!parent || followsFromIsParent) {
parent = ref.referencedContext();
break;
// This flag is used to ensure that CHILD_OF reference is preferred
// as a parent even if it comes after FOLLOWS_FROM reference.
var followsFromIsParent = false;
var parent = options.childOf instanceof _span2.default ? options.childOf.context() : options.childOf;
// If there is no childOf in options, then search list of references
for (var i = 0; i < references.length; i++) {
var ref = references[i];
if (ref.type() === opentracing.REFERENCE_CHILD_OF) {
if (!parent || followsFromIsParent) {
parent = ref.referencedContext();
break;
}
} else if (ref.type() === opentracing.REFERENCE_FOLLOWS_FROM) {
if (!parent) {
parent = ref.referencedContext();
followsFromIsParent = true;
}
}
} else if (ref.type() === opentracing.REFERENCE_FOLLOWS_FROM) {
if (!parent) {
parent = ref.referencedContext();
followsFromIsParent = true;
}
}
}
var spanKindValue = userTags[_opentracing.Tags.SPAN_KIND];
var rpcServer = spanKindValue === _opentracing.Tags.SPAN_KIND_RPC_SERVER;
var spanKindValue = userTags[_opentracing.Tags.SPAN_KIND];
var rpcServer = spanKindValue === _opentracing.Tags.SPAN_KIND_RPC_SERVER;
var ctx = new _span_context2.default();
var internalTags = {};
if (!parent || !parent.isValid) {
var randomId = _util2.default.getRandom64();
var flags = 0;
if (this._sampler.isSampled(operationName, internalTags)) {
flags |= constants.SAMPLED_MASK;
}
var ctx = new _span_context2.default();
var internalTags = {};
if (!parent || !parent.isValid) {
var randomId = _util2.default.getRandom64();
var flags = 0;
if (this._sampler.isSampled(operationName, internalTags)) {
flags |= constants.SAMPLED_MASK;
}
if (parent) {
if (parent.isDebugIDContainerOnly() && this._isDebugAllowed(operationName)) {
flags |= constants.SAMPLED_MASK | constants.DEBUG_MASK;
internalTags[constants.JAEGER_DEBUG_HEADER] = parent.debugId;
if (parent) {
if (parent.isDebugIDContainerOnly() && this._isDebugAllowed(operationName)) {
flags |= constants.SAMPLED_MASK | constants.DEBUG_MASK;
internalTags[constants.JAEGER_DEBUG_HEADER] = parent.debugId;
}
// baggage that could have been passed via `jaeger-baggage` header
ctx.baggage = parent.baggage;
}
// baggage that could have been passed via `jaeger-baggage` header
ctx.baggage = parent.baggage;
}
ctx.traceId = randomId;
ctx.spanId = randomId;
ctx.parentId = null;
ctx.flags = flags;
} else {
ctx.traceId = parent.traceId;
ctx.spanId = _util2.default.getRandom64();
ctx.parentId = parent.spanId;
ctx.flags = parent.flags;
ctx.traceId = randomId;
ctx.spanId = randomId;
ctx.parentId = null;
ctx.flags = flags;
} else {
ctx.traceId = parent.traceId;
ctx.spanId = _util2.default.getRandom64();
ctx.parentId = parent.spanId;
ctx.flags = parent.flags;
// reuse parent's baggage as we'll never change it
ctx.baggage = parent.baggage;
// reuse parent's baggage as we'll never change it
ctx.baggage = parent.baggage;
parent.finalizeSampling();
ctx.finalizeSampling();
}
parent.finalizeSampling();
ctx.finalizeSampling();
}
return this._startInternalSpan(ctx, operationName, startTime, userTags, internalTags, parent, rpcServer, references);
}
return this._startInternalSpan(
ctx,
operationName,
startTime,
userTags,
internalTags,
parent,
rpcServer,
references
);
},
/**
* Saves the span context into the carrier object for various formats, and encoders.
*
* @param {SpanContext} spanContext - the SpanContext to inject into the
* carrier object. As a convenience, a Span instance may be passed
* in instead (in which case its .context() is used for the
* inject()).
* @param {string} format - the format of the carrier.
* @param {any} carrier - see the documentation for the chosen `format`
* for a description of the carrier object.
**/
/**
* Saves the span context into the carrier object for various formats, and encoders.
*
* @param {SpanContext} spanContext - the SpanContext to inject into the
* carrier object. As a convenience, a Span instance may be passed
* in instead (in which case its .context() is used for the
* inject()).
* @param {string} format - the format of the carrier.
* @param {any} carrier - see the documentation for the chosen `format`
* for a description of the carrier object.
**/
},
{
key: 'inject',
value: function inject(spanContext, format, carrier) {
if (!spanContext) {
return;
}
}, {
key: 'inject',
value: function inject(spanContext, format, carrier) {
if (!spanContext) {
return;
}
var injector = this._injectors[format];
if (!injector) {
throw new Error('Unsupported format: ' + format);
}
var injector = this._injectors[format];
if (!injector) {
throw new Error('Unsupported format: ' + format);
}
if (spanContext instanceof _span2.default) {
spanContext = spanContext.context();
}
if (spanContext instanceof _span2.default) {
spanContext = spanContext.context();
}
spanContext.finalizeSampling();
injector.inject(spanContext, carrier);
},
spanContext.finalizeSampling();
injector.inject(spanContext, carrier);
}
/**
* Responsible for extracting a span context from various serialized formats.
*
* @param {string} format - the format of the carrier.
* @param {any} carrier - the type of the carrier object is determined by
* the format.
* @return {SpanContext}
* The extracted SpanContext, or null if no such SpanContext could
* be found in `carrier`
*/
},
{
key: 'extract',
value: function extract(format, carrier) {
var extractor = this._extractors[format];
if (!extractor) {
throw new Error('Unsupported format: ' + format);
}
/**
* Responsible for extracting a span context from various serialized formats.
*
* @param {string} format - the format of the carrier.
* @param {any} carrier - the type of the carrier object is determined by
* the format.
* @return {SpanContext}
* The extracted SpanContext, or null if no such SpanContext could
* be found in `carrier`
*/
var spanContext = extractor.extract(carrier);
}, {
key: 'extract',
value: function extract(format, carrier) {
var extractor = this._extractors[format];
if (!extractor) {
throw new Error('Unsupported format: ' + format);
}
if (spanContext) {
spanContext.finalizeSampling();
}
return spanContext;
},
var spanContext = extractor.extract(carrier);
/**
* Closes the tracer, flushes spans, and executes any callbacks if necessary.
*
* @param {Function} [callback] - a callback that runs after the tracer has been closed.
**/
},
{
key: 'close',
value: function close(callback) {
var _this = this;
if (spanContext) {
spanContext.finalizeSampling();
}
return spanContext;
}
var reporter = this._reporter;
this._reporter = new _noop_reporter2.default();
reporter.close(function() {
_this._sampler.close(callback);
});
this._debugThrottler.close();
},
/**
* Closes the tracer, flushes spans, and executes any callbacks if necessary.
*
* @param {Function} [callback] - a callback that runs after the tracer has been closed.
**/
/**
* Returns the current timestamp in milliseconds since the Unix epoch.
* Fractional values are allowed so that timestamps with sub-millisecond
* accuracy can be represented.
*/
},
{
key: 'now',
value: function now() {
// TODO investigate process.hrtime; verify it is available in all Node versions.
// http://stackoverflow.com/questions/11725691/how-to-get-a-microtime-in-node-js
return Date.now();
},
},
{
key: '_isDebugAllowed',
value: function _isDebugAllowed(operation) {
return this._debugThrottler.isAllowed(operation);
},
},
]);
}, {
key: 'close',
value: function close(callback) {
var _this = this;
var reporter = this._reporter;
this._reporter = new _noop_reporter2.default();
reporter.close(function () {
_this._sampler.close(callback);
});
this._debugThrottler.close();
}
/**
* Returns the current timestamp in milliseconds since the Unix epoch.
* Fractional values are allowed so that timestamps with sub-millisecond
* accuracy can be represented.
*/
}, {
key: 'now',
value: function now() {
// TODO investigate process.hrtime; verify it is available in all Node versions.
// http://stackoverflow.com/questions/11725691/how-to-get-a-microtime-in-node-js
return Date.now();
}
}, {
key: '_isDebugAllowed',
value: function _isDebugAllowed(operation) {
return this._debugThrottler.isAllowed(operation);
}
}]);
return Tracer;
}();
})();
exports.default = Tracer;
//# sourceMappingURL=tracer.js.map
//# sourceMappingURL=tracer.js.map
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
// Copyright (c) 2016 Uber Technologies, Inc.

@@ -36,7 +51,13 @@ //

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var Utils = function () {
var Utils = (function() {
function Utils() {

@@ -46,180 +67,164 @@ _classCallCheck(this, Utils);

_createClass(Utils, null, [{
key: 'startsWith',
_createClass(Utils, null, [
{
key: 'startsWith',
/**
* Determines whether a string contains a given prefix.
*
* @param {string} text - the string for to search for a prefix
* @param {string} prefix - the prefix to search for in the text given.
* @return {boolean} - boolean representing whether or not the
* string contains the prefix.
**/
value: function startsWith(text, prefix) {
return text.indexOf(prefix) === 0;
}
/**
* Determines whether a string contains a given prefix.
*
* @param {string} text - the string for to search for a prefix
* @param {string} prefix - the prefix to search for in the text given.
* @return {boolean} - boolean representing whether or not the
* string contains the prefix.
**/
value: function startsWith(text, prefix) {
return text.indexOf(prefix) === 0;
},
/**
* Determines whether a string contains a given suffix.
*
* @param {string} text - the string for to search for a suffix
* @param {string} suffix - the suffix to search for in the text given.
* @return {boolean} - boolean representing whether or not the
* string contains the suffix.
**/
/**
* Determines whether a string contains a given suffix.
*
* @param {string} text - the string for to search for a suffix
* @param {string} suffix - the suffix to search for in the text given.
* @return {boolean} - boolean representing whether or not the
* string contains the suffix.
**/
},
{
key: 'endsWith',
value: function endsWith(text, suffix) {
return text.lastIndexOf(suffix) === text.length - suffix.length;
},
}, {
key: 'endsWith',
value: function endsWith(text, suffix) {
return text.lastIndexOf(suffix) === text.length - suffix.length;
}
/**
* Determines whether a string contains a given prefix.
*
* @return {Buffer} - returns a buffer representing a random 64 bit
* number.
**/
},
{
key: 'getRandom64',
value: function getRandom64() {
var randint = _xorshift2.default.randomint();
var buf = new Buffer(8);
buf.writeUInt32BE(randint[0], 0);
buf.writeUInt32BE(randint[1], 4);
return buf;
},
/**
* Determines whether a string contains a given prefix.
*
* @return {Buffer} - returns a buffer representing a random 64 bit
* number.
**/
/**
* @param {string|number} numberValue - a string or number to be encoded
* as a 64 bit byte array.
* @return {Buffer} - returns a buffer representing the encoded string, or number.
**/
},
{
key: 'encodeInt64',
value: function encodeInt64(numberValue) {
return new _nodeInt2.default(numberValue).toBuffer();
},
}, {
key: 'getRandom64',
value: function getRandom64() {
var randint = _xorshift2.default.randomint();
var buf = new Buffer(8);
buf.writeUInt32BE(randint[0], 0);
buf.writeUInt32BE(randint[1], 4);
return buf;
}
/**
* @param {string|number} numberValue - a string or number to be encoded
* as a 64 bit byte array.
* @return {Buffer} - returns a buffer representing the encoded string, or number.
**/
}, {
key: 'encodeInt64',
value: function encodeInt64(numberValue) {
return new _nodeInt2.default(numberValue).toBuffer();
}
/**
* @param {string} ip - a string representation of an ip address.
* @return {number} - a 32-bit number where each byte represents an
* octect of an ip address.
**/
}, {
key: 'ipToInt',
value: function ipToInt(ip) {
var ipl = 0;
var parts = ip.split('.');
if (parts.length != 4) {
return null;
}
for (var i = 0; i < parts.length; i++) {
ipl <<= 8;
ipl += parseInt(parts[i], 10);
}
var signedLimit = 0x7fffffff;
if (ipl > signedLimit) {
return (1 << 32) - ipl;
}
return ipl;
}
/**
* @param {string} input - the input for which leading zeros should be removed.
* @return {string} - returns the input string without leading zeros.
**/
}, {
key: 'removeLeadingZeros',
value: function removeLeadingZeros(input) {
var counter = 0;
var length = input.length - 1;
for (var i = 0; i < length; i++) {
if (input.charAt(i) === '0') {
counter++;
} else {
break;
/**
* @param {string} input - the input for which leading zeros should be removed.
* @return {string} - returns the input string without leading zeros.
**/
},
{
key: 'removeLeadingZeros',
value: function removeLeadingZeros(input) {
var counter = 0;
var length = input.length - 1;
for (var i = 0; i < length; i++) {
if (input.charAt(i) === '0') {
counter++;
} else {
break;
}
}
}
return input.substring(counter);
}
}, {
key: 'myIp',
value: function myIp() {
var myIp = '0.0.0.0';
var ifaces = _os2.default.networkInterfaces();
var keys = Object.keys(ifaces);
loop1: for (var i = 0; i < keys.length; i++) {
var iface = ifaces[keys[i]];
for (var j = 0; j < iface.length; j++) {
if (iface[j].family === 'IPv4' && !iface[j].internal) {
myIp = iface[j].address;
break loop1;
return input.substring(counter);
},
},
{
key: 'myIp',
value: function myIp() {
var myIp = '0.0.0.0';
var ifaces = _os2.default.networkInterfaces();
var keys = Object.keys(ifaces);
loop1: for (var i = 0; i < keys.length; i++) {
var iface = ifaces[keys[i]];
for (var j = 0; j < iface.length; j++) {
if (iface[j].family === 'IPv4' && !iface[j].internal) {
myIp = iface[j].address;
break loop1;
}
}
}
}
return myIp;
}
}, {
key: 'clone',
value: function clone(obj) {
var newObj = {};
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
newObj[key] = obj[key];
return myIp;
},
},
{
key: 'clone',
value: function clone(obj) {
var newObj = {};
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
newObj[key] = obj[key];
}
}
}
return newObj;
}
}, {
key: 'convertObjectToTags',
value: function convertObjectToTags(dict) {
var tags = [];
for (var key in dict) {
var value = dict[key];
if (Object.prototype.hasOwnProperty.call(dict, key)) {
tags.push({ key: key, value: value });
return newObj;
},
},
{
key: 'convertObjectToTags',
value: function convertObjectToTags(dict) {
var tags = [];
for (var key in dict) {
var value = dict[key];
if (Object.prototype.hasOwnProperty.call(dict, key)) {
tags.push({ key: key, value: value });
}
}
}
return tags;
}
}, {
key: 'httpGet',
value: function httpGet(host, port, path, success, error) {
_http2.default.get({
host: host,
port: port,
path: path
}, function (res) {
// explicitly treat incoming data as utf8 (avoids issues with multi-byte chars)
res.setEncoding('utf8');
return tags;
},
},
{
key: 'httpGet',
value: function httpGet(host, port, path, success, error) {
_http2.default
.get(
{
host: host,
port: port,
path: path,
},
function(res) {
// explicitly treat incoming data as utf8 (avoids issues with multi-byte chars)
res.setEncoding('utf8');
// incrementally capture the incoming response body
var body = '';
res.on('data', function (chunk) {
body += chunk;
});
// incrementally capture the incoming response body
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function () {
success(body);
});
}).on('error', function (err) {
error(err);
});
}
}]);
res.on('end', function() {
success(body);
});
}
)
.on('error', function(err) {
error(err);
});
},
},
]);
return Utils;
}();
})();
exports.default = Utils;
//# sourceMappingURL=util.js.map
//# sourceMappingURL=util.js.map
{
"name": "jaeger-client",
"version": "3.14.4",
"version": "3.15.0",
"description": "Jaeger binding for OpenTracing Node",

@@ -20,6 +20,6 @@ "engines": {

"node-int64": "^0.4.0",
"opentracing": "^0.13.0",
"thriftrw": "^3.5.0",
"xorshift": "^0.2.0",
"opentracing": "^0.13.0",
"uuid": "^3.2.1"
"uuid": "^3.2.1",
"xorshift": "^0.2.0"
},

@@ -26,0 +26,0 @@ "devDependencies": {

@@ -20,3 +20,3 @@ [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![NPM Published Version][npm-img]][npm] [![OpenTracing 1.0 Enabled][ot-img]][ot-url]

| SAMPLER | KEY |
|---------------|-----------------|
| ------------- | --------------- |
| Constant | `const` |

@@ -48,4 +48,10 @@ | Probabilistic | `probabilistic` |

The tracer can be initialized with values coming from environment variables. None of the env vars are required and all of them can be overridden via direct setting of the property on the configuration object.
The tracer can be initialized with values coming from environment variables:
```jhavascript:
var tracer = initTracerFromEnv(config, options);
```
None of the env vars are required and all of them can be overridden via properties on the `config` object.
| Property | Description |

@@ -52,0 +58,0 @@ | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc