@azure/core-tracing 1.0.0-preview.7 → 1.0.0-preview.8

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.
Files changed (69) hide show
  1. package/{Changelog.md → CHANGELOG.md} +17 -6
  2. package/LICENSE +21 -0
  3. package/README.md +2 -15
  4. package/dist/index.js +37 -95
  5. package/dist/index.js.map +1 -1
  6. package/dist-esm/{lib → src}/index.js +0 -0
  7. package/dist-esm/src/index.js.map +1 -0
  8. package/{lib/utils/global.browser.ts → dist-esm/src/interfaces.js} +1 -4
  9. package/dist-esm/src/interfaces.js.map +1 -0
  10. package/dist-esm/{lib → src}/tracerProxy.js +0 -0
  11. package/dist-esm/src/tracerProxy.js.map +1 -0
  12. package/dist-esm/{lib → src}/tracers/noop/noOpSpan.js +5 -1
  13. package/dist-esm/src/tracers/noop/noOpSpan.js.map +1 -0
  14. package/dist-esm/{lib → src}/tracers/noop/noOpTracer.js +0 -21
  15. package/dist-esm/src/tracers/noop/noOpTracer.js.map +1 -0
  16. package/dist-esm/{lib → src}/tracers/opencensus/openCensusSpanWrapper.js +1 -1
  17. package/dist-esm/src/tracers/opencensus/openCensusSpanWrapper.js.map +1 -0
  18. package/dist-esm/{lib → src}/tracers/opencensus/openCensusTraceStateWrapper.js +0 -0
  19. package/dist-esm/src/tracers/opencensus/openCensusTraceStateWrapper.js.map +1 -0
  20. package/dist-esm/{lib → src}/tracers/opencensus/openCensusTracerWrapper.js +1 -20
  21. package/dist-esm/src/tracers/opencensus/openCensusTracerWrapper.js.map +1 -0
  22. package/dist-esm/{lib → src}/tracers/test/testSpan.js +22 -1
  23. package/dist-esm/src/tracers/test/testSpan.js.map +1 -0
  24. package/dist-esm/{lib → src}/tracers/test/testTracer.js +4 -3
  25. package/dist-esm/src/tracers/test/testTracer.js.map +1 -0
  26. package/dist-esm/{lib → src}/utils/cache.js +4 -1
  27. package/dist-esm/src/utils/cache.js.map +1 -0
  28. package/dist-esm/{lib → src}/utils/global.browser.js +0 -0
  29. package/dist-esm/src/utils/global.browser.js.map +1 -0
  30. package/dist-esm/{lib → src}/utils/global.js +0 -0
  31. package/dist-esm/src/utils/global.js.map +1 -0
  32. package/dist-esm/{lib → src}/utils/traceParentHeader.js +1 -2
  33. package/dist-esm/src/utils/traceParentHeader.js.map +1 -0
  34. package/package.json +17 -19
  35. package/types/core-tracing.d.ts +88 -43
  36. package/LICENSE.txt +0 -21
  37. package/ThirdPartyNotices.txt +0 -27
  38. package/dist-esm/lib/index.js.map +0 -1
  39. package/dist-esm/lib/tracerProxy.js.map +0 -1
  40. package/dist-esm/lib/tracers/noop/noOpBinaryFormat.js +0 -23
  41. package/dist-esm/lib/tracers/noop/noOpBinaryFormat.js.map +0 -1
  42. package/dist-esm/lib/tracers/noop/noOpHttpTextFormat.js +0 -27
  43. package/dist-esm/lib/tracers/noop/noOpHttpTextFormat.js.map +0 -1
  44. package/dist-esm/lib/tracers/noop/noOpSpan.js.map +0 -1
  45. package/dist-esm/lib/tracers/noop/noOpTracer.js.map +0 -1
  46. package/dist-esm/lib/tracers/opencensus/openCensusSpanWrapper.js.map +0 -1
  47. package/dist-esm/lib/tracers/opencensus/openCensusTraceStateWrapper.js.map +0 -1
  48. package/dist-esm/lib/tracers/opencensus/openCensusTracerWrapper.js.map +0 -1
  49. package/dist-esm/lib/tracers/test/testSpan.js.map +0 -1
  50. package/dist-esm/lib/tracers/test/testTracer.js.map +0 -1
  51. package/dist-esm/lib/utils/cache.js.map +0 -1
  52. package/dist-esm/lib/utils/global.browser.js.map +0 -1
  53. package/dist-esm/lib/utils/global.js.map +0 -1
  54. package/dist-esm/lib/utils/traceParentHeader.js.map +0 -1
  55. package/lib/index.ts +0 -21
  56. package/lib/tracerProxy.ts +0 -36
  57. package/lib/tracers/noop/noOpBinaryFormat.ts +0 -22
  58. package/lib/tracers/noop/noOpHttpTextFormat.ts +0 -25
  59. package/lib/tracers/noop/noOpSpan.ts +0 -76
  60. package/lib/tracers/noop/noOpTracer.ts +0 -68
  61. package/lib/tracers/opencensus/openCensusSpanWrapper.ts +0 -142
  62. package/lib/tracers/opencensus/openCensusTraceStateWrapper.ts +0 -32
  63. package/lib/tracers/opencensus/openCensusTracerWrapper.ts +0 -83
  64. package/lib/tracers/test/testSpan.ts +0 -119
  65. package/lib/tracers/test/testTracer.ts +0 -162
  66. package/lib/utils/browser.d.ts +0 -2
  67. package/lib/utils/cache.ts +0 -53
  68. package/lib/utils/global.ts +0 -6
  69. package/lib/utils/traceParentHeader.ts +0 -63
