@opentelemetry/sdk-trace-web 1.30.0 → 2.0.0-dev.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.
Files changed (58) hide show
  1. package/build/esm/StackContextManager.js +27 -66
  2. package/build/esm/StackContextManager.js.map +1 -1
  3. package/build/esm/WebTracerProvider.d.ts +1 -1
  4. package/build/esm/WebTracerProvider.js +43 -41
  5. package/build/esm/WebTracerProvider.js.map +1 -1
  6. package/build/esm/enums/PerformanceTimingNames.d.ts +1 -0
  7. package/build/esm/enums/PerformanceTimingNames.js +1 -0
  8. package/build/esm/enums/PerformanceTimingNames.js.map +1 -1
  9. package/build/esm/index.d.ts +1 -1
  10. package/build/esm/index.js +1 -1
  11. package/build/esm/index.js.map +1 -1
  12. package/build/esm/types.d.ts +4 -3
  13. package/build/esm/types.js.map +1 -1
  14. package/build/esm/utils.d.ts +5 -4
  15. package/build/esm/utils.js +69 -84
  16. package/build/esm/utils.js.map +1 -1
  17. package/build/esm/version.d.ts +1 -1
  18. package/build/esm/version.js +1 -1
  19. package/build/esm/version.js.map +1 -1
  20. package/build/esnext/StackContextManager.js +8 -10
  21. package/build/esnext/StackContextManager.js.map +1 -1
  22. package/build/esnext/WebTracerProvider.d.ts +1 -1
  23. package/build/esnext/WebTracerProvider.js +37 -14
  24. package/build/esnext/WebTracerProvider.js.map +1 -1
  25. package/build/esnext/enums/PerformanceTimingNames.d.ts +1 -0
  26. package/build/esnext/enums/PerformanceTimingNames.js +1 -0
  27. package/build/esnext/enums/PerformanceTimingNames.js.map +1 -1
  28. package/build/esnext/index.d.ts +1 -1
  29. package/build/esnext/index.js +1 -1
  30. package/build/esnext/index.js.map +1 -1
  31. package/build/esnext/types.d.ts +4 -3
  32. package/build/esnext/types.js.map +1 -1
  33. package/build/esnext/utils.d.ts +5 -4
  34. package/build/esnext/utils.js +19 -30
  35. package/build/esnext/utils.js.map +1 -1
  36. package/build/esnext/version.d.ts +1 -1
  37. package/build/esnext/version.js +1 -1
  38. package/build/esnext/version.js.map +1 -1
  39. package/build/src/StackContextManager.js +8 -10
  40. package/build/src/StackContextManager.js.map +1 -1
  41. package/build/src/WebTracerProvider.d.ts +1 -1
  42. package/build/src/WebTracerProvider.js +37 -14
  43. package/build/src/WebTracerProvider.js.map +1 -1
  44. package/build/src/enums/PerformanceTimingNames.d.ts +1 -0
  45. package/build/src/enums/PerformanceTimingNames.js +1 -0
  46. package/build/src/enums/PerformanceTimingNames.js.map +1 -1
  47. package/build/src/index.d.ts +1 -1
  48. package/build/src/index.js +1 -4
  49. package/build/src/index.js.map +1 -1
  50. package/build/src/types.d.ts +4 -3
  51. package/build/src/types.js.map +1 -1
  52. package/build/src/utils.d.ts +5 -4
  53. package/build/src/utils.js +19 -30
  54. package/build/src/utils.js.map +1 -1
  55. package/build/src/version.d.ts +1 -1
  56. package/build/src/version.js +1 -1
  57. package/build/src/version.js.map +1 -1
  58. package/package.json +17 -19
@@ -13,63 +13,30 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- var __read = (this && this.__read) || function (o, n) {
17
- var m = typeof Symbol === "function" && o[Symbol.iterator];
18
- if (!m) return o;
19
- var i = m.call(o), r, ar = [], e;
20
- try {
21
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
22
- }
23
- catch (error) { e = { error: error }; }
24
- finally {
25
- try {
26
- if (r && !r.done && (m = i["return"])) m.call(i);
27
- }
28
- finally { if (e) throw e.error; }
29
- }
30
- return ar;
31
- };
32
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
33
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
34
- if (ar || !(i in from)) {
35
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
36
- ar[i] = from[i];
37
- }
38
- }
39
- return to.concat(ar || Array.prototype.slice.call(from));
40
- };
41
16
  import { ROOT_CONTEXT } from '@opentelemetry/api';
42
17
  /**
43
18
  * Stack Context Manager for managing the state in web
44
19
  * it doesn't fully support the async calls though
45
20
  */
