@opentelemetry/sdk-trace-web 1.30.1 → 2.0.0-dev.1

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
@@ -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
@@ -29,7 +29,6 @@ function getUrlNormalizingAnchor() {
29
29
  * @param obj
30
30
  * @param key
31
31
  */
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
32
  export function hasKey(obj, key) {
34
33
  return key in obj;
35
34
  }
@@ -38,24 +37,13 @@ export function hasKey(obj, key) {
38
37
  * @param span
39
38
  * @param performanceName name of performance entry for time start
40
39
  * @param entries
41
- * @param refPerfName name of performance entry to use for reference
40
+ * @param ignoreZeros
42
41
  */
43
- export function addSpanNetworkEvent(span, performanceName, entries, refPerfName) {
44
- let perfTime = undefined;
45
- let refTime = undefined;
42
+ export function addSpanNetworkEvent(span, performanceName, entries, ignoreZeros = true) {
46
43
  if (hasKey(entries, performanceName) &&
47
- typeof entries[performanceName] === 'number') {
48
- perfTime = entries[performanceName];
49
- }
50
- const refName = refPerfName || PTN.FETCH_START;
51
- // Use a reference time which is the earliest possible value so that the performance timings that are earlier should not be added
52
- // using FETCH START time in case no reference is provided
53
- if (hasKey(entries, refName) && typeof entries[refName] === 'number') {
54
- refTime = entries[refName];
55
- }
56
- if (perfTime !== undefined && refTime !== undefined && perfTime >= refTime) {
57
- span.addEvent(performanceName, perfTime);
58
- return span;
44
+ typeof entries[performanceName] === 'number' &&
45
+ !(ignoreZeros && entries[performanceName] === 0)) {
46
+ return span.addEvent(performanceName, entries[performanceName]);
59
47
  }
60
48
  return undefined;
61
49
  }
@@ -64,21 +52,22 @@ export function addSpanNetworkEvent(span, performanceName, entries, refPerfName)
64
52
  * @param span
65
53
  * @param resource
66
54
  * @param ignoreNetworkEvents
55
+ * @param ignoreZeros
67
56
  */
68
- export function addSpanNetworkEvents(span, resource, ignoreNetworkEvents = false) {
57
+ export function addSpanNetworkEvents(span, resource, ignoreNetworkEvents = false, ignoreZeros) {
58
+ if (ignoreZeros === undefined) {
59
+ ignoreZeros = resource[PTN.START_TIME] !== 0;
60
+ }
69
61
  if (!ignoreNetworkEvents) {
70
- addSpanNetworkEvent(span, PTN.FETCH_START, resource);
71
- addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_START, resource);
72
- addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_END, resource);
73
- addSpanNetworkEvent(span, PTN.CONNECT_START, resource);
74
- if (hasKey(resource, 'name') &&
75
- resource['name'].startsWith('https:')) {
76
- addSpanNetworkEvent(span, PTN.SECURE_CONNECTION_START, resource);
77
- }
78
- addSpanNetworkEvent(span, PTN.CONNECT_END, resource);
79
- addSpanNetworkEvent(span, PTN.REQUEST_START, resource);
80
- addSpanNetworkEvent(span, PTN.RESPONSE_START, resource);
81
- addSpanNetworkEvent(span, PTN.RESPONSE_END, resource);
62
+ addSpanNetworkEvent(span, PTN.FETCH_START, resource, ignoreZeros);
63
+ addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_START, resource, ignoreZeros);
64
+ addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_END, resource, ignoreZeros);
65
+ addSpanNetworkEvent(span, PTN.CONNECT_START, resource, ignoreZeros);
66
+ addSpanNetworkEvent(span, PTN.SECURE_CONNECTION_START, resource, ignoreZeros);
67
+ addSpanNetworkEvent(span, PTN.CONNECT_END, resource, ignoreZeros);
68
+ addSpanNetworkEvent(span, PTN.REQUEST_START, resource, ignoreZeros);
69
+ addSpanNetworkEvent(span, PTN.RESPONSE_START, resource, ignoreZeros);
70
+ addSpanNetworkEvent(span, PTN.RESPONSE_END, resource, ignoreZeros);
82
71
  }
83
72
  const encodedLength = resource[PTN.ENCODED_BODY_SIZE];
84
73
  if (encodedLength !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAAE,sBAAsB,IAAI,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qCAAqC,EACrC,kDAAkD,GACnD,MAAM,qCAAqC,CAAC;AAE7C,kCAAkC;AAClC,IAAI,oBAAmD,CAAC;AACxD,SAAS,uBAAuB;IAC9B,IAAI,CAAC,oBAAoB,EAAE;QACzB,oBAAoB,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;KACpD;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,8DAA8D;AAC9D,MAAM,UAAU,MAAM,CACpB,GAAM,EACN,GAAc;IAEd,OAAO,GAAG,IAAI,GAAG,CAAC;AACpB,CAAC;AAED;;;;;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,KAAK,IAAI,CAAC,YAAY,EAAE;QACzC,SAAS,GAAG,WAAW,CAAC;KACzB;SAAM;QACL,OAAO,EAAE,CAAC;KACX;IACD,2CAA2C;IAC3C,IAAI,SAAS,IAAI,KAAK,GAAG,CAAC,EAAE;QAC1B,OAAO,IAAI,SAAS,IAAI,KAAK,GAAG,CAAC;KAClC;IACD,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAe,EACf,4BAA2D;IAE3D,IAAI,wBAAwB,GAAG,4BAA4B,IAAI,EAAE,CAAC;IAClE,IACE,OAAO,wBAAwB,KAAK,QAAQ;QAC5C,wBAAwB,YAAY,MAAM,EAC1C;QACA,wBAAwB,GAAG,CAAC,wBAAwB,CAAC,CAAC;KACvD;IACD,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAExC,IAAI,aAAa,CAAC,MAAM,KAAK,SAAS,EAAE,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,wBAAwB,CAAC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAC7D,UAAU,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAC7C,CAAC;KACH;AACH,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\nimport {\n PerformanceEntries,\n PerformanceResourceTimingInfo,\n PropagateTraceHeaderCorsUrls,\n} from './types';\nimport { PerformanceTimingNames as PTN } from './enums/PerformanceTimingNames';\nimport * as api from '@opentelemetry/api';\nimport {\n hrTimeToNanoseconds,\n timeInputToHrTime,\n urlMatches,\n} from '@opentelemetry/core';\nimport {\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH,\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n} from '@opentelemetry/semantic-conventions';\n\n// Used to normalize relative URLs\nlet urlNormalizingAnchor: HTMLAnchorElement | undefined;\nfunction getUrlNormalizingAnchor(): HTMLAnchorElement {\n if (!urlNormalizingAnchor) {\n urlNormalizingAnchor = document.createElement('a');\n }\n\n return urlNormalizingAnchor;\n}\n\n/**\n * Helper function to be able to use enum as typed key in type and in interface when using forEach\n * @param obj\n * @param key\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function hasKey<O extends object>(\n obj: O,\n key: keyof any\n): key is keyof O {\n return key in obj;\n}\n\n/**\n * Helper function for starting an event on span based on {@link PerformanceEntries}\n * @param span\n * @param performanceName name of performance entry for time start\n * @param entries\n * @param refPerfName name of performance entry to use for reference\n */\nexport function addSpanNetworkEvent(\n span: api.Span,\n performanceName: string,\n entries: PerformanceEntries,\n refPerfName?: string\n): api.Span | undefined {\n let perfTime = undefined;\n let refTime = undefined;\n if (\n hasKey(entries, performanceName) &&\n typeof entries[performanceName] === 'number'\n ) {\n perfTime = entries[performanceName];\n }\n const refName = refPerfName || PTN.FETCH_START;\n // Use a reference time which is the earliest possible value so that the performance timings that are earlier should not be added\n // using FETCH START time in case no reference is provided\n if (hasKey(entries, refName) && typeof entries[refName] === 'number') {\n refTime = entries[refName];\n }\n if (perfTime !== undefined && refTime !== undefined && perfTime >= refTime) {\n span.addEvent(performanceName, perfTime);\n return span;\n }\n return undefined;\n}\n\n/**\n * Helper function for adding network events and content length attributes\n * @param span\n * @param resource\n * @param ignoreNetworkEvents\n */\nexport function addSpanNetworkEvents(\n span: api.Span,\n resource: PerformanceEntries,\n ignoreNetworkEvents = false\n): void {\n if (!ignoreNetworkEvents) {\n addSpanNetworkEvent(span, PTN.FETCH_START, resource);\n addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_START, resource);\n addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_END, resource);\n addSpanNetworkEvent(span, PTN.CONNECT_START, resource);\n if (\n hasKey(resource as PerformanceResourceTiming, 'name') &&\n (resource as PerformanceResourceTiming)['name'].startsWith('https:')\n ) {\n addSpanNetworkEvent(span, PTN.SECURE_CONNECTION_START, resource);\n }\n addSpanNetworkEvent(span, PTN.CONNECT_END, resource);\n addSpanNetworkEvent(span, PTN.REQUEST_START, resource);\n addSpanNetworkEvent(span, PTN.RESPONSE_START, resource);\n addSpanNetworkEvent(span, PTN.RESPONSE_END, resource);\n }\n const encodedLength = resource[PTN.ENCODED_BODY_SIZE];\n if (encodedLength !== undefined) {\n span.setAttribute(SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH, encodedLength);\n }\n const decodedLength = resource[PTN.DECODED_BODY_SIZE];\n // Spec: Not set if transport encoding not used (in which case encoded and decoded sizes match)\n if (decodedLength !== undefined && encodedLength !== decodedLength) {\n span.setAttribute(\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n decodedLength\n );\n }\n}\n\n/**\n * sort resources by startTime\n * @param filteredResources\n */\nexport function sortResources(\n filteredResources: PerformanceResourceTiming[]\n): PerformanceResourceTiming[] {\n return filteredResources.slice().sort((a, b) => {\n const valueA = a[PTN.FETCH_START];\n const valueB = b[PTN.FETCH_START];\n if (valueA > valueB) {\n return 1;\n } else if (valueA < valueB) {\n return -1;\n }\n return 0;\n });\n}\n\n/** Returns the origin if present (if in browser context). */\nfunction getOrigin(): string | undefined {\n return typeof location !== 'undefined' ? location.origin : undefined;\n}\n\n/**\n * Get closest performance resource ignoring the resources that have been\n * already used.\n * @param spanUrl\n * @param startTimeHR\n * @param endTimeHR\n * @param resources\n * @param ignoredResources\n * @param initiatorType\n */\nexport function getResource(\n spanUrl: string,\n startTimeHR: api.HrTime,\n endTimeHR: api.HrTime,\n resources: PerformanceResourceTiming[],\n ignoredResources: WeakSet<PerformanceResourceTiming> = new WeakSet<PerformanceResourceTiming>(),\n initiatorType?: string\n): PerformanceResourceTimingInfo {\n // de-relativize the URL before usage (does no harm to absolute URLs)\n const parsedSpanUrl = parseUrl(spanUrl);\n spanUrl = parsedSpanUrl.toString();\n\n const filteredResources = filterResourcesForSpan(\n spanUrl,\n startTimeHR,\n endTimeHR,\n resources,\n ignoredResources,\n initiatorType\n );\n\n if (filteredResources.length === 0) {\n return {\n mainRequest: undefined,\n };\n }\n if (filteredResources.length === 1) {\n return {\n mainRequest: filteredResources[0],\n };\n }\n const sorted = sortResources(filteredResources);\n\n if (parsedSpanUrl.origin !== getOrigin() && sorted.length > 1) {\n let corsPreFlightRequest: PerformanceResourceTiming | undefined = sorted[0];\n let mainRequest: PerformanceResourceTiming = findMainRequest(\n sorted,\n corsPreFlightRequest[PTN.RESPONSE_END],\n endTimeHR\n );\n\n const responseEnd = corsPreFlightRequest[PTN.RESPONSE_END];\n const fetchStart = mainRequest[PTN.FETCH_START];\n\n // no corsPreFlightRequest\n if (fetchStart < responseEnd) {\n mainRequest = corsPreFlightRequest;\n corsPreFlightRequest = undefined;\n }\n\n return {\n corsPreFlightRequest,\n mainRequest,\n };\n } else {\n return {\n mainRequest: filteredResources[0],\n };\n }\n}\n\n/**\n * Will find the main request skipping the cors pre flight requests\n * @param resources\n * @param corsPreFlightRequestEndTime\n * @param spanEndTimeHR\n */\nfunction findMainRequest(\n resources: PerformanceResourceTiming[],\n corsPreFlightRequestEndTime: number,\n spanEndTimeHR: api.HrTime\n): PerformanceResourceTiming {\n const spanEndTime = hrTimeToNanoseconds(spanEndTimeHR);\n const minTime = hrTimeToNanoseconds(\n timeInputToHrTime(corsPreFlightRequestEndTime)\n );\n\n let mainRequest: PerformanceResourceTiming = resources[1];\n let bestGap;\n\n const length = resources.length;\n for (let i = 1; i < length; i++) {\n const resource = resources[i];\n const resourceStartTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.FETCH_START])\n );\n\n const resourceEndTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.RESPONSE_END])\n );\n\n const currentGap = spanEndTime - resourceEndTime;\n\n if (resourceStartTime >= minTime && (!bestGap || currentGap < bestGap)) {\n bestGap = currentGap;\n mainRequest = resource;\n }\n }\n return mainRequest;\n}\n\n/**\n * Filter all resources that has started and finished according to span start time and end time.\n * It will return the closest resource to a start time\n * @param spanUrl\n * @param startTimeHR\n * @param endTimeHR\n * @param resources\n * @param ignoredResources\n */\nfunction filterResourcesForSpan(\n spanUrl: string,\n startTimeHR: api.HrTime,\n endTimeHR: api.HrTime,\n resources: PerformanceResourceTiming[],\n ignoredResources: WeakSet<PerformanceResourceTiming>,\n initiatorType?: string\n) {\n const startTime = hrTimeToNanoseconds(startTimeHR);\n const endTime = hrTimeToNanoseconds(endTimeHR);\n let filteredResources = resources.filter(resource => {\n const resourceStartTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.FETCH_START])\n );\n const resourceEndTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.RESPONSE_END])\n );\n\n return (\n resource.initiatorType.toLowerCase() ===\n (initiatorType || 'xmlhttprequest') &&\n resource.name === spanUrl &&\n resourceStartTime >= startTime &&\n resourceEndTime <= endTime\n );\n });\n\n if (filteredResources.length > 0) {\n filteredResources = filteredResources.filter(resource => {\n return !ignoredResources.has(resource);\n });\n }\n\n return filteredResources;\n}\n\n/**\n * The URLLike interface represents an URL and HTMLAnchorElement compatible fields.\n */\nexport interface URLLike {\n hash: string;\n host: string;\n hostname: string;\n href: string;\n readonly origin: string;\n password: string;\n pathname: string;\n port: string;\n protocol: string;\n search: string;\n username: string;\n}\n\n/**\n * Parses url using URL constructor or fallback to anchor element.\n * @param url\n */\nexport function parseUrl(url: string): URLLike {\n if (typeof URL === 'function') {\n return new URL(\n url,\n typeof document !== 'undefined'\n ? document.baseURI\n : typeof location !== 'undefined' // Some JS runtimes (e.g. Deno) don't define this\n ? location.href\n : undefined\n );\n }\n const element = getUrlNormalizingAnchor();\n element.href = url;\n return element;\n}\n\n/**\n * Parses url using URL constructor or fallback to anchor element and serialize\n * it to a string.\n *\n * Performs the steps described in https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url\n *\n * @param url\n */\nexport function normalizeUrl(url: string): string {\n const urlLike = parseUrl(url);\n return urlLike.href;\n}\n\n/**\n * Get element XPath\n * @param target - target element\n * @param optimised - when id attribute of element is present the xpath can be\n * simplified to contain id\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\nexport function getElementXPath(target: any, optimised?: boolean): string {\n if (target.nodeType === Node.DOCUMENT_NODE) {\n return '/';\n }\n const targetValue = getNodeValue(target, optimised);\n if (optimised && targetValue.indexOf('@id') > 0) {\n return targetValue;\n }\n let xpath = '';\n if (target.parentNode) {\n xpath += getElementXPath(target.parentNode, false);\n }\n xpath += targetValue;\n\n return xpath;\n}\n\n/**\n * get node index within the siblings\n * @param target\n */\nfunction getNodeIndex(target: HTMLElement): number {\n if (!target.parentNode) {\n return 0;\n }\n const allowedTypes = [target.nodeType];\n if (target.nodeType === Node.CDATA_SECTION_NODE) {\n allowedTypes.push(Node.TEXT_NODE);\n }\n let elements = Array.from(target.parentNode.childNodes);\n elements = elements.filter((element: Node) => {\n const localName = (element as HTMLElement).localName;\n return (\n allowedTypes.indexOf(element.nodeType) >= 0 &&\n localName === target.localName\n );\n });\n if (elements.length >= 1) {\n return elements.indexOf(target) + 1; // xpath starts from 1\n }\n // if there are no other similar child xpath doesn't need index\n return 0;\n}\n\n/**\n * get node value for xpath\n * @param target\n * @param optimised\n */\nfunction getNodeValue(target: HTMLElement, optimised?: boolean): string {\n const nodeType = target.nodeType;\n const index = getNodeIndex(target);\n let nodeValue = '';\n if (nodeType === Node.ELEMENT_NODE) {\n const id = target.getAttribute('id');\n if (optimised && id) {\n return `//*[@id=\"${id}\"]`;\n }\n nodeValue = target.localName;\n } else if (\n nodeType === Node.TEXT_NODE ||\n nodeType === Node.CDATA_SECTION_NODE\n ) {\n nodeValue = 'text()';\n } else if (nodeType === Node.COMMENT_NODE) {\n nodeValue = 'comment()';\n } else {\n return '';\n }\n // if index is 1 it can be omitted in xpath\n if (nodeValue && index > 1) {\n return `/${nodeValue}[${index}]`;\n }\n return `/${nodeValue}`;\n}\n\n/**\n * Checks if trace headers should be propagated\n * @param spanUrl\n * @private\n */\nexport function shouldPropagateTraceHeaders(\n spanUrl: string,\n propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls\n): boolean {\n let propagateTraceHeaderUrls = propagateTraceHeaderCorsUrls || [];\n if (\n typeof propagateTraceHeaderUrls === 'string' ||\n propagateTraceHeaderUrls instanceof RegExp\n ) {\n propagateTraceHeaderUrls = [propagateTraceHeaderUrls];\n }\n const parsedSpanUrl = parseUrl(spanUrl);\n\n if (parsedSpanUrl.origin === getOrigin()) {\n return true;\n } else {\n return propagateTraceHeaderUrls.some(propagateTraceHeaderUrl =>\n urlMatches(spanUrl, propagateTraceHeaderUrl)\n );\n }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAAE,sBAAsB,IAAI,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qCAAqC,EACrC,kDAAkD,GACnD,MAAM,qCAAqC,CAAC;AAE7C,kCAAkC;AAClC,IAAI,oBAAmD,CAAC;AACxD,SAAS,uBAAuB;IAC9B,IAAI,CAAC,oBAAoB,EAAE;QACzB,oBAAoB,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;KACpD;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAC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AAS,IAAI,KAAK,GAAG,CAAC;KAClC;IACD,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAe,EACf,4BAA2D;IAE3D,IAAI,wBAAwB,GAAG,4BAA4B,IAAI,EAAE,CAAC;IAClE,IACE,OAAO,wBAAwB,KAAK,QAAQ;QAC5C,wBAAwB,YAAY,MAAM,EAC1C;QACA,wBAAwB,GAAG,CAAC,wBAAwB,CAAC,CAAC;KACvD;IACD,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAExC,IAAI,aAAa,CAAC,MAAM,KAAK,SAAS,EAAE,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,wBAAwB,CAAC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAC7D,UAAU,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAC7C,CAAC;KACH;AACH,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\nimport {\n PerformanceEntries,\n PerformanceResourceTimingInfo,\n PropagateTraceHeaderCorsUrls,\n} from './types';\nimport { PerformanceTimingNames as PTN } from './enums/PerformanceTimingNames';\nimport * as api from '@opentelemetry/api';\nimport {\n hrTimeToNanoseconds,\n timeInputToHrTime,\n urlMatches,\n} from '@opentelemetry/core';\nimport {\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH,\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n} from '@opentelemetry/semantic-conventions';\n\n// Used to normalize relative URLs\nlet urlNormalizingAnchor: HTMLAnchorElement | undefined;\nfunction getUrlNormalizingAnchor(): HTMLAnchorElement {\n if (!urlNormalizingAnchor) {\n urlNormalizingAnchor = document.createElement('a');\n }\n\n return urlNormalizingAnchor;\n}\n\n/**\n * Helper function to be able to use enum as typed key in type and in interface when using forEach\n * @param obj\n * @param key\n */\nexport function hasKey<O extends object>(\n obj: O,\n key: PropertyKey\n): key is keyof O {\n return key in obj;\n}\n\n/**\n * Helper function for starting an event on span based on {@link PerformanceEntries}\n * @param span\n * @param performanceName name of performance entry for time start\n * @param entries\n * @param ignoreZeros\n */\nexport function addSpanNetworkEvent(\n span: api.Span,\n performanceName: string,\n entries: PerformanceEntries,\n ignoreZeros = true\n): api.Span | undefined {\n if (\n hasKey(entries, performanceName) &&\n typeof entries[performanceName] === 'number' &&\n !(ignoreZeros && entries[performanceName] === 0)\n ) {\n return span.addEvent(performanceName, entries[performanceName]);\n }\n\n return undefined;\n}\n\n/**\n * Helper function for adding network events and content length attributes\n * @param span\n * @param resource\n * @param ignoreNetworkEvents\n * @param ignoreZeros\n */\nexport function addSpanNetworkEvents(\n span: api.Span,\n resource: PerformanceEntries,\n ignoreNetworkEvents = false,\n ignoreZeros?: boolean\n): void {\n if (ignoreZeros === undefined) {\n ignoreZeros = resource[PTN.START_TIME] !== 0;\n }\n\n if (!ignoreNetworkEvents) {\n addSpanNetworkEvent(span, PTN.FETCH_START, resource, ignoreZeros);\n addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_START, resource, ignoreZeros);\n addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_END, resource, ignoreZeros);\n addSpanNetworkEvent(span, PTN.CONNECT_START, resource, ignoreZeros);\n addSpanNetworkEvent(\n span,\n PTN.SECURE_CONNECTION_START,\n resource,\n ignoreZeros\n );\n addSpanNetworkEvent(span, PTN.CONNECT_END, resource, ignoreZeros);\n addSpanNetworkEvent(span, PTN.REQUEST_START, resource, ignoreZeros);\n addSpanNetworkEvent(span, PTN.RESPONSE_START, resource, ignoreZeros);\n addSpanNetworkEvent(span, PTN.RESPONSE_END, resource, ignoreZeros);\n }\n\n const encodedLength = resource[PTN.ENCODED_BODY_SIZE];\n if (encodedLength !== undefined) {\n span.setAttribute(SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH, encodedLength);\n }\n\n const decodedLength = resource[PTN.DECODED_BODY_SIZE];\n // Spec: Not set if transport encoding not used (in which case encoded and decoded sizes match)\n if (decodedLength !== undefined && encodedLength !== decodedLength) {\n span.setAttribute(\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n decodedLength\n );\n }\n}\n\n/**\n * sort resources by startTime\n * @param filteredResources\n */\nexport function sortResources(\n filteredResources: PerformanceResourceTiming[]\n): PerformanceResourceTiming[] {\n return filteredResources.slice().sort((a, b) => {\n const valueA = a[PTN.FETCH_START];\n const valueB = b[PTN.FETCH_START];\n if (valueA > valueB) {\n return 1;\n } else if (valueA < valueB) {\n return -1;\n }\n return 0;\n });\n}\n\n/** Returns the origin if present (if in browser context). */\nfunction getOrigin(): string | undefined {\n return typeof location !== 'undefined' ? location.origin : undefined;\n}\n\n/**\n * Get closest performance resource ignoring the resources that have been\n * already used.\n * @param spanUrl\n * @param startTimeHR\n * @param endTimeHR\n * @param resources\n * @param ignoredResources\n * @param initiatorType\n */\nexport function getResource(\n spanUrl: string,\n startTimeHR: api.HrTime,\n endTimeHR: api.HrTime,\n resources: PerformanceResourceTiming[],\n ignoredResources: WeakSet<PerformanceResourceTiming> = new WeakSet<PerformanceResourceTiming>(),\n initiatorType?: string\n): PerformanceResourceTimingInfo {\n // de-relativize the URL before usage (does no harm to absolute URLs)\n const parsedSpanUrl = parseUrl(spanUrl);\n spanUrl = parsedSpanUrl.toString();\n\n const filteredResources = filterResourcesForSpan(\n spanUrl,\n startTimeHR,\n endTimeHR,\n resources,\n ignoredResources,\n initiatorType\n );\n\n if (filteredResources.length === 0) {\n return {\n mainRequest: undefined,\n };\n }\n if (filteredResources.length === 1) {\n return {\n mainRequest: filteredResources[0],\n };\n }\n const sorted = sortResources(filteredResources);\n\n if (parsedSpanUrl.origin !== getOrigin() && sorted.length > 1) {\n let corsPreFlightRequest: PerformanceResourceTiming | undefined = sorted[0];\n let mainRequest: PerformanceResourceTiming = findMainRequest(\n sorted,\n corsPreFlightRequest[PTN.RESPONSE_END],\n endTimeHR\n );\n\n const responseEnd = corsPreFlightRequest[PTN.RESPONSE_END];\n const fetchStart = mainRequest[PTN.FETCH_START];\n\n // no corsPreFlightRequest\n if (fetchStart < responseEnd) {\n mainRequest = corsPreFlightRequest;\n corsPreFlightRequest = undefined;\n }\n\n return {\n corsPreFlightRequest,\n mainRequest,\n };\n } else {\n return {\n mainRequest: filteredResources[0],\n };\n }\n}\n\n/**\n * Will find the main request skipping the cors pre flight requests\n * @param resources\n * @param corsPreFlightRequestEndTime\n * @param spanEndTimeHR\n */\nfunction findMainRequest(\n resources: PerformanceResourceTiming[],\n corsPreFlightRequestEndTime: number,\n spanEndTimeHR: api.HrTime\n): PerformanceResourceTiming {\n const spanEndTime = hrTimeToNanoseconds(spanEndTimeHR);\n const minTime = hrTimeToNanoseconds(\n timeInputToHrTime(corsPreFlightRequestEndTime)\n );\n\n let mainRequest: PerformanceResourceTiming = resources[1];\n let bestGap;\n\n const length = resources.length;\n for (let i = 1; i < length; i++) {\n const resource = resources[i];\n const resourceStartTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.FETCH_START])\n );\n\n const resourceEndTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.RESPONSE_END])\n );\n\n const currentGap = spanEndTime - resourceEndTime;\n\n if (resourceStartTime >= minTime && (!bestGap || currentGap < bestGap)) {\n bestGap = currentGap;\n mainRequest = resource;\n }\n }\n return mainRequest;\n}\n\n/**\n * Filter all resources that has started and finished according to span start time and end time.\n * It will return the closest resource to a start time\n * @param spanUrl\n * @param startTimeHR\n * @param endTimeHR\n * @param resources\n * @param ignoredResources\n */\nfunction filterResourcesForSpan(\n spanUrl: string,\n startTimeHR: api.HrTime,\n endTimeHR: api.HrTime,\n resources: PerformanceResourceTiming[],\n ignoredResources: WeakSet<PerformanceResourceTiming>,\n initiatorType?: string\n) {\n const startTime = hrTimeToNanoseconds(startTimeHR);\n const endTime = hrTimeToNanoseconds(endTimeHR);\n let filteredResources = resources.filter(resource => {\n const resourceStartTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.FETCH_START])\n );\n const resourceEndTime = hrTimeToNanoseconds(\n timeInputToHrTime(resource[PTN.RESPONSE_END])\n );\n\n return (\n resource.initiatorType.toLowerCase() ===\n (initiatorType || 'xmlhttprequest') &&\n resource.name === spanUrl &&\n resourceStartTime >= startTime &&\n resourceEndTime <= endTime\n );\n });\n\n if (filteredResources.length > 0) {\n filteredResources = filteredResources.filter(resource => {\n return !ignoredResources.has(resource);\n });\n }\n\n return filteredResources;\n}\n\n/**\n * The URLLike interface represents an URL and HTMLAnchorElement compatible fields.\n */\nexport interface URLLike {\n hash: string;\n host: string;\n hostname: string;\n href: string;\n readonly origin: string;\n password: string;\n pathname: string;\n port: string;\n protocol: string;\n search: string;\n username: string;\n}\n\n/**\n * Parses url using URL constructor or fallback to anchor element.\n * @param url\n */\nexport function parseUrl(url: string): URLLike {\n if (typeof URL === 'function') {\n return new URL(\n url,\n typeof document !== 'undefined'\n ? document.baseURI\n : typeof location !== 'undefined' // Some JS runtimes (e.g. Deno) don't define this\n ? location.href\n : undefined\n );\n }\n const element = getUrlNormalizingAnchor();\n element.href = url;\n return element;\n}\n\n/**\n * Parses url using URL constructor or fallback to anchor element and serialize\n * it to a string.\n *\n * Performs the steps described in https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url\n *\n * @param url\n */\nexport function normalizeUrl(url: string): string {\n const urlLike = parseUrl(url);\n return urlLike.href;\n}\n\n/**\n * Get element XPath\n * @param target - target element\n * @param optimised - when id attribute of element is present the xpath can be\n * simplified to contain id\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\nexport function getElementXPath(target: any, optimised?: boolean): string {\n if (target.nodeType === Node.DOCUMENT_NODE) {\n return '/';\n }\n const targetValue = getNodeValue(target, optimised);\n if (optimised && targetValue.indexOf('@id') > 0) {\n return targetValue;\n }\n let xpath = '';\n if (target.parentNode) {\n xpath += getElementXPath(target.parentNode, false);\n }\n xpath += targetValue;\n\n return xpath;\n}\n\n/**\n * get node index within the siblings\n * @param target\n */\nfunction getNodeIndex(target: HTMLElement): number {\n if (!target.parentNode) {\n return 0;\n }\n const allowedTypes = [target.nodeType];\n if (target.nodeType === Node.CDATA_SECTION_NODE) {\n allowedTypes.push(Node.TEXT_NODE);\n }\n let elements = Array.from(target.parentNode.childNodes);\n elements = elements.filter((element: Node) => {\n const localName = (element as HTMLElement).localName;\n return (\n allowedTypes.indexOf(element.nodeType) >= 0 &&\n localName === target.localName\n );\n });\n if (elements.length >= 1) {\n return elements.indexOf(target) + 1; // xpath starts from 1\n }\n // if there are no other similar child xpath doesn't need index\n return 0;\n}\n\n/**\n * get node value for xpath\n * @param target\n * @param optimised\n */\nfunction getNodeValue(target: HTMLElement, optimised?: boolean): string {\n const nodeType = target.nodeType;\n const index = getNodeIndex(target);\n let nodeValue = '';\n if (nodeType === Node.ELEMENT_NODE) {\n const id = target.getAttribute('id');\n if (optimised && id) {\n return `//*[@id=\"${id}\"]`;\n }\n nodeValue = target.localName;\n } else if (\n nodeType === Node.TEXT_NODE ||\n nodeType === Node.CDATA_SECTION_NODE\n ) {\n nodeValue = 'text()';\n } else if (nodeType === Node.COMMENT_NODE) {\n nodeValue = 'comment()';\n } else {\n return '';\n }\n // if index is 1 it can be omitted in xpath\n if (nodeValue && index > 1) {\n return `/${nodeValue}[${index}]`;\n }\n return `/${nodeValue}`;\n}\n\n/**\n * Checks if trace headers should be propagated\n * @param spanUrl\n * @private\n */\nexport function shouldPropagateTraceHeaders(\n spanUrl: string,\n propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls\n): boolean {\n let propagateTraceHeaderUrls = propagateTraceHeaderCorsUrls || [];\n if (\n typeof propagateTraceHeaderUrls === 'string' ||\n propagateTraceHeaderUrls instanceof RegExp\n ) {\n propagateTraceHeaderUrls = [propagateTraceHeaderUrls];\n }\n const parsedSpanUrl = parseUrl(spanUrl);\n\n if (parsedSpanUrl.origin === getOrigin()) {\n return true;\n } else {\n return propagateTraceHeaderUrls.some(propagateTraceHeaderUrl =>\n urlMatches(spanUrl, propagateTraceHeaderUrl)\n );\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.30.1";
1
+ export declare const VERSION = "2.0.0-dev.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // this is autogenerated file, see scripts/version-update.js
17
- export const VERSION = '1.30.1';
17
+ export const VERSION = '2.0.0-dev.1';
18
18
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,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\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '1.30.1';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,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\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '2.0.0-dev.1';\n"]}
@@ -22,16 +22,14 @@ const api_1 = require("@opentelemetry/api");
22
22
  * it doesn't fully support the async calls though
23
23
  */
24
24
  class StackContextManager {
25
- constructor() {
26
- /**
27
- * whether the context manager is enabled or not
28
- */
29
- this._enabled = false;
30
- /**
31
- * Keeps the reference to current context
32
- */
33
- this._currentContext = api_1.ROOT_CONTEXT;
34
- }
25
+ /**
26
+ * whether the context manager is enabled or not
27
+ */
28
+ _enabled = false;
29
+ /**
30
+ * Keeps the reference to current context
31
+ */
32
+ _currentContext = api_1.ROOT_CONTEXT;
35
33
  /**
36
34
  *
37
35
  * @param context
@@ -1 +1 @@
1
- {"version":3,"file":"StackContextManager.js","sourceRoot":"","sources":["../../src/StackContextManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA2E;AAE3E;;;GAGG;AACH,MAAa,mBAAmB;IAAhC;QACE;;WAEG;QACK,aAAQ,GAAG,KAAK,CAAC;QAEzB;;WAEG;QACI,oBAAe,GAAG,kBAAY,CAAC;IA6FxC,CAAC;IA3FC;;;;OAIG;IACH,wDAAwD;IAChD,aAAa,CACnB,OAAO,GAAG,kBAAY,EACtB,MAAS;QAET,MAAM,OAAO,GAAG,IAAI,CAAC;QACrB,MAAM,cAAc,GAAG,UAAyB,GAAG,IAAe;YAChE,O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CAAC,eAAe,GAAG,OAAO,IAAI,kBAAY,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;AAtGD,kDAsGC","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,4CAA2E;AAE3E;;;GAGG;AACH,MAAa,mBAAmB;IAC9B;;OAEG;IACK,QAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACI,eAAe,GAAG,kBAAY,CAAC;IAEtC;;;;OAIG;IACH,wDAAwD;IAChD,aAAa,CACnB,OAAO,GAAG,kBAAY,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;YA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AC;CACF;AAtGD,kDAsGC","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
  */
@@ -18,6 +18,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.WebTracerProvider = void 0;
19
19
  const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
20
20
  const StackContextManager_1 = require("./StackContextManager");
21
+ const api_1 = require("@opentelemetry/api");
22
+ const core_1 = require("@opentelemetry/core");
23
+ function setupContextManager(contextManager) {
24
+ // null means 'do not register'
25
+ if (contextManager === null) {
26
+ return;
27
+ }
28
+ // undefined means 'register default'
29
+ if (contextManager === undefined) {
30
+ const defaultContextManager = new StackContextManager_1.StackContextManager();
31
+ defaultContextManager.enable();
32
+ api_1.context.setGlobalContextManager(defaultContextManager);
33
+ return;
34
+ }
35
+ contextManager.enable();
36
+ api_1.context.setGlobalContextManager(contextManager);
37
+ }
38
+ function setupPropagator(propagator) {
39
+ // null means 'do not register'
40
+ if (propagator === null) {
41
+ return;
42
+ }
43
+ // undefined means 'register default'
44
+ if (propagator === undefined) {
45
+ api_1.propagation.setGlobalPropagator(new core_1.CompositePropagator({
46
+ propagators: [
47
+ new core_1.W3CTraceContextPropagator(),
48
+ new core_1.W3CBaggagePropagator(),
49
+ ],
50
+ }));
51
+ return;
52
+ }
53
+ api_1.propagation.setGlobalPropagator(propagator);
54
+ }
21
55
  /**
22
56
  * This class represents a web tracer with {@link StackContextManager}
23
57
  */
@@ -28,13 +62,6 @@ class WebTracerProvider extends sdk_trace_base_1.BasicTracerProvider {
28
62
  */
29
63
  constructor(config = {}) {
30
64
  super(config);
31
- if (config.contextManager) {
32
- throw ('contextManager should be defined in register method not in' +
33
- ' constructor');
34
- }
35
- if (config.propagator) {
36
- throw 'propagator should be defined in register method not in constructor';
37
- }
38
65
  }
39
66
  /**
40
67
  * Register this TracerProvider for use with the OpenTelemetry API.
@@ -44,13 +71,9 @@ class WebTracerProvider extends sdk_trace_base_1.BasicTracerProvider {
44
71
  * @param config Configuration object for SDK registration
45
72
  */
46
73
  register(config = {}) {
47
- if (config.contextManager === undefined) {
48
- config.contextManager = new StackContextManager_1.StackContextManager();
49
- }
50
- if (config.contextManager) {
51
- config.contextManager.enable();
52
- }
53
- super.register(config);
74
+ api_1.trace.setGlobalTracerProvider(this);
75
+ setupPropagator(config.propagator);
76
+ setupContextManager(config.contextManager);
54
77
  }
55
78
  }
56
79
  exports.WebTracerProvider = WebTracerProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"WebTracerProvider.js","sourceRoot":"","sources":["../../src/WebTracerProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,kEAIuC;AACvC,+DAA4D;AAO5D;;GAEG;AACH,MAAa,iBAAkB,SAAQ,oCAAmB;IACxD;;;OAGG;IACH,YAAY,SAA0B,EAAE;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,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,QAAQ,CAAC,SAAgC,EAAE;QAClD,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE;YACvC,MAAM,CAAC,cAAc,GAAG,IAAI,yCAAmB,EAAE,CAAC;SACnD;QACD,IAAI,MAAM,CAAC,cAAc,EAAE;YACzB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;SAChC;QAED,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;CACF;AApCD,8CAoCC","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,kEAIuC;AACvC,+DAA4D;AAC5D,4CAM4B;AAC5B,8CAI6B;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,yCAAmB,EAAE,CAAC;QACxD,qBAAqB,CAAC,MAAM,EAAE,CAAC;QAC/B,aAAO,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,CAAC;QACvD,OAAO;KACR;IAED,cAAc,CAAC,MAAM,EAAE,CAAC;IACxB,aAAO,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,iBAAW,CAAC,mBAAmB,CAC7B,IAAI,0BAAmB,CAAC;YACtB,WAAW,EAAE;gBACX,IAAI,gCAAyB,EAAE;gBAC/B,IAAI,2BAAoB,EAAE;aAC3B;SACF,CAAC,CACH,CAAC;QACF,OAAO;KACR;IAED,iBAAW,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC9C,CAAC;AAOD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,oCAAmB;IACxD;;;OAGG;IACH,YAAY,SAA0B,EAAE;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,SAAgC,EAAE;QACzC,WAAK,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;AArBD,8CAqBC","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
  }
@@ -38,6 +38,7 @@ var PerformanceTimingNames;
38
38
  PerformanceTimingNames["RESPONSE_END"] = "responseEnd";
39
39
  PerformanceTimingNames["RESPONSE_START"] = "responseStart";
40
40
  PerformanceTimingNames["SECURE_CONNECTION_START"] = "secureConnectionStart";
41
+ PerformanceTimingNames["START_TIME"] = "startTime";
41
42
  PerformanceTimingNames["UNLOAD_EVENT_END"] = "unloadEventEnd";
42
43
  PerformanceTimingNames["UNLOAD_EVENT_START"] = "unloadEventStart";
43
44
  })(PerformanceTimingNames = exports.PerformanceTimingNames || (exports.PerformanceTimingNames = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"PerformanceTimingNames.js","sourceRoot":"","sources":["../../../src/enums/PerformanceTimingNames.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,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,GAAtB,8BAAsB,KAAtB,8BAAsB,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,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,GAAtB,8BAAsB,KAAtB,8BAAsB,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
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.Tracer = exports.TraceIdRatioBasedSampler = exports.Span = exports.SimpleSpanProcessor = exports.SamplingDecision = exports.RandomIdGenerator = exports.ParentBasedSampler = exports.NoopSpanProcessor = exports.InMemorySpanExporter = exports.ForceFlushState = exports.ConsoleSpanExporter = exports.BatchSpanProcessor = exports.BasicTracerProvider = exports.AlwaysOnSampler = exports.AlwaysOffSampler = exports.sortResources = exports.shouldPropagateTraceHeaders = exports.parseUrl = exports.normalizeUrl = exports.hasKey = exports.getResource = exports.getElementXPath = exports.addSpanNetworkEvents = exports.addSpanNetworkEvent = exports.PerformanceTimingNames = exports.StackContextManager = exports.WebTracerProvider = void 0;
18
+ exports.TraceIdRatioBasedSampler = exports.SimpleSpanProcessor = exports.SamplingDecision = exports.RandomIdGenerator = exports.ParentBasedSampler = exports.NoopSpanProcessor = exports.InMemorySpanExporter = exports.ConsoleSpanExporter = exports.BatchSpanProcessor = exports.BasicTracerProvider = exports.AlwaysOnSampler = exports.AlwaysOffSampler = exports.sortResources = exports.shouldPropagateTraceHeaders = exports.parseUrl = exports.normalizeUrl = exports.hasKey = exports.getResource = exports.getElementXPath = exports.addSpanNetworkEvents = exports.addSpanNetworkEvent = exports.PerformanceTimingNames = exports.StackContextManager = exports.WebTracerProvider = void 0;
19
19
  var WebTracerProvider_1 = require("./WebTracerProvider");
20
20
  Object.defineProperty(exports, "WebTracerProvider", { enumerable: true, get: function () { return WebTracerProvider_1.WebTracerProvider; } });
21
21
  var StackContextManager_1 = require("./StackContextManager");
@@ -38,14 +38,11 @@ Object.defineProperty(exports, "AlwaysOnSampler", { enumerable: true, get: funct
38
38
  Object.defineProperty(exports, "BasicTracerProvider", { enumerable: true, get: function () { return sdk_trace_base_1.BasicTracerProvider; } });
39
39
  Object.defineProperty(exports, "BatchSpanProcessor", { enumerable: true, get: function () { return sdk_trace_base_1.BatchSpanProcessor; } });
40
40
  Object.defineProperty(exports, "ConsoleSpanExporter", { enumerable: true, get: function () { return sdk_trace_base_1.ConsoleSpanExporter; } });
41
- Object.defineProperty(exports, "ForceFlushState", { enumerable: true, get: function () { return sdk_trace_base_1.ForceFlushState; } });
42
41
  Object.defineProperty(exports, "InMemorySpanExporter", { enumerable: true, get: function () { return sdk_trace_base_1.InMemorySpanExporter; } });
43
42
  Object.defineProperty(exports, "NoopSpanProcessor", { enumerable: true, get: function () { return sdk_trace_base_1.NoopSpanProcessor; } });
44
43
  Object.defineProperty(exports, "ParentBasedSampler", { enumerable: true, get: function () { return sdk_trace_base_1.ParentBasedSampler; } });
45
44
  Object.defineProperty(exports, "RandomIdGenerator", { enumerable: true, get: function () { return sdk_trace_base_1.RandomIdGenerator; } });
46
45
  Object.defineProperty(exports, "SamplingDecision", { enumerable: true, get: function () { return sdk_trace_base_1.SamplingDecision; } });
47
46
  Object.defineProperty(exports, "SimpleSpanProcessor", { enumerable: true, get: function () { return sdk_trace_base_1.SimpleSpanProcessor; } });
48
- Object.defineProperty(exports, "Span", { enumerable: true, get: function () { return sdk_trace_base_1.Span; } });
49
47
  Object.defineProperty(exports, "TraceIdRatioBasedSampler", { enumerable: true, get: function () { return sdk_trace_base_1.TraceIdRatioBasedSampler; } });
50
- Object.defineProperty(exports, "Tracer", { enumerable: true, get: function () { return sdk_trace_base_1.Tracer; } });
51
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yDAAyE;AAA/C,sHAAA,iBAAiB,OAAA;AAC3C,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,yEAAwE;AAA/D,gIAAA,sBAAsB,OAAA;AAO/B,iCAWiB;AATf,4GAAA,mBAAmB,OAAA;AACnB,6GAAA,oBAAoB,OAAA;AACpB,wGAAA,eAAe,OAAA;AACf,oGAAA,WAAW,OAAA;AACX,+FAAA,MAAM,OAAA;AACN,qGAAA,YAAY,OAAA;AACZ,iGAAA,QAAQ,OAAA;AACR,oHAAA,2BAA2B,OAAA;AAC3B,sGAAA,aAAa,OAAA;AAEf,gEA+BuC;AA9BrC,kHAAA,gBAAgB,OAAA;AAChB,iHAAA,eAAe,OAAA;AACf,qHAAA,mBAAmB,OAAA;AACnB,oHAAA,kBAAkB,OAAA;AAGlB,qHAAA,mBAAmB,OAAA;AAEnB,iHAAA,eAAe,OAAA;AAGf,sHAAA,oBAAoB,OAAA;AACpB,mHAAA,iBAAiB,OAAA;AACjB,oHAAA,kBAAkB,OAAA;AAElB,mHAAA,iBAAiB,OAAA;AAGjB,kHAAA,gBAAgB,OAAA;AAGhB,qHAAA,mBAAmB,OAAA;AACnB,sGAAA,IAAI,OAAA;AAKJ,0HAAA,wBAAwB,OAAA;AACxB,wGAAA,MAAM,OAAA","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,yDAAyE;AAA/C,sHAAA,iBAAiB,OAAA;AAC3C,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,yEAAwE;AAA/D,gIAAA,sBAAsB,OAAA;AAO/B,iCAWiB;AATf,4GAAA,mBAAmB,OAAA;AACnB,6GAAA,oBAAoB,OAAA;AACpB,wGAAA,eAAe,OAAA;AACf,oGAAA,WAAW,OAAA;AACX,+FAAA,MAAM,OAAA;AACN,qGAAA,YAAY,OAAA;AACZ,iGAAA,QAAQ,OAAA;AACR,oHAAA,2BAA2B,OAAA;AAC3B,sGAAA,aAAa,OAAA;AAEf,gEA2BuC;AA1BrC,kHAAA,gBAAgB,OAAA;AAChB,iHAAA,eAAe,OAAA;AACf,qHAAA,mBAAmB,OAAA;AACnB,oHAAA,kBAAkB,OAAA;AAGlB,qHAAA,mBAAmB,OAAA;AAGnB,sHAAA,oBAAoB,OAAA;AACpB,mHAAA,iBAAiB,OAAA;AACjB,oHAAA,kBAAkB,OAAA;AAClB,mHAAA,iBAAiB,OAAA;AAGjB,kHAAA,gBAAgB,OAAA;AAGhB,qHAAA,mBAAmB,OAAA;AAMnB,0HAAA,wBAAwB,OAAA","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