@@ -1,27 +1,38 @@
1
- # 1.0.0-preview.7 2nd December 2019
1
+ # Release History
2
+
3
+ ## 1.0.0-preview.8 (2020-04-28)
4
+
5
+ - Update `TestSpan` to allow setting span attributes [PR link](https://github.com/Azure/azure-sdk-for-js/pull/6565).
6
+ - [BREAKING] Migrate to OpenTelemetry 0.6 using the new `@opentelemetry/api` package. There were a few breaking changes:
7
+ - `SpanContext` now requires traceFlags to be set.
8
+ - `Tracer` has removed `recordSpanData`, `getBinaryFormat`, and `getHttpTextFormat`.
9
+ - `Tracer.getCurrentSpan` returns `undefined` instead of `null` when unset.
10
+ - `Link` objects renamed `spanContext` property to `context`.
11
+
12
+ ## 1.0.0-preview.7 (2019-12-03)
2
13
 
3
14
  - Updated the behavior of how incompatible versions of OpenTelemetry Tracer are handled. Now, errors will be thrown only if the user has manually set a Tracer. This means that incompatible versions will be silently ignored when tracing is not enabled.
4
15
  - Updated to use OpenTelemetry 0.2 via the `@opentelemetry/types` package. There were two breaking changes in this update:
5
16
  - `isRecordingEvents` on `Span` was renamed to `isRecording`. [PR link](https://github.com/open-telemetry/opentelemetry-js/pull/454)
6
17
  - `addLink` was removed from `Span` as links are now only allowed to be added during span creation. This is possible by specifying any necessary links inside `SpanOptions`. [PR link](https://github.com/open-telemetry/opentelemetry-js/pull/449)
7
18
 
8
- # 1.0.0-preview.5 22nd October 2019
19
+ ## 1.0.0-preview.5 (2019-10-22)
9
20
 
10
21
  - Fixes issue where loading multiple copies of this module could result in the tracer set by `setTracer()` being reset.
11
22
 
12
- # 1.0.0-preview.4 8th October 2019
23
+ ## 1.0.0-preview.4 (2019-10-08)
13
24
 
14
25
  - Remove dependency on the `debug` module to ensure compatibility with IE11
15
26
 
16
- # 1.0.0-preview.3 7th October 2019
27
+ ## 1.0.0-preview.3 (2019-10-07)
17
28
 
18
29
  - Updated to use the latest types from OpenTelemetry (PR [#5182](https://github.com/Azure/azure-sdk-for-js/pull/5182))
19
30
  - Clean up and refactored code for easier usage and testability. (PR [#5233](https://github.com/Azure/azure-sdk-for-js/pull/5233) and PR [#5283](https://github.com/Azure/azure-sdk-for-js/pull/5283))
20
31
 
21
- # 1.0.0-preview.2 9th September 2019
32
+ ## 1.0.0-preview.2 (2019-09-09)
22
33
 
23
34
  Updated the `OpenCensusSpanPlugin` & the `NoOpSpanPlugin` to support for retrieving span context. This allows updating of request headers with the right [span context](https://www.w3.org/TR/trace-context/#trace-context-http-headers-format). (PR [#4712](https://github.com/Azure/azure-sdk-for-js/pull/4712))
24
35
 
25
- # 1.0.0-preview.1 5th August 2019
36
+ ## 1.0.0-preview.1 (2019-08-05)
26
37
 
27
38
  Provides low-level interfaces and helper methods for tracing in Azure SDK
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Microsoft
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Azure Core tracing library for JS
1
+ # Azure Core tracing library for JavaScript
2
2
 
3
3
  This is the core tracing library that provides low-level interfaces and helper methods for tracing in Azure SDK JavaScript libraries which work in the browser and Node.js.
4
4
 
@@ -85,19 +85,6 @@ const result = await blobClient.download(undefined, undefined, {
85
85
 
86
86
  ## Contributing
87
87
 
88
- This project welcomes contributions and suggestions. Most contributions require you to agree to a
89
- Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
90
- the rights to use your contribution. For details, visit https://cla.microsoft.com.
91
-
92
- When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
93
- a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
94
- provided by the bot. You will only need to do this once across all repos using our CLA.
95
-
96
- If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/tree/48cdcfb307b4754c1cac269ef2867c70206492af/CONTRIBUTING.md) to learn more about how to build and test the code.
97
-
98
- This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
99
- For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
100
- contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
101
-
88
+ If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/master/CONTRIBUTING.md) to learn more about how to build and test the code.
102
89
 
103
90
  ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore%2Fcore-tracing%2FREADME.png)
package/dist/index.js CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var api = require('@opentelemetry/api');
5
6
  var tslib = require('tslib');
6
- var types = require('@opentelemetry/types');
7
7
 
8
+ // Copyright (c) Microsoft Corporation. All rights reserved.
8
9
  /**
9
10
  * A no-op implementation of Span that can safely be used without side-effects.
10
11
  */
@@ -17,7 +18,8 @@ var NoOpSpan = /** @class */ (function () {
17
18
  NoOpSpan.prototype.context = function () {
18
19
  return {
19
20
  spanId: "",
20
- traceId: ""
21
+ traceId: "",
22
+ traceFlags: api.TraceFlags.NONE
21
23
  };
22
24
  };
23
25
  /**
@@ -74,54 +76,6 @@ var NoOpSpan = /** @class */ (function () {
74
76
  return NoOpSpan;
75
77
  }());
76
78
 
77
- // Copyright (c) Microsoft Corporation. All rights reserved.
78
- // Licensed under the MIT License.
79
- /**
80
- * A no-op implementation of BinaryFormat to be used when tracing is disabled.
81
- */
82
- var NoOpBinaryFormat = /** @class */ (function () {
83
- function NoOpBinaryFormat() {
84
- }
85
- /** Serialize the given SpanContext to a buffer */
86
- NoOpBinaryFormat.prototype.toBytes = function (_spanContext) {
87
- return new ArrayBuffer(0);
88
- };
89
- /**
90
- * Deserialize a SpanContext from binary encoding.
91
- * Returns null if the buffer does not contain a valid SpanContext.
92
- */
93
- NoOpBinaryFormat.prototype.fromBytes = function (_buffer) {
94
- return null;
95
- };
96
- return NoOpBinaryFormat;
97
- }());
98
-
99
- // Copyright (c) Microsoft Corporation. All rights reserved.
100
- // Licensed under the MIT License.
101
- /**
102
- * A no-op implementation of HttpTextFormat to be used when tracing is disabled.
103
- */
104
- var NoOpHttpTextFormat = /** @class */ (function () {
105
- function NoOpHttpTextFormat() {
106
- }
107
- /**
108
- * Injects the given SpanContext for transmitting to a remote server.
109
- * @param _spanContext The SpanContext to transmit
110
- * @param _format The format of the carrier
111
- * @param _carrier The carrier to propagate through, e.g. an HTTP request
112
- */
113
- NoOpHttpTextFormat.prototype.inject = function (_spanContext, _format, _carrier) { };
114
- /**
115
- * Returns a SpanContext intance extracted from the carrier.
116
- * @param _format the format of the carrier
117
- * @param _carrier The carrier being used for propagation, e.g. an HTTP request
118
- */
119
- NoOpHttpTextFormat.prototype.extract = function (_format, _carrier) {
120
- return null;
121
- };
122
- return NoOpHttpTextFormat;
123
- }());
124
-
125
79
  // Copyright (c) Microsoft Corporation. All rights reserved.
126
80
  /**
127
81
  * A no-op implementation of Tracer that can be used when tracing
@@ -160,25 +114,6 @@ var NoOpTracer = /** @class */ (function () {
160
114
  NoOpTracer.prototype.bind = function (target, _span) {
161
115
  return target;
162
116
  };
163
- /**
164
- * Send a pre-populated Span object to the exporter.
165
- * @param _span The span to pass along.
166
- */
167
- NoOpTracer.prototype.recordSpanData = function (_span) {
168
- /* NOOP */
169
- };
170
- /**
171
- * Returns the BinaryFormat interface for serializing/deserializing Spans.
172
- */
173
- NoOpTracer.prototype.getBinaryFormat = function () {
174
- return new NoOpBinaryFormat();
175
- };
176
- /**
177
- * Returns the HttpTextFormat interface for injecting/extracting Spans.
178
- */
179
- NoOpTracer.prototype.getHttpTextFormat = function () {
180
- return new NoOpHttpTextFormat();
181
- };
182
117
  return NoOpTracer;
183
118
  }());
184
119
 
@@ -189,7 +124,10 @@ function getGlobalObject() {
189
124
  }
190
125
 
191
126
  // Copyright (c) Microsoft Corporation. All rights reserved.
192
- var GLOBAL_TRACER_VERSION = 2;
127
+ // V1 = OpenTelemetry 0.1
128
+ // V2 = OpenTelemetry 0.2
129
+ // V3 = OpenTelemetry 0.6.1
130
+ var GLOBAL_TRACER_VERSION = 3;
193
131
  // preview5 shipped with @azure/core-tracing.tracerCache
194
132
  // and didn't have smart detection for collisions
195
133
  var GLOBAL_TRACER_SYMBOL = Symbol.for("@azure/core-tracing.tracerCache2");
@@ -303,7 +241,7 @@ var OpenCensusSpanWrapper = /** @class */ (function () {
303
241
  for (var _i = 0, _a = options.links; _i < _a.length; _i++) {
304
242
  var link = _a[_i];
305
243
  // Since there is no way to set the link relationship, leave it as Unspecified.
306
- this._span.addLink(link.spanContext.traceId, link.spanContext.spanId, 0 /* LinkType.UNSPECIFIED */, link.attributes);
244
+ this._span.addLink(link.context.traceId, link.context.spanId, 0 /* LinkType.UNSPECIFIED */, link.attributes);
307
245
  }
308
246
  }
309
247
  }
@@ -417,7 +355,7 @@ var OpenCensusTracerWrapper = /** @class */ (function () {
417
355
  * Returns the current Span from the current context, if available.
418
356
  */
419
357
  OpenCensusTracerWrapper.prototype.getCurrentSpan = function () {
420
- return null;
358
+ return undefined;
421
359
  };
422
360
  /**
423
361
  * Executes the given function within the context provided by a Span.
@@ -435,25 +373,6 @@ var OpenCensusTracerWrapper = /** @class */ (function () {
435
373
  OpenCensusTracerWrapper.prototype.bind = function (_target, _span) {
436
374
  throw new Error("Method not implemented.");
437
375
  };
438
- /**
439
- * Send a pre-populated Span object to the exporter.
440
- * @param _span The span to pass along.
441
- */
442
- OpenCensusTracerWrapper.prototype.recordSpanData = function (_span) {
443
- throw new Error("Method not implemented.");
444
- };
445
- /**
446
- * Returns the BinaryFormat interface for serializing/deserializing Spans.
447
- */
448
- OpenCensusTracerWrapper.prototype.getBinaryFormat = function () {
449
- throw new Error("Method not implemented.");
450
- };
451
- /**
452
- * Returns the HttpTextFormat interface for injecting/extracting Spans.
453
- */
454
- OpenCensusTracerWrapper.prototype.getHttpTextFormat = function () {
455
- throw new Error("Method not implemented.");
456
- };
457
376
  return OpenCensusTracerWrapper;
458
377
  }());
459
378
 
@@ -480,10 +399,11 @@ var TestSpan = /** @class */ (function (_super) {
480
399
  _this.startTime = startTime;
481
400
  _this.parentSpanId = parentSpanId;
482
401
  _this.status = {
483
- code: types.CanonicalCode.OK
402
+ code: api.CanonicalCode.OK
484
403
  };
485
404
  _this.endCalled = false;
486
405
  _this._context = context;
406
+ _this.attributes = {};
487
407
  return _this;
488
408
  }
489
409
  /**
@@ -520,6 +440,26 @@ var TestSpan = /** @class */ (function (_super) {
520
440
  TestSpan.prototype.isRecording = function () {
521
441
  return true;
522
442
  };
443
+ /**
444
+ * Sets an attribute on the Span
445
+ * @param key the attribute key
446
+ * @param value the attribute value
447
+ */
448
+ TestSpan.prototype.setAttribute = function (key, value) {
449
+ this.attributes[key] = value;
450
+ return this;
451
+ };
452
+ /**
453
+ * Sets attributes on the Span
454
+ * @param attributes the attributes to add
455
+ */
456
+ TestSpan.prototype.setAttributes = function (attributes) {
457
+ for (var _i = 0, _a = Object.keys(attributes); _i < _a.length; _i++) {
458
+ var key = _a[_i];
459
+ this.attributes[key] = attributes[key];
460
+ }
461
+ return this;
462
+ };
523
463
  return TestSpan;
524
464
  }(NoOpSpan));
525
465
 
@@ -617,9 +557,10 @@ var TestTracer = /** @class */ (function (_super) {
617
557
  }
618
558
  var context = {
619
559
  traceId: traceId,
620
- spanId: this.getNextSpanId()
560
+ spanId: this.getNextSpanId(),
561
+ traceFlags: api.TraceFlags.NONE
621
562
  };
622
- var span = new TestSpan(this, name, context, options.kind || types.SpanKind.INTERNAL, parentContext ? parentContext.spanId : undefined, options.startTime);
563
+ var span = new TestSpan(this, name, context, options.kind || api.SpanKind.INTERNAL, parentContext ? parentContext.spanId : undefined, options.startTime);
623
564
  this.knownSpans.push(span);
624
565
  if (isRootSpan) {
625
566
  this.rootSpans.push(span);
@@ -643,6 +584,7 @@ var TestTracer = /** @class */ (function (_super) {
643
584
  }(NoOpTracer));
644
585
 
645
586
  // Copyright (c) Microsoft Corporation. All rights reserved.
587
+ // Licensed under the MIT License.
646
588
  var VERSION = "00";
647
589
  /**
648
590
  * Generates a `SpanContext` given a `traceparent` header value.
@@ -682,7 +624,7 @@ function getTraceParentHeader(spanContext) {
682
624
  if (missingFields.length) {
683
625
  return;
684
626
  }
685
- var flags = spanContext.traceFlags || types.TraceFlags.UNSAMPLED;
627
+ var flags = spanContext.traceFlags || 0 /* NONE */;
686
628
  var hexFlags = flags.toString(16);
687
629
  var traceFlags = hexFlags.length === 1 ? "0" + hexFlags : hexFlags;
688
630
  // https://www.w3.org/TR/trace-context/#traceparent-header-field-values
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../lib/tracers/noop/noOpSpan.ts","../lib/tracers/noop/noOpBinaryFormat.ts","../lib/tracers/noop/noOpHttpTextFormat.ts","../lib/tracers/noop/noOpTracer.ts","../lib/utils/global.ts","../lib/utils/cache.ts","../lib/tracerProxy.ts","../lib/tracers/opencensus/openCensusTraceStateWrapper.ts","../lib/tracers/opencensus/openCensusSpanWrapper.ts","../lib/tracers/opencensus/openCensusTracerWrapper.ts","../lib/tracers/test/testSpan.ts","../lib/tracers/test/testTracer.ts","../lib/utils/traceParentHeader.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\nimport { Span, SpanContext, Attributes, Status } from \"@opentelemetry/types\";\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 };\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { BinaryFormat, SpanContext } from \"@opentelemetry/types\";\n\n/**\n * A no-op implementation of BinaryFormat to be used when tracing is disabled.\n */\nexport class NoOpBinaryFormat implements BinaryFormat {\n /** Serialize the given SpanContext to a buffer */\n toBytes(_spanContext: SpanContext): ArrayBuffer {\n return new ArrayBuffer(0);\n }\n\n /** \n * Deserialize a SpanContext from binary encoding. \n * Returns null if the buffer does not contain a valid SpanContext.\n */\n fromBytes(_buffer: ArrayBuffer): SpanContext | null {\n return null;\n }\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { HttpTextFormat, SpanContext } from \"@opentelemetry/types\";\n\n/**\n * A no-op implementation of HttpTextFormat to be used when tracing is disabled.\n */\nexport class NoOpHttpTextFormat implements HttpTextFormat {\n /**\n * Injects the given SpanContext for transmitting to a remote server.\n * @param _spanContext The SpanContext to transmit\n * @param _format The format of the carrier\n * @param _carrier The carrier to propagate through, e.g. an HTTP request\n */\n inject(_spanContext: SpanContext, _format: string, _carrier: unknown): void {}\n /**\n * Returns a SpanContext intance extracted from the carrier.\n * @param _format the format of the carrier\n * @param _carrier The carrier being used for propagation, e.g. an HTTP request\n */\n extract(_format: string, _carrier: unknown): SpanContext | null {\n return null;\n }\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\nimport { NoOpSpan } from \"./noOpSpan\";\nimport { BinaryFormat, HttpTextFormat, Tracer, Span, SpanOptions } from \"@opentelemetry/types\";\nimport { NoOpBinaryFormat } from \"./noOpBinaryFormat\";\nimport { NoOpHttpTextFormat } from \"./noOpHttpTextFormat\";\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 /**\n * Send a pre-populated Span object to the exporter.\n * @param _span The span to pass along.\n */\n recordSpanData(_span: Span): void {\n /* NOOP */\n }\n\n /**\n * Returns the BinaryFormat interface for serializing/deserializing Spans.\n */\n getBinaryFormat(): BinaryFormat {\n return new NoOpBinaryFormat();\n }\n\n /**\n * Returns the HttpTextFormat interface for injecting/extracting Spans.\n */\n getHttpTextFormat(): HttpTextFormat {\n return new NoOpHttpTextFormat();\n }\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nexport function getGlobalObject(): any {\n return global;\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { Tracer } from \"@opentelemetry/types\";\nimport { getGlobalObject } from \"./global\";\n\nconst GLOBAL_TRACER_VERSION = 2;\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { NoOpTracer } from \"./tracers/noop/noOpTracer\";\nimport { Tracer } from \"@opentelemetry/types\";\nimport { getCache } from \"./utils/cache\";\n\nlet defaultTracer: Tracer;\n\nfunction getDefaultTracer(): Tracer {\n if (!defaultTracer) {\n defaultTracer = new NoOpTracer();\n }\n return defaultTracer;\n}\n\n/**\n * Sets the global tracer, enabling tracing for the Azure SDK.\n * @param tracer An OpenTelemetry Tracer instance.\n */\nexport function setTracer(tracer: Tracer) {\n const cache = getCache();\n cache.tracer = tracer;\n}\n\n/**\n * Retrieves the active tracer, or returns a\n * no-op implementation if one is not set.\n */\nexport function getTracer() {\n const cache = getCache();\n if (!cache.tracer) {\n return getDefaultTracer();\n }\n return cache.tracer;\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { TraceState } from \"@opentelemetry/types\";\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\nimport { SpanContext, Span, SpanOptions, Attributes, Status } from \"@opentelemetry/types\";\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): 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() {\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(link.spanContext.traceId, link.spanContext.spanId, 0 /* LinkType.UNSPECIFIED */, link.attributes as OpenCensusAttributes);\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,\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\nimport { BinaryFormat, HttpTextFormat, Tracer, Span, SpanOptions } from \"@opentelemetry/types\";\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() {\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 | null {\n return null;\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 /**\n * Send a pre-populated Span object to the exporter.\n * @param _span The span to pass along.\n */\n recordSpanData(_span: Span): void {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Returns the BinaryFormat interface for serializing/deserializing Spans.\n */\n getBinaryFormat(): BinaryFormat {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Returns the HttpTextFormat interface for injecting/extracting Spans.\n */\n getHttpTextFormat(): HttpTextFormat {\n throw new Error(\"Method not implemented.\");\n }\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\nimport { NoOpSpan } from \"../noop/noOpSpan\";\nimport {\n TimeInput,\n Tracer,\n SpanKind,\n Status,\n SpanContext,\n CanonicalCode\n} from \"@opentelemetry/types\";\nimport { TestTracer } from \"./testTracer\";\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 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: TestTracer,\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 }\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\nimport { NoOpTracer } from \"../noop/noOpTracer\";\nimport { TestSpan } from \"./testSpan\";\nimport { SpanContext, SpanKind, SpanOptions } from \"@opentelemetry/types\";\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 };\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { SpanContext, TraceFlags } from \"@opentelemetry/types\";\n\nconst VERSION = \"00\";\n\n/**\n * Generates a `SpanContext` given a `traceparent` header value.\n * @param traceParent Serialized span context data as a `traceparent` header value.\n * @returns The `SpanContext` generated from the `traceparent` value.\n */\nexport function extractSpanContextFromTraceParentHeader(\n traceParentHeader: string\n): SpanContext | undefined {\n const parts = traceParentHeader.split(\"-\");\n\n if (parts.length !== 4) {\n return;\n }\n\n const [version, traceId, spanId, traceOptions] = parts;\n\n if (version !== VERSION) {\n return;\n }\n\n const traceFlags = parseInt(traceOptions, 16);\n\n const spanContext: SpanContext = {\n spanId,\n traceId,\n traceFlags\n };\n\n return spanContext;\n}\n\n/**\n * Generates a `traceparent` value given a span context.\n * @param spanContext Contains context for a specific span.\n * @returns The `spanContext` represented as a `traceparent` value.\n */\nexport function getTraceParentHeader(spanContext: SpanContext): string | undefined {\n const missingFields: string[] = [];\n if (!spanContext.traceId) {\n missingFields.push(\"traceId\");\n }\n if (!spanContext.spanId) {\n missingFields.push(\"spanId\");\n }\n\n if (missingFields.length) {\n return;\n }\n\n const flags = spanContext.traceFlags || TraceFlags.UNSAMPLED;\n const hexFlags = flags.toString(16);\n const traceFlags = hexFlags.length === 1 ? `0${hexFlags}` : hexFlags;\n\n // https://www.w3.org/TR/trace-context/#traceparent-header-field-values\n return `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-${traceFlags}`;\n}\n"],"names":["__extends","CanonicalCode","SpanKind","TraceFlags"],"mappings":";;;;;;;AAIA;;;AAGA;IAAA;KAoEC;;;;IAhEC,0BAAO,GAAP;QACE,OAAO;YACL,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;SACZ,CAAC;KACH;;;;;;IAOD,sBAAG,GAAH,UAAI,QAAiB;;KAEpB;;;;;;IAOD,+BAAY,GAAZ,UAAa,IAAY,EAAE,MAAe;QACxC,OAAO,IAAI,CAAC;KACb;;;;;IAMD,gCAAa,GAAb,UAAc,WAAuB;QACnC,OAAO,IAAI,CAAC;KACb;;;;;;IAOD,2BAAQ,GAAR,UAAS,KAAa,EAAE,WAAwB;QAC9C,OAAO,IAAI,CAAC;KACb;;;;;IAMD,4BAAS,GAAT,UAAU,OAAe;QACvB,OAAO,IAAI,CAAC;KACb;;;;;IAMD,6BAAU,GAAV,UAAW,KAAa;QACtB,OAAO,IAAI,CAAC;KACb;;;;IAKD,8BAAW,GAAX;QACE,OAAO,KAAK,CAAC;KACd;IACH,eAAC;CAAA;;AC3ED;;;;;AAQA;IAAA;KAaC;;IAXC,kCAAO,GAAP,UAAQ,YAAyB;QAC/B,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;KAC3B;;;;;IAMD,oCAAS,GAAT,UAAU,OAAoB;QAC5B,OAAO,IAAI,CAAC;KACb;IACH,uBAAC;CAAA,IAAA;;ACrBD;;;;;AAQA;IAAA;KAgBC;;;;;;;IATC,mCAAM,GAAN,UAAO,YAAyB,EAAE,OAAe,EAAE,QAAiB,KAAU;;;;;;IAM9E,oCAAO,GAAP,UAAQ,OAAe,EAAE,QAAiB;QACxC,OAAO,IAAI,CAAC;KACb;IACH,yBAAC;CAAA,IAAA;;ACxBD;AACA,AAMA;;;;AAIA;IAAA;K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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;CACpB;;;;;;AAOD,SAAgB,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,IAAIC,gBAAU,CAAC,SAAS,CAAC;IAC7D,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpC,IAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,GAAG,MAAI,QAAU,GAAG,QAAQ,CAAC;;IAGrE,OAAU,OAAO,SAAI,WAAW,CAAC,OAAO,SAAI,WAAW,CAAC,MAAM,SAAI,UAAY,CAAC;CAChF;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/tracers/noop/noOpSpan.ts","../src/tracers/noop/noOpTracer.ts","../src/utils/global.ts","../src/utils/cache.ts","../src/tracerProxy.ts","../src/tracers/opencensus/openCensusTraceStateWrapper.ts","../src/tracers/opencensus/openCensusSpanWrapper.ts","../src/tracers/opencensus/openCensusTracerWrapper.ts","../src/tracers/test/testSpan.ts","../src/tracers/test/testTracer.ts","../src/utils/traceParentHeader.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nexport function getGlobalObject(): any {\n return global;\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { NoOpTracer } from \"./tracers/noop/noOpTracer\";\nimport { Tracer } from \"@opentelemetry/api\";\nimport { getCache } from \"./utils/cache\";\n\nlet defaultTracer: Tracer;\n\nfunction getDefaultTracer(): Tracer {\n if (!defaultTracer) {\n defaultTracer = new NoOpTracer();\n }\n return defaultTracer;\n}\n\n/**\n * Sets the global tracer, enabling tracing for the Azure SDK.\n * @param tracer An OpenTelemetry Tracer instance.\n */\nexport function setTracer(tracer: Tracer) {\n const cache = getCache();\n cache.tracer = tracer;\n}\n\n/**\n * Retrieves the active tracer, or returns a\n * no-op implementation if one is not set.\n */\nexport function getTracer() {\n const cache = getCache();\n if (!cache.tracer) {\n return getDefaultTracer();\n }\n return cache.tracer;\n}\n","// Copyright (c) Microsoft Corporation. All rights reserved.\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\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() {\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\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() {\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\nimport {\n TimeInput,\n Tracer,\n SpanKind,\n Status,\n SpanContext,\n CanonicalCode,\n Attributes\n} from \"@opentelemetry/api\";\nimport { NoOpSpan } from \"../noop/noOpSpan\";\nimport { TestTracer } from \"./testTracer\";\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: TestTracer,\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\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","// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { SpanContext, TraceFlags } from \"../interfaces\";\n\nconst VERSION = \"00\";\n\n/**\n * Generates a `SpanContext` given a `traceparent` header value.\n * @param traceParent Serialized span context data as a `traceparent` header value.\n * @returns The `SpanContext` generated from the `traceparent` value.\n */\nexport function extractSpanContextFromTraceParentHeader(\n traceParentHeader: string\n): SpanContext | undefined {\n const parts = traceParentHeader.split(\"-\");\n\n if (parts.length !== 4) {\n return;\n }\n\n const [version, traceId, spanId, traceOptions] = parts;\n\n if (version !== VERSION) {\n return;\n }\n\n const traceFlags = parseInt(traceOptions, 16);\n\n const spanContext: SpanContext = {\n spanId,\n traceId,\n traceFlags\n };\n\n return spanContext;\n}\n\n/**\n * Generates a `traceparent` value given a span context.\n * @param spanContext Contains context for a specific span.\n * @returns The `spanContext` represented as a `traceparent` value.\n */\nexport function getTraceParentHeader(spanContext: SpanContext): string | undefined {\n const missingFields: string[] = [];\n if (!spanContext.traceId) {\n missingFields.push(\"traceId\");\n }\n if (!spanContext.spanId) {\n missingFields.push(\"spanId\");\n }\n\n if (missingFields.length) {\n return;\n }\n\n const flags = spanContext.traceFlags || TraceFlags.NONE;\n const hexFlags = flags.toString(16);\n const traceFlags = hexFlags.length === 1 ? `0${hexFlags}` : hexFlags;\n\n // https://www.w3.org/TR/trace-context/#traceparent-header-field-values\n return `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-${traceFlags}`;\n}\n"],"names":["TraceFlags","__extends","CanonicalCode","SpanKind"],"mappings":";;;;;;;AAAA;AAIA;;;;IAGA;KAqEC;;;;IAjEC,0BAAO,GAAP;QACE,OAAO;YACL,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;YACX,UAAU,EAAEA,cAAU,CAAC,IAAI;SAC5B,CAAC;KACH;;;;;;IAOD,sBAAG,GAAH,UAAI,QAAiB;;KAEpB;;;;;;IAOD,+BAAY,GAAZ,UAAa,IAAY,EAAE,MA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ACpC,IAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,GAAG,MAAI,QAAU,GAAG,QAAQ,CAAC;;IAGrE,OAAU,OAAO,SAAI,WAAW,CAAC,OAAO,SAAI,WAAW,CAAC,MAAM,SAAI,UAAY,CAAC;AACjF,CAAC;;;;;;;;;;;;;"}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAErD,uBAAuB;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,UAAU,EAA4B,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAQnD,YAAY;AACZ,OAAO,EACL,uCAAuC,EACvC,oBAAoB,EACrB,MAAM,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nexport { getTracer, setTracer } from \"./tracerProxy\";\n\n// Tracers and wrappers\nexport { NoOpSpan } from \"./tracers/noop/noOpSpan\";\nexport { NoOpTracer } from \"./tracers/noop/noOpTracer\";\nexport { OpenCensusSpanWrapper } from \"./tracers/opencensus/openCensusSpanWrapper\";\nexport { OpenCensusTracerWrapper } from \"./tracers/opencensus/openCensusTracerWrapper\";\nexport { TestTracer, SpanGraph, SpanGraphNode } from \"./tracers/test/testTracer\";\nexport { TestSpan } from \"./tracers/test/testSpan\";\n\n// Shared interfaces\nexport { SpanContext, SpanOptions, TraceFlags } from \"./interfaces\";\n\n// OT interfaces\nexport { SpanContext as OTSpanContext, SpanOptions as OTSpanOptions } from \"@opentelemetry/api\";\n\n// Utilities\nexport {\n extractSpanContextFromTraceParentHeader,\n getTraceParentHeader\n} from \"./utils/traceParentHeader\";\n\n// OpenCensus Interfaces\nexport { Tracer as OpenCensusTracer, Span as OpenCensusSpan } from \"@opencensus/web-types\";\n\nexport { OperationTracingOptions } from \"./interfaces\";\n"]}
@@ -1,6 +1,3 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
-
4
- export function getGlobalObject(): any {
5
- return self;
6
- }
3
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n/**\n * Shorthand enum for common traceFlags values inside SpanContext\n */\nexport const enum TraceFlags {\n /** No flag set. */\n NONE = 0x0,\n /** Caller is collecting trace information. */\n SAMPLED = 0x1\n}\n\n/**\n * A light interface that tries to be structurally compatible with OpenTelemetry\n */\nexport interface SpanContext {\n /**\n * UUID of a trace.\n */\n traceId: string;\n /**\n * UUID of a Span.\n */\n spanId: string;\n /**\n * https://www.w3.org/TR/trace-context/#trace-flags\n */\n traceFlags: number;\n}\n\n/**\n * An interface that enables manual propagation of Spans\n */\nexport interface SpanOptions {\n /**\n * The SpanContext that refers to a parent span, if any.\n * A null value indicates that this should be a new root span,\n * rather than potentially detecting a span via a context manager.\n */\n parent?: SpanContext | null;\n /**\n * Attributes to set on the Span\n */\n attributes?: { [key: string]: unknown };\n}\n\n/**\n * Tracing options to set on an operation.\n */\nexport interface OperationTracingOptions {\n /**\n * OpenTelemetry SpanOptions used to create a span when tracing is enabled.\n */\n spanOptions?: SpanOptions;\n}\n"]}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracerProxy.js","sourceRoot":"","sources":["../../src/tracerProxy.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,IAAI,aAAqB,CAAC;AAE1B,SAAS,gBAAgB;IACvB,IAAI,CAAC,aAAa,EAAE;QAClB,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;KAClC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,IAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,IAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,gBAAgB,EAAE,CAAC;KAC3B;IACD,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { NoOpTracer } from \"./tracers/noop/noOpTracer\";\nimport { Tracer } from \"@opentelemetry/api\";\nimport { getCache } from \"./utils/cache\";\n\nlet defaultTracer: Tracer;\n\nfunction getDefaultTracer(): Tracer {\n if (!defaultTracer) {\n defaultTracer = new NoOpTracer();\n }\n return defaultTracer;\n}\n\n/**\n * Sets the global tracer, enabling tracing for the Azure SDK.\n * @param tracer An OpenTelemetry Tracer instance.\n */\nexport function setTracer(tracer: Tracer) {\n const cache = getCache();\n cache.tracer = tracer;\n}\n\n/**\n * Retrieves the active tracer, or returns a\n * no-op implementation if one is not set.\n */\nexport function getTracer() {\n const cache = getCache();\n if (!cache.tracer) {\n return getDefaultTracer();\n }\n return cache.tracer;\n}\n"]}
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ import { TraceFlags } from "@opentelemetry/api";
1
4
  /**
2
5
  * A no-op implementation of Span that can safely be used without side-effects.
3
6
  */
@@ -10,7 +13,8 @@ var NoOpSpan = /** @class */ (function () {
10
13
  NoOpSpan.prototype.context = function () {
11
14
  return {
12
15
  spanId: "",
13
- traceId: ""
16
+ traceId: "",
17
+ traceFlags: TraceFlags.NONE
14
18
  };
15
19
  };
16
20
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noOpSpan.js","sourceRoot":"","sources":["../../../../src/tracers/noop/noOpSpan.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAClC,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. All rights reserved.\n// Licensed under the MIT License.\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,8 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
  import { NoOpSpan } from "./noOpSpan";
4
- import { NoOpBinaryFormat } from "./noOpBinaryFormat";
5
- import { NoOpHttpTextFormat } from "./noOpHttpTextFormat";
6
4
  /**
7
5
  * A no-op implementation of Tracer that can be used when tracing
8
6
  * is disabled.
@@ -40,25 +38,6 @@ var NoOpTracer = /** @class */ (function () {
40
38
  NoOpTracer.prototype.bind = function (target, _span) {
41
39
  return target;
42
40
  };
43
- /**
44
- * Send a pre-populated Span object to the exporter.
45
- * @param _span The span to pass along.
46
- */
47
- NoOpTracer.prototype.recordSpanData = function (_span) {
48
- /* NOOP */
49
- };
50
- /**
51
- * Returns the BinaryFormat interface for serializing/deserializing Spans.
52
- */
53
- NoOpTracer.prototype.getBinaryFormat = function () {
54
- return new NoOpBinaryFormat();
55
- };
56
- /**
57
- * Returns the HttpTextFormat interface for injecting/extracting Spans.
58
- */
59
- NoOpTracer.prototype.getHttpTextFormat = function () {
60
- return new NoOpHttpTextFormat();
61
- };
62
41
  return NoOpTracer;
63
42
  }());
64
43
  export { NoOpTracer };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noOpTracer.js","sourceRoot":"","sources":["../../../../src/tracers/noop/noOpTracer.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAClC,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. All rights reserved.\n// Licensed under the MIT License.\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"]}
@@ -23,7 +23,7 @@ var OpenCensusSpanWrapper = /** @class */ (function () {
23
23
  for (var _i = 0, _a = options.links; _i < _a.length; _i++) {
24
24
  var link = _a[_i];
25
25
  // Since there is no way to set the link relationship, leave it as Unspecified.
26
- this._span.addLink(link.spanContext.traceId, link.spanContext.spanId, 0 /* LinkType.UNSPECIFIED */, link.attributes);
26
+ this._span.addLink(link.context.traceId, link.context.spanId, 0 /* LinkType.UNSPECIFIED */, link.attributes);
27
27
  }
28
28
  }
29
29
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openCensusSpanWrapper.js","sourceRoot":"","sources":["../../../../src/tracers/opencensus/openCensusSpanWrapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAI5E,SAAS,aAAa,CAAC,IAAgC;IACrD,OAAO,CAAC,CAAC,IAAI,IAAK,IAA8B,CAAC,cAAc,KAAK,SAAS,CAAC;AAChF,CAAC;AAED,SAAS,QAAQ,CACf,YAAsD;IAEtD,OAAQ,YAAwC,CAAC,gBAAgB,KAAK,SAAS,CAAC;AAClF,CAAC;AAED;;GAEG;AACH;IAsBE,+BACE,YAAsD,EACtD,IAAiB,EACjB,OAAyB;QADzB,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AAC,OAAqB;YACvD,UAAU,EAAE,IAAI,2BAA2B,CAAC,qBAAqB,CAAC,UAAU,CAAC;SAC9E,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,4CAAY,GAAZ,UAAa,GAAW,EAAE,KAAc;QACtC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,KAAY,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,6CAAa,GAAb,UAAc,UAAsB;QAClC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,UAAkC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,wCAAQ,GAAR,UAAS,KAAa,EAAE,WAAwB;QAC9C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,yCAAS,GAAT,UAAU,MAAc;QACtB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,0CAAU,GAAV,UAAW,IAAY;QACrB,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,2CAAW,GAAX;QACE,sCAAsC;QACtC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAC9B,CAAC;IACH,4BAAC;AAAD,CAAC,AA9HD,IA8HC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\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() {\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"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openCensusTraceStateWrapper.js","sourceRoot":"","sources":["../../../../src/tracers/opencensus/openCensusTraceStateWrapper.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,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. All rights reserved.\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"]}