UNPKG

1.58 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var span_1 = require("./span");
4/**
5 * Reference pairs a reference type constant (e.g., REFERENCE_CHILD_OF or
6 * REFERENCE_FOLLOWS_FROM) with the SpanContext it points to.
7 *
8 * See the exported childOf() and followsFrom() functions at the package level.
9 */
10var Reference = /** @class */ (function () {
11 /**
12 * Initialize a new Reference instance.
13 *
14 * @param {string} type - the Reference type constant (e.g.,
15 * REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
16 * @param {SpanContext} referencedContext - the SpanContext being referred
17 * to. As a convenience, a Span instance may be passed in instead
18 * (in which case its .context() is used here).
19 */
20 function Reference(type, referencedContext) {
21 this._type = type;
22 this._referencedContext = (referencedContext instanceof span_1.default ?
23 referencedContext.context() :
24 referencedContext);
25 }
26 /**
27 * @return {string} The Reference type (e.g., REFERENCE_CHILD_OF or
28 * REFERENCE_FOLLOWS_FROM).
29 */
30 Reference.prototype.type = function () {
31 return this._type;
32 };
33 /**
34 * @return {SpanContext} The SpanContext being referred to (e.g., the
35 * parent in a REFERENCE_CHILD_OF Reference).
36 */
37 Reference.prototype.referencedContext = function () {
38 return this._referencedContext;
39 };
40 return Reference;
41}());
42exports.default = Reference;
43//# sourceMappingURL=reference.js.map
\No newline at end of file