Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opentracing

Package Overview
Dependencies
Maintainers
5
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opentracing - npm Package Compare versions

Comparing version 0.13.0 to 0.14.0

lib/binary_carrier.d.ts

21

lib/binary_carrier.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
Object.defineProperty(exports, "__esModule", { value: true });
/**

@@ -15,10 +9,9 @@ * Convenience class to use as a binary carrier.

*/
var BinaryCarrier = function BinaryCarrier(binaryData) {
_classCallCheck(this, BinaryCarrier);
this._buffer = binaryData;
};
var BinaryCarrier = (function () {
function BinaryCarrier(buffer) {
this.buffer = buffer;
}
return BinaryCarrier;
}());
exports.default = BinaryCarrier;
//# sourceMappingURL=binary_carrier.js.map

@@ -1,6 +0,3 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**

@@ -19,4 +16,3 @@ * The FORMAT_BINARY format represents SpanContexts in an opaque binary

*/
var FORMAT_BINARY = exports.FORMAT_BINARY = 'binary';
exports.FORMAT_BINARY = 'binary';
/**

@@ -35,4 +31,3 @@ * The FORMAT_TEXT_MAP format represents SpanContexts using a

*/
var FORMAT_TEXT_MAP = exports.FORMAT_TEXT_MAP = 'text_map';
exports.FORMAT_TEXT_MAP = 'text_map';
/**

@@ -54,4 +49,3 @@ * The FORMAT_HTTP_HEADERS format represents SpanContexts using a

*/
var FORMAT_HTTP_HEADERS = exports.FORMAT_HTTP_HEADERS = 'http_headers';
exports.FORMAT_HTTP_HEADERS = 'http_headers';
/**

@@ -63,4 +57,3 @@ * A Span may be the "child of" a parent Span. In a “child of” reference,

*/
var REFERENCE_CHILD_OF = exports.REFERENCE_CHILD_OF = 'child_of';
exports.REFERENCE_CHILD_OF = 'child_of';
/**

@@ -73,4 +66,3 @@ * Some parent Spans do not depend in any way on the result of their child

*/
var REFERENCE_FOLLOWS_FROM = exports.REFERENCE_FOLLOWS_FROM = 'follows_from';
exports.REFERENCE_FOLLOWS_FROM = 'follows_from';
//# sourceMappingURL=constants.js.map

@@ -1,17 +0,8 @@

'use strict';
var _ = require('../../..');
var _2 = _interopRequireDefault(_);
var _mock_tracer = require('../../mock_tracer');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable */
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("../../index");
var mock_tracer_1 = require("../../mock_tracer");
console.log('\nRunning demo...\n');
var tracer = new _mock_tracer.MockTracer();
var tracer = new mock_tracer_1.MockTracer();
console.log('Starting parent.');

@@ -21,3 +12,2 @@ var parent = tracer.startSpan('parent_span');

parent.setTag('alpha', '1000');
console.log('Waiting to start child...');

