@azure/core-tracing 1.0.0-preview.9 → 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 +57 -0
- package/README.md +18 -71
- package/dist/index.js +147 -606
- package/dist/index.js.map +1 -1
- package/dist-esm/src/index.js +2 -10
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/instrumenter.js +61 -0
- package/dist-esm/src/instrumenter.js.map +1 -0
- package/dist-esm/src/interfaces.js +1 -0
- package/dist-esm/src/interfaces.js.map +1 -1
- 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 +49 -46
- package/types/core-tracing.d.ts +197 -345
- package/dist-esm/src/tracerProxy.js +0 -31
- package/dist-esm/src/tracerProxy.js.map +0 -1
- package/dist-esm/src/tracers/noop/noOpSpan.js +0 -74
- package/dist-esm/src/tracers/noop/noOpSpan.js.map +0 -1
- package/dist-esm/src/tracers/noop/noOpTracer.js +0 -44
- package/dist-esm/src/tracers/noop/noOpTracer.js.map +0 -1
- package/dist-esm/src/tracers/opencensus/openCensusSpanWrapper.js +0 -113
- package/dist-esm/src/tracers/opencensus/openCensusSpanWrapper.js.map +0 -1
- package/dist-esm/src/tracers/opencensus/openCensusTraceStateWrapper.js +0 -26
- package/dist-esm/src/tracers/opencensus/openCensusTraceStateWrapper.js.map +0 -1
- package/dist-esm/src/tracers/opencensus/openCensusTracerWrapper.js +0 -54
- package/dist-esm/src/tracers/opencensus/openCensusTracerWrapper.js.map +0 -1
- package/dist-esm/src/tracers/test/testSpan.js +0 -93
- package/dist-esm/src/tracers/test/testSpan.js.map +0 -1
- package/dist-esm/src/tracers/test/testTracer.js +0 -127
- package/dist-esm/src/tracers/test/testTracer.js.map +0 -1
- package/dist-esm/src/utils/cache.js +0 -43
- package/dist-esm/src/utils/cache.js.map +0 -1
- package/dist-esm/src/utils/global.browser.js +0 -6
- package/dist-esm/src/utils/global.browser.js.map +0 -1
- package/dist-esm/src/utils/global.js +0 -6
- package/dist-esm/src/utils/global.js.map +0 -1
- package/dist-esm/src/utils/traceParentHeader.js +0 -48
- package/dist-esm/src/utils/traceParentHeader.js.map +0 -1
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { TraceFlags } from "@opentelemetry/api";
|
|
4
|
-
/**
|
|
5
|
-
* A no-op implementation of Span that can safely be used without side-effects.
|
|
6
|
-
*/
|
|
7
|
-
var NoOpSpan = /** @class */ (function () {
|
|
8
|
-
function NoOpSpan() {
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Returns the SpanContext associated with this Span.
|
|
12
|
-
*/
|
|
13
|
-
NoOpSpan.prototype.context = function () {
|
|
14
|
-
return {
|
|
15
|
-
spanId: "",
|
|
16
|
-
traceId: "",
|
|
17
|
-
traceFlags: TraceFlags.NONE
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Marks the end of Span execution.
|
|
22
|
-
* @param _endTime The time to use as the Span's end time. Defaults to
|
|
23
|
-
* the current time.
|
|
24
|
-
*/
|
|
25
|
-
NoOpSpan.prototype.end = function (_endTime) {
|
|
26
|
-
/* Noop */
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Sets an attribute on the Span
|
|
30
|
-
* @param _key the attribute key
|
|
31
|
-
* @param _value the attribute value
|
|
32
|
-
*/
|
|
33
|
-
NoOpSpan.prototype.setAttribute = function (_key, _value) {
|
|
34
|
-
return this;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Sets attributes on the Span
|
|
38
|
-
* @param _attributes the attributes to add
|
|
39
|
-
*/
|
|
40
|
-
NoOpSpan.prototype.setAttributes = function (_attributes) {
|
|
41
|
-
return this;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Adds an event to the Span
|
|
45
|
-
* @param _name The name of the event
|
|
46
|
-
* @param _attributes The associated attributes to add for this event
|
|
47
|
-
*/
|
|
48
|
-
NoOpSpan.prototype.addEvent = function (_name, _attributes) {
|
|
49
|
-
return this;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Sets a status on the span. Overrides the default of CanonicalCode.OK.
|
|
53
|
-
* @param _status The status to set.
|
|
54
|
-
*/
|
|
55
|
-
NoOpSpan.prototype.setStatus = function (_status) {
|
|
56
|
-
return this;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Updates the name of the Span
|
|
60
|
-
* @param _name the new Span name
|
|
61
|
-
*/
|
|
62
|
-
NoOpSpan.prototype.updateName = function (_name) {
|
|
63
|
-
return this;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Returns whether this span will be recorded
|
|
67
|
-
*/
|
|
68
|
-
NoOpSpan.prototype.isRecording = function () {
|
|
69
|
-
return false;
|
|
70
|
-
};
|
|
71
|
-
return NoOpSpan;
|
|
72
|
-
}());
|
|
73
|
-
export { NoOpSpan };
|
|
74
|
-
//# sourceMappingURL=noOpSpan.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noOpSpan.js","sourceRoot":"","sources":["../../../../src/tracers/noop/noOpSpan.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAyC,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvF;;GAEG;AACH;IAAA;IAqEA,CAAC;IApEC;;OAEG;IACH,0BAAO,GAAP;QACE,OAAO;YACL,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,UAAU,CAAC,IAAI;SAC5B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,sBAAG,GAAH,UAAI,QAAiB;QACnB,UAAU;IACZ,CAAC;IAED;;;;OAIG;IACH,+BAAY,GAAZ,UAAa,IAAY,EAAE,MAAe;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,gCAAa,GAAb,UAAc,WAAuB;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,2BAAQ,GAAR,UAAS,KAAa,EAAE,WAAwB;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,4BAAS,GAAT,UAAU,OAAe;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,6BAAU,GAAV,UAAW,KAAa;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,8BAAW,GAAX;QACE,OAAO,KAAK,CAAC;IACf,CAAC;IACH,eAAC;AAAD,CAAC,AArED,IAqEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Span, SpanContext, Attributes, Status, TraceFlags } from \"@opentelemetry/api\";\n\n/**\n * A no-op implementation of Span that can safely be used without side-effects.\n */\nexport class NoOpSpan implements Span {\n /**\n * Returns the SpanContext associated with this Span.\n */\n context(): SpanContext {\n return {\n spanId: \"\",\n traceId: \"\",\n traceFlags: TraceFlags.NONE\n };\n }\n\n /**\n * Marks the end of Span execution.\n * @param _endTime The time to use as the Span's end time. Defaults to\n * the current time.\n */\n end(_endTime?: number): void {\n /* Noop */\n }\n\n /**\n * Sets an attribute on the Span\n * @param _key the attribute key\n * @param _value the attribute value\n */\n setAttribute(_key: string, _value: unknown): this {\n return this;\n }\n\n /**\n * Sets attributes on the Span\n * @param _attributes the attributes to add\n */\n setAttributes(_attributes: Attributes): this {\n return this;\n }\n\n /**\n * Adds an event to the Span\n * @param _name The name of the event\n * @param _attributes The associated attributes to add for this event\n */\n addEvent(_name: string, _attributes?: Attributes): this {\n return this;\n }\n\n /**\n * Sets a status on the span. Overrides the default of CanonicalCode.OK.\n * @param _status The status to set.\n */\n setStatus(_status: Status): this {\n return this;\n }\n\n /**\n * Updates the name of the Span\n * @param _name the new Span name\n */\n updateName(_name: string): this {\n return this;\n }\n\n /**\n * Returns whether this span will be recorded\n */\n isRecording(): boolean {\n return false;\n }\n}\n"]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { NoOpSpan } from "./noOpSpan";
|
|
4
|
-
/**
|
|
5
|
-
* A no-op implementation of Tracer that can be used when tracing
|
|
6
|
-
* is disabled.
|
|
7
|
-
*/
|
|
8
|
-
var NoOpTracer = /** @class */ (function () {
|
|
9
|
-
function NoOpTracer() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Starts a new Span.
|
|
13
|
-
* @param _name The name of the span.
|
|
14
|
-
* @param _options The SpanOptions used during Span creation.
|
|
15
|
-
*/
|
|
16
|
-
NoOpTracer.prototype.startSpan = function (_name, _options) {
|
|
17
|
-
return new NoOpSpan();
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Returns the current Span from the current context, if available.
|
|
21
|
-
*/
|
|
22
|
-
NoOpTracer.prototype.getCurrentSpan = function () {
|
|
23
|
-
return new NoOpSpan();
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Executes the given function within the context provided by a Span.
|
|
27
|
-
* @param _span The span that provides the context.
|
|
28
|
-
* @param fn The function to be executed.
|
|
29
|
-
*/
|
|
30
|
-
NoOpTracer.prototype.withSpan = function (_span, fn) {
|
|
31
|
-
return fn();
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Bind a Span as the target's scope
|
|
35
|
-
* @param target An object to bind the scope.
|
|
36
|
-
* @param _span A specific Span to use. Otherwise, use the current one.
|
|
37
|
-
*/
|
|
38
|
-
NoOpTracer.prototype.bind = function (target, _span) {
|
|
39
|
-
return target;
|
|
40
|
-
};
|
|
41
|
-
return NoOpTracer;
|
|
42
|
-
}());
|
|
43
|
-
export { NoOpTracer };
|
|
44
|
-
//# sourceMappingURL=noOpTracer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noOpTracer.js","sourceRoot":"","sources":["../../../../src/tracers/noop/noOpTracer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;;GAGG;AACH;IAAA;IAkCA,CAAC;IAjCC;;;;OAIG;IACH,8BAAS,GAAT,UAAU,KAAa,EAAE,QAAsB;QAC7C,OAAO,IAAI,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,mCAAc,GAAd;QACE,OAAO,IAAI,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,6BAAQ,GAAR,UAA0D,KAAW,EAAE,EAAK;QAC1E,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,yBAAI,GAAJ,UAAQ,MAAS,EAAE,KAAY;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,iBAAC;AAAD,CAAC,AAlCD,IAkCC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { NoOpSpan } from \"./noOpSpan\";\nimport { Tracer, Span, SpanOptions } from \"@opentelemetry/api\";\n\n/**\n * A no-op implementation of Tracer that can be used when tracing\n * is disabled.\n */\nexport class NoOpTracer implements Tracer {\n /**\n * Starts a new Span.\n * @param _name The name of the span.\n * @param _options The SpanOptions used during Span creation.\n */\n startSpan(_name: string, _options?: SpanOptions): Span {\n return new NoOpSpan();\n }\n\n /**\n * Returns the current Span from the current context, if available.\n */\n getCurrentSpan(): Span {\n return new NoOpSpan();\n }\n\n /**\n * Executes the given function within the context provided by a Span.\n * @param _span The span that provides the context.\n * @param fn The function to be executed.\n */\n withSpan<T extends (...args: unknown[]) => ReturnType<T>>(_span: Span, fn: T): ReturnType<T> {\n return fn();\n }\n\n /**\n * Bind a Span as the target's scope\n * @param target An object to bind the scope.\n * @param _span A specific Span to use. Otherwise, use the current one.\n */\n bind<T>(target: T, _span?: Span): T {\n return target;\n }\n}\n"]}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { OpenCensusTraceStateWrapper } from "./openCensusTraceStateWrapper";
|
|
4
|
-
function isWrappedSpan(span) {
|
|
5
|
-
return !!span && span.getWrappedSpan !== undefined;
|
|
6
|
-
}
|
|
7
|
-
function isTracer(tracerOrSpan) {
|
|
8
|
-
return tracerOrSpan.getWrappedTracer !== undefined;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* An implementation of OpenTelemetry Span that wraps an OpenCensus Span.
|
|
12
|
-
*/
|
|
13
|
-
var OpenCensusSpanWrapper = /** @class */ (function () {
|
|
14
|
-
function OpenCensusSpanWrapper(tracerOrSpan, name, options) {
|
|
15
|
-
if (name === void 0) { name = ""; }
|
|
16
|
-
if (options === void 0) { options = {}; }
|
|
17
|
-
if (isTracer(tracerOrSpan)) {
|
|
18
|
-
var parent = isWrappedSpan(options.parent) ? options.parent.getWrappedSpan() : undefined;
|
|
19
|
-
this._span = tracerOrSpan.getWrappedTracer().startChildSpan({
|
|
20
|
-
name: name,
|
|
21
|
-
childOf: parent
|
|
22
|
-
});
|
|
23
|
-
this._span.start();
|
|
24
|
-
if (options.links) {
|
|
25
|
-
for (var _i = 0, _a = options.links; _i < _a.length; _i++) {
|
|
26
|
-
var link = _a[_i];
|
|
27
|
-
// Since there is no way to set the link relationship, leave it as Unspecified.
|
|
28
|
-
this._span.addLink(link.context.traceId, link.context.spanId, 0 /* LinkType.UNSPECIFIED */, link.attributes);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this._span = tracerOrSpan;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* The underlying OpenCensus Span
|
|
38
|
-
*/
|
|
39
|
-
OpenCensusSpanWrapper.prototype.getWrappedSpan = function () {
|
|
40
|
-
return this._span;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Marks the end of Span execution.
|
|
44
|
-
* @param endTime The time to use as the Span's end time. Defaults to
|
|
45
|
-
* the current time.
|
|
46
|
-
*/
|
|
47
|
-
OpenCensusSpanWrapper.prototype.end = function (_endTime) {
|
|
48
|
-
this._span.end();
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Returns the SpanContext associated with this Span.
|
|
52
|
-
*/
|
|
53
|
-
OpenCensusSpanWrapper.prototype.context = function () {
|
|
54
|
-
var openCensusSpanContext = this._span.spanContext;
|
|
55
|
-
return {
|
|
56
|
-
spanId: openCensusSpanContext.spanId,
|
|
57
|
-
traceId: openCensusSpanContext.traceId,
|
|
58
|
-
traceFlags: openCensusSpanContext.options,
|
|
59
|
-
traceState: new OpenCensusTraceStateWrapper(openCensusSpanContext.traceState)
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Sets an attribute on the Span
|
|
64
|
-
* @param key the attribute key
|
|
65
|
-
* @param value the attribute value
|
|
66
|
-
*/
|
|
67
|
-
OpenCensusSpanWrapper.prototype.setAttribute = function (key, value) {
|
|
68
|
-
this._span.addAttribute(key, value);
|
|
69
|
-
return this;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Sets attributes on the Span
|
|
73
|
-
* @param attributes the attributes to add
|
|
74
|
-
*/
|
|
75
|
-
OpenCensusSpanWrapper.prototype.setAttributes = function (attributes) {
|
|
76
|
-
this._span.attributes = attributes;
|
|
77
|
-
return this;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Adds an event to the Span
|
|
81
|
-
* @param name The name of the event
|
|
82
|
-
* @param attributes The associated attributes to add for this event
|
|
83
|
-
*/
|
|
84
|
-
OpenCensusSpanWrapper.prototype.addEvent = function (_name, _attributes) {
|
|
85
|
-
throw new Error("Method not implemented.");
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Sets a status on the span. Overrides the default of CanonicalCode.OK.
|
|
89
|
-
* @param status The status to set.
|
|
90
|
-
*/
|
|
91
|
-
OpenCensusSpanWrapper.prototype.setStatus = function (status) {
|
|
92
|
-
this._span.setStatus(status.code, status.message);
|
|
93
|
-
return this;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Updates the name of the Span
|
|
97
|
-
* @param name the new Span name
|
|
98
|
-
*/
|
|
99
|
-
OpenCensusSpanWrapper.prototype.updateName = function (name) {
|
|
100
|
-
this._span.name = name;
|
|
101
|
-
return this;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Returns whether this span will be recorded
|
|
105
|
-
*/
|
|
106
|
-
OpenCensusSpanWrapper.prototype.isRecording = function () {
|
|
107
|
-
// NoRecordSpans have an empty traceId
|
|
108
|
-
return !!this._span.traceId;
|
|
109
|
-
};
|
|
110
|
-
return OpenCensusSpanWrapper;
|
|
111
|
-
}());
|
|
112
|
-
export { OpenCensusSpanWrapper };
|
|
113
|
-
//# sourceMappingURL=openCensusSpanWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openCensusSpanWrapper.js","sourceRoot":"","sources":["../../../../src/tracers/opencensus/openCensusSpanWrapper.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SpanContext, Span, SpanOptions, Attributes, Status, TraceFlags } from \"@opentelemetry/api\";\nimport { OpenCensusTraceStateWrapper } from \"./openCensusTraceStateWrapper\";\nimport { OpenCensusTracerWrapper } from \"./openCensusTracerWrapper\";\nimport { Attributes as OpenCensusAttributes, Span as OpenCensusSpan } from \"@opencensus/web-types\";\n\nfunction isWrappedSpan(span?: Span | SpanContext | null): span is OpenCensusSpanWrapper {\n return !!span && (span as OpenCensusSpanWrapper).getWrappedSpan !== undefined;\n}\n\nfunction isTracer(\n tracerOrSpan: OpenCensusTracerWrapper | OpenCensusSpan\n): tracerOrSpan is OpenCensusTracerWrapper {\n return (tracerOrSpan as OpenCensusTracerWrapper).getWrappedTracer !== undefined;\n}\n\n/**\n * An implementation of OpenTelemetry Span that wraps an OpenCensus Span.\n */\nexport class OpenCensusSpanWrapper implements Span {\n private _span: OpenCensusSpan;\n\n /**\n * The underlying OpenCensus Span\n */\n public getWrappedSpan(): OpenCensusSpan {\n return this._span;\n }\n\n /**\n * Wraps an existing OpenCensus Span\n * @param span A Span or RootSpan from OpenCensus\n */\n constructor(span: OpenCensusSpan);\n /**\n * Create a new OpenCensus Span and wrap it.\n * @param tracer The OpenCensus tracer that has been wrapped in OpenCensusTracerWrapper\n * @param name The name of the Span\n * @param options Options for the Span\n */\n constructor(tracer: OpenCensusTracerWrapper, name: string, options?: SpanOptions);\n constructor(\n tracerOrSpan: OpenCensusTracerWrapper | OpenCensusSpan,\n name: string = \"\",\n options: SpanOptions = {}\n ) {\n if (isTracer(tracerOrSpan)) {\n const parent = isWrappedSpan(options.parent) ? options.parent.getWrappedSpan() : undefined;\n this._span = tracerOrSpan.getWrappedTracer().startChildSpan({\n name,\n childOf: parent\n });\n this._span.start();\n if (options.links) {\n for (const link of options.links) {\n // Since there is no way to set the link relationship, leave it as Unspecified.\n this._span.addLink(\n link.context.traceId,\n link.context.spanId,\n 0 /* LinkType.UNSPECIFIED */,\n link.attributes as OpenCensusAttributes\n );\n }\n }\n } else {\n this._span = tracerOrSpan;\n }\n }\n\n /**\n * Marks the end of Span execution.\n * @param endTime The time to use as the Span's end time. Defaults to\n * the current time.\n */\n end(_endTime?: number): void {\n this._span.end();\n }\n\n /**\n * Returns the SpanContext associated with this Span.\n */\n context(): SpanContext {\n const openCensusSpanContext = this._span.spanContext;\n\n return {\n spanId: openCensusSpanContext.spanId,\n traceId: openCensusSpanContext.traceId,\n traceFlags: openCensusSpanContext.options as TraceFlags,\n traceState: new OpenCensusTraceStateWrapper(openCensusSpanContext.traceState)\n };\n }\n\n /**\n * Sets an attribute on the Span\n * @param key the attribute key\n * @param value the attribute value\n */\n setAttribute(key: string, value: unknown): this {\n this._span.addAttribute(key, value as any);\n return this;\n }\n\n /**\n * Sets attributes on the Span\n * @param attributes the attributes to add\n */\n setAttributes(attributes: Attributes): this {\n this._span.attributes = attributes as OpenCensusAttributes;\n return this;\n }\n\n /**\n * Adds an event to the Span\n * @param name The name of the event\n * @param attributes The associated attributes to add for this event\n */\n addEvent(_name: string, _attributes?: Attributes): this {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Sets a status on the span. Overrides the default of CanonicalCode.OK.\n * @param status The status to set.\n */\n setStatus(status: Status): this {\n this._span.setStatus(status.code, status.message);\n return this;\n }\n\n /**\n * Updates the name of the Span\n * @param name the new Span name\n */\n updateName(name: string): this {\n this._span.name = name;\n return this;\n }\n\n /**\n * Returns whether this span will be recorded\n */\n isRecording(): boolean {\n // NoRecordSpans have an empty traceId\n return !!this._span.traceId;\n }\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
/**
|
|
4
|
-
* @ignore
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
var OpenCensusTraceStateWrapper = /** @class */ (function () {
|
|
8
|
-
function OpenCensusTraceStateWrapper(state) {
|
|
9
|
-
this._state = state;
|
|
10
|
-
}
|
|
11
|
-
OpenCensusTraceStateWrapper.prototype.get = function (_key) {
|
|
12
|
-
throw new Error("Method not implemented.");
|
|
13
|
-
};
|
|
14
|
-
OpenCensusTraceStateWrapper.prototype.set = function (_key, _value) {
|
|
15
|
-
throw new Error("Method not implemented.");
|
|
16
|
-
};
|
|
17
|
-
OpenCensusTraceStateWrapper.prototype.unset = function (_key) {
|
|
18
|
-
throw new Error("Method not implemented");
|
|
19
|
-
};
|
|
20
|
-
OpenCensusTraceStateWrapper.prototype.serialize = function () {
|
|
21
|
-
return this._state || "";
|
|
22
|
-
};
|
|
23
|
-
return OpenCensusTraceStateWrapper;
|
|
24
|
-
}());
|
|
25
|
-
export { OpenCensusTraceStateWrapper };
|
|
26
|
-
//# sourceMappingURL=openCensusTraceStateWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openCensusTraceStateWrapper.js","sourceRoot":"","sources":["../../../../src/tracers/opencensus/openCensusTraceStateWrapper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;;GAGG;AACH;IAGE,qCAAY,KAAc;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,yCAAG,GAAH,UAAI,IAAY;QACd,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,yCAAG,GAAH,UAAI,IAAY,EAAE,MAAc;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,2CAAK,GAAL,UAAM,IAAY;QAChB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,+CAAS,GAAT;QACE,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAC3B,CAAC;IACH,kCAAC;AAAD,CAAC,AAtBD,IAsBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TraceState } from \"@opentelemetry/api\";\n\n/**\n * @ignore\n * @internal\n */\nexport class OpenCensusTraceStateWrapper implements TraceState {\n private readonly _state?: string;\n\n constructor(state?: string) {\n this._state = state;\n }\n\n get(_key: string): string | undefined {\n throw new Error(\"Method not implemented.\");\n }\n\n set(_key: string, _value: string): void {\n throw new Error(\"Method not implemented.\");\n }\n\n unset(_key: string): void {\n throw new Error(\"Method not implemented\");\n }\n\n serialize(): string {\n return this._state || \"\";\n }\n}\n"]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { OpenCensusSpanWrapper } from "./openCensusSpanWrapper";
|
|
4
|
-
/**
|
|
5
|
-
* An implementation of OpenTelemetry Tracer that wraps an OpenCensus Tracer.
|
|
6
|
-
*/
|
|
7
|
-
var OpenCensusTracerWrapper = /** @class */ (function () {
|
|
8
|
-
/**
|
|
9
|
-
* Create a new wrapper around a given OpenCensus Tracer.
|
|
10
|
-
* @param tracer The OpenCensus Tracer to wrap.
|
|
11
|
-
*/
|
|
12
|
-
function OpenCensusTracerWrapper(tracer) {
|
|
13
|
-
this._tracer = tracer;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The wrapped OpenCensus Tracer
|
|
17
|
-
*/
|
|
18
|
-
OpenCensusTracerWrapper.prototype.getWrappedTracer = function () {
|
|
19
|
-
return this._tracer;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Starts a new Span.
|
|
23
|
-
* @param name The name of the span.
|
|
24
|
-
* @param options The SpanOptions used during Span creation.
|
|
25
|
-
*/
|
|
26
|
-
OpenCensusTracerWrapper.prototype.startSpan = function (name, options) {
|
|
27
|
-
return new OpenCensusSpanWrapper(this, name, options);
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Returns the current Span from the current context, if available.
|
|
31
|
-
*/
|
|
32
|
-
OpenCensusTracerWrapper.prototype.getCurrentSpan = function () {
|
|
33
|
-
return undefined;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Executes the given function within the context provided by a Span.
|
|
37
|
-
* @param _span The span that provides the context.
|
|
38
|
-
* @param _fn The function to be executed.
|
|
39
|
-
*/
|
|
40
|
-
OpenCensusTracerWrapper.prototype.withSpan = function (_span, _fn) {
|
|
41
|
-
throw new Error("Method not implemented.");
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Bind a Span as the target's scope
|
|
45
|
-
* @param target An object to bind the scope.
|
|
46
|
-
* @param _span A specific Span to use. Otherwise, use the current one.
|
|
47
|
-
*/
|
|
48
|
-
OpenCensusTracerWrapper.prototype.bind = function (_target, _span) {
|
|
49
|
-
throw new Error("Method not implemented.");
|
|
50
|
-
};
|
|
51
|
-
return OpenCensusTracerWrapper;
|
|
52
|
-
}());
|
|
53
|
-
export { OpenCensusTracerWrapper };
|
|
54
|
-
//# sourceMappingURL=openCensusTracerWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openCensusTracerWrapper.js","sourceRoot":"","sources":["../../../../src/tracers/opencensus/openCensusTracerWrapper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE;;GAEG;AACH;IAUE;;;OAGG;IACH,iCAAmB,MAAwB;QACzC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAbD;;OAEG;IACI,kDAAgB,GAAvB;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAUD;;;;OAIG;IACH,2CAAS,GAAT,UAAU,IAAY,EAAE,OAAqB;QAC3C,OAAO,IAAI,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,gDAAc,GAAd;QACE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,0CAAQ,GAAR,UAAoD,KAAW,EAAE,GAAM;QACrE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,sCAAI,GAAJ,UAAQ,OAAU,EAAE,KAAY;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACH,8BAAC;AAAD,CAAC,AAnDD,IAmDC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Tracer, Span, SpanOptions } from \"@opentelemetry/api\";\nimport { OpenCensusSpanWrapper } from \"./openCensusSpanWrapper\";\nimport { TracerBase as OpenCensusTracer } from \"@opencensus/web-types\";\n\n/**\n * An implementation of OpenTelemetry Tracer that wraps an OpenCensus Tracer.\n */\nexport class OpenCensusTracerWrapper implements Tracer {\n private _tracer: OpenCensusTracer;\n\n /**\n * The wrapped OpenCensus Tracer\n */\n public getWrappedTracer(): OpenCensusTracer {\n return this._tracer;\n }\n\n /**\n * Create a new wrapper around a given OpenCensus Tracer.\n * @param tracer The OpenCensus Tracer to wrap.\n */\n public constructor(tracer: OpenCensusTracer) {\n this._tracer = tracer;\n }\n\n /**\n * Starts a new Span.\n * @param name The name of the span.\n * @param options The SpanOptions used during Span creation.\n */\n startSpan(name: string, options?: SpanOptions): Span {\n return new OpenCensusSpanWrapper(this, name, options);\n }\n\n /**\n * Returns the current Span from the current context, if available.\n */\n getCurrentSpan(): Span | undefined {\n return undefined;\n }\n\n /**\n * Executes the given function within the context provided by a Span.\n * @param _span The span that provides the context.\n * @param _fn The function to be executed.\n */\n withSpan<T extends (...args: unknown[]) => unknown>(_span: Span, _fn: T): ReturnType<T> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Bind a Span as the target's scope\n * @param target An object to bind the scope.\n * @param _span A specific Span to use. Otherwise, use the current one.\n */\n bind<T>(_target: T, _span?: Span): T {\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { __extends } from "tslib";
|
|
4
|
-
import { CanonicalCode } from "@opentelemetry/api";
|
|
5
|
-
import { NoOpSpan } from "../noop/noOpSpan";
|
|
6
|
-
/**
|
|
7
|
-
* A mock span useful for testing.
|
|
8
|
-
*/
|
|
9
|
-
var TestSpan = /** @class */ (function (_super) {
|
|
10
|
-
__extends(TestSpan, _super);
|
|
11
|
-
/**
|
|
12
|
-
* Starts a new Span.
|
|
13
|
-
* @param parentTracer The tracer that created this Span
|
|
14
|
-
* @param name The name of the span.
|
|
15
|
-
* @param context The SpanContext this span belongs to
|
|
16
|
-
* @param kind The SpanKind of this Span
|
|
17
|
-
* @param parentSpanId The identifier of the parent Span
|
|
18
|
-
* @param startTime The startTime of the event (defaults to now)
|
|
19
|
-
*/
|
|
20
|
-
function TestSpan(parentTracer, name, context, kind, parentSpanId, startTime) {
|
|
21
|
-
if (startTime === void 0) { startTime = Date.now(); }
|
|
22
|
-
var _this = _super.call(this) || this;
|
|
23
|
-
_this._tracer = parentTracer;
|
|
24
|
-
_this.name = name;
|
|
25
|
-
_this.kind = kind;
|
|
26
|
-
_this.startTime = startTime;
|
|
27
|
-
_this.parentSpanId = parentSpanId;
|
|
28
|
-
_this.status = {
|
|
29
|
-
code: CanonicalCode.OK
|
|
30
|
-
};
|
|
31
|
-
_this.endCalled = false;
|
|
32
|
-
_this._context = context;
|
|
33
|
-
_this.attributes = {};
|
|
34
|
-
return _this;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Returns the Tracer that created this Span
|
|
38
|
-
*/
|
|
39
|
-
TestSpan.prototype.tracer = function () {
|
|
40
|
-
return this._tracer;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Returns the SpanContext associated with this Span.
|
|
44
|
-
*/
|
|
45
|
-
TestSpan.prototype.context = function () {
|
|
46
|
-
return this._context;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Marks the end of Span execution.
|
|
50
|
-
* @param _endTime The time to use as the Span's end time. Defaults to
|
|
51
|
-
* the current time.
|
|
52
|
-
*/
|
|
53
|
-
TestSpan.prototype.end = function (_endTime) {
|
|
54
|
-
this.endCalled = true;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Sets a status on the span. Overrides the default of CanonicalCode.OK.
|
|
58
|
-
* @param status The status to set.
|
|
59
|
-
*/
|
|
60
|
-
TestSpan.prototype.setStatus = function (status) {
|
|
61
|
-
this.status = status;
|
|
62
|
-
return this;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Returns whether this span will be recorded
|
|
66
|
-
*/
|
|
67
|
-
TestSpan.prototype.isRecording = function () {
|
|
68
|
-
return true;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Sets an attribute on the Span
|
|
72
|
-
* @param key the attribute key
|
|
73
|
-
* @param value the attribute value
|
|
74
|
-
*/
|
|
75
|
-
TestSpan.prototype.setAttribute = function (key, value) {
|
|
76
|
-
this.attributes[key] = value;
|
|
77
|
-
return this;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Sets attributes on the Span
|
|
81
|
-
* @param attributes the attributes to add
|
|
82
|
-
*/
|
|
83
|
-
TestSpan.prototype.setAttributes = function (attributes) {
|
|
84
|
-
for (var _i = 0, _a = Object.keys(attributes); _i < _a.length; _i++) {
|
|
85
|
-
var key = _a[_i];
|
|
86
|
-
this.attributes[key] = attributes[key];
|
|
87
|
-
}
|
|
88
|
-
return this;
|
|
89
|
-
};
|
|
90
|
-
return TestSpan;
|
|
91
|
-
}(NoOpSpan));
|
|
92
|
-
export { TestSpan };
|
|
93
|
-
//# sourceMappingURL=testSpan.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testSpan.js","sourceRoot":"","sources":["../../../../src/tracers/test/testSpan.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAML,aAAa,EAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;GAEG;AACH;IAA8B,4BAAQ;IAuCpC;;;;;;;;OAQG;IACH,kBACE,YAAoB,EACpB,IAAY,EACZ,OAAoB,EACpB,IAAc,EACd,YAAqB,EACrB,SAAiC;QAAjC,0BAAA,EAAA,YAAuB,IAAI,CAAC,GAAG,EAAE;QANnC,YAQE,iBAAO,SAYR;QAXC,KAAI,CAAC,OAAO,GAAG,YAAY,CAAC;QAC5B,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,KAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,KAAI,CAAC,MAAM,GAAG;YACZ,IAAI,EAAE,aAAa,CAAC,EAAE;SACvB,CAAC;QACF,KAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,KAAI,CAAC,UAAU,GAAG,EAAE,CAAC;;IACvB,CAAC;IAED;;OAEG;IACH,yBAAM,GAAN;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,0BAAO,GAAP;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,sBAAG,GAAH,UAAI,QAAiB;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,4BAAS,GAAT,UAAU,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,8BAAW,GAAX;QACE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,+BAAY,GAAZ,UAAa,GAAW,EAAE,KAAc;QACtC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,gCAAa,GAAb,UAAc,UAAsB;QAClC,KAAkB,UAAuB,EAAvB,KAAA,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAvB,cAAuB,EAAvB,IAAuB,EAAE;YAAtC,IAAM,GAAG,SAAA;YACZ,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;SACxC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACH,eAAC;AAAD,CAAC,AAjID,CAA8B,QAAQ,GAiIrC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TimeInput,\n Tracer,\n SpanKind,\n Status,\n SpanContext,\n CanonicalCode,\n Attributes\n} from \"@opentelemetry/api\";\nimport { NoOpSpan } from \"../noop/noOpSpan\";\n\n/**\n * A mock span useful for testing.\n */\nexport class TestSpan extends NoOpSpan {\n /**\n * The Span's current name\n */\n name: string;\n\n /**\n * The Span's current status\n */\n status: Status;\n\n /**\n * The Span's kind\n */\n kind: SpanKind;\n\n /**\n * True if end() has been called on the Span\n */\n endCalled: boolean;\n\n /**\n * The start time of the Span\n */\n readonly startTime: TimeInput;\n\n /**\n * The id of the parent Span, if any.\n */\n readonly parentSpanId?: string;\n\n /**\n * Known attributes, if any.\n */\n readonly attributes: Attributes;\n\n private _context: SpanContext;\n private readonly _tracer: Tracer;\n\n /**\n * Starts a new Span.\n * @param parentTracer The tracer that created this Span\n * @param name The name of the span.\n * @param context The SpanContext this span belongs to\n * @param kind The SpanKind of this Span\n * @param parentSpanId The identifier of the parent Span\n * @param startTime The startTime of the event (defaults to now)\n */\n constructor(\n parentTracer: Tracer,\n name: string,\n context: SpanContext,\n kind: SpanKind,\n parentSpanId?: string,\n startTime: TimeInput = Date.now()\n ) {\n super();\n this._tracer = parentTracer;\n this.name = name;\n this.kind = kind;\n this.startTime = startTime;\n this.parentSpanId = parentSpanId;\n this.status = {\n code: CanonicalCode.OK\n };\n this.endCalled = false;\n this._context = context;\n this.attributes = {};\n }\n\n /**\n * Returns the Tracer that created this Span\n */\n tracer(): Tracer {\n return this._tracer;\n }\n\n /**\n * Returns the SpanContext associated with this Span.\n */\n context(): SpanContext {\n return this._context;\n }\n\n /**\n * Marks the end of Span execution.\n * @param _endTime The time to use as the Span's end time. Defaults to\n * the current time.\n */\n end(_endTime?: number): void {\n this.endCalled = true;\n }\n\n /**\n * Sets a status on the span. Overrides the default of CanonicalCode.OK.\n * @param status The status to set.\n */\n setStatus(status: Status): this {\n this.status = status;\n return this;\n }\n\n /**\n * Returns whether this span will be recorded\n */\n isRecording(): boolean {\n return true;\n }\n\n /**\n * Sets an attribute on the Span\n * @param key the attribute key\n * @param value the attribute value\n */\n setAttribute(key: string, value: unknown): this {\n this.attributes[key] = value;\n return this;\n }\n\n /**\n * Sets attributes on the Span\n * @param attributes the attributes to add\n */\n setAttributes(attributes: Attributes): this {\n for (const key of Object.keys(attributes)) {\n this.attributes[key] = attributes[key];\n }\n return this;\n }\n}\n"]}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { __extends } from "tslib";
|
|
4
|
-
import { TestSpan } from "./testSpan";
|
|
5
|
-
import { NoOpTracer } from "../noop/noOpTracer";
|
|
6
|
-
import { SpanKind, TraceFlags } from "@opentelemetry/api";
|
|
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
|
-
traceFlags: TraceFlags.NONE
|
|
103
|
-
};
|
|
104
|
-
var span = new TestSpan(this, name, context, options.kind || SpanKind.INTERNAL, parentContext ? parentContext.spanId : undefined, options.startTime);
|
|
105
|
-
this.knownSpans.push(span);
|
|
106
|
-
if (isRootSpan) {
|
|
107
|
-
this.rootSpans.push(span);
|
|
108
|
-
}
|
|
109
|
-
return span;
|
|
110
|
-
};
|
|
111
|
-
TestTracer.prototype._getParentContext = function (options) {
|
|
112
|
-
var parent = options.parent;
|
|
113
|
-
var result;
|
|
114
|
-
if (parent) {
|
|
115
|
-
if ("traceId" in parent) {
|
|
116
|
-
result = parent;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
result = parent.context();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return result;
|
|
123
|
-
};
|
|
124
|
-
return TestTracer;
|
|
125
|
-
}(NoOpTracer));
|
|
126
|
-
export { TestTracer };
|
|
127
|
-
//# sourceMappingURL=testTracer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testTracer.js","sourceRoot":"","sources":["../../../../src/tracers/test/testTracer.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TestSpan } from \"./testSpan\";\nimport { NoOpTracer } from \"../noop/noOpTracer\";\nimport { SpanContext, SpanKind, SpanOptions, TraceFlags } from \"@opentelemetry/api\";\n\n/**\n * Simple representation of a Span that only has name and child relationships.\n * Children should be arranged in the order they were created.\n */\nexport interface SpanGraphNode {\n /**\n * The Span name\n */\n name: string;\n /**\n * All child Spans of this Span\n */\n children: SpanGraphNode[];\n}\n\n/**\n * Contains all the spans for a particular TraceID\n * starting at unparented roots\n */\nexport interface SpanGraph {\n /**\n * All Spans without a parentSpanId\n */\n roots: SpanGraphNode[];\n}\n\n/**\n * A mock tracer useful for testing\n */\nexport class TestTracer extends NoOpTracer {\n private traceIdCounter = 0;\n private getNextTraceId(): string {\n this.traceIdCounter++;\n return String(this.traceIdCounter);\n }\n\n private spanIdCounter = 0;\n private getNextSpanId(): string {\n this.spanIdCounter++;\n return String(this.spanIdCounter);\n }\n\n private rootSpans: TestSpan[] = [];\n private knownSpans: TestSpan[] = [];\n\n /**\n * Returns all Spans that were created without a parent\n */\n getRootSpans(): TestSpan[] {\n return this.rootSpans;\n }\n\n /**\n * Returns all Spans this Tracer knows about\n */\n getKnownSpans(): TestSpan[] {\n return this.knownSpans;\n }\n\n /**\n * Returns all Spans where end() has not been called\n */\n getActiveSpans(): TestSpan[] {\n return this.knownSpans.filter((span) => {\n return !span.endCalled;\n });\n }\n\n /**\n * Return all Spans for a particular trace, grouped by their\n * parent Span in a tree-like structure\n * @param traceId The traceId to return the graph for\n */\n getSpanGraph(traceId: string): SpanGraph {\n const traceSpans = this.knownSpans.filter((span) => {\n return span.context().traceId === traceId;\n });\n\n const roots: SpanGraphNode[] = [];\n const nodeMap: Map<string, SpanGraphNode> = new Map<string, SpanGraphNode>();\n\n for (const span of traceSpans) {\n const spanId = span.context().spanId;\n const node: SpanGraphNode = {\n name: span.name,\n children: []\n };\n nodeMap.set(spanId, node);\n if (span.parentSpanId) {\n const parent = nodeMap.get(span.parentSpanId);\n if (!parent) {\n throw new Error(\n `Span with name ${node.name} has an unknown parentSpan with id ${span.parentSpanId}`\n );\n }\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n }\n\n return {\n roots\n };\n }\n\n /**\n * Starts a new Span.\n * @param name The name of the span.\n * @param options The SpanOptions used during Span creation.\n */\n startSpan(name: string, options: SpanOptions = {}): TestSpan {\n const parentContext = this._getParentContext(options);\n\n let traceId: string;\n let isRootSpan = false;\n\n if (parentContext && parentContext.traceId) {\n traceId = parentContext.traceId;\n } else {\n traceId = this.getNextTraceId();\n isRootSpan = true;\n }\n\n const context: SpanContext = {\n traceId,\n spanId: this.getNextSpanId(),\n traceFlags: TraceFlags.NONE\n };\n const span = new TestSpan(\n this,\n name,\n context,\n options.kind || SpanKind.INTERNAL,\n parentContext ? parentContext.spanId : undefined,\n options.startTime\n );\n this.knownSpans.push(span);\n if (isRootSpan) {\n this.rootSpans.push(span);\n }\n return span;\n }\n\n private _getParentContext(options: SpanOptions): SpanContext | undefined {\n const parent = options.parent;\n let result: SpanContext | undefined;\n if (parent) {\n if (\"traceId\" in parent) {\n result = parent;\n } else {\n result = parent.context();\n }\n }\n return result;\n }\n}\n"]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { getGlobalObject } from "./global";
|
|
4
|
-
// V1 = OpenTelemetry 0.1
|
|
5
|
-
// V2 = OpenTelemetry 0.2
|
|
6
|
-
// V3 = OpenTelemetry 0.6.1
|
|
7
|
-
var GLOBAL_TRACER_VERSION = 3;
|
|
8
|
-
// preview5 shipped with @azure/core-tracing.tracerCache
|
|
9
|
-
// and didn't have smart detection for collisions
|
|
10
|
-
var GLOBAL_TRACER_SYMBOL = Symbol.for("@azure/core-tracing.tracerCache2");
|
|
11
|
-
var cache;
|
|
12
|
-
function loadTracerCache() {
|
|
13
|
-
var globalObj = getGlobalObject();
|
|
14
|
-
var existingCache = globalObj[GLOBAL_TRACER_SYMBOL];
|
|
15
|
-
var setGlobalCache = true;
|
|
16
|
-
if (existingCache) {
|
|
17
|
-
if (existingCache.version === GLOBAL_TRACER_VERSION) {
|
|
18
|
-
cache = existingCache;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
setGlobalCache = false;
|
|
22
|
-
if (existingCache.tracer) {
|
|
23
|
-
throw new Error("Two incompatible versions of @azure/core-tracing have been loaded.\n This library is " + GLOBAL_TRACER_VERSION + ", existing is " + existingCache.version + ".");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (!cache) {
|
|
28
|
-
cache = {
|
|
29
|
-
tracer: undefined,
|
|
30
|
-
version: GLOBAL_TRACER_VERSION
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if (setGlobalCache) {
|
|
34
|
-
globalObj[GLOBAL_TRACER_SYMBOL] = cache;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export function getCache() {
|
|
38
|
-
if (!cache) {
|
|
39
|
-
loadTracerCache();
|
|
40
|
-
}
|
|
41
|
-
return cache;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/utils/cache.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,yBAAyB;AACzB,yBAAyB;AACzB,2BAA2B;AAC3B,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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Tracer } from \"@opentelemetry/api\";\nimport { getGlobalObject } from \"./global\";\n\n// V1 = OpenTelemetry 0.1\n// V2 = OpenTelemetry 0.2\n// V3 = OpenTelemetry 0.6.1\nconst GLOBAL_TRACER_VERSION = 3;\n// preview5 shipped with @azure/core-tracing.tracerCache\n// and didn't have smart detection for collisions\nconst GLOBAL_TRACER_SYMBOL = Symbol.for(\"@azure/core-tracing.tracerCache2\");\n\nexport interface TracerCache {\n version: number;\n tracer?: Tracer;\n}\n\nlet cache: TracerCache;\n\nfunction loadTracerCache(): void {\n const globalObj = getGlobalObject();\n const existingCache: TracerCache = globalObj[GLOBAL_TRACER_SYMBOL];\n let setGlobalCache = true;\n if (existingCache) {\n if (existingCache.version === GLOBAL_TRACER_VERSION) {\n cache = existingCache;\n } else {\n setGlobalCache = false;\n if (existingCache.tracer) {\n throw new Error(\n `Two incompatible versions of @azure/core-tracing have been loaded.\n This library is ${GLOBAL_TRACER_VERSION}, existing is ${existingCache.version}.`\n );\n }\n }\n }\n\n if (!cache) {\n cache = {\n tracer: undefined,\n version: GLOBAL_TRACER_VERSION\n };\n }\n if (setGlobalCache) {\n globalObj[GLOBAL_TRACER_SYMBOL] = cache;\n }\n}\n\nexport function getCache(): TracerCache {\n if (!cache) {\n loadTracerCache();\n }\n return cache;\n}\n"]}
|