@azure/core-tracing 1.0.0-preview.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -0
- package/LICENSE +21 -0
- package/README.md +16 -82
- package/dist/index.js +150 -663
- package/dist/index.js.map +1 -1
- package/dist-esm/src/index.js +5 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/instrumenter.js +61 -0
- package/dist-esm/src/instrumenter.js.map +1 -0
- package/dist-esm/src/interfaces.js +4 -0
- package/dist-esm/src/interfaces.js.map +1 -0
- package/dist-esm/src/tracingClient.js +74 -0
- package/dist-esm/src/tracingClient.js.map +1 -0
- package/dist-esm/src/tracingContext.js +52 -0
- package/dist-esm/src/tracingContext.js.map +1 -0
- package/package.json +63 -60
- package/types/core-tracing.d.ts +211 -314
- package/Changelog.md +0 -27
- package/LICENSE.txt +0 -21
- package/ThirdPartyNotices.txt +0 -27
- package/dist-esm/lib/index.js +0 -13
- package/dist-esm/lib/index.js.map +0 -1
- package/dist-esm/lib/tracerProxy.js +0 -31
- package/dist-esm/lib/tracerProxy.js.map +0 -1
- package/dist-esm/lib/tracers/noop/noOpBinaryFormat.js +0 -23
- package/dist-esm/lib/tracers/noop/noOpBinaryFormat.js.map +0 -1
- package/dist-esm/lib/tracers/noop/noOpHttpTextFormat.js +0 -27
- package/dist-esm/lib/tracers/noop/noOpHttpTextFormat.js.map +0 -1
- package/dist-esm/lib/tracers/noop/noOpSpan.js +0 -70
- package/dist-esm/lib/tracers/noop/noOpSpan.js.map +0 -1
- package/dist-esm/lib/tracers/noop/noOpTracer.js +0 -65
- package/dist-esm/lib/tracers/noop/noOpTracer.js.map +0 -1
- package/dist-esm/lib/tracers/opencensus/openCensusSpanWrapper.js +0 -111
- package/dist-esm/lib/tracers/opencensus/openCensusSpanWrapper.js.map +0 -1
- package/dist-esm/lib/tracers/opencensus/openCensusTraceStateWrapper.js +0 -26
- package/dist-esm/lib/tracers/opencensus/openCensusTraceStateWrapper.js.map +0 -1
- package/dist-esm/lib/tracers/opencensus/openCensusTracerWrapper.js +0 -71
- package/dist-esm/lib/tracers/opencensus/openCensusTracerWrapper.js.map +0 -1
- package/dist-esm/lib/tracers/test/testSpan.js +0 -72
- package/dist-esm/lib/tracers/test/testSpan.js.map +0 -1
- package/dist-esm/lib/tracers/test/testTracer.js +0 -126
- package/dist-esm/lib/tracers/test/testTracer.js.map +0 -1
- package/dist-esm/lib/utils/cache.js +0 -40
- package/dist-esm/lib/utils/cache.js.map +0 -1
- package/dist-esm/lib/utils/global.browser.js +0 -6
- package/dist-esm/lib/utils/global.browser.js.map +0 -1
- package/dist-esm/lib/utils/global.js +0 -6
- package/dist-esm/lib/utils/global.js.map +0 -1
- package/dist-esm/lib/utils/traceParentHeader.js +0 -49
- package/dist-esm/lib/utils/traceParentHeader.js.map +0 -1
- package/lib/index.ts +0 -21
- package/lib/tracerProxy.ts +0 -36
- package/lib/tracers/noop/noOpBinaryFormat.ts +0 -22
- package/lib/tracers/noop/noOpHttpTextFormat.ts +0 -25
- package/lib/tracers/noop/noOpSpan.ts +0 -76
- package/lib/tracers/noop/noOpTracer.ts +0 -68
- package/lib/tracers/opencensus/openCensusSpanWrapper.ts +0 -142
- package/lib/tracers/opencensus/openCensusTraceStateWrapper.ts +0 -32
- package/lib/tracers/opencensus/openCensusTracerWrapper.ts +0 -83
- package/lib/tracers/test/testSpan.ts +0 -119
- package/lib/tracers/test/testTracer.ts +0 -162
- package/lib/utils/browser.d.ts +0 -2
- package/lib/utils/cache.ts +0 -53
- package/lib/utils/global.browser.ts +0 -6
- package/lib/utils/global.ts +0 -6
- package/lib/utils/traceParentHeader.ts +0 -63
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
// Licensed under the MIT License.
|
|
4
|
-
import { NoOpTracer } from "../noop/noOpTracer";
|
|
5
|
-
import { TestSpan } from "./testSpan";
|
|
6
|
-
import { SpanKind } from "@opentelemetry/types";
|
|
7
|
-
/**
|
|
8
|
-
* A mock tracer useful for testing
|
|
9
|
-
*/
|
|
10
|
-
var TestTracer = /** @class */ (function (_super) {
|
|
11
|
-
__extends(TestTracer, _super);
|
|
12
|
-
function TestTracer() {
|
|
13
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
14
|
-
_this.traceIdCounter = 0;
|
|
15
|
-
_this.spanIdCounter = 0;
|
|
16
|
-
_this.rootSpans = [];
|
|
17
|
-
_this.knownSpans = [];
|
|
18
|
-
return _this;
|
|
19
|
-
}
|
|
20
|
-
TestTracer.prototype.getNextTraceId = function () {
|
|
21
|
-
this.traceIdCounter++;
|
|
22
|
-
return String(this.traceIdCounter);
|
|
23
|
-
};
|
|
24
|
-
TestTracer.prototype.getNextSpanId = function () {
|
|
25
|
-
this.spanIdCounter++;
|
|
26
|
-
return String(this.spanIdCounter);
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Returns all Spans that were created without a parent
|
|
30
|
-
*/
|
|
31
|
-
TestTracer.prototype.getRootSpans = function () {
|
|
32
|
-
return this.rootSpans;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Returns all Spans this Tracer knows about
|
|
36
|
-
*/
|
|
37
|
-
TestTracer.prototype.getKnownSpans = function () {
|
|
38
|
-
return this.knownSpans;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Returns all Spans where end() has not been called
|
|
42
|
-
*/
|
|
43
|
-
TestTracer.prototype.getActiveSpans = function () {
|
|
44
|
-
return this.knownSpans.filter(function (span) {
|
|
45
|
-
return !span.endCalled;
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Return all Spans for a particular trace, grouped by their
|
|
50
|
-
* parent Span in a tree-like structure
|
|
51
|
-
* @param traceId The traceId to return the graph for
|
|
52
|
-
*/
|
|
53
|
-
TestTracer.prototype.getSpanGraph = function (traceId) {
|
|
54
|
-
var traceSpans = this.knownSpans.filter(function (span) {
|
|
55
|
-
return span.context().traceId === traceId;
|
|
56
|
-
});
|
|
57
|
-
var roots = [];
|
|
58
|
-
var nodeMap = new Map();
|
|
59
|
-
for (var _i = 0, traceSpans_1 = traceSpans; _i < traceSpans_1.length; _i++) {
|
|
60
|
-
var span = traceSpans_1[_i];
|
|
61
|
-
var spanId = span.context().spanId;
|
|
62
|
-
var node = {
|
|
63
|
-
name: span.name,
|
|
64
|
-
children: []
|
|
65
|
-
};
|
|
66
|
-
nodeMap.set(spanId, node);
|
|
67
|
-
if (span.parentSpanId) {
|
|
68
|
-
var parent = nodeMap.get(span.parentSpanId);
|
|
69
|
-
if (!parent) {
|
|
70
|
-
throw new Error("Span with name " + node.name + " has an unknown parentSpan with id " + span.parentSpanId);
|
|
71
|
-
}
|
|
72
|
-
parent.children.push(node);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
roots.push(node);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
roots: roots
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Starts a new Span.
|
|
84
|
-
* @param name The name of the span.
|
|
85
|
-
* @param options The SpanOptions used during Span creation.
|
|
86
|
-
*/
|
|
87
|
-
TestTracer.prototype.startSpan = function (name, options) {
|
|
88
|
-
if (options === void 0) { options = {}; }
|
|
89
|
-
var parentContext = this._getParentContext(options);
|
|
90
|
-
var traceId;
|
|
91
|
-
var isRootSpan = false;
|
|
92
|
-
if (parentContext && parentContext.traceId) {
|
|
93
|
-
traceId = parentContext.traceId;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
traceId = this.getNextTraceId();
|
|
97
|
-
isRootSpan = true;
|
|
98
|
-
}
|
|
99
|
-
var context = {
|
|
100
|
-
traceId: traceId,
|
|
101
|
-
spanId: this.getNextSpanId()
|
|
102
|
-
};
|
|
103
|
-
var span = new TestSpan(this, name, context, options.kind || SpanKind.INTERNAL, parentContext ? parentContext.spanId : undefined, options.startTime);
|
|
104
|
-
this.knownSpans.push(span);
|
|
105
|
-
if (isRootSpan) {
|
|
106
|
-
this.rootSpans.push(span);
|
|
107
|
-
}
|
|
108
|
-
return span;
|
|
109
|
-
};
|
|
110
|
-
TestTracer.prototype._getParentContext = function (options) {
|
|
111
|
-
var parent = options.parent;
|
|
112
|
-
var result;
|
|
113
|
-
if (parent) {
|
|
114
|
-
if ("traceId" in parent) {
|
|
115
|
-
result = parent;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
result = parent.context();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
};
|
|
123
|
-
return TestTracer;
|
|
124
|
-
}(NoOpTracer));
|
|
125
|
-
export { TestTracer };
|
|
126
|
-
//# sourceMappingURL=testTracer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testTracer.js","sourceRoot":"","sources":["../../../../lib/tracers/test/testTracer.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { getGlobalObject } from "./global";
|
|
4
|
-
var GLOBAL_TRACER_VERSION = 2;
|
|
5
|
-
// preview5 shipped with @azure/core-tracing.tracerCache
|
|
6
|
-
// and didn't have smart detection for collisions
|
|
7
|
-
var GLOBAL_TRACER_SYMBOL = Symbol.for("@azure/core-tracing.tracerCache2");
|
|
8
|
-
var cache;
|
|
9
|
-
function loadTracerCache() {
|
|
10
|
-
var globalObj = getGlobalObject();
|
|
11
|
-
var existingCache = globalObj[GLOBAL_TRACER_SYMBOL];
|
|
12
|
-
var setGlobalCache = true;
|
|
13
|
-
if (existingCache) {
|
|
14
|
-
if (existingCache.version === GLOBAL_TRACER_VERSION) {
|
|
15
|
-
cache = existingCache;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
setGlobalCache = false;
|
|
19
|
-
if (existingCache.tracer) {
|
|
20
|
-
throw new Error("Two incompatible versions of @azure/core-tracing have been loaded.\n This library is " + GLOBAL_TRACER_VERSION + ", existing is " + existingCache.version + ".");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!cache) {
|
|
25
|
-
cache = {
|
|
26
|
-
tracer: undefined,
|
|
27
|
-
version: GLOBAL_TRACER_VERSION
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (setGlobalCache) {
|
|
31
|
-
globalObj[GLOBAL_TRACER_SYMBOL] = cache;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export function getCache() {
|
|
35
|
-
if (!cache) {
|
|
36
|
-
loadTracerCache();
|
|
37
|
-
}
|
|
38
|
-
return cache;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../lib/utils/cache.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAGlC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,IAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,wDAAwD;AACxD,iDAAiD;AACjD,IAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAO5E,IAAI,KAAkB,CAAC;AAEvB,SAAS,eAAe;IACtB,IAAM,SAAS,GAAG,eAAe,EAAE,CAAC;IACpC,IAAM,aAAa,GAAgB,SAAS,CAAC,oBAAoB,CAAC,CAAC;IACnE,IAAI,cAAc,GAAG,IAAI,CAAC;IAC1B,IAAI,aAAa,EAAE;QACjB,IAAI,aAAa,CAAC,OAAO,KAAK,qBAAqB,EAAE;YACnD,KAAK,GAAG,aAAa,CAAC;SACvB;aAAM;YACL,cAAc,GAAG,KAAK,CAAC;YACvB,IAAI,aAAa,CAAC,MAAM,EAAE;gBACxB,MAAM,IAAI,KAAK,CACb,mGACkB,qBAAqB,sBAAiB,aAAa,CAAC,OAAO,MAAG,CACjF,CAAC;aACH;SACF;KACF;IAED,IAAI,CAAC,KAAK,EAAE;QACV,KAAK,GAAG;YACN,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,qBAAqB;SAC/B,CAAC;KACH;IACD,IAAI,cAAc,EAAE;QAClB,SAAS,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC;KACzC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,IAAI,CAAC,KAAK,EAAE;QACV,eAAe,EAAE,CAAC;KACnB;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global.browser.js","sourceRoot":"","sources":["../../../lib/utils/global.browser.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../../lib/utils/global.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC,MAAM,UAAU,eAAe;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { TraceFlags } from "@opentelemetry/types";
|
|
4
|
-
var VERSION = "00";
|
|
5
|
-
/**
|
|
6
|
-
* Generates a `SpanContext` given a `traceparent` header value.
|
|
7
|
-
* @param traceParent Serialized span context data as a `traceparent` header value.
|
|
8
|
-
* @returns The `SpanContext` generated from the `traceparent` value.
|
|
9
|
-
*/
|
|
10
|
-
export function extractSpanContextFromTraceParentHeader(traceParentHeader) {
|
|
11
|
-
var parts = traceParentHeader.split("-");
|
|
12
|
-
if (parts.length !== 4) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
var version = parts[0], traceId = parts[1], spanId = parts[2], traceOptions = parts[3];
|
|
16
|
-
if (version !== VERSION) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
var traceFlags = parseInt(traceOptions, 16);
|
|
20
|
-
var spanContext = {
|
|
21
|
-
spanId: spanId,
|
|
22
|
-
traceId: traceId,
|
|
23
|
-
traceFlags: traceFlags
|
|
24
|
-
};
|
|
25
|
-
return spanContext;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Generates a `traceparent` value given a span context.
|
|
29
|
-
* @param spanContext Contains context for a specific span.
|
|
30
|
-
* @returns The `spanContext` represented as a `traceparent` value.
|
|
31
|
-
*/
|
|
32
|
-
export function getTraceParentHeader(spanContext) {
|
|
33
|
-
var missingFields = [];
|
|
34
|
-
if (!spanContext.traceId) {
|
|
35
|
-
missingFields.push("traceId");
|
|
36
|
-
}
|
|
37
|
-
if (!spanContext.spanId) {
|
|
38
|
-
missingFields.push("spanId");
|
|
39
|
-
}
|
|
40
|
-
if (missingFields.length) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var flags = spanContext.traceFlags || TraceFlags.UNSAMPLED;
|
|
44
|
-
var hexFlags = flags.toString(16);
|
|
45
|
-
var traceFlags = hexFlags.length === 1 ? "0" + hexFlags : hexFlags;
|
|
46
|
-
// https://www.w3.org/TR/trace-context/#traceparent-header-field-values
|
|
47
|
-
return VERSION + "-" + spanContext.traceId + "-" + spanContext.spanId + "-" + traceFlags;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=traceParentHeader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"traceParentHeader.js","sourceRoot":"","sources":["../../../lib/utils/traceParentHeader.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC,OAAO,EAAe,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE/D,IAAM,OAAO,GAAG,IAAI,CAAC;AAErB;;;;GAIG;AACH,MAAM,UAAU,uCAAuC,CACrD,iBAAyB;IAEzB,IAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO;KACR;IAEM,IAAA,kBAAO,EAAE,kBAAO,EAAE,iBAAM,EAAE,uBAAY,CAAU;IAEvD,IAAI,OAAO,KAAK,OAAO,EAAE;QACvB,OAAO;KACR;IAED,IAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAE9C,IAAM,WAAW,GAAgB;QAC/B,MAAM,QAAA;QACN,OAAO,SAAA;QACP,UAAU,YAAA;KACX,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAwB;IAC3D,IAAM,aAAa,GAAa,EAAE,CAAC;IACnC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QACxB,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KAC/B;IACD,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;QACvB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9B;IAED,IAAI,aAAa,CAAC,MAAM,EAAE;QACxB,OAAO;KACR;IAED,IAAM,KAAK,GAAG,WAAW,CAAC,UAAU,IAAI,UAAU,CAAC,SAAS,CAAC;IAC7D,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpC,IAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAI,QAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;IAErE,uEAAuE;IACvE,OAAU,OAAO,SAAI,WAAW,CAAC,OAAO,SAAI,WAAW,CAAC,MAAM,SAAI,UAAY,CAAC;AACjF,CAAC"}
|
package/lib/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
export { getTracer, setTracer } from "./tracerProxy";
|
|
5
|
-
|
|
6
|
-
// Tracers and wrappers
|
|
7
|
-
export { NoOpSpan } from "./tracers/noop/noOpSpan";
|
|
8
|
-
export { NoOpTracer } from "./tracers/noop/noOpTracer";
|
|
9
|
-
export { OpenCensusSpanWrapper } from "./tracers/opencensus/openCensusSpanWrapper";
|
|
10
|
-
export { OpenCensusTracerWrapper } from "./tracers/opencensus/openCensusTracerWrapper";
|
|
11
|
-
export { TestTracer, SpanGraph, SpanGraphNode } from "./tracers/test/testTracer";
|
|
12
|
-
export { TestSpan } from "./tracers/test/testSpan";
|
|
13
|
-
|
|
14
|
-
// Utilities
|
|
15
|
-
export {
|
|
16
|
-
extractSpanContextFromTraceParentHeader,
|
|
17
|
-
getTraceParentHeader
|
|
18
|
-
} from "./utils/traceParentHeader";
|
|
19
|
-
|
|
20
|
-
// OpenCensus Interfaces
|
|
21
|
-
export { Tracer as OpenCensusTracer, Span as OpenCensusSpan } from "@opencensus/web-types";
|
package/lib/tracerProxy.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { NoOpTracer } from "./tracers/noop/noOpTracer";
|
|
5
|
-
import { Tracer } from "@opentelemetry/types";
|
|
6
|
-
import { getCache } from "./utils/cache";
|
|
7
|
-
|
|
8
|
-
let defaultTracer: Tracer;
|
|
9
|
-
|
|
10
|
-
function getDefaultTracer(): Tracer {
|
|
11
|
-
if (!defaultTracer) {
|
|
12
|
-
defaultTracer = new NoOpTracer();
|
|
13
|
-
}
|
|
14
|
-
return defaultTracer;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Sets the global tracer, enabling tracing for the Azure SDK.
|
|
19
|
-
* @param tracer An OpenTelemetry Tracer instance.
|
|
20
|
-
*/
|
|
21
|
-
export function setTracer(tracer: Tracer) {
|
|
22
|
-
const cache = getCache();
|
|
23
|
-
cache.tracer = tracer;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Retrieves the active tracer, or returns a
|
|
28
|
-
* no-op implementation if one is not set.
|
|
29
|
-
*/
|
|
30
|
-
export function getTracer() {
|
|
31
|
-
const cache = getCache();
|
|
32
|
-
if (!cache.tracer) {
|
|
33
|
-
return getDefaultTracer();
|
|
34
|
-
}
|
|
35
|
-
return cache.tracer;
|
|
36
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { BinaryFormat, SpanContext } from "@opentelemetry/types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A no-op implementation of BinaryFormat to be used when tracing is disabled.
|
|
8
|
-
*/
|
|
9
|
-
export class NoOpBinaryFormat implements BinaryFormat {
|
|
10
|
-
/** Serialize the given SpanContext to a buffer */
|
|
11
|
-
toBytes(_spanContext: SpanContext): ArrayBuffer {
|
|
12
|
-
return new ArrayBuffer(0);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Deserialize a SpanContext from binary encoding.
|
|
17
|
-
* Returns null if the buffer does not contain a valid SpanContext.
|
|
18
|
-
*/
|
|
19
|
-
fromBytes(_buffer: ArrayBuffer): SpanContext | null {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { HttpTextFormat, SpanContext } from "@opentelemetry/types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A no-op implementation of HttpTextFormat to be used when tracing is disabled.
|
|
8
|
-
*/
|
|
9
|
-
export class NoOpHttpTextFormat implements HttpTextFormat {
|
|
10
|
-
/**
|
|
11
|
-
* Injects the given SpanContext for transmitting to a remote server.
|
|
12
|
-
* @param _spanContext The SpanContext to transmit
|
|
13
|
-
* @param _format The format of the carrier
|
|
14
|
-
* @param _carrier The carrier to propagate through, e.g. an HTTP request
|
|
15
|
-
*/
|
|
16
|
-
inject(_spanContext: SpanContext, _format: string, _carrier: unknown): void {}
|
|
17
|
-
/**
|
|
18
|
-
* Returns a SpanContext intance extracted from the carrier.
|
|
19
|
-
* @param _format the format of the carrier
|
|
20
|
-
* @param _carrier The carrier being used for propagation, e.g. an HTTP request
|
|
21
|
-
*/
|
|
22
|
-
extract(_format: string, _carrier: unknown): SpanContext | null {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { Span, SpanContext, Attributes, Status } from "@opentelemetry/types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A no-op implementation of Span that can safely be used without side-effects.
|
|
7
|
-
*/
|
|
8
|
-
export class NoOpSpan implements Span {
|
|
9
|
-
/**
|
|
10
|
-
* Returns the SpanContext associated with this Span.
|
|
11
|
-
*/
|
|
12
|
-
context(): SpanContext {
|
|
13
|
-
return {
|
|
14
|
-
spanId: "",
|
|
15
|
-
traceId: ""
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Marks the end of Span execution.
|
|
21
|
-
* @param _endTime The time to use as the Span's end time. Defaults to
|
|
22
|
-
* the current time.
|
|
23
|
-
*/
|
|
24
|
-
end(_endTime?: number): void {
|
|
25
|
-
/* Noop */
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Sets an attribute on the Span
|
|
30
|
-
* @param _key the attribute key
|
|
31
|
-
* @param _value the attribute value
|
|
32
|
-
*/
|
|
33
|
-
setAttribute(_key: string, _value: unknown): this {
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Sets attributes on the Span
|
|
39
|
-
* @param _attributes the attributes to add
|
|
40
|
-
*/
|
|
41
|
-
setAttributes(_attributes: Attributes): this {
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Adds an event to the Span
|
|
47
|
-
* @param _name The name of the event
|
|
48
|
-
* @param _attributes The associated attributes to add for this event
|
|
49
|
-
*/
|
|
50
|
-
addEvent(_name: string, _attributes?: Attributes): this {
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Sets a status on the span. Overrides the default of CanonicalCode.OK.
|
|
56
|
-
* @param _status The status to set.
|
|
57
|
-
*/
|
|
58
|
-
setStatus(_status: Status): this {
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Updates the name of the Span
|
|
64
|
-
* @param _name the new Span name
|
|
65
|
-
*/
|
|
66
|
-
updateName(_name: string): this {
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Returns whether this span will be recorded
|
|
72
|
-
*/
|
|
73
|
-
isRecording(): boolean {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { NoOpSpan } from "./noOpSpan";
|
|
4
|
-
import { BinaryFormat, HttpTextFormat, Tracer, Span, SpanOptions } from "@opentelemetry/types";
|
|
5
|
-
import { NoOpBinaryFormat } from "./noOpBinaryFormat";
|
|
6
|
-
import { NoOpHttpTextFormat } from "./noOpHttpTextFormat";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A no-op implementation of Tracer that can be used when tracing
|
|
10
|
-
* is disabled.
|
|
11
|
-
*/
|
|
12
|
-
export class NoOpTracer implements Tracer {
|
|
13
|
-
/**
|
|
14
|
-
* Starts a new Span.
|
|
15
|
-
* @param _name The name of the span.
|
|
16
|
-
* @param _options The SpanOptions used during Span creation.
|
|
17
|
-
*/
|
|
18
|
-
startSpan(_name: string, _options?: SpanOptions): Span {
|
|
19
|
-
return new NoOpSpan();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns the current Span from the current context, if available.
|
|
24
|
-
*/
|
|
25
|
-
getCurrentSpan(): Span {
|
|
26
|
-
return new NoOpSpan();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Executes the given function within the context provided by a Span.
|
|
31
|
-
* @param _span The span that provides the context.
|
|
32
|
-
* @param fn The function to be executed.
|
|
33
|
-
*/
|
|
34
|
-
withSpan<T extends (...args: unknown[]) => ReturnType<T>>(_span: Span, fn: T): ReturnType<T> {
|
|
35
|
-
return fn();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Bind a Span as the target's scope
|
|
40
|
-
* @param target An object to bind the scope.
|
|
41
|
-
* @param _span A specific Span to use. Otherwise, use the current one.
|
|
42
|
-
*/
|
|
43
|
-
bind<T>(target: T, _span?: Span): T {
|
|
44
|
-
return target;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Send a pre-populated Span object to the exporter.
|
|
49
|
-
* @param _span The span to pass along.
|
|
50
|
-
*/
|
|
51
|
-
recordSpanData(_span: Span): void {
|
|
52
|
-
/* NOOP */
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns the BinaryFormat interface for serializing/deserializing Spans.
|
|
57
|
-
*/
|
|
58
|
-
getBinaryFormat(): BinaryFormat {
|
|
59
|
-
return new NoOpBinaryFormat();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Returns the HttpTextFormat interface for injecting/extracting Spans.
|
|
64
|
-
*/
|
|
65
|
-
getHttpTextFormat(): HttpTextFormat {
|
|
66
|
-
return new NoOpHttpTextFormat();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { SpanContext, Span, SpanOptions, Attributes, Status } from "@opentelemetry/types";
|
|
4
|
-
import { OpenCensusTraceStateWrapper } from "./openCensusTraceStateWrapper";
|
|
5
|
-
import { OpenCensusTracerWrapper } from "./openCensusTracerWrapper";
|
|
6
|
-
import { Attributes as OpenCensusAttributes, Span as OpenCensusSpan } from "@opencensus/web-types";
|
|
7
|
-
|
|
8
|
-
function isWrappedSpan(span?: Span | SpanContext): span is OpenCensusSpanWrapper {
|
|
9
|
-
return !!span && (span as OpenCensusSpanWrapper).getWrappedSpan !== undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function isTracer(
|
|
13
|
-
tracerOrSpan: OpenCensusTracerWrapper | OpenCensusSpan
|
|
14
|
-
): tracerOrSpan is OpenCensusTracerWrapper {
|
|
15
|
-
return (tracerOrSpan as OpenCensusTracerWrapper).getWrappedTracer !== undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* An implementation of OpenTelemetry Span that wraps an OpenCensus Span.
|
|
20
|
-
*/
|
|
21
|
-
export class OpenCensusSpanWrapper implements Span {
|
|
22
|
-
private _span: OpenCensusSpan;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The underlying OpenCensus Span
|
|
26
|
-
*/
|
|
27
|
-
public getWrappedSpan() {
|
|
28
|
-
return this._span;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Wraps an existing OpenCensus Span
|
|
33
|
-
* @param span A Span or RootSpan from OpenCensus
|
|
34
|
-
*/
|
|
35
|
-
constructor(span: OpenCensusSpan);
|
|
36
|
-
/**
|
|
37
|
-
* Create a new OpenCensus Span and wrap it.
|
|
38
|
-
* @param tracer The OpenCensus tracer that has been wrapped in OpenCensusTracerWrapper
|
|
39
|
-
* @param name The name of the Span
|
|
40
|
-
* @param options Options for the Span
|
|
41
|
-
*/
|
|
42
|
-
constructor(tracer: OpenCensusTracerWrapper, name: string, options?: SpanOptions);
|
|
43
|
-
constructor(
|
|
44
|
-
tracerOrSpan: OpenCensusTracerWrapper | OpenCensusSpan,
|
|
45
|
-
name: string = "",
|
|
46
|
-
options: SpanOptions = {}
|
|
47
|
-
) {
|
|
48
|
-
if (isTracer(tracerOrSpan)) {
|
|
49
|
-
const parent = isWrappedSpan(options.parent) ? options.parent.getWrappedSpan() : undefined;
|
|
50
|
-
this._span = tracerOrSpan.getWrappedTracer().startChildSpan({
|
|
51
|
-
name,
|
|
52
|
-
childOf: parent
|
|
53
|
-
});
|
|
54
|
-
this._span.start();
|
|
55
|
-
if (options.links) {
|
|
56
|
-
for (const link of options.links) {
|
|
57
|
-
// Since there is no way to set the link relationship, leave it as Unspecified.
|
|
58
|
-
this._span.addLink(link.spanContext.traceId, link.spanContext.spanId, 0 /* LinkType.UNSPECIFIED */, link.attributes as OpenCensusAttributes);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
this._span = tracerOrSpan;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Marks the end of Span execution.
|
|
68
|
-
* @param endTime The time to use as the Span's end time. Defaults to
|
|
69
|
-
* the current time.
|
|
70
|
-
*/
|
|
71
|
-
end(_endTime?: number): void {
|
|
72
|
-
this._span.end();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Returns the SpanContext associated with this Span.
|
|
77
|
-
*/
|
|
78
|
-
context(): SpanContext {
|
|
79
|
-
const openCensusSpanContext = this._span.spanContext;
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
spanId: openCensusSpanContext.spanId,
|
|
83
|
-
traceId: openCensusSpanContext.traceId,
|
|
84
|
-
traceFlags: openCensusSpanContext.options,
|
|
85
|
-
traceState: new OpenCensusTraceStateWrapper(openCensusSpanContext.traceState)
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Sets an attribute on the Span
|
|
91
|
-
* @param key the attribute key
|
|
92
|
-
* @param value the attribute value
|
|
93
|
-
*/
|
|
94
|
-
setAttribute(key: string, value: unknown): this {
|
|
95
|
-
this._span.addAttribute(key, value as any);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Sets attributes on the Span
|
|
101
|
-
* @param attributes the attributes to add
|
|
102
|
-
*/
|
|
103
|
-
setAttributes(attributes: Attributes): this {
|
|
104
|
-
this._span.attributes = attributes as OpenCensusAttributes;
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Adds an event to the Span
|
|
110
|
-
* @param name The name of the event
|
|
111
|
-
* @param attributes The associated attributes to add for this event
|
|
112
|
-
*/
|
|
113
|
-
addEvent(_name: string, _attributes?: Attributes): this {
|
|
114
|
-
throw new Error("Method not implemented.");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Sets a status on the span. Overrides the default of CanonicalCode.OK.
|
|
119
|
-
* @param status The status to set.
|
|
120
|
-
*/
|
|
121
|
-
setStatus(status: Status): this {
|
|
122
|
-
this._span.setStatus(status.code, status.message);
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Updates the name of the Span
|
|
128
|
-
* @param name the new Span name
|
|
129
|
-
*/
|
|
130
|
-
updateName(name: string): this {
|
|
131
|
-
this._span.name = name;
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Returns whether this span will be recorded
|
|
137
|
-
*/
|
|
138
|
-
isRecording(): boolean {
|
|
139
|
-
// NoRecordSpans have an empty traceId
|
|
140
|
-
return !!this._span.traceId;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { TraceState } from "@opentelemetry/types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export class OpenCensusTraceStateWrapper implements TraceState {
|
|
11
|
-
private readonly _state?: string;
|
|
12
|
-
|
|
13
|
-
constructor(state?: string) {
|
|
14
|
-
this._state = state;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get(_key: string): string | undefined {
|
|
18
|
-
throw new Error("Method not implemented.");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
set(_key: string, _value: string): void {
|
|
22
|
-
throw new Error("Method not implemented.");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
unset(_key: string): void {
|
|
26
|
-
throw new Error("Method not implemented");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
serialize(): string {
|
|
30
|
-
return this._state || "";
|
|
31
|
-
}
|
|
32
|
-
}
|