@@ -29,11 +19,9 @@ setTimeout(function () {

child.setTag('beta', '50');
child.log({ state: "waiting" });
child.log({ state: 'waiting' });
console.log('Waiting...');
setTimeout(function () {
console.log('Finishing child and parent.');
child.log({ state: "done" });
child.log({ state: 'done' });
child.finish();
parent.finish();
// Print some information about the two spans. Note the `report` method

@@ -44,12 +32,11 @@ // is specific to the MockTracer implementation and is not part of the

var report = tracer.report();
for (var i = 0; i < report.spans.length; i++) {
var span = report.spans[i];
for (var _i = 0, _a = report.spans; _i < _a.length; _i++) {
var span = _a[_i];
var tags = span.tags();
var tagKeys = Object.keys(tags);
console.log(' ' + span.operationName() + ' - ' + span.durationMs() + 'ms');
for (var j = 0; j < tagKeys.length; j++) {
var key = tagKeys[j];
console.log(" " + span.operationName() + " - " + span.durationMs() + "ms");
for (var _b = 0, tagKeys_1 = tagKeys; _b < tagKeys_1.length; _b++) {
var key = tagKeys_1[_b];
var value = tags[key];
console.log(' tag \'' + key + '\':\'' + value + '\'');
console.log(" tag '" + key + "':'" + value + "'");
}

@@ -59,3 +46,2 @@ }

}, 1000);
//# sourceMappingURL=demo.js.map

@@ -1,69 +0,108 @@

'use strict';
module.exports = {
/** ------------------------------------------------------------------------
* SPAN_KIND hints at relationship between spans, e.g. client/server
* --------------------------------------------------------------------------*/
SPAN_KIND: 'span.kind',
// Marks a span representing the client-side of an RPC or other remote call
SPAN_KIND_RPC_CLIENT: 'client',
// Marks a span representing the server-side of an RPC or other remote call
SPAN_KIND_RPC_SERVER: 'server',
/** ------------------------------------------------------------------------
* ERROR (boolean) indicates whether a Span ended in an error state.
* --------------------------------------------------------------------------*/
ERROR: 'error',
/** ------------------------------------------------------------------------
* COMPONENT (string) ia s low-cardinality identifier of the module, library,
* or package that is generating a span.
* --------------------------------------------------------------------------*/
COMPONENT: 'component',
/** ------------------------------------------------------------------------
* SAMPLING_PRIORITY (number) determines the priority of sampling this Span.
* --------------------------------------------------------------------------*/
SAMPLING_PRIORITY: 'sampling.priority',
/** ------------------------------------------------------------------------
* PEER_* tags can be emitted by either client-side of server-side to describe
* the other side/service in a peer-to-peer communications, like an RPC call.
* ---------------------------------------------------------------------------*/
// PEER_SERVICE (string) records the service name of the peer
PEER_SERVICE: 'peer.service',
// PEER_HOSTNAME records the host name of the peer
PEER_HOSTNAME: 'peer.hostname',
// PEER_HOST_IPV4 (number) records IP v4 host address of the peer
PEER_HOST_IPV4: 'peer.ipv4',
// PEER_HOST_IPV6 (string) records IP v6 host address of the peer
PEER_HOST_IPV6: 'peer.ipv6',
// PEER_PORT (number) records port number of the peer
PEER_PORT: 'peer.port',
/** ------------------------------------------------------------------------
* HTTP tags
* ---------------------------------------------------------------------------*/
// HTTP_URL (string) should be the URL of the request being handled in this
// segment of the trace, in standard URI format. The protocol is optional.
HTTP_URL: 'http.url',
// HTTP_METHOD (string) is the HTTP method of the request.
// Both upper/lower case values are allowed.
HTTP_METHOD: 'http.method',
// HTTP_STATUS_CODE (number) is the numeric HTTP status code (200, 404, etc)
// of the HTTP response.
HTTP_STATUS_CODE: 'http.status_code'
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/** SPAN_KIND hints at relationship between spans, e.g. client/server */
exports.SPAN_KIND = 'span.kind';
/** Marks a span representing the client-side of an RPC or other remote call */
exports.SPAN_KIND_RPC_CLIENT = 'client';
/** Marks a span representing the server-side of an RPC or other remote call */
exports.SPAN_KIND_RPC_SERVER = 'server';
/** Marks a span representing the producing-side within a messaging system or other remote call */
exports.SPAN_KIND_MESSAGING_PRODUCER = 'producer';
/** Marks a span representing the consuming-side within a messaging system or other remote call */
exports.SPAN_KIND_MESSAGING_CONSUMER = 'consumer';
/**
* ERROR (boolean) true if and only if the application considers the operation
* represented by the Span to have failed
*/
exports.ERROR = 'error';
/**
* COMPONENT (string) ia s low-cardinality identifier of the module, library,
* or package that is generating a span.
*/
exports.COMPONENT = 'component';
/**
* SAMPLING_PRIORITY (number) determines the priority of sampling this Span.
* If greater than 0, a hint to the Tracer to do its best to capture the trace.
* If 0, a hint to the trace to not-capture the trace. If absent, the Tracer
* should use its default sampling mechanism.
*/
exports.SAMPLING_PRIORITY = 'sampling.priority';
// ---------------------------------------------------------------------------
// PEER_* tags can be emitted by either client-side of server-side to describe
// the other side/service in a peer-to-peer communications, like an RPC call.
// ---------------------------------------------------------------------------
/**
* PEER_SERVICE (string) Remote service name (for some unspecified
* definition of "service"). E.g., "elasticsearch", "a_custom_microservice", "memcache"
*/
exports.PEER_SERVICE = 'peer.service';
/** PEER_HOSTNAME (string) Remote hostname. E.g., "opentracing.io", "internal.dns.name" */
exports.PEER_HOSTNAME = 'peer.hostname';
/**
* PEER_ADDRESS (string) Remote "address", suitable for use in a
* networking client library. This may be a "ip:port", a bare
* "hostname", a FQDN, or even a JDBC substring like "mysql://prod-db:3306"
*/
exports.PEER_ADDRESS = 'peer.address';
/**
* PEER_HOST_IPV4 (number) Remote IPv4 address as a .-separated tuple.
* E.g., "127.0.0.1"
*/
exports.PEER_HOST_IPV4 = 'peer.ipv4';
// PEER_HOST_IPV6 (string) Remote IPv6 address as a string of
// colon-separated 4-char hex tuples. E.g., "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
exports.PEER_HOST_IPV6 = 'peer.ipv6';
// PEER_PORT (number) Remote port. E.g., 80
exports.PEER_PORT = 'peer.port';
// ---------------------------------------------------------------------------
// HTTP tags
// ---------------------------------------------------------------------------
/**
* HTTP_URL (string) URL of the request being handled in this segment of the
* trace, in standard URI format. E.g., "https://domain.net/path/to?resource=here"
*/
exports.HTTP_URL = 'http.url';
/**
* HTTP_METHOD (string) HTTP method of the request for the associated Span. E.g.,
* "GET", "POST"
*/
exports.HTTP_METHOD = 'http.method';
/**
* HTTP_STATUS_CODE (number) HTTP response status code for the associated Span.
* E.g., 200, 503, 404
*/
exports.HTTP_STATUS_CODE = 'http.status_code';
// -------------------------------------------------------------------------
// Messaging tags
// -------------------------------------------------------------------------
/**
* MESSAGE_BUS_DESTINATION (string) An address at which messages can be exchanged.
* E.g. A Kafka record has an associated "topic name" that can be extracted
* by the instrumented producer or consumer and stored using this tag.
*/
exports.MESSAGE_BUS_DESTINATION = 'message_bus.destination';
// --------------------------------------------------------------------------
// Database tags
// --------------------------------------------------------------------------
/**
* DB_INSTANCE (string) Database instance name. E.g., In java, if the
* jdbc.url="jdbc:mysql://127.0.0.1:3306/customers", the instance name is "customers".
*/
exports.DB_INSTANCE = 'db.instance';
/**
* DB_STATEMENT (string) A database statement for the given database type.
* E.g., for db.type="SQL", "SELECT * FROM wuser_table";
* for db.type="redis", "SET mykey 'WuValue'".
*/
exports.DB_STATEMENT = 'db.statement';
/**
* DB_TYPE (string) Database type. For any SQL database, "sql". For others,
* the lower-case database category, e.g. "cassandra", "hbase", or "redis".
*/
exports.DB_TYPE = 'db.type';
/**
* DB_USER (string) Username for accessing database. E.g., "readonly_user"
* or "reporting_user"
*/
exports.DB_USER = 'db.user';
//# sourceMappingURL=tags.js.map

@@ -1,25 +0,6 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.childOf = childOf;
exports.followsFrom = followsFrom;
var _constants = require('./constants');
var Constants = _interopRequireWildcard(_constants);
var _span = require('./span');
var _span2 = _interopRequireDefault(_span);
var _reference = require('./reference');
var _reference2 = _interopRequireDefault(_reference);
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; } }
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Constants = require("./constants");
var reference_1 = require("./reference");
var span_1 = require("./span");
/**

@@ -34,8 +15,8 @@ * Return a new REFERENCE_CHILD_OF reference.

// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof _span2.default) {
if (spanContext instanceof span_1.default) {
spanContext = spanContext.context();
}
return new _reference2.default(Constants.REFERENCE_CHILD_OF, spanContext);
return new reference_1.default(Constants.REFERENCE_CHILD_OF, spanContext);
}
exports.childOf = childOf;
/**

@@ -50,8 +31,8 @@ * Return a new REFERENCE_FOLLOWS_FROM reference.

// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof _span2.default) {
if (spanContext instanceof span_1.default) {
spanContext = spanContext.context();
}
return new _reference2.default(Constants.REFERENCE_FOLLOWS_FROM, spanContext);
return new reference_1.default(Constants.REFERENCE_FOLLOWS_FROM, spanContext);
}
exports.followsFrom = followsFrom;
//# sourceMappingURL=functions.js.map

@@ -1,27 +0,16 @@

'use strict';
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; }; }();
exports.initGlobalTracer = initGlobalTracer;
exports.globalTracer = globalTracer;
var _tracer = require('./tracer');
var _tracer2 = _interopRequireDefault(_tracer);
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var noopTracer = new _tracer2.default();
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var tracer_1 = require("./tracer");
var noopTracer = new tracer_1.default();
var _globalTracer = null;
// Allows direct importing/requiring of the global tracer:

@@ -38,37 +27,22 @@ //

// case where
var GlobalTracerDelegate = function (_Tracer) {
_inherits(GlobalTracerDelegate, _Tracer);
var GlobalTracerDelegate = (function (_super) {
__extends(GlobalTracerDelegate, _super);
function GlobalTracerDelegate() {
_classCallCheck(this, GlobalTracerDelegate);
return _possibleConstructorReturn(this, (GlobalTracerDelegate.__proto__ || Object.getPrototypeOf(GlobalTracerDelegate)).apply(this, arguments));
return _super !== null && _super.apply(this, arguments) || this;
}
_createClass(GlobalTracerDelegate, [{
key: 'startSpan',
value: function startSpan() {
var tracer = _globalTracer || noopTracer;
return tracer.startSpan.apply(tracer, arguments);
}
}, {
key: 'inject',
value: function inject() {
var tracer = _globalTracer || noopTracer;
return tracer.inject.apply(tracer, arguments);
}
}, {
key: 'extract',
value: function extract() {
var tracer = _globalTracer || noopTracer;
return tracer.extract.apply(tracer, arguments);
}
}]);
GlobalTracerDelegate.prototype.startSpan = function () {
var tracer = _globalTracer || noopTracer;
return tracer.startSpan.apply(this, arguments);
};
GlobalTracerDelegate.prototype.inject = function () {
var tracer = _globalTracer || noopTracer;
return tracer.inject.apply(this, arguments);
};
GlobalTracerDelegate.prototype.extract = function () {
var tracer = _globalTracer || noopTracer;
return tracer.extract.apply(this, arguments);
};
return GlobalTracerDelegate;
}(_tracer2.default);
}(tracer_1.default));
var globalTracerDelegate = new GlobalTracerDelegate();
/**

@@ -84,3 +58,3 @@ * Set the global Tracer.

}
exports.initGlobalTracer = initGlobalTracer;
/**

@@ -96,3 +70,3 @@ * Returns the global tracer.

}
exports.globalTracer = globalTracer;
//# sourceMappingURL=global_tracer.js.map

@@ -1,76 +0,24 @@

'use strict';
var _global_tracer = require('./global_tracer');
var GlobalTracer = _interopRequireWildcard(_global_tracer);
var _constants = require('./constants');
var Constants = _interopRequireWildcard(_constants);
var _functions = require('./functions');
var Functions = _interopRequireWildcard(_functions);
var _noop = require('./noop');
var Noop = _interopRequireWildcard(_noop);
var _tags = require('./ext/tags');
var Tags = _interopRequireWildcard(_tags);
var _binary_carrier = require('./binary_carrier');
var _binary_carrier2 = _interopRequireDefault(_binary_carrier);
var _reference = require('./reference');
var _reference2 = _interopRequireDefault(_reference);
var _span_context = require('./span_context');
var _span_context2 = _interopRequireDefault(_span_context);
var _span = require('./span');
var _span2 = _interopRequireDefault(_span);
var _tracer = require('./tracer');
var _tracer2 = _interopRequireDefault(_tracer);
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; } }
// Object.assign() is not available on Node v0.12, so implement a similar
// function here (subset of a proper polyfill).
function _extend(target) {
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
for (var key in source) {
// eslint-disable-line no-restricted-syntax
if (source.hasOwnProperty(key)) {
target[key] = source[key];
}
}
}
return target;
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
// Use `module.exports` rather than `export` to avoid the need to use `.default`
// when requiring the package in ES5 code.
module.exports = _extend({
BinaryCarrier: _binary_carrier2.default,
Reference: _reference2.default,
SpanContext: _span_context2.default,
Span: _span2.default,
Tracer: _tracer2.default,
Tags: Tags
}, Constants, Functions, GlobalTracer);
Object.defineProperty(exports, "__esModule", { value: true });
var binary_carrier_1 = require("./binary_carrier");
exports.BinaryCarrier = binary_carrier_1.default;
var Tags = require("./ext/tags");
exports.Tags = Tags;
var Noop = require("./noop");
var reference_1 = require("./reference");
exports.Reference = reference_1.default;
var span_1 = require("./span");
exports.Span = span_1.default;
var span_context_1 = require("./span_context");
exports.SpanContext = span_context_1.default;
var tracer_1 = require("./tracer");
exports.Tracer = tracer_1.default;
__export(require("./global_tracer"));
__export(require("./constants"));
__export(require("./functions"));
// Initialize the noops last to avoid a dependecy cycle between the classes.
Noop.initialize();
//# sourceMappingURL=index.js.map

@@ -1,26 +0,9 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MockContext = exports.MockSpan = exports.MockTracer = undefined;
var _mock_tracer = require('./mock_tracer');
var _mock_tracer2 = _interopRequireDefault(_mock_tracer);
var _mock_span = require('./mock_span');
var _mock_span2 = _interopRequireDefault(_mock_span);
var _mock_context = require('./mock_context');
var _mock_context2 = _interopRequireDefault(_mock_context);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.MockTracer = _mock_tracer2.default;
exports.MockSpan = _mock_span2.default;
exports.MockContext = _mock_context2.default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mock_context_1 = require("./mock_context");
exports.MockContext = mock_context_1.default;
var mock_span_1 = require("./mock_span");
exports.MockSpan = mock_span_1.default;
var mock_tracer_1 = require("./mock_tracer");
exports.MockTracer = mock_tracer_1.default;
//# sourceMappingURL=index.js.map

@@ -1,19 +0,14 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _ = require('../..');
var _2 = _interopRequireDefault(_);
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var opentracing = require("../index");
/**

@@ -23,25 +18,15 @@ * OpenTracing Context implementation designed for use in

*/
var MockContext = function (_opentracing$SpanCont) {
_inherits(MockContext, _opentracing$SpanCont);
//------------------------------------------------------------------------//
// MockContext-specific
//------------------------------------------------------------------------//
var MockContext = (function (_super) {
__extends(MockContext, _super);
function MockContext(span) {
_classCallCheck(this, MockContext);
var _this = _super.call(this) || this;
// Store a reference to the span itself since this is a mock tracer
// intended to make debugging and unit testing easier.
var _this = _possibleConstructorReturn(this, (MockContext.__proto__ || Object.getPrototypeOf(MockContext)).call(this));
_this._span = span;
return _this;
}
return MockContext;
}(_2.default.SpanContext);
}(opentracing.SpanContext));
exports.MockContext = MockContext;
exports.default = MockContext;
//# sourceMappingURL=mock_context.js.map

@@ -1,18 +0,5 @@

'use strict';
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; }; }(); /* eslint-disable import/no-extraneous-dependencies */
var _underscore = require('underscore');
var _underscore2 = _interopRequireDefault(_underscore);
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"); } }
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable import/no-extraneous-dependencies */
var _ = require("lodash");
/**

@@ -22,8 +9,5 @@ * Index a collection of reported MockSpans in a way that's easy to run unit

*/
var MockReport = function () {
var MockReport = (function () {
function MockReport(spans) {
var _this = this;
_classCallCheck(this, MockReport);
this.spans = spans;

@@ -33,14 +17,10 @@ this.spansByUUID = {};

this.debugSpans = [];
this.unfinishedSpans = [];
_underscore2.default.each(spans, function (span) {
_.each(spans, function (span) {
if (span._finishMs === 0) {
_this.unfinishedSpans.push(span);
}
_this.spansByUUID[span.uuid()] = span;
_this.debugSpans.push(span.debug());
_underscore2.default.each(span._tags, function (val, key) {
_.each(span.tags(), function (val, key) {
_this.spansByTag[key] = _this.spansByTag[key] || {};

@@ -52,23 +32,17 @@ _this.spansByTag[key][val] = _this.spansByTag[key][val] || [];

}
_createClass(MockReport, [{
key: 'firstSpanWithTagValue',
value: function firstSpanWithTagValue(key, val) {
var m = this.spansByTag[key];
if (!m) {
return null;
}
var n = m[val];
if (!n) {
return null;
}
return n[0];
MockReport.prototype.firstSpanWithTagValue = function (key, val) {
var m = this.spansByTag[key];
if (!m) {
return null;
}
}]);
var n = m[val];
if (!n) {
return null;
}
return n[0];
};
return MockReport;
}();
}());
exports.MockReport = MockReport;
exports.default = MockReport;
//# sourceMappingURL=mock_report.js.map

@@ -1,86 +0,28 @@

'use strict';
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 _2 = require('../..');
var _3 = _interopRequireDefault(_2);
var _mock_context = require('./mock_context');
var _mock_context2 = _interopRequireDefault(_mock_context);
var _underscore = require('underscore');
var _underscore2 = _interopRequireDefault(_underscore);
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies */
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var _ = require("lodash");
var opentracing = require("../index");
var mock_context_1 = require("./mock_context");
/**
* OpenTracing Span implementation designed for use in unit tests.
*/
var MockSpan = function (_opentracing$Span) {
_inherits(MockSpan, _opentracing$Span);
_createClass(MockSpan, [{
key: '_context',
//------------------------------------------------------------------------//
// OpenTracing implementation
//------------------------------------------------------------------------//
value: function _context() {
return new _mock_context2.default(this);
}
}, {
key: '_setOperationName',
value: function _setOperationName(name) {
this._operationName = name;
}
}, {
key: '_addTags',
value: function _addTags(set) {
var keys = Object.keys(set);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
this._tags[key] = set[key];
}
}
}, {
key: '_log',
value: function _log(fields, timestamp) {
this._logs.push({
fields: fields,
timestamp: timestamp
});
}
}, {
key: '_finish',
value: function _finish(finishTime) {
this._finishMs = finishTime || Date.now();
}
//------------------------------------------------------------------------//
// MockSpan-specific
//------------------------------------------------------------------------//
}]);
var MockSpan = (function (_super) {
__extends(MockSpan, _super);
//------------------------------------------------------------------------//
// MockSpan-specific
//------------------------------------------------------------------------//
function MockSpan(tracer) {
_classCallCheck(this, MockSpan);
var _this = _possibleConstructorReturn(this, (MockSpan.__proto__ || Object.getPrototypeOf(MockSpan)).call(this));
_this._tracer = tracer;
var _this = _super.call(this) || this;
_this._mockTracer = tracer;
_this._uuid = _this._generateUUID();

@@ -94,58 +36,64 @@ _this._startMs = Date.now();

}
_createClass(MockSpan, [{
key: 'uuid',
value: function uuid() {
return this._uuid;
//------------------------------------------------------------------------//
// OpenTracing implementation
//------------------------------------------------------------------------//
MockSpan.prototype._context = function () {
return new mock_context_1.default(this);
};
MockSpan.prototype._setOperationName = function (name) {
this._operationName = name;
};
MockSpan.prototype._addTags = function (set) {
var keys = Object.keys(set);
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
var key = keys_1[_i];
this._tags[key] = set[key];
}
}, {
key: 'operationName',
value: function operationName() {
return this._operationName;
};
MockSpan.prototype._log = function (fields, timestamp) {
this._logs.push({
fields: fields,
timestamp: timestamp
});
};
MockSpan.prototype._finish = function (finishTime) {
this._finishMs = finishTime || Date.now();
};
MockSpan.prototype.uuid = function () {
return this._uuid;
};
MockSpan.prototype.operationName = function () {
return this._operationName;
};
MockSpan.prototype.durationMs = function () {
return this._finishMs - this._startMs;
};
MockSpan.prototype.tags = function () {
return this._tags;
};
MockSpan.prototype._generateUUID = function () {
var p0 = ("00000000" + Math.abs((Math.random() * 0xFFFFFFFF) | 0).toString(16)).substr(-8);
var p1 = ("00000000" + Math.abs((Math.random() * 0xFFFFFFFF) | 0).toString(16)).substr(-8);
return "" + p0 + p1;
};
MockSpan.prototype.addReference = function (ref) {
};
/**
* Returns a simplified object better for console.log()'ing.
*/
MockSpan.prototype.debug = function () {
var obj = {
uuid: this._uuid,
operation: this._operationName,
millis: [this._finishMs - this._startMs, this._startMs, this._finishMs]
};
if (_.size(this._tags)) {
obj.tags = this._tags;
}
}, {
key: 'durationMs',
value: function durationMs() {
return this._finishMs - this._startMs;
}
}, {
key: 'tags',
value: function tags() {
return this._tags;
}
}, {
key: '_generateUUID',
value: function _generateUUID() {
var p0 = ('00000000' + Math.abs(Math.random() * 0xFFFFFFFF | 0).toString(16)).substr(-8);
var p1 = ('00000000' + Math.abs(Math.random() * 0xFFFFFFFF | 0).toString(16)).substr(-8);
return '' + p0 + p1;
}
}, {
key: 'addReference',
value: function addReference(ref) {}
/**
* Returns a simplified object better for console.log()'ing.
*/
}, {
key: 'debug',
value: function debug() {
var obj = {
uuid: this._uuid,
operation: this._operationName,
millis: [this._finishMs - this._startMs, this._startMs, this._finishMs]
};
if (_underscore2.default.size(this._tags)) {
obj.tags = this._tags;
}
return obj;
}
}]);
return obj;
};
return MockSpan;
}(_3.default.Span);
}(opentracing.Span));
exports.MockSpan = MockSpan;
exports.default = MockSpan;
//# sourceMappingURL=mock_span.js.map

@@ -1,122 +0,75 @@

'use strict';
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 _ = require('../..');
var _2 = _interopRequireDefault(_);
var _mock_span = require('./mock_span');
var _mock_span2 = _interopRequireDefault(_mock_span);
var _mock_report = require('./mock_report');
var _mock_report2 = _interopRequireDefault(_mock_report);
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
// TODO: Move mock-tracer to its own NPM package once it is complete and tested.
var opentracing = require("../index");
var mock_report_1 = require("./mock_report");
var mock_span_1 = require("./mock_span");
/**
* OpenTracing Tracer implementation designed for use in unit tests.
*/
var MockTracer = function (_opentracing$Tracer) {
_inherits(MockTracer, _opentracing$Tracer);
_createClass(MockTracer, [{
key: '_startSpan',
//------------------------------------------------------------------------//
// OpenTracing implementation
//------------------------------------------------------------------------//
value: function _startSpan(name, fields) {
// _allocSpan is given it's own method so that derived classes can
// allocate any type of object they want, but not have to duplicate
// the other common logic in startSpan().
var span = this._allocSpan(fields);
span.setOperationName(name);
this._spans.push(span);
if (fields.references) {
for (var i = 0; i < fields.references; i++) {
span.addReference(fields.references[i]);
}
}
// Capture the stack at the time the span started
span._startStack = new Error().stack;
return span;
}
}, {
key: '_inject',
value: function _inject(span, format, carrier) {
throw new Error('NOT YET IMPLEMENTED');
}
}, {
key: '_extract',
value: function _extract(format, carrier) {
throw new Error('NOT YET IMPLEMENTED');
}
//------------------------------------------------------------------------//
// MockTracer-specific
//------------------------------------------------------------------------//
}]);
var MockTracer = (function (_super) {
__extends(MockTracer, _super);
//------------------------------------------------------------------------//
// MockTracer-specific
//------------------------------------------------------------------------//
function MockTracer() {
_classCallCheck(this, MockTracer);
var _this = _possibleConstructorReturn(this, (MockTracer.__proto__ || Object.getPrototypeOf(MockTracer)).call(this));
var _this = _super.call(this) || this;
_this._spans = [];
return _this;
}
_createClass(MockTracer, [{
key: '_allocSpan',
value: function _allocSpan() {
return new _mock_span2.default(this);
//------------------------------------------------------------------------//
// OpenTracing implementation
//------------------------------------------------------------------------//
MockTracer.prototype._startSpan = function (name, fields) {
// _allocSpan is given it's own method so that derived classes can
// allocate any type of object they want, but not have to duplicate
// the other common logic in startSpan().
var span = this._allocSpan();
span.setOperationName(name);
this._spans.push(span);
if (fields.references) {
for (var i = 0; i < fields.references; i++) {
span.addReference(fields.references[i]);
}
}
/**
* Discard any buffered data.
*/
}, {
key: 'clear',
value: function clear() {
this._spans = [];
}
/**
* Return the buffered data in a format convenient for making unit test
* assertions.
*/
}, {
key: 'report',
value: function report() {
return new _mock_report2.default(this._spans);
}
}]);
// Capture the stack at the time the span started
span._startStack = new Error().stack;
return span;
};
MockTracer.prototype._inject = function (span, format, carrier) {
throw new Error('NOT YET IMPLEMENTED');
};
MockTracer.prototype._extract = function (format, carrier) {
throw new Error('NOT YET IMPLEMENTED');
};
MockTracer.prototype._allocSpan = function () {
return new mock_span_1.default(this);
};
/**
* Discard any buffered data.
*/
MockTracer.prototype.clear = function () {
this._spans = [];
};
/**
* Return the buffered data in a format convenient for making unit test
* assertions.
*/
MockTracer.prototype.report = function () {
return new mock_report_1.default(this._spans);
};
return MockTracer;
}(_2.default.Tracer);
}(opentracing.Tracer));
exports.MockTracer = MockTracer;
exports.default = MockTracer;
//# sourceMappingURL=mock_tracer.js.map

@@ -1,37 +0,17 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.span = exports.spanContext = exports.tracer = undefined;
exports.initialize = initialize;
var _tracer = require('./tracer');
var _tracer2 = _interopRequireDefault(_tracer);
var _span_context = require('./span_context');
var _span_context2 = _interopRequireDefault(_span_context);
var _span = require('./span');
var _span2 = _interopRequireDefault(_span);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable import/no-mutable-exports */
var tracer = exports.tracer = null;
var spanContext = exports.spanContext = null;
var span = exports.span = null;
/* eslint-enable import/no-mutable-exports */
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var span_1 = require("./span");
var span_context_1 = require("./span_context");
var tracer_1 = require("./tracer");
exports.tracer = null;
exports.spanContext = null;
exports.span = null;
// Deferred initialization to avoid a dependency cycle where Tracer depends on
// Span which depends on the noop tracer.
function initialize() {
exports.tracer = tracer = new _tracer2.default();
exports.span = span = new _span2.default();
exports.spanContext = spanContext = new _span_context2.default();
exports.tracer = new tracer_1.default();
exports.span = new span_1.default();
exports.spanContext = new span_context_1.default();
}
exports.initialize = initialize;
//# sourceMappingURL=noop.js.map

@@ -1,21 +0,4 @@

'use strict';
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 _span = require('./span');
var _span2 = _interopRequireDefault(_span);
var _span_context = require('./span_context');
var _span_context2 = _interopRequireDefault(_span_context);
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"); } }
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var span_1 = require("./span");
/**

@@ -27,50 +10,35 @@ * Reference pairs a reference type constant (e.g., REFERENCE_CHILD_OF or

*/
var Reference = function () {
_createClass(Reference, [{
key: 'type',
/**
* @return {string} The Reference type (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM).
*/
value: function type() {
return this._type;
}
/**
* @return {SpanContext} The SpanContext being referred to (e.g., the
* parent in a REFERENCE_CHILD_OF Reference).
*/
}, {
key: 'referencedContext',
value: function referencedContext() {
return this._referencedContext;
}
/**
* Initialize a new Reference instance.
*
* @param {string} type - the Reference type constant (e.g.,
* REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
* @param {SpanContext} referencedContext - the SpanContext being referred
* to. As a convenience, a Span instance may be passed in instead
* (in which case its .context() is used here).
*/
}]);
var Reference = (function () {
/**
* Initialize a new Reference instance.
*
* @param {string} type - the Reference type constant (e.g.,
* REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
* @param {SpanContext} referencedContext - the SpanContext being referred
* to. As a convenience, a Span instance may be passed in instead
* (in which case its .context() is used here).
*/
function Reference(type, referencedContext) {
_classCallCheck(this, Reference);
this._type = type;
this._referencedContext = referencedContext instanceof _span2.default ? referencedContext.context() : referencedContext;
this._referencedContext = (referencedContext instanceof span_1.default ?
referencedContext.context() :
referencedContext);
}
/**
* @return {string} The Reference type (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM).
*/
Reference.prototype.type = function () {
return this._type;
};
/**
* @return {SpanContext} The SpanContext being referred to (e.g., the
* parent in a REFERENCE_CHILD_OF Reference).
*/
Reference.prototype.referencedContext = function () {
return this._referencedContext;
};
return Reference;
}();
}());
exports.default = Reference;
//# sourceMappingURL=reference.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
Object.defineProperty(exports, "__esModule", { value: true });
/**

@@ -19,8 +13,9 @@ * SpanContext represents Span state that must propagate to descendant Spans

*/
var SpanContext = function SpanContext() {
_classCallCheck(this, SpanContext);
};
var SpanContext = (function () {
function SpanContext() {
}
return SpanContext;
}());
exports.SpanContext = SpanContext;
exports.default = SpanContext;
//# sourceMappingURL=span_context.js.map

@@ -1,21 +0,4 @@

'use strict';
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 ? "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 _noop = require('./noop');
var noop = _interopRequireWildcard(_noop);
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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var noop = require("./noop");
/**

@@ -27,300 +10,199 @@ * Span represents a logical unit of work as part of a broader Trace. Examples

*/
var Span = function () {
var Span = (function () {
function Span() {
_classCallCheck(this, Span);
}
_createClass(Span, [{
key: 'context',
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Returns the SpanContext object associated with this Span.
*
* @return {SpanContext}
*/
value: function context() {
return this._context();
// Debug-only runtime checks on the arguments
}
/**
* Returns the Tracer object used to create this Span.
*
* @return {Tracer}
*/
}, {
key: 'tracer',
value: function tracer() {
return this._tracer();
// Debug-only runtime checks on the arguments
}
/**
* Sets the string name for the logical operation this span represents.
*
* @param {string} name
*/
}, {
key: 'setOperationName',
value: function setOperationName(name) {
this._setOperationName(name);
// Debug-only runtime checks on the arguments
return this;
}
/**
* Sets a key:value pair on this Span that also propagates to future
* children of the associated Span.
*
* setBaggageItem() enables powerful functionality given a full-stack
* opentracing integration (e.g., arbitrary application data from a web
* client can make it, transparently, all the way into the depths of a
* storage system), and with it some powerful costs: use this feature with
* care.
*
* IMPORTANT NOTE #1: setBaggageItem() will only propagate baggage items to
* *future* causal descendants of the associated Span.
*
* IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and
* value is copied into every local *and remote* child of the associated
* Span, and that can add up to a lot of network and cpu overhead.
*
* @param {string} key
* @param {string} value
*/
}, {
key: 'setBaggageItem',
value: function setBaggageItem(key, value) {
this._setBaggageItem(key, value);
// Debug-only runtime checks on the arguments
return this;
}
/**
* Returns the value for a baggage item given its key.
*
* @param {string} key
* The key for the given trace attribute.
* @return {string}
* String value for the given key, or undefined if the key does not
* correspond to a set trace attribute.
*/
}, {
key: 'getBaggageItem',
value: function getBaggageItem(key) {
return this._getBaggageItem(key);
// Debug-only runtime checks on the arguments
}
/**
* Adds a single tag to the span. See `addTags()` for details.
*
* @param {string} key
* @param {any} value
*/
}, {
key: 'setTag',
value: function setTag(key, value) {
// NOTE: the call is normalized to a call to _addTags()
this._addTags(_defineProperty({}, key, value));
// Debug-only runtime checks on the arguments
return this;
}
/**
* Adds the given key value pairs to the set of span tags.
*
* Multiple calls to addTags() results in the tags being the superset of
* all calls.
*
* The behavior of setting the same key multiple times on the same span
* is undefined.
*
* The supported type of the values is implementation-dependent.
* Implementations are expected to safely handle all types of values but
* may choose to ignore unrecognized / unhandle-able values (e.g. objects
* with cyclic references, function objects).
*
* @return {[type]} [description]
*/
}, {
key: 'addTags',
value: function addTags(keyValueMap) {
this._addTags(keyValueMap);
// Debug-only runtime checks on the arguments
return this;
}
/**
* Add a log record to this Span, optionally at a user-provided timestamp.
*
* For example:
*
* span.log({
* size: rpc.size(), // numeric value
* URI: rpc.URI(), // string value
* payload: rpc.payload(), // Object value
* "keys can be arbitrary strings": rpc.foo(),
* });
*
* span.log({
* "error.description": error.description(), // numeric value
* }, error.timestampMillis());
*
* @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.
*/
}, {
key: 'log',
value: function log(keyValuePairs, timestamp) {
this._log(keyValuePairs, timestamp);
// Debug-only runtime checks on the arguments
return this;
}
/**
* DEPRECATED
*/
}, {
key: 'logEvent',
value: function logEvent(eventName, payload) {
return this._log({
event: eventName,
payload: payload
});
// Debug-only runtime checks on the arguments
}
/**
* 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) {
this._finish(finishTime);
// Do not return `this`. The Span generally should not be used after it
// is finished so chaining is not desired in this context.
// Debug-only runtime checks on the arguments
}
// ---------------------------------------------------------------------- //
// Derived classes can choose to implement the below
// ---------------------------------------------------------------------- //
// By default returns a no-op SpanContext.
}, {
key: '_context',
value: function _context() {
return noop.spanContext;
}
// By default returns a no-op tracer.
//
// The base class could store the tracer that created it, but it does not
// in order to ensure the no-op span implementation has zero members,
// which allows V8 to aggressively optimize calls to such objects.
}, {
key: '_tracer',
value: function _tracer() {
return noop.tracer;
}
// By default does nothing
}, {
key: '_setOperationName',
value: function _setOperationName(name) {}
// By default does nothing
}, {
key: '_setBaggageItem',
value: function _setBaggageItem(key, value) {}
// By default does nothing
}, {
key: '_getBaggageItem',
value: function _getBaggageItem(key) {}
// By default does nothing
//
// NOTE: both setTag() and addTags() map to this function. keyValuePairs
// will always be an associative array.
}, {
key: '_addTags',
value: function _addTags(keyValuePairs) {}
// By default does nothing
}, {
key: '_log',
value: function _log(keyValuePairs, timestamp) {}
// By default does nothing
//
// finishTime is expected to be either a number or undefined.
}, {
key: '_finish',
value: function _finish(finishTime) {}
}]);
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Returns the SpanContext object associated with this Span.
*
* @return {SpanContext}
*/
Span.prototype.context = function () {
return this._context();
};
/**
* Returns the Tracer object used to create this Span.
*
* @return {Tracer}
*/
Span.prototype.tracer = function () {
return this._tracer();
};
/**
* Sets the string name for the logical operation this span represents.
*
* @param {string} name
*/
Span.prototype.setOperationName = function (name) {
this._setOperationName(name);
return this;
};
/**
* Sets a key:value pair on this Span that also propagates to future
* children of the associated Span.
*
* setBaggageItem() enables powerful functionality given a full-stack
* opentracing integration (e.g., arbitrary application data from a web
* client can make it, transparently, all the way into the depths of a
* storage system), and with it some powerful costs: use this feature with
* care.
*
* IMPORTANT NOTE #1: setBaggageItem() will only propagate baggage items to
* *future* causal descendants of the associated Span.
*
* IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and
* value is copied into every local *and remote* child of the associated
* Span, and that can add up to a lot of network and cpu overhead.
*
* @param {string} key
* @param {string} value
*/
Span.prototype.setBaggageItem = function (key, value) {
this._setBaggageItem(key, value);
return this;
};
/**
* Returns the value for a baggage item given its key.
*
* @param {string} key
* The key for the given trace attribute.
* @return {string}
* String value for the given key, or undefined if the key does not
* correspond to a set trace attribute.
*/
Span.prototype.getBaggageItem = function (key) {
return this._getBaggageItem(key);
};
/**
* Adds a single tag to the span. See `addTags()` for details.
*
* @param {string} key
* @param {any} value
*/
Span.prototype.setTag = function (key, value) {
// NOTE: the call is normalized to a call to _addTags()
this._addTags((_a = {}, _a[key] = value, _a));
return this;
var _a;
};
/**
* Adds the given key value pairs to the set of span tags.
*
* Multiple calls to addTags() results in the tags being the superset of
* all calls.
*
* The behavior of setting the same key multiple times on the same span
* is undefined.
*
* The supported type of the values is implementation-dependent.
* Implementations are expected to safely handle all types of values but
* may choose to ignore unrecognized / unhandle-able values (e.g. objects
* with cyclic references, function objects).
*
* @return {[type]} [description]
*/
Span.prototype.addTags = function (keyValueMap) {
this._addTags(keyValueMap);
return this;
};
/**
* Add a log record to this Span, optionally at a user-provided timestamp.
*
* For example:
*
* span.log({
* size: rpc.size(), // numeric value
* URI: rpc.URI(), // string value
* payload: rpc.payload(), // Object value
* "keys can be arbitrary strings": rpc.foo(),
* });
*
* span.log({
* "error.description": someError.description(),
* }, someError.timestampMillis());
*
* @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.
*/
Span.prototype.log = function (keyValuePairs, timestamp) {
this._log(keyValuePairs, timestamp);
return this;
};
/**
* DEPRECATED
*/
Span.prototype.logEvent = function (eventName, payload) {
return 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.
*/
Span.prototype.finish = function (finishTime) {
this._finish(finishTime);
// Do not return `this`. The Span generally should not be used after it
// is finished so chaining is not desired in this context.
};
// ---------------------------------------------------------------------- //
// Derived classes can choose to implement the below
// ---------------------------------------------------------------------- //
// By default returns a no-op SpanContext.
Span.prototype._context = function () {
return noop.spanContext;
};
// By default returns a no-op tracer.
//
// The base class could store the tracer that created it, but it does not
// in order to ensure the no-op span implementation has zero members,
// which allows V8 to aggressively optimize calls to such objects.
Span.prototype._tracer = function () {
return noop.tracer;
};
// By default does nothing
Span.prototype._setOperationName = function (name) {
};
// By default does nothing
Span.prototype._setBaggageItem = function (key, value) {
};
// By default does nothing
Span.prototype._getBaggageItem = function (key) {
return undefined;
};
// By default does nothing
//
// NOTE: both setTag() and addTags() map to this function. keyValuePairs
// will always be an associative array.
Span.prototype._addTags = function (keyValuePairs) {
};
// By default does nothing
Span.prototype._log = function (keyValuePairs, timestamp) {
};
// By default does nothing
//
// finishTime is expected to be either a number or undefined.
Span.prototype._finish = function (finishTime) {
};
return Span;
}();
}());
exports.Span = Span;
exports.default = Span;
//# sourceMappingURL=span.js.map

@@ -1,37 +0,6 @@

'use strict';
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 ? "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 _span = require('./span');
var _span2 = _interopRequireDefault(_span);
var _span_context = require('./span_context');
var _span_context2 = _interopRequireDefault(_span_context);
var _constants = require('./constants');
var Constants = _interopRequireWildcard(_constants);
var _functions = require('./functions');
var Functions = _interopRequireWildcard(_functions);
var _noop = require('./noop');
var Noop = _interopRequireWildcard(_noop);
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Functions = require("./functions");
var Noop = require("./noop");
var span_1 = require("./span");
/**

@@ -48,178 +17,132 @@ * Tracer is the entry-point between the instrumentation API and the tracing

*/
var Tracer = function () {
var Tracer = (function () {
function Tracer() {
_classCallCheck(this, Tracer);
}
_createClass(Tracer, [{
key: 'startSpan',
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Starts and returns a new Span representing a logical unit of work.
*
* For example:
*
* // Start a new (parentless) root Span:
* var parent = Tracer.startSpan('DoWork');
*
* // Start a new (child) Span:
* var child = Tracer.startSpan('Subroutine', {
* childOf: parent.context(),
* });
*
* @param {string} name - the name of the operation.
* @param {object} [fields] - the fields to set on the newly created span.
* @param {string} [fields.operationName] - the name to use for the newly
* created span. Required if called with a single argument.
* @param {SpanContext} [fields.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} [fields.references] - an array of Reference instances,
* each pointing to a causal parent SpanContext. If specified,
* `fields.childOf` must be unspecified.
* @param {object} [fields.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} [fields.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.
*/
value: function startSpan(name, fields) {
// Convert fields.childOf to fields.references as needed.
fields = fields || {};
// Debug-only runtime checks on the arguments
if (fields.childOf) {
// Convert from a Span or a SpanContext into a Reference.
var childOf = Functions.childOf(fields.childOf);
if (fields.references) {
fields.references.push(childOf);
} else {
fields.references = [childOf];
}
delete fields.childOf;
// ---------------------------------------------------------------------- //
// OpenTracing API methods
// ---------------------------------------------------------------------- //
/**
* Starts and returns a new Span representing a logical unit of work.
*
* For example:
*
* // Start a new (parentless) root Span:
* var parent = Tracer.startSpan('DoWork');
*
* // Start a new (child) Span:
* var child = Tracer.startSpan('load-from-db', {
* childOf: parent.context(),
* });
*
* // Start a new async (FollowsFrom) Span:
* var child = Tracer.startSpan('async-cache-write', {
* references: [
* opentracing.followsFrom(parent.context())
* ],
* });
*
* @param {string} name - the name of the operation (REQUIRED).
* @param {SpanOptions} [options] - options for the newly created span.
* @return {Span} - a new Span object.
*/
Tracer.prototype.startSpan = function (name, options) {
if (options === void 0) { options = {}; }
// Convert options.childOf to fields.references as needed.
if (options.childOf) {
// Convert from a Span or a SpanContext into a Reference.
var childOf = Functions.childOf(options.childOf);
if (options.references) {
options.references.push(childOf);
}
return this._startSpan(name, fields);
}
/**
* Injects the given SpanContext instance for cross-process propagation
* within `carrier`. The expected type of `carrier` depends on the value of
* `format.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* var clientSpan = ...;
* ...
* // Inject clientSpan into a text carrier.
* var headersCarrier = {};
* Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* // Incorporate the textCarrier into the outbound HTTP request header
* // map.
* Object.assign(outboundHTTPReq.headers, headersCarrier);
* // ... send the httpReq
*
* @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) {
// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof _span2.default) {
spanContext = spanContext.context();
else {
options.references = [childOf];
}
// Debug-only runtime checks on the arguments
return this._inject(spanContext, format, carrier);
delete (options.childOf);
}
/**
* Returns a SpanContext instance extracted from `carrier` in the given
* `format`.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* // Use the inbound HTTP request's headers as a text map carrier.
* var headersCarrier = inboundHTTPReq.headers;
* var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
*
* @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) {
return this._extract(format, carrier);
// Debug-only runtime checks on the arguments
return this._startSpan(name, options);
};
/**
* Injects the given SpanContext instance for cross-process propagation
* within `carrier`. The expected type of `carrier` depends on the value of
* `format.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* var clientSpan = ...;
* ...
* // Inject clientSpan into a text carrier.
* var headersCarrier = {};
* Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* // Incorporate the textCarrier into the outbound HTTP request header
* // map.
* Object.assign(outboundHTTPReq.headers, headersCarrier);
* // ... send the httpReq
*
* @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.
*/
Tracer.prototype.inject = function (spanContext, format, carrier) {
// Allow the user to pass a Span instead of a SpanContext
if (spanContext instanceof span_1.default) {
spanContext = spanContext.context();
}
// ---------------------------------------------------------------------- //
// Derived classes can choose to implement the below
// ---------------------------------------------------------------------- //
// NOTE: the input to this method is *always* an associative array. The
// public-facing startSpan() method normalizes the arguments so that
// all N implementations do not need to worry about variations in the call
// signature.
//
// The default behavior returns a no-op span.
}, {
key: '_startSpan',
value: function _startSpan(name, fields) {
return Noop.span;
}
// The default behavior is a no-op.
}, {
key: '_inject',
value: function _inject(spanContext, format, carrier) {}
// The default behavior is to return null.
}, {
key: '_extract',
value: function _extract(format, carrier) {
return Noop.spanContext;
}
}]);
return this._inject(spanContext, format, carrier);
};
/**
* Returns a SpanContext instance extracted from `carrier` in the given
* `format`.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* // Use the inbound HTTP request's headers as a text map carrier.
* var headersCarrier = inboundHTTPReq.headers;
* var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
*
* @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`
*/
Tracer.prototype.extract = function (format, carrier) {
return this._extract(format, carrier);
};
// ---------------------------------------------------------------------- //
// Derived classes can choose to implement the below
// ---------------------------------------------------------------------- //
// NOTE: the input to this method is *always* an associative array. The
// public-facing startSpan() method normalizes the arguments so that
// all N implementations do not need to worry about variations in the call
// signature.
//
// The default behavior returns a no-op span.
Tracer.prototype._startSpan = function (name, fields) {
return Noop.span;
};
// The default behavior is a no-op.
Tracer.prototype._inject = function (spanContext, format, carrier) {
};
// The default behavior is to return a no-op SpanContext.
Tracer.prototype._extract = function (format, carrier) {
return Noop.spanContext;
};
return Tracer;
}();
}());
exports.Tracer = Tracer;
exports.default = Tracer;
//# sourceMappingURL=tracer.js.map
{
"name": "opentracing",
"version": "0.13.0",
"version": "0.14.0",
"licence": "MIT",

@@ -12,11 +12,15 @@ "licenses": [

"main": "lib/index.js",
"typings": "lib/index.d.ts",
"scripts": {
"prepublish": "npm run webpack",
"test": "npm run test-cover",
"prepublish": "npm run build",
"lint": "tslint -t msbuild -c tslint.json 'src/**/*.ts'",
"test": "mocha lib/test/unittest.js --check-leaks --color",
"cover": "npm run test-cover && istanbul check-coverage",
"test-cover": "NODE_ENV=debug istanbul cover --report lcovonly --print none ./node_modules/.bin/_mocha test/unittest.js -- --check-leaks --color && istanbul report text",
"cover-html": "NODE_ENV=debug istanbul cover --report html --print none ./node_modules/.bin/_mocha test/unittest.js -- --check-leaks --color && istanbul report text",
"webpack": "npm run webpack-browser-debug && npm run webpack-browser-prod",
"webpack-browser-debug": "BUILD_CONFIG=debug webpack --display-error-details",
"webpack-browser-prod": "BUILD_CONFIG=production webpack --display-error-details"
"test-cover": "istanbul cover --report lcovonly --print none ./node_modules/.bin/_mocha lib/test/unittest.js -- --check-leaks --color && istanbul report text",
"cover-html": "istanbul cover --report html --print none ./node_modules/.bin/_mocha lib/test/unittest.js -- --check-leaks --color && istanbul report text",
"webpack": "webpack --display-error-details",
"build": "tsc -p .",
"watch": "tsc -w -p .",
"typedoc": "typedoc --out typedoc --tsconfig tsconfig.json --mode file",
"example": "node lib/examples/demo/demo.js"
},

@@ -29,25 +33,6 @@ "repository": {

"devDependencies": {
"babel-cli": "^6.11.4",
"babel-core": "^6.3.26",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-check-es2015-constants": "^6.7.2",
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.6.5",
"babel-plugin-transform-es2015-block-scoping": "^6.7.1",
"babel-plugin-transform-es2015-classes": "^6.6.5",
"babel-plugin-transform-es2015-computed-properties": "^6.6.5",
"babel-plugin-transform-es2015-destructuring": "^6.6.5",
"babel-plugin-transform-es2015-duplicate-keys": "^6.6.4",
"babel-plugin-transform-es2015-literals": "^6.5.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.7.4",
"babel-plugin-transform-es2015-object-super": "^6.6.5",
"babel-plugin-transform-es2015-parameters": "^6.7.0",
"babel-plugin-transform-es2015-spread": "^6.6.5",
"babel-plugin-transform-es2015-sticky-regex": "^6.5.0",
"babel-plugin-transform-es2015-template-literals": "^6.6.5",
"babel-plugin-transform-es2015-unicode-regex": "^6.5.0",
"babel-plugin-transform-node-env-inline-and-fold": "^6.8.1",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.13.2",
"@types/chai": "3.4.35",
"@types/lodash": "4.14.61",
"@types/mocha": "2.2.40",
"@types/node": "7.0.12",
"chai": "^3.4.1",

@@ -57,15 +42,16 @@ "clone": "^1.0.2",

"coveralls": "^2.11.12",
"eslint": "2.13.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.10.2",
"eslint-plugin-jsx-a11y": "^1.5.5",
"eslint-plugin-react": "^5.2.2",
"cross-env": "^4.0.0",
"istanbul": "^0.4.5",
"json-loader": "^0.5.4",
"lodash": "^4.17.4",
"mocha": "^2.4.5",
"shelljs": "^0.5.3",
"source-map-support": "^0.3.3",
"underscore": "^1.8.3",
"webpack": "^1.12.9"
"surge": "^0.19.0",
"ts-loader": "^2.0.3",
"tslint": "^5.0.0",
"typedoc": "^0.5.10",
"typescript": "^2.2.2",
"webpack": "^2.3.3"
}
}

@@ -0,1 +1,3 @@

[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![NPM Published Version][npm-img]][npm]
# OpenTracing API for JavaScript

@@ -5,4 +7,2 @@

[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]
## Required Reading

@@ -26,3 +26,3 @@

```bash
make example
npm run example
```

@@ -47,11 +47,11 @@

```js
var http = require('http');
var opentracing = require('opentracing');
const http = require('http');
const opentracing = require('opentracing');
// NOTE: the default OpenTracing tracer does not record any tracing information.
// Replace this line with the tracer implementation of your choice.
var tracer = new opentracing.Tracer();
const tracer = new opentracing.Tracer();
var span = tracer.startSpan('http_request');
var opts = {
const span = tracer.startSpan('http_request');
const opts = {
host : 'example.com',

@@ -62,13 +62,15 @@ method: 'GET',

};
http.request(opts, function (res) {
http.request(opts, res => {
res.setEncoding('utf8');
res.on('error', function (err) {
span.logEvent('request_error', err);
res.on('error', err => {
// assuming no retries, mark the span as failed
span.setTag(opentracing.Tags.ERROR, true);
span.log({'event': 'error', 'error.object': err, 'message': err.message, 'stack': err.stack});
span.finish();
});
res.on('data', function (chunk) {
span.logEvent('data_received', chunk);
res.on('data', chunk => {
span.log({'event': 'data_received', 'chunk_length': chunk.length});
});
res.on('end', function(err) {
span.logEvent('request_end', err);
res.on('end', () {
span.log({'event': 'request_end'});
span.finish();

@@ -82,4 +84,4 @@ });

```js
var CustomTracer = require('tracing-implementation-of-your-choice');
var tracer = new CustomTracer();
const CustomTracer = require('tracing-implementation-of-your-choice');
const tracer = new CustomTracer();
```

@@ -89,3 +91,3 @@

The package contains two bundles built with webpack that can be included using a standard `<script>` tag. The library will be exposed under the global `opentracing` symbol:
The package contains two bundles built with webpack that can be included using a standard `<script>` tag. The library will be exposed under the global `opentracing` namespace:

@@ -95,2 +97,7 @@ * `dist/opentracing-browser.min.js` - minified, no runtime checks

### Usage with TypeScript
Since the source is written in TypeScript, if you are using TypeScript, you can just `npm install` the package and it will work out of the box.
This is especially useful for implementators who want to typecheck their implementation with the base interface.
### Global tracer

@@ -103,3 +110,3 @@

var tracer = opentracing.globalTracer();
const tracer = opentracing.globalTracer();
```

@@ -109,13 +116,5 @@

### Node.js debug version
```javascript
var opentracing = require('opentracing/debug');
```
Requiring `opentracing/debug` will include a version of the library with additional runtime checks that are useful for debugging but not desirable for production use.
## API Documentation
There is a hosted copy of the current generated [ESDoc API Documentation here](https://doc.esdoc.org/github.com/opentracing/opentracing-javascript/).
There is a hosted copy of the current generated [ESDoc API Documentation here](https://opentracing-javascript.surge.sh).

@@ -126,6 +125,9 @@ ## Contributing & developer information

The project is built using a `Makefile`. Run:
The project is written in TypeScript and built using a npm scripts. Run:
* `make build` creates the compiled, distributable code
* `make test` runs the tests
* `npm run build` creates the compiled, distributable JavaScript code in `./lib`
* `npm run watch` incrementally compiles on file changes
* `npm run webpack` creates the bundles for the browser in `./dist`
* `npm test` runs the tests
* `npm run typedoc` generates the documentation in `./typedoc`

@@ -138,17 +140,11 @@ ## OpenTracing tracer implementations

Implementations can subclass `opentracing.Trace`, `opentracing.Span`, and the other API classes to build a OpenTracing tracer.
Implementations can subclass `opentracing.Trace`, `opentracing.Span`, and the other API classes to build a OpenTracing tracer and implement the underscore prefixed methods such as `_addTag` to pick up a bit of common code implemented in the base classes.
Due to the dynamic nature of JavaScript, implementations can simply implement classes with the same signatures as the OpenTracing classes and use these directly as well (there's no need to subclass).
Lastly, optionally implementations may choose to subclass `opentracing.Trace`, etc. and implement the underscore prefixed methods such as `_addTag` to pick up a bit of common code implemented in the base classes. This is entirely optional.
### API compatibility testing
If `mocha` is being used for unit testing, the `api_compatibility.js` file can be used to test the custom tracer. The file exports a single function that expects as an argument a function that will return a new instance of the tracer.
If `mocha` is being used for unit testing, `test/api_compatibility` can be used to test the custom tracer. The file exports a single function that expects as an argument a function that will return a new instance of the tracer.
```javascript
var apiCompatibilityChecks = require('opentracing/test/api_compatibility.js');
apiCompatibilityCheck(function() {
return new CustomTracer();
});
const apiCompatibilityChecks = require('opentracing/test/api_compatibility.js');
apiCompatibilityCheck(() => new CustomTracer());
```

@@ -162,3 +158,6 @@

[cov-img]: https://coveralls.io/repos/github/opentracing/opentracing-javascript/badge.svg?branch=master
[npm-img]: https://badge.fury.io/js/opentracing.svg
[ci]: https://travis-ci.org/opentracing/opentracing-javascript
[cov]: https://coveralls.io/github/opentracing/opentracing-javascript?branch=master
[npm]: https://www.npmjs.com/package/opentracing

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

var webpack = require("webpack");
const webpack = require("webpack");

@@ -7,34 +7,21 @@ // Pass in the build configuration as environment variables

// Modify the webpack settings based on the configuration
var plugins = [];
var bundleSuffix = '';
var devtool = undefined;
const plugins = [];
let bundleSuffix = '';
let devtool;
if (CONFIG === 'debug') {
devtool = "source-map";
plugins.push(
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"debug"'
}
})
);
} else {
bundleSuffix = ".min";
plugins.push(
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress : {
dead_code : true,
unused : true,
compress: {
dead_code: true,
unused: true,
// Hide the dead code warnings. The defines intentionally create
// dead code paths.
warnings : false,
warnings: false,
},
}),
new webpack.optimize.DedupePlugin()
})
);

@@ -47,53 +34,28 @@ }

module.exports = {
entry : "./src/index.js",
target : 'web',
devtool : devtool,
output : {
path : "dist/",
filename : 'opentracing-browser' + bundleSuffix + ".js",
library : "opentracing",
libraryTarget : 'umd',
entry: './src/index.ts',
target: 'web',
output: {
path: __dirname + '/dist/',
filename: 'opentracing-browser' + bundleSuffix + '.js',
library: 'opentracing',
libraryTarget: 'umd',
},
plugins : plugins,
module : {
loaders : [
plugins,
module: {
rules: [
{
test : /\.js$/,
loader : "babel",
include : /src\//,
exclude : /node_modules/,
query : {
cacheDirectory : true,
presets : [ ],
plugins : [
"add-module-exports",
// Manually specify the *subset* of the ES2015 preset
// to use. This reduces the output file size and improves
// interoperability (e.g. Symbol on IE).
'babel-plugin-transform-es2015-template-literals',
'babel-plugin-transform-es2015-literals',
//'babel-plugin-transform-es2015-function-name',
'babel-plugin-transform-es2015-arrow-functions',
'babel-plugin-transform-es2015-block-scoped-functions',
'babel-plugin-transform-es2015-classes',
'babel-plugin-transform-es2015-object-super',
// 'babel-plugin-transform-es2015-shorthand-properties',
'babel-plugin-transform-es2015-duplicate-keys',
'babel-plugin-transform-es2015-computed-properties',
// 'babel-plugin-transform-es2015-for-of',
'babel-plugin-transform-es2015-sticky-regex',
'babel-plugin-transform-es2015-unicode-regex',
'babel-plugin-check-es2015-constants',
'babel-plugin-transform-es2015-spread',
'babel-plugin-transform-es2015-parameters',
'babel-plugin-transform-es2015-destructuring',
'babel-plugin-transform-es2015-block-scoping',
//'babel-plugin-transform-es2015-typeof-symbol',
'babel-plugin-transform-es2015-modules-commonjs',
],
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
compilerOptions: {
declaration: false
}
}
},
}
]
},
resolve: {
extensions: ['.ts']
},
};

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc