lightstep-tracer
Version:
> ❗ **This instrumentation is no longer recommended**. Please review [documentation on setting up and configuring the OpenTelemetry Node.js Launcher](https://github.com/lightstep/otel-launcher-node) or [OpenTelemetry JS (Browser)](https://github.com/open-
95 lines (77 loc) • 3.47 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _each2 = _interopRequireDefault(require("../_each"));
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 _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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
var SpanContextImp = /*#__PURE__*/function () {
// ---------------------------------------------------------------------- //
// Private methods
// ---------------------------------------------------------------------- //
function SpanContextImp(spanGUID, traceGUID, sampled) {
_classCallCheck(this, SpanContextImp);
this._baggage = {};
this._guid = spanGUID;
this._sampled = true; // Ignore undefined or null when determining truthiness.
if (sampled === false) {
this._sampled = sampled;
} // upperTraceGUID is the most significant 8 bytes of a B3/TraceContext
// 16 byte trace ID. Represented in base16.
this._upperTraceGUID = '0000000000000000';
this._traceGUID = traceGUID;
if (this._traceGUID && this._traceGUID.length === 32) {
this._upperTraceGUID = traceGUID.substr(0, 16);
this._traceGUID = traceGUID.substr(16);
}
}
_createClass(SpanContextImp, [{
key: "setBaggageItem",
value: // ---------------------------------------------------------------------- //
// OpenTracing Implementation
// ---------------------------------------------------------------------- //
function setBaggageItem(key, value) {
this._baggage[key] = value;
}
}, {
key: "getBaggageItem",
value: function getBaggageItem(key) {
return this._baggage[key];
}
}, {
key: "toTraceId",
value: function toTraceId() {
return this._traceGUID;
}
}, {
key: "toSpanId",
value: function toSpanId() {
return this._guid;
} // ---------------------------------------------------------------------- //
// LightStep Extensions
// ---------------------------------------------------------------------- //
// This is part of the formal OT API in Go; and will likely be supported
// across platforms.
//
// https://github.com/opentracing/opentracing.github.io/issues/103
}, {
key: "forEachBaggageItem",
value: function forEachBaggageItem(f) {
(0, _each2["default"])(this._baggage, function (val, key) {
f(key, val);
});
} // traceGUID returns a 128 bit trace ID.
}, {
key: "traceGUID",
value: function traceGUID() {
return "".concat(this._upperTraceGUID).concat(this._traceGUID);
}
}]);
return SpanContextImp;
}();
exports["default"] = SpanContextImp;
module.exports = exports.default;
//# sourceMappingURL=span_context_imp.js.map
;