@opentelemetry/sdk-trace-web 2.11.0 → 3.0.0-development.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StackContextManager.cjs +89 -0
- package/dist/StackContextManager.cjs.map +1 -0
- package/dist/StackContextManager.d.cts +53 -0
- package/dist/StackContextManager.d.cts.map +1 -0
- package/dist/StackContextManager.d.mts +53 -0
- package/dist/StackContextManager.d.mts.map +1 -0
- package/dist/StackContextManager.mjs +89 -0
- package/dist/StackContextManager.mjs.map +1 -0
- package/dist/WebTracerProvider.cjs +52 -0
- package/dist/WebTracerProvider.cjs.map +1 -0
- package/dist/WebTracerProvider.d.cts +27 -0
- package/dist/WebTracerProvider.d.cts.map +1 -0
- package/dist/WebTracerProvider.d.mts +27 -0
- package/dist/WebTracerProvider.d.mts.map +1 -0
- package/dist/WebTracerProvider.mjs +52 -0
- package/dist/WebTracerProvider.mjs.map +1 -0
- package/dist/enums/PerformanceTimingNames.cjs +31 -0
- package/dist/enums/PerformanceTimingNames.cjs.map +1 -0
- package/dist/enums/PerformanceTimingNames.d.cts +29 -0
- package/dist/enums/PerformanceTimingNames.d.cts.map +1 -0
- package/dist/enums/PerformanceTimingNames.d.mts +29 -0
- package/dist/enums/PerformanceTimingNames.d.mts.map +1 -0
- package/dist/enums/PerformanceTimingNames.mjs +31 -0
- package/dist/enums/PerformanceTimingNames.mjs.map +1 -0
- package/dist/index.cjs +90 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +6 -0
- package/dist/semconv.cjs +26 -0
- package/dist/semconv.cjs.map +1 -0
- package/dist/semconv.mjs +25 -0
- package/dist/semconv.mjs.map +1 -0
- package/dist/types.d.cts +49 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +49 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/utils.cjs +237 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +83 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +83 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +229 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +31 -29
- package/build/esm/StackContextManager.d.ts +0 -50
- package/build/esm/StackContextManager.js +0 -98
- package/build/esm/StackContextManager.js.map +0 -1
- package/build/esm/WebTracerProvider.d.ts +0 -25
- package/build/esm/WebTracerProvider.js +0 -65
- package/build/esm/WebTracerProvider.js.map +0 -1
- package/build/esm/enums/PerformanceTimingNames.d.ts +0 -26
- package/build/esm/enums/PerformanceTimingNames.js +0 -31
- package/build/esm/enums/PerformanceTimingNames.js.map +0 -1
- package/build/esm/index.d.ts +0 -10
- package/build/esm/index.js +0 -10
- package/build/esm/index.js.map +0 -1
- package/build/esm/semconv.d.ts +0 -21
- package/build/esm/semconv.js +0 -30
- package/build/esm/semconv.js.map +0 -1
- package/build/esm/types.d.ts +0 -47
- package/build/esm/types.js +0 -2
- package/build/esm/types.js.map +0 -1
- package/build/esm/utils.d.ts +0 -80
- package/build/esm/utils.js +0 -316
- package/build/esm/utils.js.map +0 -1
- package/build/esm/version.d.ts +0 -2
- package/build/esm/version.js +0 -7
- package/build/esm/version.js.map +0 -1
- package/build/esnext/StackContextManager.d.ts +0 -50
- package/build/esnext/StackContextManager.js +0 -98
- package/build/esnext/StackContextManager.js.map +0 -1
- package/build/esnext/WebTracerProvider.d.ts +0 -25
- package/build/esnext/WebTracerProvider.js +0 -65
- package/build/esnext/WebTracerProvider.js.map +0 -1
- package/build/esnext/enums/PerformanceTimingNames.d.ts +0 -26
- package/build/esnext/enums/PerformanceTimingNames.js +0 -31
- package/build/esnext/enums/PerformanceTimingNames.js.map +0 -1
- package/build/esnext/index.d.ts +0 -10
- package/build/esnext/index.js +0 -10
- package/build/esnext/index.js.map +0 -1
- package/build/esnext/semconv.d.ts +0 -21
- package/build/esnext/semconv.js +0 -30
- package/build/esnext/semconv.js.map +0 -1
- package/build/esnext/types.d.ts +0 -47
- package/build/esnext/types.js +0 -2
- package/build/esnext/types.js.map +0 -1
- package/build/esnext/utils.d.ts +0 -80
- package/build/esnext/utils.js +0 -316
- package/build/esnext/utils.js.map +0 -1
- package/build/esnext/version.d.ts +0 -2
- package/build/esnext/version.js +0 -7
- package/build/esnext/version.js.map +0 -1
- package/build/src/StackContextManager.d.ts +0 -50
- package/build/src/StackContextManager.js +0 -102
- package/build/src/StackContextManager.js.map +0 -1
- package/build/src/WebTracerProvider.d.ts +0 -25
- package/build/src/WebTracerProvider.js +0 -69
- package/build/src/WebTracerProvider.js.map +0 -1
- package/build/src/enums/PerformanceTimingNames.d.ts +0 -26
- package/build/src/enums/PerformanceTimingNames.js +0 -34
- package/build/src/enums/PerformanceTimingNames.js.map +0 -1
- package/build/src/index.d.ts +0 -10
- package/build/src/index.js +0 -37
- package/build/src/index.js.map +0 -1
- package/build/src/semconv.d.ts +0 -21
- package/build/src/semconv.js +0 -33
- package/build/src/semconv.js.map +0 -1
- package/build/src/types.d.ts +0 -47
- package/build/src/types.js +0 -3
- package/build/src/types.js.map +0 -1
- package/build/src/utils.d.ts +0 -80
- package/build/src/utils.js +0 -328
- package/build/src/utils.js.map +0 -1
- package/build/src/version.d.ts +0 -2
- package/build/src/version.js +0 -10
- package/build/src/version.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_StackContextManager = require("./StackContextManager.cjs");
|
|
3
|
+
const require_WebTracerProvider = require("./WebTracerProvider.cjs");
|
|
4
|
+
const require_PerformanceTimingNames = require("./enums/PerformanceTimingNames.cjs");
|
|
5
|
+
const require_utils = require("./utils.cjs");
|
|
6
|
+
let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
7
|
+
Object.defineProperty(exports, "AlwaysOffSampler", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function() {
|
|
10
|
+
return _opentelemetry_sdk_trace_base.AlwaysOffSampler;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "AlwaysOnSampler", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return _opentelemetry_sdk_trace_base.AlwaysOnSampler;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "BasicTracerProvider", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return _opentelemetry_sdk_trace_base.BasicTracerProvider;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "BatchSpanProcessor", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return _opentelemetry_sdk_trace_base.BatchSpanProcessor;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "ConsoleSpanExporter", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function() {
|
|
34
|
+
return _opentelemetry_sdk_trace_base.ConsoleSpanExporter;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "InMemorySpanExporter", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return _opentelemetry_sdk_trace_base.InMemorySpanExporter;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "NoopSpanProcessor", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function() {
|
|
46
|
+
return _opentelemetry_sdk_trace_base.NoopSpanProcessor;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "ParentBasedSampler", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return _opentelemetry_sdk_trace_base.ParentBasedSampler;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
exports.PerformanceTimingNames = require_PerformanceTimingNames.PerformanceTimingNames;
|
|
56
|
+
Object.defineProperty(exports, "RandomIdGenerator", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function() {
|
|
59
|
+
return _opentelemetry_sdk_trace_base.RandomIdGenerator;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "SamplingDecision", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function() {
|
|
65
|
+
return _opentelemetry_sdk_trace_base.SamplingDecision;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "SimpleSpanProcessor", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function() {
|
|
71
|
+
return _opentelemetry_sdk_trace_base.SimpleSpanProcessor;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
exports.StackContextManager = require_StackContextManager.StackContextManager;
|
|
75
|
+
Object.defineProperty(exports, "TraceIdRatioBasedSampler", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return _opentelemetry_sdk_trace_base.TraceIdRatioBasedSampler;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
exports.WebTracerProvider = require_WebTracerProvider.WebTracerProvider;
|
|
82
|
+
exports.addSpanNetworkEvent = require_utils.addSpanNetworkEvent;
|
|
83
|
+
exports.addSpanNetworkEvents = require_utils.addSpanNetworkEvents;
|
|
84
|
+
exports.getElementXPath = require_utils.getElementXPath;
|
|
85
|
+
exports.getResource = require_utils.getResource;
|
|
86
|
+
exports.hasKey = require_utils.hasKey;
|
|
87
|
+
exports.normalizeUrl = require_utils.normalizeUrl;
|
|
88
|
+
exports.parseUrl = require_utils.parseUrl;
|
|
89
|
+
exports.shouldPropagateTraceHeaders = require_utils.shouldPropagateTraceHeaders;
|
|
90
|
+
exports.sortResources = require_utils.sortResources;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WebTracerConfig, WebTracerProvider } from "./WebTracerProvider.cjs";
|
|
2
|
+
import { StackContextManager } from "./StackContextManager.cjs";
|
|
3
|
+
import { PerformanceTimingNames } from "./enums/PerformanceTimingNames.cjs";
|
|
4
|
+
import { PerformanceEntries, PerformanceLegacy, PerformanceResourceTimingInfo, PropagateTraceHeaderCorsUrls } from "./types.cjs";
|
|
5
|
+
import { URLLike, addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources } from "./utils.cjs";
|
|
6
|
+
import { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, BatchSpanProcessorBrowserConfig, BufferConfig, ConsoleSpanExporter, GeneralLimits, IdGenerator, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, RandomIdGenerator, ReadableSpan, SDKRegistrationConfig, Sampler, SamplingDecision, SamplingResult, SimpleSpanProcessor, Span, SpanExporter, SpanLimits, SpanProcessor, TimedEvent, TraceIdRatioBasedSampler, TracerConfig } from "@opentelemetry/sdk-trace-base";
|
|
7
|
+
export { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, type BatchSpanProcessorBrowserConfig, type BufferConfig, ConsoleSpanExporter, type GeneralLimits, type IdGenerator, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, type PerformanceEntries, type PerformanceLegacy, type PerformanceResourceTimingInfo, PerformanceTimingNames, type PropagateTraceHeaderCorsUrls, RandomIdGenerator, type ReadableSpan, type SDKRegistrationConfig, type Sampler, SamplingDecision, type SamplingResult, SimpleSpanProcessor, type Span, type SpanExporter, type SpanLimits, type SpanProcessor, StackContextManager, type TimedEvent, TraceIdRatioBasedSampler, type TracerConfig, type URLLike, type WebTracerConfig, WebTracerProvider, addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WebTracerConfig, WebTracerProvider } from "./WebTracerProvider.mjs";
|
|
2
|
+
import { StackContextManager } from "./StackContextManager.mjs";
|
|
3
|
+
import { PerformanceTimingNames } from "./enums/PerformanceTimingNames.mjs";
|
|
4
|
+
import { PerformanceEntries, PerformanceLegacy, PerformanceResourceTimingInfo, PropagateTraceHeaderCorsUrls } from "./types.mjs";
|
|
5
|
+
import { URLLike, addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources } from "./utils.mjs";
|
|
6
|
+
import { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, BatchSpanProcessorBrowserConfig, BufferConfig, ConsoleSpanExporter, GeneralLimits, IdGenerator, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, RandomIdGenerator, ReadableSpan, SDKRegistrationConfig, Sampler, SamplingDecision, SamplingResult, SimpleSpanProcessor, Span, SpanExporter, SpanLimits, SpanProcessor, TimedEvent, TraceIdRatioBasedSampler, TracerConfig } from "@opentelemetry/sdk-trace-base";
|
|
7
|
+
export { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, type BatchSpanProcessorBrowserConfig, type BufferConfig, ConsoleSpanExporter, type GeneralLimits, type IdGenerator, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, type PerformanceEntries, type PerformanceLegacy, type PerformanceResourceTimingInfo, PerformanceTimingNames, type PropagateTraceHeaderCorsUrls, RandomIdGenerator, type ReadableSpan, type SDKRegistrationConfig, type Sampler, SamplingDecision, type SamplingResult, SimpleSpanProcessor, type Span, type SpanExporter, type SpanLimits, type SpanProcessor, StackContextManager, type TimedEvent, TraceIdRatioBasedSampler, type TracerConfig, type URLLike, type WebTracerConfig, WebTracerProvider, addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StackContextManager } from "./StackContextManager.mjs";
|
|
2
|
+
import { WebTracerProvider } from "./WebTracerProvider.mjs";
|
|
3
|
+
import { PerformanceTimingNames } from "./enums/PerformanceTimingNames.mjs";
|
|
4
|
+
import { addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources } from "./utils.mjs";
|
|
5
|
+
import { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, ConsoleSpanExporter, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, RandomIdGenerator, SamplingDecision, SimpleSpanProcessor, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
|
|
6
|
+
export { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, ConsoleSpanExporter, InMemorySpanExporter, NoopSpanProcessor, ParentBasedSampler, PerformanceTimingNames, RandomIdGenerator, SamplingDecision, SimpleSpanProcessor, StackContextManager, TraceIdRatioBasedSampler, WebTracerProvider, addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources };
|
package/dist/semconv.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/semconv.ts
|
|
2
|
+
/**
|
|
3
|
+
* Deprecated, use `http.response.header.<key>` instead.
|
|
4
|
+
*
|
|
5
|
+
* @example 3495
|
|
6
|
+
*
|
|
7
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Replaced by `http.response.header.<key>`.
|
|
10
|
+
*/
|
|
11
|
+
const ATTR_HTTP_RESPONSE_CONTENT_LENGTH = "http.response_content_length";
|
|
12
|
+
/**
|
|
13
|
+
* Deprecated, use `http.response.body.size` instead.
|
|
14
|
+
*
|
|
15
|
+
* @example 5493
|
|
16
|
+
*
|
|
17
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
18
|
+
*
|
|
19
|
+
* @deprecated Replace by `http.response.body.size`.
|
|
20
|
+
*/
|
|
21
|
+
const ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED = "http.response_content_length_uncompressed";
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.ATTR_HTTP_RESPONSE_CONTENT_LENGTH = ATTR_HTTP_RESPONSE_CONTENT_LENGTH;
|
|
24
|
+
exports.ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED = ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=semconv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semconv.cjs","names":[],"sources":["../src/semconv.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `http.response.header.<key>` instead.\n *\n * @example 3495\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.response.header.<key>`.\n */\nexport const ATTR_HTTP_RESPONSE_CONTENT_LENGTH =\n 'http.response_content_length' as const;\n\n/**\n * Deprecated, use `http.response.body.size` instead.\n *\n * @example 5493\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replace by `http.response.body.size`.\n */\nexport const ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED =\n 'http.response_content_length_uncompressed' as const;\n"],"mappings":";;;;;;;;;;AAoBA,MAAa,oCACX;;;;;;;;;;AAWF,MAAa,iDACX"}
|
package/dist/semconv.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/semconv.ts
|
|
2
|
+
/**
|
|
3
|
+
* Deprecated, use `http.response.header.<key>` instead.
|
|
4
|
+
*
|
|
5
|
+
* @example 3495
|
|
6
|
+
*
|
|
7
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Replaced by `http.response.header.<key>`.
|
|
10
|
+
*/
|
|
11
|
+
const ATTR_HTTP_RESPONSE_CONTENT_LENGTH = "http.response_content_length";
|
|
12
|
+
/**
|
|
13
|
+
* Deprecated, use `http.response.body.size` instead.
|
|
14
|
+
*
|
|
15
|
+
* @example 5493
|
|
16
|
+
*
|
|
17
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
18
|
+
*
|
|
19
|
+
* @deprecated Replace by `http.response.body.size`.
|
|
20
|
+
*/
|
|
21
|
+
const ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED = "http.response_content_length_uncompressed";
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ATTR_HTTP_RESPONSE_CONTENT_LENGTH, ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=semconv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semconv.mjs","names":[],"sources":["../src/semconv.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `http.response.header.<key>` instead.\n *\n * @example 3495\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.response.header.<key>`.\n */\nexport const ATTR_HTTP_RESPONSE_CONTENT_LENGTH =\n 'http.response_content_length' as const;\n\n/**\n * Deprecated, use `http.response.body.size` instead.\n *\n * @example 5493\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replace by `http.response.body.size`.\n */\nexport const ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED =\n 'http.response_content_length_uncompressed' as const;\n"],"mappings":";;;;;;;;;;AAoBA,MAAa,oCACX;;;;;;;;;;AAWF,MAAa,iDACX"}
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PerformanceTimingNames } from "./enums/PerformanceTimingNames.cjs";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
type PerformanceEntries = {
|
|
4
|
+
[PerformanceTimingNames.CONNECT_END]?: number;
|
|
5
|
+
[PerformanceTimingNames.CONNECT_START]?: number;
|
|
6
|
+
[PerformanceTimingNames.DECODED_BODY_SIZE]?: number;
|
|
7
|
+
[PerformanceTimingNames.DOM_COMPLETE]?: number;
|
|
8
|
+
[PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_END]?: number;
|
|
9
|
+
[PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_START]?: number;
|
|
10
|
+
[PerformanceTimingNames.DOM_INTERACTIVE]?: number;
|
|
11
|
+
[PerformanceTimingNames.DOMAIN_LOOKUP_END]?: number;
|
|
12
|
+
[PerformanceTimingNames.DOMAIN_LOOKUP_START]?: number;
|
|
13
|
+
[PerformanceTimingNames.ENCODED_BODY_SIZE]?: number;
|
|
14
|
+
[PerformanceTimingNames.FETCH_START]?: number;
|
|
15
|
+
[PerformanceTimingNames.LOAD_EVENT_END]?: number;
|
|
16
|
+
[PerformanceTimingNames.LOAD_EVENT_START]?: number;
|
|
17
|
+
[PerformanceTimingNames.REDIRECT_END]?: number;
|
|
18
|
+
[PerformanceTimingNames.REDIRECT_START]?: number;
|
|
19
|
+
[PerformanceTimingNames.REQUEST_START]?: number;
|
|
20
|
+
[PerformanceTimingNames.RESPONSE_END]?: number;
|
|
21
|
+
[PerformanceTimingNames.RESPONSE_START]?: number;
|
|
22
|
+
[PerformanceTimingNames.SECURE_CONNECTION_START]?: number;
|
|
23
|
+
[PerformanceTimingNames.START_TIME]?: number;
|
|
24
|
+
[PerformanceTimingNames.UNLOAD_EVENT_END]?: number;
|
|
25
|
+
[PerformanceTimingNames.UNLOAD_EVENT_START]?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* This interface defines a fallback to read performance metrics,
|
|
29
|
+
* this happens for example on Safari Mac
|
|
30
|
+
*/
|
|
31
|
+
interface PerformanceLegacy {
|
|
32
|
+
timing?: PerformanceEntries;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* This interface is used in {@link getResource} function to return
|
|
36
|
+
* main request and it's corresponding PreFlight request
|
|
37
|
+
*/
|
|
38
|
+
interface PerformanceResourceTimingInfo {
|
|
39
|
+
corsPreFlightRequest?: PerformanceResourceTiming;
|
|
40
|
+
mainRequest?: PerformanceResourceTiming;
|
|
41
|
+
}
|
|
42
|
+
type PropagateTraceHeaderCorsUrl = string | RegExp;
|
|
43
|
+
/**
|
|
44
|
+
* urls which should include trace headers when origin doesn't match
|
|
45
|
+
*/
|
|
46
|
+
type PropagateTraceHeaderCorsUrls = PropagateTraceHeaderCorsUrl | PropagateTraceHeaderCorsUrl[];
|
|
47
|
+
//#endregion
|
|
48
|
+
export { PerformanceEntries, PerformanceLegacy, PerformanceResourceTimingInfo, PropagateTraceHeaderCorsUrls };
|
|
49
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.d.ts"],"mappings":";;KACY;GACP,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;;;;;;UAMX;EACb,SAAS;;;;;;UAMI;EACb,uBAAuB;EACvB,cAAc;;KAEb,uCAAuC;;;;KAIhC,+BAA+B,8BAA8B"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PerformanceTimingNames } from "./enums/PerformanceTimingNames.mjs";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
type PerformanceEntries = {
|
|
4
|
+
[PerformanceTimingNames.CONNECT_END]?: number;
|
|
5
|
+
[PerformanceTimingNames.CONNECT_START]?: number;
|
|
6
|
+
[PerformanceTimingNames.DECODED_BODY_SIZE]?: number;
|
|
7
|
+
[PerformanceTimingNames.DOM_COMPLETE]?: number;
|
|
8
|
+
[PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_END]?: number;
|
|
9
|
+
[PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_START]?: number;
|
|
10
|
+
[PerformanceTimingNames.DOM_INTERACTIVE]?: number;
|
|
11
|
+
[PerformanceTimingNames.DOMAIN_LOOKUP_END]?: number;
|
|
12
|
+
[PerformanceTimingNames.DOMAIN_LOOKUP_START]?: number;
|
|
13
|
+
[PerformanceTimingNames.ENCODED_BODY_SIZE]?: number;
|
|
14
|
+
[PerformanceTimingNames.FETCH_START]?: number;
|
|
15
|
+
[PerformanceTimingNames.LOAD_EVENT_END]?: number;
|
|
16
|
+
[PerformanceTimingNames.LOAD_EVENT_START]?: number;
|
|
17
|
+
[PerformanceTimingNames.REDIRECT_END]?: number;
|
|
18
|
+
[PerformanceTimingNames.REDIRECT_START]?: number;
|
|
19
|
+
[PerformanceTimingNames.REQUEST_START]?: number;
|
|
20
|
+
[PerformanceTimingNames.RESPONSE_END]?: number;
|
|
21
|
+
[PerformanceTimingNames.RESPONSE_START]?: number;
|
|
22
|
+
[PerformanceTimingNames.SECURE_CONNECTION_START]?: number;
|
|
23
|
+
[PerformanceTimingNames.START_TIME]?: number;
|
|
24
|
+
[PerformanceTimingNames.UNLOAD_EVENT_END]?: number;
|
|
25
|
+
[PerformanceTimingNames.UNLOAD_EVENT_START]?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* This interface defines a fallback to read performance metrics,
|
|
29
|
+
* this happens for example on Safari Mac
|
|
30
|
+
*/
|
|
31
|
+
interface PerformanceLegacy {
|
|
32
|
+
timing?: PerformanceEntries;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* This interface is used in {@link getResource} function to return
|
|
36
|
+
* main request and it's corresponding PreFlight request
|
|
37
|
+
*/
|
|
38
|
+
interface PerformanceResourceTimingInfo {
|
|
39
|
+
corsPreFlightRequest?: PerformanceResourceTiming;
|
|
40
|
+
mainRequest?: PerformanceResourceTiming;
|
|
41
|
+
}
|
|
42
|
+
type PropagateTraceHeaderCorsUrl = string | RegExp;
|
|
43
|
+
/**
|
|
44
|
+
* urls which should include trace headers when origin doesn't match
|
|
45
|
+
*/
|
|
46
|
+
type PropagateTraceHeaderCorsUrls = PropagateTraceHeaderCorsUrl | PropagateTraceHeaderCorsUrl[];
|
|
47
|
+
//#endregion
|
|
48
|
+
export { PerformanceEntries, PerformanceLegacy, PerformanceResourceTimingInfo, PropagateTraceHeaderCorsUrls };
|
|
49
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.d.ts"],"mappings":";;KACY;GACP,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;;;;;;UAMX;EACb,SAAS;;;;;;UAMI;EACb,uBAAuB;EACvB,cAAc;;KAEb,uCAAuC;;;;KAIhC,+BAA+B,8BAA8B"}
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
require("./enums/PerformanceTimingNames.cjs");
|
|
2
|
+
const require_semconv = require("./semconv.cjs");
|
|
3
|
+
let _opentelemetry_core = require("@opentelemetry/core");
|
|
4
|
+
//#region src/utils.ts
|
|
5
|
+
let urlNormalizingAnchor;
|
|
6
|
+
function getUrlNormalizingAnchor() {
|
|
7
|
+
if (!urlNormalizingAnchor) urlNormalizingAnchor = document.createElement("a");
|
|
8
|
+
return urlNormalizingAnchor;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to be able to use enum as typed key in type and in interface when using forEach
|
|
12
|
+
* @param obj
|
|
13
|
+
* @param key
|
|
14
|
+
*/
|
|
15
|
+
function hasKey(obj, key) {
|
|
16
|
+
return key in obj;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper function for starting an event on span based on {@link PerformanceEntries}
|
|
20
|
+
* @param span
|
|
21
|
+
* @param performanceName name of performance entry for time start
|
|
22
|
+
* @param entries
|
|
23
|
+
* @param ignoreZeros
|
|
24
|
+
*/
|
|
25
|
+
function addSpanNetworkEvent(span, performanceName, entries, ignoreZeros = true) {
|
|
26
|
+
if (hasKey(entries, performanceName) && typeof entries[performanceName] === "number" && !(ignoreZeros && entries[performanceName] === 0)) return span.addEvent(performanceName, entries[performanceName]);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Helper function for adding network events and content length attributes.
|
|
30
|
+
*/
|
|
31
|
+
function addSpanNetworkEvents(span, resource, ignoreNetworkEvents = false, ignoreZeros, skipOldSemconvContentLengthAttrs) {
|
|
32
|
+
if (ignoreZeros === void 0) ignoreZeros = resource["startTime"] !== 0;
|
|
33
|
+
if (!ignoreNetworkEvents) {
|
|
34
|
+
addSpanNetworkEvent(span, "fetchStart", resource, ignoreZeros);
|
|
35
|
+
addSpanNetworkEvent(span, "domainLookupStart", resource, ignoreZeros);
|
|
36
|
+
addSpanNetworkEvent(span, "domainLookupEnd", resource, ignoreZeros);
|
|
37
|
+
addSpanNetworkEvent(span, "connectStart", resource, ignoreZeros);
|
|
38
|
+
addSpanNetworkEvent(span, "secureConnectionStart", resource, ignoreZeros);
|
|
39
|
+
addSpanNetworkEvent(span, "connectEnd", resource, ignoreZeros);
|
|
40
|
+
addSpanNetworkEvent(span, "requestStart", resource, ignoreZeros);
|
|
41
|
+
addSpanNetworkEvent(span, "responseStart", resource, ignoreZeros);
|
|
42
|
+
addSpanNetworkEvent(span, "responseEnd", resource, ignoreZeros);
|
|
43
|
+
}
|
|
44
|
+
if (!skipOldSemconvContentLengthAttrs) {
|
|
45
|
+
const encodedLength = resource["encodedBodySize"];
|
|
46
|
+
if (encodedLength !== void 0) span.setAttribute(require_semconv.ATTR_HTTP_RESPONSE_CONTENT_LENGTH, encodedLength);
|
|
47
|
+
const decodedLength = resource["decodedBodySize"];
|
|
48
|
+
if (decodedLength !== void 0 && encodedLength !== decodedLength) span.setAttribute(require_semconv.ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED, decodedLength);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* sort resources by startTime
|
|
53
|
+
* @param filteredResources
|
|
54
|
+
*/
|
|
55
|
+
function sortResources(filteredResources) {
|
|
56
|
+
return filteredResources.slice().sort((a, b) => {
|
|
57
|
+
const valueA = a["fetchStart"];
|
|
58
|
+
const valueB = b["fetchStart"];
|
|
59
|
+
if (valueA > valueB) return 1;
|
|
60
|
+
else if (valueA < valueB) return -1;
|
|
61
|
+
return 0;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Returns the origin if present (if in browser context). */
|
|
65
|
+
function getOrigin() {
|
|
66
|
+
return typeof location !== "undefined" ? location.origin : void 0;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get closest performance resource ignoring the resources that have been
|
|
70
|
+
* already used.
|
|
71
|
+
* @param spanUrl
|
|
72
|
+
* @param startTimeHR
|
|
73
|
+
* @param endTimeHR
|
|
74
|
+
* @param resources
|
|
75
|
+
* @param ignoredResources
|
|
76
|
+
* @param initiatorType
|
|
77
|
+
*/
|
|
78
|
+
function getResource(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources = /* @__PURE__ */ new WeakSet(), initiatorType) {
|
|
79
|
+
const parsedSpanUrl = parseUrl(spanUrl);
|
|
80
|
+
spanUrl = parsedSpanUrl.toString();
|
|
81
|
+
const filteredResources = filterResourcesForSpan(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources, initiatorType);
|
|
82
|
+
if (filteredResources.length === 0) return { mainRequest: void 0 };
|
|
83
|
+
if (filteredResources.length === 1) return { mainRequest: filteredResources[0] };
|
|
84
|
+
const sorted = sortResources(filteredResources);
|
|
85
|
+
if (parsedSpanUrl.origin !== getOrigin() && sorted.length > 1) {
|
|
86
|
+
let corsPreFlightRequest = sorted[0];
|
|
87
|
+
let mainRequest = findMainRequest(sorted, corsPreFlightRequest["responseEnd"], endTimeHR);
|
|
88
|
+
const responseEnd = corsPreFlightRequest["responseEnd"];
|
|
89
|
+
if (mainRequest["fetchStart"] < responseEnd) {
|
|
90
|
+
mainRequest = corsPreFlightRequest;
|
|
91
|
+
corsPreFlightRequest = void 0;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
corsPreFlightRequest,
|
|
95
|
+
mainRequest
|
|
96
|
+
};
|
|
97
|
+
} else return { mainRequest: filteredResources[0] };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Will find the main request skipping the cors pre flight requests
|
|
101
|
+
* @param resources
|
|
102
|
+
* @param corsPreFlightRequestEndTime
|
|
103
|
+
* @param spanEndTimeHR
|
|
104
|
+
*/
|
|
105
|
+
function findMainRequest(resources, corsPreFlightRequestEndTime, spanEndTimeHR) {
|
|
106
|
+
const spanEndTime = (0, _opentelemetry_core.hrTimeToNanoseconds)(spanEndTimeHR);
|
|
107
|
+
const minTime = (0, _opentelemetry_core.hrTimeToNanoseconds)((0, _opentelemetry_core.timeInputToHrTime)(corsPreFlightRequestEndTime));
|
|
108
|
+
let mainRequest = resources[1];
|
|
109
|
+
let bestGap;
|
|
110
|
+
const length = resources.length;
|
|
111
|
+
for (let i = 1; i < length; i++) {
|
|
112
|
+
const resource = resources[i];
|
|
113
|
+
const resourceStartTime = (0, _opentelemetry_core.hrTimeToNanoseconds)((0, _opentelemetry_core.timeInputToHrTime)(resource["fetchStart"]));
|
|
114
|
+
const currentGap = spanEndTime - (0, _opentelemetry_core.hrTimeToNanoseconds)((0, _opentelemetry_core.timeInputToHrTime)(resource["responseEnd"]));
|
|
115
|
+
if (resourceStartTime >= minTime && (!bestGap || currentGap < bestGap)) {
|
|
116
|
+
bestGap = currentGap;
|
|
117
|
+
mainRequest = resource;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return mainRequest;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Filter all resources that has started and finished according to span start time and end time.
|
|
124
|
+
* It will return the closest resource to a start time
|
|
125
|
+
* @param spanUrl
|
|
126
|
+
* @param startTimeHR
|
|
127
|
+
* @param endTimeHR
|
|
128
|
+
* @param resources
|
|
129
|
+
* @param ignoredResources
|
|
130
|
+
*/
|
|
131
|
+
function filterResourcesForSpan(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources, initiatorType) {
|
|
132
|
+
const startTime = (0, _opentelemetry_core.hrTimeToNanoseconds)(startTimeHR);
|
|
133
|
+
const endTime = (0, _opentelemetry_core.hrTimeToNanoseconds)(endTimeHR);
|
|
134
|
+
let filteredResources = resources.filter((resource) => {
|
|
135
|
+
const resourceStartTime = (0, _opentelemetry_core.hrTimeToNanoseconds)((0, _opentelemetry_core.timeInputToHrTime)(resource["fetchStart"]));
|
|
136
|
+
const resourceEndTime = (0, _opentelemetry_core.hrTimeToNanoseconds)((0, _opentelemetry_core.timeInputToHrTime)(resource["responseEnd"]));
|
|
137
|
+
return resource.initiatorType.toLowerCase() === (initiatorType || "xmlhttprequest") && resource.name === spanUrl && resourceStartTime >= startTime && resourceEndTime <= endTime;
|
|
138
|
+
});
|
|
139
|
+
if (filteredResources.length > 0) filteredResources = filteredResources.filter((resource) => {
|
|
140
|
+
return !ignoredResources.has(resource);
|
|
141
|
+
});
|
|
142
|
+
return filteredResources;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Parses url using URL constructor or fallback to anchor element.
|
|
146
|
+
* @param url
|
|
147
|
+
*/
|
|
148
|
+
function parseUrl(url) {
|
|
149
|
+
if (typeof URL === "function") return new URL(url, typeof document !== "undefined" ? document.baseURI : typeof location !== "undefined" ? location.href : void 0);
|
|
150
|
+
const element = getUrlNormalizingAnchor();
|
|
151
|
+
element.href = url;
|
|
152
|
+
return element;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Parses url using URL constructor or fallback to anchor element and serialize
|
|
156
|
+
* it to a string.
|
|
157
|
+
*
|
|
158
|
+
* Performs the steps described in https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
|
|
159
|
+
*
|
|
160
|
+
* @param url
|
|
161
|
+
*/
|
|
162
|
+
function normalizeUrl(url) {
|
|
163
|
+
return parseUrl(url).href;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get element XPath
|
|
167
|
+
* @param target - target element
|
|
168
|
+
* @param optimised - when id attribute of element is present the xpath can be
|
|
169
|
+
* simplified to contain id
|
|
170
|
+
*/
|
|
171
|
+
function getElementXPath(target, optimised) {
|
|
172
|
+
if (target.nodeType === Node.DOCUMENT_NODE) return "/";
|
|
173
|
+
const targetValue = getNodeValue(target, optimised);
|
|
174
|
+
if (optimised && targetValue.indexOf("@id") > 0) return targetValue;
|
|
175
|
+
let xpath = "";
|
|
176
|
+
if (target.parentNode) xpath += getElementXPath(target.parentNode, optimised);
|
|
177
|
+
xpath += targetValue;
|
|
178
|
+
return xpath;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* get node index within the siblings
|
|
182
|
+
* @param target
|
|
183
|
+
*/
|
|
184
|
+
function getNodeIndex(target) {
|
|
185
|
+
if (!target.parentNode) return 0;
|
|
186
|
+
const allowedTypes = [target.nodeType];
|
|
187
|
+
if (target.nodeType === Node.CDATA_SECTION_NODE) allowedTypes.push(Node.TEXT_NODE);
|
|
188
|
+
let elements = Array.from(target.parentNode.childNodes);
|
|
189
|
+
elements = elements.filter((element) => {
|
|
190
|
+
const localName = element.localName;
|
|
191
|
+
return allowedTypes.indexOf(element.nodeType) >= 0 && localName === target.localName;
|
|
192
|
+
});
|
|
193
|
+
if (elements.length >= 1) return elements.indexOf(target) + 1;
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* get node value for xpath
|
|
198
|
+
* @param target
|
|
199
|
+
* @param optimised
|
|
200
|
+
*/
|
|
201
|
+
function getNodeValue(target, optimised) {
|
|
202
|
+
const nodeType = target.nodeType;
|
|
203
|
+
const index = getNodeIndex(target);
|
|
204
|
+
let nodeValue;
|
|
205
|
+
if (nodeType === Node.ELEMENT_NODE) {
|
|
206
|
+
const id = target.getAttribute("id");
|
|
207
|
+
if (optimised && id) return `//*[@id="${id}"]`;
|
|
208
|
+
nodeValue = target.localName;
|
|
209
|
+
} else if (nodeType === Node.TEXT_NODE || nodeType === Node.CDATA_SECTION_NODE) nodeValue = "text()";
|
|
210
|
+
else if (nodeType === Node.COMMENT_NODE) nodeValue = "comment()";
|
|
211
|
+
else return "";
|
|
212
|
+
if (nodeValue && index > 1) return `/${nodeValue}[${index}]`;
|
|
213
|
+
return `/${nodeValue}`;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Checks if trace headers should be propagated
|
|
217
|
+
* @param spanUrl
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
function shouldPropagateTraceHeaders(spanUrl, propagateTraceHeaderCorsUrls) {
|
|
221
|
+
let propagateTraceHeaderUrls = propagateTraceHeaderCorsUrls || [];
|
|
222
|
+
if (typeof propagateTraceHeaderUrls === "string" || propagateTraceHeaderUrls instanceof RegExp) propagateTraceHeaderUrls = [propagateTraceHeaderUrls];
|
|
223
|
+
if (parseUrl(spanUrl).origin === getOrigin()) return true;
|
|
224
|
+
else return propagateTraceHeaderUrls.some((propagateTraceHeaderUrl) => (0, _opentelemetry_core.urlMatches)(spanUrl, propagateTraceHeaderUrl));
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
exports.addSpanNetworkEvent = addSpanNetworkEvent;
|
|
228
|
+
exports.addSpanNetworkEvents = addSpanNetworkEvents;
|
|
229
|
+
exports.getElementXPath = getElementXPath;
|
|
230
|
+
exports.getResource = getResource;
|
|
231
|
+
exports.hasKey = hasKey;
|
|
232
|
+
exports.normalizeUrl = normalizeUrl;
|
|
233
|
+
exports.parseUrl = parseUrl;
|
|
234
|
+
exports.shouldPropagateTraceHeaders = shouldPropagateTraceHeaders;
|
|
235
|
+
exports.sortResources = sortResources;
|
|
236
|
+
|
|
237
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["ATTR_HTTP_RESPONSE_CONTENT_LENGTH","ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED","hrTimeToNanoseconds","timeInputToHrTime","urlMatches"],"sources":["../src/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n PerformanceEntries,\n PerformanceResourceTimingInfo,\n PropagateTraceHeaderCorsUrls,\n} from './types';\nimport { PerformanceTimingNames as PTN } from './enums/PerformanceTimingNames';\nimport type * as api from '@opentelemetry/api';\nimport {\n hrTimeToNanoseconds,\n timeInputToHrTime,\n urlMatches,\n} from '@opentelemetry/core';\nimport {\n ATTR_HTTP_RESPONSE_CONTENT_LENGTH,\n ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n} from './semconv';\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 */\nexport function addSpanNetworkEvents(\n span: api.Span,\n resource: PerformanceEntries,\n ignoreNetworkEvents = false,\n ignoreZeros?: boolean,\n skipOldSemconvContentLengthAttrs?: 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 if (!skipOldSemconvContentLengthAttrs) {\n // This block adds content-length-related span attributes using the\n // *old* HTTP semconv (v1.7.0).\n const encodedLength = resource[PTN.ENCODED_BODY_SIZE];\n if (encodedLength !== undefined) {\n span.setAttribute(ATTR_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 ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n decodedLength\n );\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\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, optimised);\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: string;\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"],"mappings":"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"}
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PerformanceEntries, PerformanceResourceTimingInfo, PropagateTraceHeaderCorsUrls } from "./types.cjs";
|
|
2
|
+
import * as api from "@opentelemetry/api";
|
|
3
|
+
//#region src/utils.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to be able to use enum as typed key in type and in interface when using forEach
|
|
6
|
+
* @param obj
|
|
7
|
+
* @param key
|
|
8
|
+
*/
|
|
9
|
+
declare function hasKey<O extends object>(obj: O, key: PropertyKey): key is keyof O;
|
|
10
|
+
/**
|
|
11
|
+
* Helper function for starting an event on span based on {@link PerformanceEntries}
|
|
12
|
+
* @param span
|
|
13
|
+
* @param performanceName name of performance entry for time start
|
|
14
|
+
* @param entries
|
|
15
|
+
* @param ignoreZeros
|
|
16
|
+
*/
|
|
17
|
+
declare function addSpanNetworkEvent(span: api.Span, performanceName: string, entries: PerformanceEntries, ignoreZeros?: boolean): api.Span | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Helper function for adding network events and content length attributes.
|
|
20
|
+
*/
|
|
21
|
+
declare function addSpanNetworkEvents(span: api.Span, resource: PerformanceEntries, ignoreNetworkEvents?: boolean, ignoreZeros?: boolean, skipOldSemconvContentLengthAttrs?: boolean): void;
|
|
22
|
+
/**
|
|
23
|
+
* sort resources by startTime
|
|
24
|
+
* @param filteredResources
|
|
25
|
+
*/
|
|
26
|
+
declare function sortResources(filteredResources: PerformanceResourceTiming[]): PerformanceResourceTiming[];
|
|
27
|
+
/**
|
|
28
|
+
* Get closest performance resource ignoring the resources that have been
|
|
29
|
+
* already used.
|
|
30
|
+
* @param spanUrl
|
|
31
|
+
* @param startTimeHR
|
|
32
|
+
* @param endTimeHR
|
|
33
|
+
* @param resources
|
|
34
|
+
* @param ignoredResources
|
|
35
|
+
* @param initiatorType
|
|
36
|
+
*/
|
|
37
|
+
declare function getResource(spanUrl: string, startTimeHR: api.HrTime, endTimeHR: api.HrTime, resources: PerformanceResourceTiming[], ignoredResources?: WeakSet<PerformanceResourceTiming>, initiatorType?: string): PerformanceResourceTimingInfo;
|
|
38
|
+
/**
|
|
39
|
+
* The URLLike interface represents an URL and HTMLAnchorElement compatible fields.
|
|
40
|
+
*/
|
|
41
|
+
interface URLLike {
|
|
42
|
+
hash: string;
|
|
43
|
+
host: string;
|
|
44
|
+
hostname: string;
|
|
45
|
+
href: string;
|
|
46
|
+
readonly origin: string;
|
|
47
|
+
password: string;
|
|
48
|
+
pathname: string;
|
|
49
|
+
port: string;
|
|
50
|
+
protocol: string;
|
|
51
|
+
search: string;
|
|
52
|
+
username: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parses url using URL constructor or fallback to anchor element.
|
|
56
|
+
* @param url
|
|
57
|
+
*/
|
|
58
|
+
declare function parseUrl(url: string): URLLike;
|
|
59
|
+
/**
|
|
60
|
+
* Parses url using URL constructor or fallback to anchor element and serialize
|
|
61
|
+
* it to a string.
|
|
62
|
+
*
|
|
63
|
+
* Performs the steps described in https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
|
|
64
|
+
*
|
|
65
|
+
* @param url
|
|
66
|
+
*/
|
|
67
|
+
declare function normalizeUrl(url: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Get element XPath
|
|
70
|
+
* @param target - target element
|
|
71
|
+
* @param optimised - when id attribute of element is present the xpath can be
|
|
72
|
+
* simplified to contain id
|
|
73
|
+
*/
|
|
74
|
+
declare function getElementXPath(target: any, optimised?: boolean): string;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if trace headers should be propagated
|
|
77
|
+
* @param spanUrl
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
declare function shouldPropagateTraceHeaders(spanUrl: string, propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls): boolean;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { URLLike, addSpanNetworkEvent, addSpanNetworkEvents, getElementXPath, getResource, hasKey, normalizeUrl, parseUrl, shouldPropagateTraceHeaders, sortResources };
|
|
83
|
+
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../src/utils.d.ts"],"mappings":";;;;;;;;iBAOwB,OAAO,kBAAkB,KAAK,GAAG,KAAK,cAAc,aAAa;;;;;;;;iBAQjE,oBAAoB,MAAM,IAAI,MAAM,yBAAyB,SAAS,oBAAoB,wBAAwB,IAAI;;;;iBAItH,qBAAqB,MAAM,IAAI,MAAM,UAAU,oBAAoB,+BAA+B,uBAAuB;;;;;iBAKzH,cAAc,mBAAmB,8BAA8B;;;;;;;;;;;iBAW/D,YAAY,iBAAiB,aAAa,IAAI,QAAQ,WAAW,IAAI,QAAQ,WAAW,6BAA6B,mBAAmB,QAAQ,4BAA4B,yBAAyB;;;;UAI5M;EACb;EACA;EACA;EACA;WACS;EACT;EACA;EACA;EACA;EACA;EACA;;;;;;iBAMoB,SAAS,cAAc;;;;;;;;;iBASvB,aAAa;;;;;;;iBAOb,gBAAgB,aAAa;;;;;;iBAM7B,4BAA4B,iBAAiB,+BAA+B"}
|