46
- var StackContextManager = /** @class */ (function () {
47
- function StackContextManager() {
48
- /**
49
- * whether the context manager is enabled or not
50
- */
51
- this._enabled = false;
52
- /**
53
- * Keeps the reference to current context
54
- */
55
- this._currentContext = ROOT_CONTEXT;
56
- }
21
+ export class StackContextManager {
22
+ /**
23
+ * whether the context manager is enabled or not
24
+ */
25
+ _enabled = false;
26
+ /**
27
+ * Keeps the reference to current context
28
+ */
29
+ _currentContext = ROOT_CONTEXT;
57
30
  /**
58
31
  *
59
32
  * @param context
60
33
  * @param target Function to be executed within the context
61
34
  */
62
35
  // eslint-disable-next-line @typescript-eslint/ban-types
63
- StackContextManager.prototype._bindFunction = function (context, target) {
64
- if (context === void 0) { context = ROOT_CONTEXT; }
65
- var manager = this;
66
- var contextWrapper = function () {
67
- var _this = this;
68
- var args = [];
69
- for (var _i = 0; _i < arguments.length; _i++) {
70
- args[_i] = arguments[_i];
71
- }
72
- return manager.with(context, function () { return target.apply(_this, args); });
36
+ _bindFunction(context = ROOT_CONTEXT, target) {
37
+ const manager = this;
38
+ const contextWrapper = function (...args) {
39
+ return manager.with(context, () => target.apply(this, args));
73
40
  };
74
41
  Object.defineProperty(contextWrapper, 'length', {
75
42
  enumerable: false,
@@ -78,20 +45,20 @@ var StackContextManager = /** @class */ (function () {
78
45
  value: target.length,
79
46
  });
80
47
  return contextWrapper;
81
- };
48
+ }
82
49
  /**
83
50
  * Returns the active context
84
51
  */
85
- StackContextManager.prototype.active = function () {
52
+ active() {
86
53
  return this._currentContext;
87
- };
54
+ }
88
55
  /**
89
56
  * Binds a the certain context or the active one to the target function and then returns the target
90
57
  * @param context A context (span) to be bind to target
91
58
  * @param target a function or event emitter. When target or one of its callbacks is called,
92
59
  * the provided context will be used as the active context for the duration of the call.
93
60
  */
94
- StackContextManager.prototype.bind = function (context, target) {
61
+ bind(context, target) {
95
62
  // if no specific context to propagate is given, we use the current one
96
63
  if (context === undefined) {
97
64
  context = this.active();
@@ -100,26 +67,26 @@ var StackContextManager = /** @class */ (function () {
100
67
  return this._bindFunction(context, target);
101
68
  }
102
69
  return target;
103
- };
70
+ }
104
71
  /**
105
72
  * Disable the context manager (clears the current context)
106
73
  */
107
- StackContextManager.prototype.disable = function () {
74
+ disable() {
108
75
  this._currentContext = ROOT_CONTEXT;
109
76
  this._enabled = false;
110
77
  return this;
111
- };
78
+ }
112
79
  /**
113
80
  * Enables the context manager and creates a default(root) context
114
81
  */
115
- StackContextManager.prototype.enable = function () {
82
+ enable() {
116
83
  if (this._enabled) {
117
84
  return this;
118
85
  }
119
86
  this._enabled = true;
120
87
  this._currentContext = ROOT_CONTEXT;
121
88
  return this;
122
- };
89
+ }
123
90
  /**
124
91
  * Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the window.
125
92
  * The context will be set as active
@@ -128,21 +95,15 @@ var StackContextManager = /** @class */ (function () {
128
95
  * @param thisArg optional receiver to be used for calling fn
129
96
  * @param args optional arguments forwarded to fn
130
97
  */
131
- StackContextManager.prototype.with = function (context, fn, thisArg) {
132
- var args = [];
133
- for (var _i = 3; _i < arguments.length; _i++) {
134
- args[_i - 3] = arguments[_i];
135
- }
136
- var previousContext = this._currentContext;
98
+ with(context, fn, thisArg, ...args) {
99
+ const previousContext = this._currentContext;
137
100
  this._currentContext = context || ROOT_CONTEXT;
138
101
  try {
139
- return fn.call.apply(fn, __spreadArray([thisArg], __read(args), false));
102
+ return fn.call(thisArg, ...args);
140
103
  }
141
104
  finally {
142
105
  this._currentContext = previousContext;
143
106
  }
144
- };
145
- return StackContextManager;
146
- }());
147
- export { StackContextManager };
107
+ }
108
+ }
148
109
  //# sourceMappingURL=StackContextManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StackContextManager.js","sourceRoot":"","sources":["../../src/StackContextManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAA2B,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE3E;;;GAGG;AACH;IAAA;QACE;;WAEG;QACK,aAAQ,GAAG,KAAK,CAAC;QAEzB;;WAEG;QACI,oBAAe,GAAG,YAAY,CAAC;IA6FxC,CAAC;IA3FC;;;;OAIG;IACH,wDAAwD;IAChD,2CAAa,GAArB,UACE,OAAsB,EACtB,MAAS;QADT,wBAAA,EAAA,sBAAsB;QAGtB,IAAM,OAAO,GAAG,IAAI,CAAC;QACrB,IAAM,cAAc,GAAG;YAAA,iBAEtB;YAF+C,cAAkB;iBAAlB,UAAkB,EAAlB,qBAAkB,EAAlB,IAAkB;gBAAlB,yBAAkB;;YAChE,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,cAAM,OAAA,MAAM,CAAC,KAAK,CAAC,KAAI,EAAE,IAAI,CAAC,EAAxB,CAAwB,CAAC,CAAC;QAC/D,CAAC,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,QAAQ,EAAE;YAC9C,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,MAAM,CAAC,MAAM;SACrB,CAAC,CAAC;QACH,OAAO,cAA8B,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,oCAAM,GAAN;QACE,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,kCAAI,GAAJ,UAAQ,OAAgB,EAAE,MAAS;QACjC,uEAAuE;QACvE,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;SACzB;QACD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;YAChC,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SAC5C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,qCAAO,GAAP;QACE,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,oCAAM,GAAN;QACE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,IAAI,CAAC;SACb;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,kCAAI,GAAJ,UACE,OAAuB,EACvB,EAAK,EACL,OAA8B;QAC9B,cAAU;aAAV,UAAU,EAAV,qBAAU,EAAV,IAAU;YAAV,6BAAU;;QAEV,IAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,eAAe,GAAG,OAAO,IAAI,YAAY,CAAC;QAE/C,IAAI;YACF,OAAO,EAAE,CAAC,IAAI,OAAP,EAAE,iBAAM,OAAO,UAAK,IAAI,WAAE;SAClC;gBAAS;YACR,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;SACxC;IACH,CAAC;IACH,0BAAC;AAAD,CAAC,AAtGD,IAsGC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, ContextManager, ROOT_CONTEXT } from '@opentelemetry/api';\n\n/**\n * Stack Context Manager for managing the state in web\n * it doesn't fully support the async calls though\n */\nexport class StackContextManager implements ContextManager {\n /**\n * whether the context manager is enabled or not\n */\n private _enabled = false;\n\n /**\n * Keeps the reference to current context\n */\n public _currentContext = ROOT_CONTEXT;\n\n /**\n *\n * @param context\n * @param target Function to be executed within the context\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n private _bindFunction<T extends Function>(\n context = ROOT_CONTEXT,\n target: T\n ): T {\n const manager = this;\n const contextWrapper = function (this: unknown, ...args: unknown[]) {\n return manager.with(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper as unknown as T;\n }\n\n /**\n * Returns the active context\n */\n active(): Context {\n return this._currentContext;\n }\n\n /**\n * Binds a the certain context or the active one to the target function and then returns the target\n * @param context A context (span) to be bind to target\n * @param target a function or event emitter. When target or one of its callbacks is called,\n * the provided context will be used as the active context for the duration of the call.\n */\n bind<T>(context: Context, target: T): T {\n // if no specific context to propagate is given, we use the current one\n if (context === undefined) {\n context = this.active();\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target);\n }\n return target;\n }\n\n /**\n * Disable the context manager (clears the current context)\n */\n disable(): this {\n this._currentContext = ROOT_CONTEXT;\n this._enabled = false;\n return this;\n }\n\n /**\n * Enables the context manager and creates a default(root) context\n */\n enable(): this {\n if (this._enabled) {\n return this;\n }\n this._enabled = true;\n this._currentContext = ROOT_CONTEXT;\n return this;\n }\n\n /**\n * Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the window.\n * The context will be set as active\n * @param context\n * @param fn Callback function\n * @param thisArg optional receiver to be used for calling fn\n * @param args optional arguments forwarded to fn\n */\n with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context | null,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const previousContext = this._currentContext;\n this._currentContext = context || ROOT_CONTEXT;\n\n try {\n return fn.call(thisArg, ...args);\n } finally {\n this._currentContext = previousContext;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"StackContextManager.js","sourceRoot":"","sources":["../../src/StackContextManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA2B,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE3E;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAC9B;;OAEG;IACK,QAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACI,eAAe,GAAG,YAAY,CAAC;IAEtC;;;;OAIG;IACH,wDAAwD;IAChD,aAAa,CACnB,OAAO,GAAG,YAAY,EACtB,MAAS;QAET,MAAM,OAAO,GAAG,IAAI,CAAC;QACrB,MAAM,cAAc,GAAG,UAAyB,GAAG,IAAe;YAChE,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/D,CAAC,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,QAAQ,EAAE;YAC9C,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,MAAM,CAAC,MAAM;SACrB,CAAC,CAAC;QACH,OAAO,cAA8B,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAI,OAAgB,EAAE,MAAS;QACjC,uEAAuE;QACvE,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;SACzB;QACD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;YAChC,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SAC5C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,IAAI,CAAC;SACb;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CACF,OAAuB,EACvB,EAAK,EACL,OAA8B,EAC9B,GAAG,IAAO;QAEV,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,eAAe,GAAG,OAAO,IAAI,YAAY,CAAC;QAE/C,IAAI;YACF,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;SAClC;gBAAS;YACR,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, ContextManager, ROOT_CONTEXT } from '@opentelemetry/api';\n\n/**\n * Stack Context Manager for managing the state in web\n * it doesn't fully support the async calls though\n */\nexport class StackContextManager implements ContextManager {\n /**\n * whether the context manager is enabled or not\n */\n private _enabled = false;\n\n /**\n * Keeps the reference to current context\n */\n public _currentContext = ROOT_CONTEXT;\n\n /**\n *\n * @param context\n * @param target Function to be executed within the context\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n private _bindFunction<T extends Function>(\n context = ROOT_CONTEXT,\n target: T\n ): T {\n const manager = this;\n const contextWrapper = function (this: unknown, ...args: unknown[]) {\n return manager.with(context, () => target.apply(this, args));\n };\n Object.defineProperty(contextWrapper, 'length', {\n enumerable: false,\n configurable: true,\n writable: false,\n value: target.length,\n });\n return contextWrapper as unknown as T;\n }\n\n /**\n * Returns the active context\n */\n active(): Context {\n return this._currentContext;\n }\n\n /**\n * Binds a the certain context or the active one to the target function and then returns the target\n * @param context A context (span) to be bind to target\n * @param target a function or event emitter. When target or one of its callbacks is called,\n * the provided context will be used as the active context for the duration of the call.\n */\n bind<T>(context: Context, target: T): T {\n // if no specific context to propagate is given, we use the current one\n if (context === undefined) {\n context = this.active();\n }\n if (typeof target === 'function') {\n return this._bindFunction(context, target);\n }\n return target;\n }\n\n /**\n * Disable the context manager (clears the current context)\n */\n disable(): this {\n this._currentContext = ROOT_CONTEXT;\n this._enabled = false;\n return this;\n }\n\n /**\n * Enables the context manager and creates a default(root) context\n */\n enable(): this {\n if (this._enabled) {\n return this;\n }\n this._enabled = true;\n this._currentContext = ROOT_CONTEXT;\n return this;\n }\n\n /**\n * Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the window.\n * The context will be set as active\n * @param context\n * @param fn Callback function\n * @param thisArg optional receiver to be used for calling fn\n * @param args optional arguments forwarded to fn\n */\n with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context | null,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n const previousContext = this._currentContext;\n this._currentContext = context || ROOT_CONTEXT;\n\n try {\n return fn.call(thisArg, ...args);\n } finally {\n this._currentContext = previousContext;\n }\n }\n}\n"]}
@@ -2,7 +2,7 @@ import { BasicTracerProvider, SDKRegistrationConfig, TracerConfig } from '@opent
2
2
  /**
3
3
  * WebTracerConfig provides an interface for configuring a Web Tracer.
4
4
  */
5
- export declare type WebTracerConfig = TracerConfig;
5
+ export type WebTracerConfig = TracerConfig;
6
6
  /**
7
7
  * This class represents a web tracer with {@link StackContextManager}
8
8
  */
@@ -13,43 +13,52 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- var __extends = (this && this.__extends) || (function () {
17
- var extendStatics = function (d, b) {
18
- extendStatics = Object.setPrototypeOf ||
19
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21
- return extendStatics(d, b);
22
- };
23
- return function (d, b) {
24
- if (typeof b !== "function" && b !== null)
25
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
26
- extendStatics(d, b);
27
- function __() { this.constructor = d; }
28
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
- };
30
- })();
31
16
  import { BasicTracerProvider, } from '@opentelemetry/sdk-trace-base';
32
17
  import { StackContextManager } from './StackContextManager';
18
+ import { trace, context, propagation, } from '@opentelemetry/api';
19
+ import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator, } from '@opentelemetry/core';
20
+ function setupContextManager(contextManager) {
21
+ // null means 'do not register'
22
+ if (contextManager === null) {
23
+ return;
24
+ }
25
+ // undefined means 'register default'
26
+ if (contextManager === undefined) {
27
+ const defaultContextManager = new StackContextManager();
28
+ defaultContextManager.enable();
29
+ context.setGlobalContextManager(defaultContextManager);
30
+ return;
31
+ }
32
+ contextManager.enable();
33
+ context.setGlobalContextManager(contextManager);
34
+ }
35
+ function setupPropagator(propagator) {
36
+ // null means 'do not register'
37
+ if (propagator === null) {
38
+ return;
39
+ }
40
+ // undefined means 'register default'
41
+ if (propagator === undefined) {
42
+ propagation.setGlobalPropagator(new CompositePropagator({
43
+ propagators: [
44
+ new W3CTraceContextPropagator(),
45
+ new W3CBaggagePropagator(),
46
+ ],
47
+ }));
48
+ return;
49
+ }
50
+ propagation.setGlobalPropagator(propagator);
51
+ }
33
52
  /**
34
53
  * This class represents a web tracer with {@link StackContextManager}
35
54
  */
36
- var WebTracerProvider = /** @class */ (function (_super) {
37
- __extends(WebTracerProvider, _super);
55
+ export class WebTracerProvider extends BasicTracerProvider {
38
56
  /**
39
57
  * Constructs a new Tracer instance.
40
58
  * @param config Web Tracer config
41
59
  */
42
- function WebTracerProvider(config) {
43
- if (config === void 0) { config = {}; }
44
- var _this = _super.call(this, config) || this;
45
- if (config.contextManager) {
46
- throw ('contextManager should be defined in register method not in' +
47
- ' constructor');
48
- }
49
- if (config.propagator) {
50
- throw 'propagator should be defined in register method not in constructor';
51
- }
52
- return _this;
60
+ constructor(config = {}) {
61
+ super(config);
53
62
  }
54
63
  /**
55
64
  * Register this TracerProvider for use with the OpenTelemetry API.
@@ -58,17 +67,10 @@ var WebTracerProvider = /** @class */ (function (_super) {
58
67
  *
59
68
  * @param config Configuration object for SDK registration
60
69
  */
61
- WebTracerProvider.prototype.register = function (config) {
62
- if (config === void 0) { config = {}; }
63
- if (config.contextManager === undefined) {
64
- config.contextManager = new StackContextManager();
65
- }
66
- if (config.contextManager) {
67
- config.contextManager.enable();
68
- }
69
- _super.prototype.register.call(this, config);
70
- };
71
- return WebTracerProvider;
72
- }(BasicTracerProvider));
73
- export { WebTracerProvider };
70
+ register(config = {}) {
71
+ trace.setGlobalTracerProvider(this);
72
+ setupPropagator(config.propagator);
73
+ setupContextManager(config.contextManager);
74
+ }
75
+ }
74
76
  //# sourceMappingURL=WebTracerProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebTracerProvider.js","sourceRoot":"","sources":["../../src/WebTracerProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,OAAO,EACL,mBAAmB,GAGpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5D;;GAEG;AACH;IAAuC,qCAAmB;IACxD;;;OAGG;IACH,2BAAY,MAA4B;QAA5B,uBAAA,EAAA,WAA4B;QAAxC,YACE,kBAAM,MAAM,CAAC,SAWd;QATC,IAAK,MAAgC,CAAC,cAAc,EAAE;YACpD,MAAM,CACJ,4DAA4D;gBAC5D,cAAc,CACf,CAAC;SACH;QACD,IAAK,MAAgC,CAAC,UAAU,EAAE;YAChD,MAAM,oEAAoE,CAAC;SAC5E;;IACH,CAAC;IAED;;;;;;OAMG;IACM,oCAAQ,GAAjB,UAAkB,MAAkC;QAAlC,uBAAA,EAAA,WAAkC;QAClD,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE;YACvC,MAAM,CAAC,cAAc,GAAG,IAAI,mBAAmB,EAAE,CAAC;SACnD;QACD,IAAI,MAAM,CAAC,cAAc,EAAE;YACzB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;SAChC;QAED,iBAAM,QAAQ,YAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IACH,wBAAC;AAAD,CAAC,AApCD,CAAuC,mBAAmB,GAoCzD","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BasicTracerProvider,\n SDKRegistrationConfig,\n TracerConfig,\n} from '@opentelemetry/sdk-trace-base';\nimport { StackContextManager } from './StackContextManager';\n\n/**\n * WebTracerConfig provides an interface for configuring a Web Tracer.\n */\nexport type WebTracerConfig = TracerConfig;\n\n/**\n * This class represents a web tracer with {@link StackContextManager}\n */\nexport class WebTracerProvider extends BasicTracerProvider {\n /**\n * Constructs a new Tracer instance.\n * @param config Web Tracer config\n */\n constructor(config: WebTracerConfig = {}) {\n super(config);\n\n if ((config as SDKRegistrationConfig).contextManager) {\n throw (\n 'contextManager should be defined in register method not in' +\n ' constructor'\n );\n }\n if ((config as SDKRegistrationConfig).propagator) {\n throw 'propagator should be defined in register method not in constructor';\n }\n }\n\n /**\n * Register this TracerProvider for use with the OpenTelemetry API.\n * Undefined values may be replaced with defaults, and\n * null values will be skipped.\n *\n * @param config Configuration object for SDK registration\n */\n override register(config: SDKRegistrationConfig = {}): void {\n if (config.contextManager === undefined) {\n config.contextManager = new StackContextManager();\n }\n if (config.contextManager) {\n config.contextManager.enable();\n }\n\n super.register(config);\n }\n}\n"]}
1
+ {"version":3,"file":"WebTracerProvider.js","sourceRoot":"","sources":["../../src/WebTracerProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,mBAAmB,GAGpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,KAAK,EACL,OAAO,EAEP,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,SAAS,mBAAmB,CAC1B,cAAiD;IAEjD,+BAA+B;IAC/B,IAAI,cAAc,KAAK,IAAI,EAAE;QAC3B,OAAO;KACR;IAED,qCAAqC;IACrC,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,MAAM,qBAAqB,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACxD,qBAAqB,CAAC,MAAM,EAAE,CAAC;QAC/B,OAAO,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,CAAC;QACvD,OAAO;KACR;IAED,cAAc,CAAC,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,eAAe,CAAC,UAAgD;IACvE,+BAA+B;IAC/B,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,OAAO;KACR;IAED,qCAAqC;IACrC,IAAI,UAAU,KAAK,SAAS,EAAE;QAC5B,WAAW,CAAC,mBAAmB,CAC7B,IAAI,mBAAmB,CAAC;YACtB,WAAW,EAAE;gBACX,IAAI,yBAAyB,EAAE;gBAC/B,IAAI,oBAAoB,EAAE;aAC3B;SACF,CAAC,CACH,CAAC;QACF,OAAO;KACR;IAED,WAAW,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC9C,CAAC;AAOD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,mBAAmB;IACxD;;;OAGG;IACH,YAAY,SAA0B,EAAE;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,SAAgC,EAAE;QACzC,KAAK,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;QACpC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACnC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BasicTracerProvider,\n SDKRegistrationConfig,\n TracerConfig,\n} from '@opentelemetry/sdk-trace-base';\nimport { StackContextManager } from './StackContextManager';\nimport {\n trace,\n context,\n ContextManager,\n propagation,\n TextMapPropagator,\n} from '@opentelemetry/api';\nimport {\n CompositePropagator,\n W3CBaggagePropagator,\n W3CTraceContextPropagator,\n} from '@opentelemetry/core';\n\nfunction setupContextManager(\n contextManager: ContextManager | null | undefined\n) {\n // null means 'do not register'\n if (contextManager === null) {\n return;\n }\n\n // undefined means 'register default'\n if (contextManager === undefined) {\n const defaultContextManager = new StackContextManager();\n defaultContextManager.enable();\n context.setGlobalContextManager(defaultContextManager);\n return;\n }\n\n contextManager.enable();\n context.setGlobalContextManager(contextManager);\n}\n\nfunction setupPropagator(propagator: TextMapPropagator | null | undefined) {\n // null means 'do not register'\n if (propagator === null) {\n return;\n }\n\n // undefined means 'register default'\n if (propagator === undefined) {\n propagation.setGlobalPropagator(\n new CompositePropagator({\n propagators: [\n new W3CTraceContextPropagator(),\n new W3CBaggagePropagator(),\n ],\n })\n );\n return;\n }\n\n propagation.setGlobalPropagator(propagator);\n}\n\n/**\n * WebTracerConfig provides an interface for configuring a Web Tracer.\n */\nexport type WebTracerConfig = TracerConfig;\n\n/**\n * This class represents a web tracer with {@link StackContextManager}\n */\nexport class WebTracerProvider extends BasicTracerProvider {\n /**\n * Constructs a new Tracer instance.\n * @param config Web Tracer config\n */\n constructor(config: WebTracerConfig = {}) {\n super(config);\n }\n\n /**\n * Register this TracerProvider for use with the OpenTelemetry API.\n * Undefined values may be replaced with defaults, and\n * null values will be skipped.\n *\n * @param config Configuration object for SDK registration\n */\n register(config: SDKRegistrationConfig = {}): void {\n trace.setGlobalTracerProvider(this);\n setupPropagator(config.propagator);\n setupContextManager(config.contextManager);\n }\n}\n"]}
@@ -19,6 +19,7 @@ export declare enum PerformanceTimingNames {
19
19
  RESPONSE_END = "responseEnd",
20
20
  RESPONSE_START = "responseStart",
21
21
  SECURE_CONNECTION_START = "secureConnectionStart",
22
+ START_TIME = "startTime",
22
23
  UNLOAD_EVENT_END = "unloadEventEnd",
23
24
  UNLOAD_EVENT_START = "unloadEventStart"
24
25
  }
@@ -35,6 +35,7 @@ export var PerformanceTimingNames;
35
35
  PerformanceTimingNames["RESPONSE_END"] = "responseEnd";
36
36
  PerformanceTimingNames["RESPONSE_START"] = "responseStart";
37
37
  PerformanceTimingNames["SECURE_CONNECTION_START"] = "secureConnectionStart";
38
+ PerformanceTimingNames["START_TIME"] = "startTime";
38
39
  PerformanceTimingNames["UNLOAD_EVENT_END"] = "unloadEventEnd";
39
40
  PerformanceTimingNames["UNLOAD_EVENT_START"] = "unloadEventStart";
40
41
  })(PerformanceTimingNames || (PerformanceTimingNames = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"PerformanceTimingNames.js","sourceRoot":"","sources":["../../../src/enums/PerformanceTimingNames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAN,IAAY,sBAuBX;AAvBD,WAAY,sBAAsB;IAChC,oDAA0B,CAAA;IAC1B,wDAA8B,CAAA;IAC9B,+DAAqC,CAAA;IACrC,sDAA4B,CAAA;IAC5B,mFAAyD,CAAA;IACzD,uFAA6D,CAAA;IAC7D,4DAAkC,CAAA;IAClC,+DAAqC,CAAA;IACrC,mEAAyC,CAAA;IACzC,+DAAqC,CAAA;IACrC,oDAA0B,CAAA;IAC1B,yDAA+B,CAAA;IAC/B,6DAAmC,CAAA;IACnC,8DAAoC,CAAA;IACpC,sDAA4B,CAAA;IAC5B,0DAAgC,CAAA;IAChC,wDAA8B,CAAA;IAC9B,sDAA4B,CAAA;IAC5B,0DAAgC,CAAA;IAChC,2EAAiD,CAAA;IACjD,6DAAmC,CAAA;IACnC,iEAAuC,CAAA;AACzC,CAAC,EAvBW,sBAAsB,KAAtB,sBAAsB,QAuBjC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum PerformanceTimingNames {\n CONNECT_END = 'connectEnd',\n CONNECT_START = 'connectStart',\n DECODED_BODY_SIZE = 'decodedBodySize',\n DOM_COMPLETE = 'domComplete',\n DOM_CONTENT_LOADED_EVENT_END = 'domContentLoadedEventEnd',\n DOM_CONTENT_LOADED_EVENT_START = 'domContentLoadedEventStart',\n DOM_INTERACTIVE = 'domInteractive',\n DOMAIN_LOOKUP_END = 'domainLookupEnd',\n DOMAIN_LOOKUP_START = 'domainLookupStart',\n ENCODED_BODY_SIZE = 'encodedBodySize',\n FETCH_START = 'fetchStart',\n LOAD_EVENT_END = 'loadEventEnd',\n LOAD_EVENT_START = 'loadEventStart',\n NAVIGATION_START = 'navigationStart',\n REDIRECT_END = 'redirectEnd',\n REDIRECT_START = 'redirectStart',\n REQUEST_START = 'requestStart',\n RESPONSE_END = 'responseEnd',\n RESPONSE_START = 'responseStart',\n SECURE_CONNECTION_START = 'secureConnectionStart',\n UNLOAD_EVENT_END = 'unloadEventEnd',\n UNLOAD_EVENT_START = 'unloadEventStart',\n}\n"]}
1
+ {"version":3,"file":"PerformanceTimingNames.js","sourceRoot":"","sources":["../../../src/enums/PerformanceTimingNames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAN,IAAY,sBAwBX;AAxBD,WAAY,sBAAsB;IAChC,oDAA0B,CAAA;IAC1B,wDAA8B,CAAA;IAC9B,+DAAqC,CAAA;IACrC,sDAA4B,CAAA;IAC5B,mFAAyD,CAAA;IACzD,uFAA6D,CAAA;IAC7D,4DAAkC,CAAA;IAClC,+DAAqC,CAAA;IACrC,mEAAyC,CAAA;IACzC,+DAAqC,CAAA;IACrC,oDAA0B,CAAA;IAC1B,yDAA+B,CAAA;IAC/B,6DAAmC,CAAA;IACnC,8DAAoC,CAAA;IACpC,sDAA4B,CAAA;IAC5B,0DAAgC,CAAA;IAChC,wDAA8B,CAAA;IAC9B,sDAA4B,CAAA;IAC5B,0DAAgC,CAAA;IAChC,2EAAiD,CAAA;IACjD,kDAAwB,CAAA;IACxB,6DAAmC,CAAA;IACnC,iEAAuC,CAAA;AACzC,CAAC,EAxBW,sBAAsB,KAAtB,sBAAsB,QAwBjC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum PerformanceTimingNames {\n CONNECT_END = 'connectEnd',\n CONNECT_START = 'connectStart',\n DECODED_BODY_SIZE = 'decodedBodySize',\n DOM_COMPLETE = 'domComplete',\n DOM_CONTENT_LOADED_EVENT_END = 'domContentLoadedEventEnd',\n DOM_CONTENT_LOADED_EVENT_START = 'domContentLoadedEventStart',\n DOM_INTERACTIVE = 'domInteractive',\n DOMAIN_LOOKUP_END = 'domainLookupEnd',\n DOMAIN_LOOKUP_START = 'domainLookupStart',\n ENCODED_BODY_SIZE = 'encodedBodySize',\n FETCH_START = 'fetchStart',\n LOAD_EVENT_END = 'loadEventEnd',\n LOAD_EVENT_START = 'loadEventStart',\n NAVIGATION_START = 'navigationStart',\n REDIRECT_END = 'redirectEnd',\n REDIRECT_START = 'redirectStart',\n REQUEST_START = 'requestStart',\n RESPONSE_END = 'responseEnd',\n RESPONSE_START = 'responseStart',\n SECURE_CONNECTION_START = 'secureConnectionStart',\n START_TIME = 'startTime',\n UNLOAD_EVENT_END = 'unloadEventEnd',\n UNLOAD_EVENT_START = 'unloadEventStart',\n}\n"]}
@@ -3,5 +3,5 @@ export { StackContextManager } from './StackContextManager';
3
3
  export { PerformanceTimingNames } from './enums/PerformanceTimingNames';
4
4
  export { PerformanceEntries, PerformanceLegacy, PerformanceResourceTimingInfo, PropagateTraceHeaderCorsUrls, } from './types';
5
5
  export { URLLike, addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources, } from './utils';
6
- export { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, BatchSpanProcessorBrowserConfig, BufferConfig, ConsoleSpanExporter, EXPORTER_FACTORY, ForceFlushState, GeneralLimits, IdGenerator, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, PROPAGATOR_FACTORY, RandomIdGenerator, ReadableSpan, Sampler, SamplingDecision, SamplingResult, SDKRegistrationConfig, SimpleSpanProcessor, Span, SpanExporter, SpanLimits, SpanProcessor, TimedEvent, TraceIdRatioBasedSampler, Tracer, TracerConfig, } from '@opentelemetry/sdk-trace-base';
6
+ export { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, BatchSpanProcessorBrowserConfig, BufferConfig, ConsoleSpanExporter, GeneralLimits, IdGenerator, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, RandomIdGenerator, ReadableSpan, Sampler, SamplingDecision, SamplingResult, SDKRegistrationConfig, SimpleSpanProcessor, Span, SpanExporter, SpanLimits, SpanProcessor, TimedEvent, TraceIdRatioBasedSampler, TracerConfig, } from '@opentelemetry/sdk-trace-base';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -17,5 +17,5 @@ export { WebTracerProvider } from './WebTracerProvider';
17
17
  export { StackContextManager } from './StackContextManager';
18
18
  export { PerformanceTimingNames } from './enums/PerformanceTimingNames';
19
19
  export { addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources, } from './utils';
20
- export { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, ConsoleSpanExporter, ForceFlushState, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, RandomIdGenerator, SamplingDecision, SimpleSpanProcessor, Span, TraceIdRatioBasedSampler, Tracer, } from '@opentelemetry/sdk-trace-base';
20
+ export { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, ConsoleSpanExporter, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, RandomIdGenerator, SamplingDecision, SimpleSpanProcessor, TraceIdRatioBasedSampler, } from '@opentelemetry/sdk-trace-base';
21
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAmB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAOxE,OAAO,EAEL,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,2BAA2B,EAC3B,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAGlB,mBAAmB,EAEnB,eAAe,EAGf,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAElB,iBAAiB,EAGjB,gBAAgB,EAGhB,mBAAmB,EACnB,IAAI,EAKJ,wBAAwB,EACxB,MAAM,GAEP,MAAM,+BAA+B,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { WebTracerConfig, WebTracerProvider } from './WebTracerProvider';\nexport { StackContextManager } from './StackContextManager';\nexport { PerformanceTimingNames } from './enums/PerformanceTimingNames';\nexport {\n PerformanceEntries,\n PerformanceLegacy,\n PerformanceResourceTimingInfo,\n PropagateTraceHeaderCorsUrls,\n} from './types';\nexport {\n URLLike,\n addSpanNetworkEvent,\n addSpanNetworkEvents,\n getElementXPath,\n getResource,\n hasKey,\n normalizeUrl,\n parseUrl,\n shouldPropagateTraceHeaders,\n sortResources,\n} from './utils';\nexport {\n AlwaysOffSampler,\n AlwaysOnSampler,\n BasicTracerProvider,\n BatchSpanProcessor,\n BatchSpanProcessorBrowserConfig,\n BufferConfig,\n ConsoleSpanExporter,\n EXPORTER_FACTORY,\n ForceFlushState,\n GeneralLimits,\n IdGenerator,\n InMemorySpanExporter,\n NoopSpanProcessor,\n ParentBasedSampler,\n PROPAGATOR_FACTORY,\n RandomIdGenerator,\n ReadableSpan,\n Sampler,\n SamplingDecision,\n SamplingResult,\n SDKRegistrationConfig,\n SimpleSpanProcessor,\n Span,\n SpanExporter,\n SpanLimits,\n SpanProcessor,\n TimedEvent,\n TraceIdRatioBasedSampler,\n Tracer,\n TracerConfig,\n} from '@opentelemetry/sdk-trace-base';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAmB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAOxE,OAAO,EAEL,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,2BAA2B,EAC3B,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAGlB,mBAAmB,EAGnB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAGjB,gBAAgB,EAGhB,mBAAmB,EAMnB,wBAAwB,GAEzB,MAAM,+BAA+B,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { WebTracerConfig, WebTracerProvider } from './WebTracerProvider';\nexport { StackContextManager } from './StackContextManager';\nexport { PerformanceTimingNames } from './enums/PerformanceTimingNames';\nexport {\n PerformanceEntries,\n PerformanceLegacy,\n PerformanceResourceTimingInfo,\n PropagateTraceHeaderCorsUrls,\n} from './types';\nexport {\n URLLike,\n addSpanNetworkEvent,\n addSpanNetworkEvents,\n getElementXPath,\n getResource,\n hasKey,\n normalizeUrl,\n parseUrl,\n shouldPropagateTraceHeaders,\n sortResources,\n} from './utils';\nexport {\n AlwaysOffSampler,\n AlwaysOnSampler,\n BasicTracerProvider,\n BatchSpanProcessor,\n BatchSpanProcessorBrowserConfig,\n BufferConfig,\n ConsoleSpanExporter,\n GeneralLimits,\n IdGenerator,\n InMemorySpanExporter,\n NoopSpanProcessor,\n ParentBasedSampler,\n RandomIdGenerator,\n ReadableSpan,\n Sampler,\n SamplingDecision,\n SamplingResult,\n SDKRegistrationConfig,\n SimpleSpanProcessor,\n Span,\n SpanExporter,\n SpanLimits,\n SpanProcessor,\n TimedEvent,\n TraceIdRatioBasedSampler,\n TracerConfig,\n} from '@opentelemetry/sdk-trace-base';\n"]}
@@ -1,5 +1,5 @@
1
1
  import { PerformanceTimingNames } from './enums/PerformanceTimingNames';
2
- export declare type PerformanceEntries = {
2
+ export type PerformanceEntries = {
3
3
  [PerformanceTimingNames.CONNECT_END]?: number;
4
4
  [PerformanceTimingNames.CONNECT_START]?: number;
5
5
  [PerformanceTimingNames.DECODED_BODY_SIZE]?: number;
@@ -19,6 +19,7 @@ export declare type PerformanceEntries = {
19
19
  [PerformanceTimingNames.RESPONSE_END]?: number;
20
20
  [PerformanceTimingNames.RESPONSE_START]?: number;
21
21
  [PerformanceTimingNames.SECURE_CONNECTION_START]?: number;
22
+ [PerformanceTimingNames.START_TIME]?: number;
22
23
  [PerformanceTimingNames.UNLOAD_EVENT_END]?: number;
23
24
  [PerformanceTimingNames.UNLOAD_EVENT_START]?: number;
24
25
  };
@@ -37,10 +38,10 @@ export interface PerformanceResourceTimingInfo {
37
38
  corsPreFlightRequest?: PerformanceResourceTiming;
38
39
  mainRequest?: PerformanceResourceTiming;
39
40
  }
40
- declare type PropagateTraceHeaderCorsUrl = string | RegExp;
41
+ type PropagateTraceHeaderCorsUrl = string | RegExp;
41
42
  /**
42
43
  * urls which should include trace headers when origin doesn't match
43
44
  */
44
- export declare type PropagateTraceHeaderCorsUrls = PropagateTraceHeaderCorsUrl | PropagateTraceHeaderCorsUrl[];
45
+ export type PropagateTraceHeaderCorsUrls = PropagateTraceHeaderCorsUrl | PropagateTraceHeaderCorsUrl[];
45
46
  export {};
46
47
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { PerformanceTimingNames } from './enums/PerformanceTimingNames';\n\nexport type PerformanceEntries = {\n [PerformanceTimingNames.CONNECT_END]?: number;\n [PerformanceTimingNames.CONNECT_START]?: number;\n [PerformanceTimingNames.DECODED_BODY_SIZE]?: number;\n [PerformanceTimingNames.DOM_COMPLETE]?: number;\n [PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_END]?: number;\n [PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_START]?: number;\n [PerformanceTimingNames.DOM_INTERACTIVE]?: number;\n [PerformanceTimingNames.DOMAIN_LOOKUP_END]?: number;\n [PerformanceTimingNames.DOMAIN_LOOKUP_START]?: number;\n [PerformanceTimingNames.ENCODED_BODY_SIZE]?: number;\n [PerformanceTimingNames.FETCH_START]?: number;\n [PerformanceTimingNames.LOAD_EVENT_END]?: number;\n [PerformanceTimingNames.LOAD_EVENT_START]?: number;\n [PerformanceTimingNames.REDIRECT_END]?: number;\n [PerformanceTimingNames.REDIRECT_START]?: number;\n [PerformanceTimingNames.REQUEST_START]?: number;\n [PerformanceTimingNames.RESPONSE_END]?: number;\n [PerformanceTimingNames.RESPONSE_START]?: number;\n [PerformanceTimingNames.SECURE_CONNECTION_START]?: number;\n [PerformanceTimingNames.UNLOAD_EVENT_END]?: number;\n [PerformanceTimingNames.UNLOAD_EVENT_START]?: number;\n};\n\n/**\n * This interface defines a fallback to read performance metrics,\n * this happens for example on Safari Mac\n */\nexport interface PerformanceLegacy {\n timing?: PerformanceEntries;\n}\n\n/**\n * This interface is used in {@link getResource} function to return\n * main request and it's corresponding PreFlight request\n */\nexport interface PerformanceResourceTimingInfo {\n corsPreFlightRequest?: PerformanceResourceTiming;\n mainRequest?: PerformanceResourceTiming;\n}\n\ntype PropagateTraceHeaderCorsUrl = string | RegExp;\n\n/**\n * urls which should include trace headers when origin doesn't match\n */\nexport type PropagateTraceHeaderCorsUrls =\n | PropagateTraceHeaderCorsUrl\n | PropagateTraceHeaderCorsUrl[];\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { PerformanceTimingNames } from './enums/PerformanceTimingNames';\n\nexport type PerformanceEntries = {\n [PerformanceTimingNames.CONNECT_END]?: number;\n [PerformanceTimingNames.CONNECT_START]?: number;\n [PerformanceTimingNames.DECODED_BODY_SIZE]?: number;\n [PerformanceTimingNames.DOM_COMPLETE]?: number;\n [PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_END]?: number;\n [PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_START]?: number;\n [PerformanceTimingNames.DOM_INTERACTIVE]?: number;\n [PerformanceTimingNames.DOMAIN_LOOKUP_END]?: number;\n [PerformanceTimingNames.DOMAIN_LOOKUP_START]?: number;\n [PerformanceTimingNames.ENCODED_BODY_SIZE]?: number;\n [PerformanceTimingNames.FETCH_START]?: number;\n [PerformanceTimingNames.LOAD_EVENT_END]?: number;\n [PerformanceTimingNames.LOAD_EVENT_START]?: number;\n [PerformanceTimingNames.REDIRECT_END]?: number;\n [PerformanceTimingNames.REDIRECT_START]?: number;\n [PerformanceTimingNames.REQUEST_START]?: number;\n [PerformanceTimingNames.RESPONSE_END]?: number;\n [PerformanceTimingNames.RESPONSE_START]?: number;\n [PerformanceTimingNames.SECURE_CONNECTION_START]?: number;\n [PerformanceTimingNames.START_TIME]?: number;\n [PerformanceTimingNames.UNLOAD_EVENT_END]?: number;\n [PerformanceTimingNames.UNLOAD_EVENT_START]?: number;\n};\n\n/**\n * This interface defines a fallback to read performance metrics,\n * this happens for example on Safari Mac\n */\nexport interface PerformanceLegacy {\n timing?: PerformanceEntries;\n}\n\n/**\n * This interface is used in {@link getResource} function to return\n * main request and it's corresponding PreFlight request\n */\nexport interface PerformanceResourceTimingInfo {\n corsPreFlightRequest?: PerformanceResourceTiming;\n mainRequest?: PerformanceResourceTiming;\n}\n\ntype PropagateTraceHeaderCorsUrl = string | RegExp;\n\n/**\n * urls which should include trace headers when origin doesn't match\n */\nexport type PropagateTraceHeaderCorsUrls =\n | PropagateTraceHeaderCorsUrl\n | PropagateTraceHeaderCorsUrl[];\n"]}
@@ -5,22 +5,23 @@ import * as api from '@opentelemetry/api';
5
5
  * @param obj
6
6
  * @param key
7
7
  */
8
- export declare function hasKey<O extends object>(obj: O, key: keyof any): key is keyof O;
8
+ export declare function hasKey<O extends object>(obj: O, key: PropertyKey): key is keyof O;
9
9
  /**
10
10
  * Helper function for starting an event on span based on {@link PerformanceEntries}
11
11
  * @param span
12
12
  * @param performanceName name of performance entry for time start
13
13
  * @param entries
14
- * @param refPerfName name of performance entry to use for reference
14
+ * @param ignoreZeros
15
15
  */
16
- export declare function addSpanNetworkEvent(span: api.Span, performanceName: string, entries: PerformanceEntries, refPerfName?: string): api.Span | undefined;
16
+ export declare function addSpanNetworkEvent(span: api.Span, performanceName: string, entries: PerformanceEntries, ignoreZeros?: boolean): api.Span | undefined;
17
17
  /**
18
18
  * Helper function for adding network events and content length attributes
19
19
  * @param span
20
20
  * @param resource
21
21
  * @param ignoreNetworkEvents
22
+ * @param ignoreZeros
22
23
  */
23
- export declare function addSpanNetworkEvents(span: api.Span, resource: PerformanceEntries, ignoreNetworkEvents?: boolean): void;
24
+ export declare function addSpanNetworkEvents(span: api.Span, resource: PerformanceEntries, ignoreNetworkEvents?: boolean, ignoreZeros?: boolean): void;
24
25
  /**
25
26
  * sort resources by startTime
26
27
  * @param filteredResources