@opentelemetry/instrumentation-xml-http-request 0.200.0 → 0.201.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.
- package/README.md +33 -19
- package/build/esm/semconv.d.ts +93 -0
- package/build/esm/semconv.js +113 -0
- package/build/esm/semconv.js.map +1 -0
- package/build/esm/utils.d.ts +7 -0
- package/build/esm/utils.js +56 -0
- package/build/esm/utils.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esm/xhr.d.ts +3 -0
- package/build/esm/xhr.js +84 -25
- package/build/esm/xhr.js.map +1 -1
- package/build/esnext/semconv.d.ts +93 -0
- package/build/esnext/semconv.js +113 -0
- package/build/esnext/semconv.js.map +1 -0
- package/build/esnext/utils.d.ts +7 -0
- package/build/esnext/utils.js +56 -0
- package/build/esnext/utils.js.map +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/esnext/xhr.d.ts +3 -0
- package/build/esnext/xhr.js +84 -25
- package/build/esnext/xhr.js.map +1 -1
- package/build/src/semconv.d.ts +93 -0
- package/build/src/semconv.js +116 -0
- package/build/src/semconv.js.map +1 -0
- package/build/src/utils.d.ts +7 -0
- package/build/src/utils.js +59 -1
- package/build/src/utils.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/build/src/xhr.d.ts +3 -0
- package/build/src/xhr.js +82 -23
- package/build/src/xhr.js.map +1 -1
- package/package.json +10 -10
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ATTR_HTTP_USER_AGENT = exports.ATTR_HTTP_URL = exports.ATTR_HTTP_STATUS_CODE = exports.ATTR_HTTP_SCHEME = exports.ATTR_HTTP_RESPONSE_CONTENT_LENGTH = exports.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED = exports.ATTR_HTTP_REQUEST_BODY_SIZE = exports.ATTR_HTTP_METHOD = exports.ATTR_HTTP_HOST = void 0;
|
|
19
|
+
/*
|
|
20
|
+
* This file contains a copy of unstable semantic convention definitions
|
|
21
|
+
* used by this package.
|
|
22
|
+
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Deprecated, use one of `server.address`, `client.address` or `http.request.header.host` instead, depending on the usage.
|
|
26
|
+
*
|
|
27
|
+
* @example www.example.org
|
|
28
|
+
*
|
|
29
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated Replaced by one of `server.address`, `client.address` or `http.request.header.host`, depending on the usage.
|
|
32
|
+
*/
|
|
33
|
+
exports.ATTR_HTTP_HOST = 'http.host';
|
|
34
|
+
/**
|
|
35
|
+
* Deprecated, use `http.request.method` instead.
|
|
36
|
+
*
|
|
37
|
+
* @example GET
|
|
38
|
+
* @example POST
|
|
39
|
+
* @example HEAD
|
|
40
|
+
*
|
|
41
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
42
|
+
*
|
|
43
|
+
* @deprecated Replaced by `http.request.method`.
|
|
44
|
+
*/
|
|
45
|
+
exports.ATTR_HTTP_METHOD = 'http.method';
|
|
46
|
+
/**
|
|
47
|
+
* The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
|
|
48
|
+
*
|
|
49
|
+
* @example 3495
|
|
50
|
+
*
|
|
51
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
52
|
+
*/
|
|
53
|
+
exports.ATTR_HTTP_REQUEST_BODY_SIZE = 'http.request.body.size';
|
|
54
|
+
/**
|
|
55
|
+
* Deprecated, use `http.request.body.size` instead.
|
|
56
|
+
*
|
|
57
|
+
* @example 5493
|
|
58
|
+
*
|
|
59
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
60
|
+
*
|
|
61
|
+
* @deprecated Replaced by `http.request.body.size`.
|
|
62
|
+
*/
|
|
63
|
+
exports.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED = 'http.request_content_length_uncompressed';
|
|
64
|
+
/**
|
|
65
|
+
* Deprecated, use `http.response.header.<key>` instead.
|
|
66
|
+
*
|
|
67
|
+
* @example 3495
|
|
68
|
+
*
|
|
69
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
70
|
+
*
|
|
71
|
+
* @deprecated Replaced by `http.response.header.<key>`.
|
|
72
|
+
*/
|
|
73
|
+
exports.ATTR_HTTP_RESPONSE_CONTENT_LENGTH = 'http.response_content_length';
|
|
74
|
+
/**
|
|
75
|
+
* Deprecated, use `url.scheme` instead.
|
|
76
|
+
*
|
|
77
|
+
* @example http
|
|
78
|
+
* @example https
|
|
79
|
+
*
|
|
80
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
81
|
+
*
|
|
82
|
+
* @deprecated Replaced by `url.scheme` instead.
|
|
83
|
+
*/
|
|
84
|
+
exports.ATTR_HTTP_SCHEME = 'http.scheme';
|
|
85
|
+
/**
|
|
86
|
+
* Deprecated, use `http.response.status_code` instead.
|
|
87
|
+
*
|
|
88
|
+
* @example 200
|
|
89
|
+
*
|
|
90
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
91
|
+
*
|
|
92
|
+
* @deprecated Replaced by `http.response.status_code`.
|
|
93
|
+
*/
|
|
94
|
+
exports.ATTR_HTTP_STATUS_CODE = 'http.status_code';
|
|
95
|
+
/**
|
|
96
|
+
* Deprecated, use `url.full` instead.
|
|
97
|
+
*
|
|
98
|
+
* @example https://www.foo.bar/search?q=OpenTelemetry#SemConv
|
|
99
|
+
*
|
|
100
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
101
|
+
*
|
|
102
|
+
* @deprecated Replaced by `url.full`.
|
|
103
|
+
*/
|
|
104
|
+
exports.ATTR_HTTP_URL = 'http.url';
|
|
105
|
+
/**
|
|
106
|
+
* Deprecated, use `user_agent.original` instead.
|
|
107
|
+
*
|
|
108
|
+
* @example CERN-LineMode/2.15 libwww/2.17b3
|
|
109
|
+
* @example Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1
|
|
110
|
+
*
|
|
111
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
112
|
+
*
|
|
113
|
+
* @deprecated Replaced by `user_agent.original`.
|
|
114
|
+
*/
|
|
115
|
+
exports.ATTR_HTTP_USER_AGENT = 'http.user_agent';
|
|
116
|
+
//# sourceMappingURL=semconv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH;;;;;;;;GAQG;AACU,QAAA,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;;;;;GAUG;AACU,QAAA,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;;;GAMG;AACU,QAAA,2BAA2B,GAAG,wBAAiC,CAAC;AAE7E;;;;;;;;GAQG;AACU,QAAA,6CAA6C,GACxD,0CAAmD,CAAC;AAEtD;;;;;;;;GAQG;AACU,QAAA,iCAAiC,GAC5C,8BAAuC,CAAC;AAE1C;;;;;;;;;GASG;AACU,QAAA,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;;;;;GAQG;AACU,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG,UAAmB,CAAC;AAEjD;;;;;;;;;GASG;AACU,QAAA,oBAAoB,GAAG,iBAA0B,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/*\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 one of `server.address`, `client.address` or `http.request.header.host` instead, depending on the usage.\n *\n * @example www.example.org\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 one of `server.address`, `client.address` or `http.request.header.host`, depending on the usage.\n */\nexport const ATTR_HTTP_HOST = 'http.host' as const;\n\n/**\n * Deprecated, use `http.request.method` instead.\n *\n * @example GET\n * @example POST\n * @example HEAD\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.request.method`.\n */\nexport const ATTR_HTTP_METHOD = 'http.method' as const;\n\n/**\n * The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.\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 */\nexport const ATTR_HTTP_REQUEST_BODY_SIZE = 'http.request.body.size' as const;\n\n/**\n * Deprecated, use `http.request.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 Replaced by `http.request.body.size`.\n */\nexport const ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED =\n 'http.request_content_length_uncompressed' as const;\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 `url.scheme` instead.\n *\n * @example http\n * @example https\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 `url.scheme` instead.\n */\nexport const ATTR_HTTP_SCHEME = 'http.scheme' as const;\n\n/**\n * Deprecated, use `http.response.status_code` instead.\n *\n * @example 200\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.status_code`.\n */\nexport const ATTR_HTTP_STATUS_CODE = 'http.status_code' as const;\n\n/**\n * Deprecated, use `url.full` instead.\n *\n * @example https://www.foo.bar/search?q=OpenTelemetry#SemConv\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 `url.full`.\n */\nexport const ATTR_HTTP_URL = 'http.url' as const;\n\n/**\n * Deprecated, use `user_agent.original` instead.\n *\n * @example CERN-LineMode/2.15 libwww/2.17b3\n * @example Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1\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 `user_agent.original`.\n */\nexport const ATTR_HTTP_USER_AGENT = 'http.user_agent' as const;\n"]}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { URLLike } from '@opentelemetry/sdk-trace-web';
|
|
1
2
|
/**
|
|
2
3
|
* Helper function to determine payload content length for XHR requests
|
|
3
4
|
* @param body
|
|
4
5
|
* @returns content length
|
|
5
6
|
*/
|
|
6
7
|
export declare function getXHRBodyLength(body: Document | XMLHttpRequestBodyInit): number | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Normalize an HTTP request method string per `http.request.method` spec
|
|
10
|
+
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeHttpRequestMethod(method: string): string;
|
|
13
|
+
export declare function serverPortFromUrl(url: URLLike): number | undefined;
|
|
7
14
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/src/utils.js
CHANGED
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getXHRBodyLength = void 0;
|
|
18
|
+
exports.serverPortFromUrl = exports.normalizeHttpRequestMethod = exports.getXHRBodyLength = void 0;
|
|
19
19
|
// Much of the logic here overlaps with the same utils file in opentelemetry-instrumentation-fetch
|
|
20
20
|
// These may be unified in the future.
|
|
21
21
|
const api = require("@opentelemetry/api");
|
|
22
|
+
const core_1 = require("@opentelemetry/core");
|
|
22
23
|
const DIAG_LOGGER = api.diag.createComponentLogger({
|
|
23
24
|
namespace: '@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils',
|
|
24
25
|
});
|
|
@@ -72,4 +73,61 @@ function getFormDataSize(formData) {
|
|
|
72
73
|
}
|
|
73
74
|
return size;
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Normalize an HTTP request method string per `http.request.method` spec
|
|
78
|
+
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span
|
|
79
|
+
*/
|
|
80
|
+
function normalizeHttpRequestMethod(method) {
|
|
81
|
+
const knownMethods = getKnownMethods();
|
|
82
|
+
const methUpper = method.toUpperCase();
|
|
83
|
+
if (methUpper in knownMethods) {
|
|
84
|
+
return methUpper;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return '_OTHER';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.normalizeHttpRequestMethod = normalizeHttpRequestMethod;
|
|
91
|
+
const DEFAULT_KNOWN_METHODS = {
|
|
92
|
+
CONNECT: true,
|
|
93
|
+
DELETE: true,
|
|
94
|
+
GET: true,
|
|
95
|
+
HEAD: true,
|
|
96
|
+
OPTIONS: true,
|
|
97
|
+
PATCH: true,
|
|
98
|
+
POST: true,
|
|
99
|
+
PUT: true,
|
|
100
|
+
TRACE: true,
|
|
101
|
+
};
|
|
102
|
+
let knownMethods;
|
|
103
|
+
function getKnownMethods() {
|
|
104
|
+
if (knownMethods === undefined) {
|
|
105
|
+
const cfgMethods = (0, core_1.getStringListFromEnv)('OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS');
|
|
106
|
+
if (cfgMethods && cfgMethods.length > 0) {
|
|
107
|
+
knownMethods = {};
|
|
108
|
+
cfgMethods.forEach(m => {
|
|
109
|
+
knownMethods[m] = true;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
knownMethods = DEFAULT_KNOWN_METHODS;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return knownMethods;
|
|
117
|
+
}
|
|
118
|
+
const HTTP_PORT_FROM_PROTOCOL = {
|
|
119
|
+
'https:': '443',
|
|
120
|
+
'http:': '80',
|
|
121
|
+
};
|
|
122
|
+
function serverPortFromUrl(url) {
|
|
123
|
+
const serverPort = Number(url.port || HTTP_PORT_FROM_PROTOCOL[url.protocol]);
|
|
124
|
+
// Guard with `if (serverPort)` because `Number('') === 0`.
|
|
125
|
+
if (serverPort && !isNaN(serverPort)) {
|
|
126
|
+
return serverPort;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.serverPortFromUrl = serverPortFromUrl;
|
|
75
133
|
//# sourceMappingURL=utils.js.map
|
package/build/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,kGAAkG;AAClG,sCAAsC;AAEtC,0CAA0C;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,kGAAkG;AAClG,sCAAsC;AAEtC,0CAA0C;AAC1C,8CAA2D;AAG3D,MAAM,WAAW,GAAG,GAA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ACzD,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,IAAI;CACd,CAAC;AACF,SAAgB,iBAAiB,CAAC,GAAY;IAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7E,2DAA2D;IAC3D,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;QACpC,OAAO,UAAU,CAAC;KACnB;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AARD,8CAQC","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// Much of the logic here overlaps with the same utils file in opentelemetry-instrumentation-fetch\n// These may be unified in the future.\n\nimport * as api from '@opentelemetry/api';\nimport { getStringListFromEnv } from '@opentelemetry/core';\nimport { URLLike } from '@opentelemetry/sdk-trace-web';\n\nconst DIAG_LOGGER = api.diag.createComponentLogger({\n namespace:\n '@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils',\n});\n\nfunction isDocument(value: unknown): value is Document {\n return typeof Document !== 'undefined' && value instanceof Document;\n}\n\n/**\n * Helper function to determine payload content length for XHR requests\n * @param body\n * @returns content length\n */\nexport function getXHRBodyLength(\n body: Document | XMLHttpRequestBodyInit\n): number | undefined {\n if (isDocument(body)) {\n return new XMLSerializer().serializeToString(document).length;\n }\n\n // XMLHttpRequestBodyInit expands to the following:\n if (typeof body === 'string') {\n return getByteLength(body);\n }\n\n if (body instanceof Blob) {\n return body.size;\n }\n\n if (body instanceof FormData) {\n return getFormDataSize(body);\n }\n\n if (body instanceof URLSearchParams) {\n return getByteLength(body.toString());\n }\n\n // ArrayBuffer | ArrayBufferView\n if (body.byteLength !== undefined) {\n return body.byteLength;\n }\n\n DIAG_LOGGER.warn('unknown body type');\n return undefined;\n}\n\nconst TEXT_ENCODER = new TextEncoder();\nfunction getByteLength(s: string): number {\n return TEXT_ENCODER.encode(s).byteLength;\n}\n\nfunction getFormDataSize(formData: FormData): number {\n let size = 0;\n for (const [key, value] of formData.entries()) {\n size += key.length;\n if (value instanceof Blob) {\n size += value.size;\n } else {\n size += value.length;\n }\n }\n return size;\n}\n\n/**\n * Normalize an HTTP request method string per `http.request.method` spec\n * https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span\n */\nexport function normalizeHttpRequestMethod(method: string): string {\n const knownMethods = getKnownMethods();\n const methUpper = method.toUpperCase();\n if (methUpper in knownMethods) {\n return methUpper;\n } else {\n return '_OTHER';\n }\n}\n\nconst DEFAULT_KNOWN_METHODS = {\n CONNECT: true,\n DELETE: true,\n GET: true,\n HEAD: true,\n OPTIONS: true,\n PATCH: true,\n POST: true,\n PUT: true,\n TRACE: true,\n};\nlet knownMethods: { [key: string]: boolean };\nfunction getKnownMethods() {\n if (knownMethods === undefined) {\n const cfgMethods = getStringListFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS'\n );\n if (cfgMethods && cfgMethods.length > 0) {\n knownMethods = {};\n cfgMethods.forEach(m => {\n knownMethods[m] = true;\n });\n } else {\n knownMethods = DEFAULT_KNOWN_METHODS;\n }\n }\n return knownMethods;\n}\n\nconst HTTP_PORT_FROM_PROTOCOL: { [key: string]: string } = {\n 'https:': '443',\n 'http:': '80',\n};\nexport function serverPortFromUrl(url: URLLike): number | undefined {\n const serverPort = Number(url.port || HTTP_PORT_FROM_PROTOCOL[url.protocol]);\n // Guard with `if (serverPort)` because `Number('') === 0`.\n if (serverPort && !isNaN(serverPort)) {\n return serverPort;\n } else {\n return undefined;\n }\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.201.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,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 = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,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 = '0.201.1';\n"]}
|
package/build/src/xhr.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface XMLHttpRequestInstrumentationConfig extends InstrumentationConf
|
|
|
28
28
|
ignoreNetworkEvents?: boolean;
|
|
29
29
|
/** Measure outgoing request size */
|
|
30
30
|
measureRequestSize?: boolean;
|
|
31
|
+
/** Select the HTTP semantic conventions version(s) used. */
|
|
32
|
+
semconvStabilityOptIn?: string;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* This class represents a XMLHttpRequest plugin for auto instrumentation
|
|
@@ -39,6 +41,7 @@ export declare class XMLHttpRequestInstrumentation extends InstrumentationBase<X
|
|
|
39
41
|
private _tasksCount;
|
|
40
42
|
private _xhrMem;
|
|
41
43
|
private _usedResources;
|
|
44
|
+
private _semconvStability;
|
|
42
45
|
constructor(config?: XMLHttpRequestInstrumentationConfig);
|
|
43
46
|
init(): void;
|
|
44
47
|
/**
|
package/build/src/xhr.js
CHANGED
|
@@ -19,8 +19,9 @@ exports.XMLHttpRequestInstrumentation = void 0;
|
|
|
19
19
|
const api = require("@opentelemetry/api");
|
|
20
20
|
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
21
21
|
const core_1 = require("@opentelemetry/core");
|
|
22
|
-
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
23
22
|
const sdk_trace_web_1 = require("@opentelemetry/sdk-trace-web");
|
|
23
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
24
|
+
const semconv_1 = require("./semconv");
|
|
24
25
|
const EventNames_1 = require("./enums/EventNames");
|
|
25
26
|
const utils_1 = require("./utils");
|
|
26
27
|
const version_1 = require("./version");
|
|
@@ -40,8 +41,10 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
40
41
|
_tasksCount = 0;
|
|
41
42
|
_xhrMem = new WeakMap();
|
|
42
43
|
_usedResources = new WeakSet();
|
|
44
|
+
_semconvStability;
|
|
43
45
|
constructor(config = {}) {
|
|
44
46
|
super('@opentelemetry/instrumentation-xml-http-request', version_1.VERSION, config);
|
|
47
|
+
this._semconvStability = (0, instrumentation_1.semconvStabilityFromStr)('http', config?.semconvStabilityOptIn);
|
|
45
48
|
}
|
|
46
49
|
init() { }
|
|
47
50
|
/**
|
|
@@ -77,7 +80,8 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
77
80
|
const childSpan = this.tracer.startSpan('CORS Preflight', {
|
|
78
81
|
startTime: corsPreFlightRequest[sdk_trace_web_1.PerformanceTimingNames.FETCH_START],
|
|
79
82
|
});
|
|
80
|
-
|
|
83
|
+
const skipOldSemconvContentLengthAttrs = !(this._semconvStability & instrumentation_1.SemconvStability.OLD);
|
|
84
|
+
(0, sdk_trace_web_1.addSpanNetworkEvents)(childSpan, corsPreFlightRequest, this.getConfig().ignoreNetworkEvents, undefined, skipOldSemconvContentLengthAttrs);
|
|
81
85
|
childSpan.end(corsPreFlightRequest[sdk_trace_web_1.PerformanceTimingNames.RESPONSE_END]);
|
|
82
86
|
});
|
|
83
87
|
}
|
|
@@ -89,19 +93,29 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
89
93
|
* @private
|
|
90
94
|
*/
|
|
91
95
|
_addFinalSpanAttributes(span, xhrMem, spanUrl) {
|
|
92
|
-
if (
|
|
93
|
-
const parsedUrl = (0, sdk_trace_web_1.parseUrl)(spanUrl);
|
|
96
|
+
if (this._semconvStability & instrumentation_1.SemconvStability.OLD) {
|
|
94
97
|
if (xhrMem.status !== undefined) {
|
|
95
|
-
span.setAttribute(
|
|
98
|
+
span.setAttribute(semconv_1.ATTR_HTTP_STATUS_CODE, xhrMem.status);
|
|
96
99
|
}
|
|
97
100
|
if (xhrMem.statusText !== undefined) {
|
|
98
101
|
span.setAttribute(AttributeNames_1.AttributeNames.HTTP_STATUS_TEXT, xhrMem.statusText);
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
if (typeof spanUrl === 'string') {
|
|
104
|
+
const parsedUrl = (0, sdk_trace_web_1.parseUrl)(spanUrl);
|
|
105
|
+
span.setAttribute(semconv_1.ATTR_HTTP_HOST, parsedUrl.host);
|
|
106
|
+
span.setAttribute(semconv_1.ATTR_HTTP_SCHEME, parsedUrl.protocol.replace(':', ''));
|
|
107
|
+
}
|
|
102
108
|
// @TODO do we want to collect this or it will be collected earlier once only or
|
|
103
109
|
// maybe when parent span is not available ?
|
|
104
|
-
span.setAttribute(
|
|
110
|
+
span.setAttribute(semconv_1.ATTR_HTTP_USER_AGENT, navigator.userAgent);
|
|
111
|
+
}
|
|
112
|
+
if (this._semconvStability & instrumentation_1.SemconvStability.STABLE) {
|
|
113
|
+
if (xhrMem.status) {
|
|
114
|
+
// Intentionally exclude status=0, because XHR uses 0 for before a
|
|
115
|
+
// response is received and semconv says to only add the attribute if
|
|
116
|
+
// received a response.
|
|
117
|
+
span.setAttribute(semantic_conventions_1.ATTR_HTTP_RESPONSE_STATUS_CODE, xhrMem.status);
|
|
118
|
+
}
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
_applyAttributesAfterXHR(span, xhr) {
|
|
@@ -186,7 +200,8 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
186
200
|
this._addChildSpan(span, corsPreFlightRequest);
|
|
187
201
|
this._markResourceAsUsed(corsPreFlightRequest);
|
|
188
202
|
}
|
|
189
|
-
|
|
203
|
+
const skipOldSemconvContentLengthAttrs = !(this._semconvStability & instrumentation_1.SemconvStability.OLD);
|
|
204
|
+
(0, sdk_trace_web_1.addSpanNetworkEvents)(span, mainRequest, this.getConfig().ignoreNetworkEvents, undefined, skipOldSemconvContentLengthAttrs);
|
|
190
205
|
}
|
|
191
206
|
}
|
|
192
207
|
/**
|
|
@@ -217,13 +232,36 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
217
232
|
this._diag.debug('ignoring span as url matches ignored url');
|
|
218
233
|
return;
|
|
219
234
|
}
|
|
220
|
-
|
|
221
|
-
const
|
|
235
|
+
let name = '';
|
|
236
|
+
const parsedUrl = (0, sdk_trace_web_1.parseUrl)(url);
|
|
237
|
+
const attributes = {};
|
|
238
|
+
if (this._semconvStability & instrumentation_1.SemconvStability.OLD) {
|
|
239
|
+
name = method.toUpperCase();
|
|
240
|
+
attributes[semconv_1.ATTR_HTTP_METHOD] = method;
|
|
241
|
+
attributes[semconv_1.ATTR_HTTP_URL] = parsedUrl.toString();
|
|
242
|
+
}
|
|
243
|
+
if (this._semconvStability & instrumentation_1.SemconvStability.STABLE) {
|
|
244
|
+
const origMethod = method;
|
|
245
|
+
const normMethod = (0, utils_1.normalizeHttpRequestMethod)(method);
|
|
246
|
+
if (!name) {
|
|
247
|
+
// The "old" span name wins if emitting both old and stable semconv
|
|
248
|
+
// ('http/dup').
|
|
249
|
+
name = normMethod;
|
|
250
|
+
}
|
|
251
|
+
attributes[semantic_conventions_1.ATTR_HTTP_REQUEST_METHOD] = normMethod;
|
|
252
|
+
if (normMethod !== origMethod) {
|
|
253
|
+
attributes[semantic_conventions_1.ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = origMethod;
|
|
254
|
+
}
|
|
255
|
+
attributes[semantic_conventions_1.ATTR_URL_FULL] = parsedUrl.toString();
|
|
256
|
+
attributes[semantic_conventions_1.ATTR_SERVER_ADDRESS] = parsedUrl.hostname;
|
|
257
|
+
const serverPort = (0, utils_1.serverPortFromUrl)(parsedUrl);
|
|
258
|
+
if (serverPort) {
|
|
259
|
+
attributes[semantic_conventions_1.ATTR_SERVER_PORT] = serverPort;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const currentSpan = this.tracer.startSpan(name, {
|
|
222
263
|
kind: api.SpanKind.CLIENT,
|
|
223
|
-
attributes
|
|
224
|
-
[semantic_conventions_1.SEMATTRS_HTTP_METHOD]: method,
|
|
225
|
-
[semantic_conventions_1.SEMATTRS_HTTP_URL]: (0, sdk_trace_web_1.parseUrl)(url).toString(),
|
|
226
|
-
},
|
|
264
|
+
attributes,
|
|
227
265
|
});
|
|
228
266
|
currentSpan.addEvent(EventNames_1.EventNames.METHOD_OPEN);
|
|
229
267
|
this._cleanPreviousSpanInformation(xhr);
|
|
@@ -279,7 +317,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
279
317
|
}
|
|
280
318
|
plugin._clearResources();
|
|
281
319
|
}
|
|
282
|
-
function endSpan(eventName, xhr) {
|
|
320
|
+
function endSpan(eventName, xhr, isError, errorType) {
|
|
283
321
|
const xhrMem = plugin._xhrMem.get(xhr);
|
|
284
322
|
if (!xhrMem) {
|
|
285
323
|
return;
|
|
@@ -288,7 +326,23 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
288
326
|
xhrMem.statusText = xhr.statusText;
|
|
289
327
|
plugin._xhrMem.delete(xhr);
|
|
290
328
|
if (xhrMem.span) {
|
|
291
|
-
|
|
329
|
+
const span = xhrMem.span;
|
|
330
|
+
plugin._applyAttributesAfterXHR(span, xhr);
|
|
331
|
+
if (plugin._semconvStability & instrumentation_1.SemconvStability.STABLE) {
|
|
332
|
+
if (isError) {
|
|
333
|
+
if (errorType) {
|
|
334
|
+
span.setStatus({
|
|
335
|
+
code: api.SpanStatusCode.ERROR,
|
|
336
|
+
message: errorType,
|
|
337
|
+
});
|
|
338
|
+
span.setAttribute(semantic_conventions_1.ATTR_ERROR_TYPE, errorType);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else if (xhrMem.status && xhrMem.status >= 400) {
|
|
342
|
+
span.setStatus({ code: api.SpanStatusCode.ERROR });
|
|
343
|
+
span.setAttribute(semantic_conventions_1.ATTR_ERROR_TYPE, String(xhrMem.status));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
292
346
|
}
|
|
293
347
|
const performanceEndTime = (0, core_1.hrTime)();
|
|
294
348
|
const endTime = Date.now();
|
|
@@ -300,20 +354,20 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
300
354
|
}, OBSERVER_WAIT_TIME_MS);
|
|
301
355
|
}
|
|
302
356
|
function onError() {
|
|
303
|
-
endSpan(EventNames_1.EventNames.EVENT_ERROR, this);
|
|
357
|
+
endSpan(EventNames_1.EventNames.EVENT_ERROR, this, true, 'error');
|
|
304
358
|
}
|
|
305
359
|
function onAbort() {
|
|
306
|
-
endSpan(EventNames_1.EventNames.EVENT_ABORT, this);
|
|
360
|
+
endSpan(EventNames_1.EventNames.EVENT_ABORT, this, false);
|
|
307
361
|
}
|
|
308
362
|
function onTimeout() {
|
|
309
|
-
endSpan(EventNames_1.EventNames.EVENT_TIMEOUT, this);
|
|
363
|
+
endSpan(EventNames_1.EventNames.EVENT_TIMEOUT, this, true, 'timeout');
|
|
310
364
|
}
|
|
311
365
|
function onLoad() {
|
|
312
366
|
if (this.status < 299) {
|
|
313
|
-
endSpan(EventNames_1.EventNames.EVENT_LOAD, this);
|
|
367
|
+
endSpan(EventNames_1.EventNames.EVENT_LOAD, this, false);
|
|
314
368
|
}
|
|
315
369
|
else {
|
|
316
|
-
endSpan(EventNames_1.EventNames.EVENT_ERROR, this);
|
|
370
|
+
endSpan(EventNames_1.EventNames.EVENT_ERROR, this, false);
|
|
317
371
|
}
|
|
318
372
|
}
|
|
319
373
|
function unregister(xhr) {
|
|
@@ -339,7 +393,12 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
339
393
|
const body = args[0];
|
|
340
394
|
const bodyLength = (0, utils_1.getXHRBodyLength)(body);
|
|
341
395
|
if (bodyLength !== undefined) {
|
|
342
|
-
|
|
396
|
+
if (plugin._semconvStability & instrumentation_1.SemconvStability.OLD) {
|
|
397
|
+
currentSpan.setAttribute(semconv_1.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, bodyLength);
|
|
398
|
+
}
|
|
399
|
+
if (plugin._semconvStability & instrumentation_1.SemconvStability.STABLE) {
|
|
400
|
+
currentSpan.setAttribute(semconv_1.ATTR_HTTP_REQUEST_BODY_SIZE, bodyLength);
|
|
401
|
+
}
|
|
343
402
|
}
|
|
344
403
|
}
|
|
345
404
|
api.context.with(api.trace.setSpan(api.context.active(), currentSpan), () => {
|
package/build/src/xhr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../src/xhr.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,0CAA0C;AAC1C,oEAKwC;AACxC,8CAA0E;AAC1E,8EAQ6C;AAC7C,gEAMsC;AACtC,mDAAgD;AAOhD,mCAA2C;AAC3C,uCAAoC;AACpC,2DAAwD;AAExD,uEAAuE;AACvE,2DAA2D;AAC3D,kEAAkE;AAClE,cAAc;AACd,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAoClC;;GAEG;AACH,MAAa,6BAA8B,SAAQ,qCAAwD;IAChG,SAAS,GAAW,kBAAkB,CAAC;IACvC,OAAO,GAAW,iBAAO,CAAC;IACnC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;IAEpB,WAAW,GAAG,CAAC,CAAC;IAChB,OAAO,GAAG,IAAI,OAAO,EAA0B,CAAC;IAChD,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IAElE,YAAY,SAA8C,EAAE;QAC1D,KAAK,CAAC,iDAAiD,EAAE,iBAAO,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,KAAI,CAAC;IAET;;;;;OAKG;IACK,WAAW,CAAC,GAAmB,EAAE,OAAe;QACtD,MAAM,GAAG,GAAG,IAAA,wBAAQ,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC;QACnC,IACE,CAAC,IAAA,2CAA2B,EAC1B,GAAG,EACH,IAAI,CAAC,SAAS,EAAE,CAAC,4BAA4B,CAC9C,EACD;YACA,MAAM,OAAO,GAAqC,EAAE,CAAC;YACrD,GAAG,CAAC,WAAW,CAAC,MAAM,CAA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,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;SAC9D;QAED,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACM,OAAO;QACd,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEvE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAE/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAA0B,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IACjE,CAAC;CACF;AA1dD,sEA0dC","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 * as api from '@opentelemetry/api';\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationConfig,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { hrTime, isUrlIgnored, otperformance } from '@opentelemetry/core';\nimport {\n SEMATTRS_HTTP_HOST,\n SEMATTRS_HTTP_METHOD,\n SEMATTRS_HTTP_SCHEME,\n SEMATTRS_HTTP_STATUS_CODE,\n SEMATTRS_HTTP_URL,\n SEMATTRS_HTTP_USER_AGENT,\n SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,\n} from '@opentelemetry/semantic-conventions';\nimport {\n addSpanNetworkEvents,\n getResource,\n PerformanceTimingNames as PTN,\n shouldPropagateTraceHeaders,\n parseUrl,\n} from '@opentelemetry/sdk-trace-web';\nimport { EventNames } from './enums/EventNames';\nimport {\n OpenFunction,\n PropagateTraceHeaderCorsUrls,\n SendFunction,\n XhrMem,\n} from './types';\nimport { getXHRBodyLength } from './utils';\nimport { VERSION } from './version';\nimport { AttributeNames } from './enums/AttributeNames';\n\n// how long to wait for observer to collect information about resources\n// this is needed as event \"load\" is called before observer\n// hard to say how long it should really wait, seems like 300ms is\n// safe enough\nconst OBSERVER_WAIT_TIME_MS = 300;\n\nexport type XHRCustomAttributeFunction = (\n span: api.Span,\n xhr: XMLHttpRequest\n) => void;\n\n/**\n * XMLHttpRequest config\n */\nexport interface XMLHttpRequestInstrumentationConfig\n extends InstrumentationConfig {\n /**\n * The number of timing resources is limited, after the limit\n * (chrome 250, safari 150) the information is not collected anymore.\n * The only way to prevent that is to regularly clean the resources\n * whenever it is possible. This is needed only when PerformanceObserver\n * is not available\n */\n clearTimingResources?: boolean;\n /** URLs which should include trace headers when origin doesn't match */\n propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls;\n /**\n * URLs that partially match any regex in ignoreUrls will not be traced.\n * In addition, URLs that are _exact matches_ of strings in ignoreUrls will\n * also not be traced.\n */\n ignoreUrls?: Array<string | RegExp>;\n /** Function for adding custom attributes on the span */\n applyCustomAttributesOnSpan?: XHRCustomAttributeFunction;\n /** Ignore adding network events as span events */\n ignoreNetworkEvents?: boolean;\n /** Measure outgoing request size */\n measureRequestSize?: boolean;\n}\n\n/**\n * This class represents a XMLHttpRequest plugin for auto instrumentation\n */\nexport class XMLHttpRequestInstrumentation extends InstrumentationBase<XMLHttpRequestInstrumentationConfig> {\n readonly component: string = 'xml-http-request';\n readonly version: string = VERSION;\n moduleName = this.component;\n\n private _tasksCount = 0;\n private _xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n private _usedResources = new WeakSet<PerformanceResourceTiming>();\n\n constructor(config: XMLHttpRequestInstrumentationConfig = {}) {\n super('@opentelemetry/instrumentation-xml-http-request', VERSION, config);\n }\n\n init() {}\n\n /**\n * Adds custom headers to XMLHttpRequest\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addHeaders(xhr: XMLHttpRequest, spanUrl: string) {\n const url = parseUrl(spanUrl).href;\n if (\n !shouldPropagateTraceHeaders(\n url,\n this.getConfig().propagateTraceHeaderCorsUrls\n )\n ) {\n const headers: Partial<Record<string, unknown>> = {};\n api.propagation.inject(api.context.active(), headers);\n if (Object.keys(headers).length > 0) {\n this._diag.debug('headers inject skipped due to CORS policy');\n }\n return;\n }\n const headers: { [key: string]: unknown } = {};\n api.propagation.inject(api.context.active(), headers);\n Object.keys(headers).forEach(key => {\n xhr.setRequestHeader(key, String(headers[key]));\n });\n }\n\n /**\n * Add cors pre flight child span\n * @param span\n * @param corsPreFlightRequest\n * @private\n */\n private _addChildSpan(\n span: api.Span,\n corsPreFlightRequest: PerformanceResourceTiming\n ): void {\n api.context.with(api.trace.setSpan(api.context.active(), span), () => {\n const childSpan = this.tracer.startSpan('CORS Preflight', {\n startTime: corsPreFlightRequest[PTN.FETCH_START],\n });\n addSpanNetworkEvents(\n childSpan,\n corsPreFlightRequest,\n this.getConfig().ignoreNetworkEvents\n );\n childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);\n });\n }\n\n /**\n * Add attributes when span is going to end\n * @param span\n * @param xhr\n * @param spanUrl\n * @private\n */\n _addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem, spanUrl?: string) {\n if (typeof spanUrl === 'string') {\n const parsedUrl = parseUrl(spanUrl);\n if (xhrMem.status !== undefined) {\n span.setAttribute(SEMATTRS_HTTP_STATUS_CODE, xhrMem.status);\n }\n if (xhrMem.statusText !== undefined) {\n span.setAttribute(AttributeNames.HTTP_STATUS_TEXT, xhrMem.statusText);\n }\n span.setAttribute(SEMATTRS_HTTP_HOST, parsedUrl.host);\n span.setAttribute(\n SEMATTRS_HTTP_SCHEME,\n parsedUrl.protocol.replace(':', '')\n );\n\n // @TODO do we want to collect this or it will be collected earlier once only or\n // maybe when parent span is not available ?\n span.setAttribute(SEMATTRS_HTTP_USER_AGENT, navigator.userAgent);\n }\n }\n\n private _applyAttributesAfterXHR(span: api.Span, xhr: XMLHttpRequest) {\n const applyCustomAttributesOnSpan =\n this.getConfig().applyCustomAttributesOnSpan;\n if (typeof applyCustomAttributesOnSpan === 'function') {\n safeExecuteInTheMiddle(\n () => applyCustomAttributesOnSpan(span, xhr),\n error => {\n if (!error) {\n return;\n }\n\n this._diag.error('applyCustomAttributesOnSpan', error);\n },\n true\n );\n }\n }\n\n /**\n * will collect information about all resources created\n * between \"send\" and \"end\" with additional waiting for main resource\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addResourceObserver(xhr: XMLHttpRequest, spanUrl: string) {\n const xhrMem = this._xhrMem.get(xhr);\n if (\n !xhrMem ||\n typeof PerformanceObserver !== 'function' ||\n typeof PerformanceResourceTiming !== 'function'\n ) {\n return;\n }\n xhrMem.createdResources = {\n observer: new PerformanceObserver(list => {\n const entries = list.getEntries() as PerformanceResourceTiming[];\n const parsedUrl = parseUrl(spanUrl);\n\n entries.forEach(entry => {\n if (\n entry.initiatorType === 'xmlhttprequest' &&\n entry.name === parsedUrl.href\n ) {\n if (xhrMem.createdResources) {\n xhrMem.createdResources.entries.push(entry);\n }\n }\n });\n }),\n entries: [],\n };\n xhrMem.createdResources.observer.observe({\n entryTypes: ['resource'],\n });\n }\n\n /**\n * Clears the resource timings and all resources assigned with spans\n * when {@link XMLHttpRequestInstrumentationConfig.clearTimingResources} is\n * set to true (default false)\n * @private\n */\n private _clearResources() {\n if (this._tasksCount === 0 && this.getConfig().clearTimingResources) {\n (otperformance as unknown as Performance).clearResourceTimings();\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n }\n\n /**\n * Finds appropriate resource and add network events to the span\n * @param span\n */\n private _findResourceAndAddNetworkEvents(\n xhrMem: XhrMem,\n span: api.Span,\n spanUrl?: string,\n startTime?: api.HrTime,\n endTime?: api.HrTime\n ): void {\n if (!spanUrl || !startTime || !endTime || !xhrMem.createdResources) {\n return;\n }\n\n let resources: PerformanceResourceTiming[] =\n xhrMem.createdResources.entries;\n\n if (!resources || !resources.length) {\n // fallback - either Observer is not available or it took longer\n // then OBSERVER_WAIT_TIME_MS and observer didn't collect enough\n // information\n // ts thinks this is the perf_hooks module, but it is the browser performance api\n resources = (otperformance as unknown as Performance).getEntriesByType(\n 'resource'\n ) as PerformanceResourceTiming[];\n }\n\n const resource = getResource(\n parseUrl(spanUrl).href,\n startTime,\n endTime,\n resources,\n this._usedResources\n );\n\n if (resource.mainRequest) {\n const mainRequest = resource.mainRequest;\n this._markResourceAsUsed(mainRequest);\n\n const corsPreFlightRequest = resource.corsPreFlightRequest;\n if (corsPreFlightRequest) {\n this._addChildSpan(span, corsPreFlightRequest);\n this._markResourceAsUsed(corsPreFlightRequest);\n }\n addSpanNetworkEvents(\n span,\n mainRequest,\n this.getConfig().ignoreNetworkEvents\n );\n }\n }\n\n /**\n * Removes the previous information about span.\n * This might happened when the same xhr is used again.\n * @param xhr\n * @private\n */\n private _cleanPreviousSpanInformation(xhr: XMLHttpRequest) {\n const xhrMem = this._xhrMem.get(xhr);\n if (xhrMem) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n if (callbackToRemoveEvents) {\n callbackToRemoveEvents();\n }\n this._xhrMem.delete(xhr);\n }\n }\n\n /**\n * Creates a new span when method \"open\" is called\n * @param xhr\n * @param url\n * @param method\n * @private\n */\n private _createSpan(\n xhr: XMLHttpRequest,\n url: string,\n method: string\n ): api.Span | undefined {\n if (isUrlIgnored(url, this.getConfig().ignoreUrls)) {\n this._diag.debug('ignoring span as url matches ignored url');\n return;\n }\n const spanName = method.toUpperCase();\n\n const currentSpan = this.tracer.startSpan(spanName, {\n kind: api.SpanKind.CLIENT,\n attributes: {\n [SEMATTRS_HTTP_METHOD]: method,\n [SEMATTRS_HTTP_URL]: parseUrl(url).toString(),\n },\n });\n\n currentSpan.addEvent(EventNames.METHOD_OPEN);\n\n this._cleanPreviousSpanInformation(xhr);\n\n this._xhrMem.set(xhr, {\n span: currentSpan,\n spanUrl: url,\n });\n\n return currentSpan;\n }\n\n /**\n * Marks certain [resource]{@link PerformanceResourceTiming} when information\n * from this is used to add events to span.\n * This is done to avoid reusing the same resource again for next span\n * @param resource\n * @private\n */\n private _markResourceAsUsed(resource: PerformanceResourceTiming) {\n this._usedResources.add(resource);\n }\n\n /**\n * Patches the method open\n * @private\n */\n protected _patchOpen() {\n return (original: OpenFunction): OpenFunction => {\n const plugin = this;\n return function patchOpen(this: XMLHttpRequest, ...args): void {\n const method: string = args[0];\n const url: string = args[1];\n plugin._createSpan(this, url, method);\n\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * Patches the method send\n * @private\n */\n protected _patchSend() {\n const plugin = this;\n\n function endSpanTimeout(\n eventName: string,\n xhrMem: XhrMem,\n performanceEndTime: api.HrTime,\n endTime: number\n ) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n\n if (typeof callbackToRemoveEvents === 'function') {\n callbackToRemoveEvents();\n }\n\n const { span, spanUrl, sendStartTime } = xhrMem;\n\n if (span) {\n plugin._findResourceAndAddNetworkEvents(\n xhrMem,\n span,\n spanUrl,\n sendStartTime,\n performanceEndTime\n );\n span.addEvent(eventName, endTime);\n plugin._addFinalSpanAttributes(span, xhrMem, spanUrl);\n span.end(endTime);\n plugin._tasksCount--;\n }\n plugin._clearResources();\n }\n\n function endSpan(eventName: string, xhr: XMLHttpRequest) {\n const xhrMem = plugin._xhrMem.get(xhr);\n if (!xhrMem) {\n return;\n }\n xhrMem.status = xhr.status;\n xhrMem.statusText = xhr.statusText;\n plugin._xhrMem.delete(xhr);\n\n if (xhrMem.span) {\n plugin._applyAttributesAfterXHR(xhrMem.span, xhr);\n }\n const performanceEndTime = hrTime();\n const endTime = Date.now();\n\n // the timeout is needed as observer doesn't have yet information\n // when event \"load\" is called. Also the time may differ depends on\n // browser and speed of computer\n setTimeout(() => {\n endSpanTimeout(eventName, xhrMem, performanceEndTime, endTime);\n }, OBSERVER_WAIT_TIME_MS);\n }\n\n function onError(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ERROR, this);\n }\n\n function onAbort(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ABORT, this);\n }\n\n function onTimeout(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_TIMEOUT, this);\n }\n\n function onLoad(this: XMLHttpRequest) {\n if (this.status < 299) {\n endSpan(EventNames.EVENT_LOAD, this);\n } else {\n endSpan(EventNames.EVENT_ERROR, this);\n }\n }\n\n function unregister(xhr: XMLHttpRequest) {\n xhr.removeEventListener('abort', onAbort);\n xhr.removeEventListener('error', onError);\n xhr.removeEventListener('load', onLoad);\n xhr.removeEventListener('timeout', onTimeout);\n const xhrMem = plugin._xhrMem.get(xhr);\n if (xhrMem) {\n xhrMem.callbackToRemoveEvents = undefined;\n }\n }\n\n return (original: SendFunction): SendFunction => {\n return function patchSend(this: XMLHttpRequest, ...args): void {\n const xhrMem = plugin._xhrMem.get(this);\n if (!xhrMem) {\n return original.apply(this, args);\n }\n const currentSpan = xhrMem.span;\n const spanUrl = xhrMem.spanUrl;\n\n if (currentSpan && spanUrl) {\n if (plugin.getConfig().measureRequestSize && args?.[0]) {\n const body = args[0];\n const bodyLength = getXHRBodyLength(body);\n if (bodyLength !== undefined) {\n currentSpan.setAttribute(\n SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,\n bodyLength\n );\n }\n }\n\n api.context.with(\n api.trace.setSpan(api.context.active(), currentSpan),\n () => {\n plugin._tasksCount++;\n xhrMem.sendStartTime = hrTime();\n currentSpan.addEvent(EventNames.METHOD_SEND);\n\n this.addEventListener('abort', onAbort);\n this.addEventListener('error', onError);\n this.addEventListener('load', onLoad);\n this.addEventListener('timeout', onTimeout);\n\n xhrMem.callbackToRemoveEvents = () => {\n unregister(this);\n if (xhrMem.createdResources) {\n xhrMem.createdResources.observer.disconnect();\n }\n };\n plugin._addHeaders(this, spanUrl);\n plugin._addResourceObserver(this, spanUrl);\n }\n );\n }\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * implements enable function\n */\n override enable() {\n this._diag.debug('applying patch to', this.moduleName, this.version);\n\n if (isWrapped(XMLHttpRequest.prototype.open)) {\n this._unwrap(XMLHttpRequest.prototype, 'open');\n this._diag.debug('removing previous patch from method open');\n }\n\n if (isWrapped(XMLHttpRequest.prototype.send)) {\n this._unwrap(XMLHttpRequest.prototype, 'send');\n this._diag.debug('removing previous patch from method send');\n }\n\n this._wrap(XMLHttpRequest.prototype, 'open', this._patchOpen());\n this._wrap(XMLHttpRequest.prototype, 'send', this._patchSend());\n }\n\n /**\n * implements disable function\n */\n override disable() {\n this._diag.debug('removing patch from', this.moduleName, this.version);\n\n this._unwrap(XMLHttpRequest.prototype, 'open');\n this._unwrap(XMLHttpRequest.prototype, 'send');\n\n this._tasksCount = 0;\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../src/xhr.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,0CAA0C;AAC1C,oEAOwC;AACxC,8CAA0E;AAC1E,gEAMsC;AACtC,8EAQ6C;AAC7C,uCASmB;AACnB,mDAAgD;AAOhD,mCAIiB;AACjB,uCAA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E,IAAI,CAAC,OAAO,CAAC,CAAC;QAEvE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAE/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAA0B,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IACjE,CAAC;CACF;AAziBD,sEAyiBC","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 * as api from '@opentelemetry/api';\nimport {\n SemconvStability,\n semconvStabilityFromStr,\n isWrapped,\n InstrumentationBase,\n InstrumentationConfig,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { hrTime, isUrlIgnored, otperformance } from '@opentelemetry/core';\nimport {\n addSpanNetworkEvents,\n getResource,\n PerformanceTimingNames as PTN,\n shouldPropagateTraceHeaders,\n parseUrl,\n} from '@opentelemetry/sdk-trace-web';\nimport {\n ATTR_ERROR_TYPE,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_REQUEST_METHOD_ORIGINAL,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_FULL,\n} from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_HTTP_HOST,\n ATTR_HTTP_METHOD,\n ATTR_HTTP_SCHEME,\n ATTR_HTTP_STATUS_CODE,\n ATTR_HTTP_URL,\n ATTR_HTTP_USER_AGENT,\n ATTR_HTTP_REQUEST_BODY_SIZE,\n ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,\n} from './semconv';\nimport { EventNames } from './enums/EventNames';\nimport {\n OpenFunction,\n PropagateTraceHeaderCorsUrls,\n SendFunction,\n XhrMem,\n} from './types';\nimport {\n normalizeHttpRequestMethod,\n serverPortFromUrl,\n getXHRBodyLength,\n} from './utils';\nimport { VERSION } from './version';\nimport { AttributeNames } from './enums/AttributeNames';\n\n// how long to wait for observer to collect information about resources\n// this is needed as event \"load\" is called before observer\n// hard to say how long it should really wait, seems like 300ms is\n// safe enough\nconst OBSERVER_WAIT_TIME_MS = 300;\n\nexport type XHRCustomAttributeFunction = (\n span: api.Span,\n xhr: XMLHttpRequest\n) => void;\n\n/**\n * XMLHttpRequest config\n */\nexport interface XMLHttpRequestInstrumentationConfig\n extends InstrumentationConfig {\n /**\n * The number of timing resources is limited, after the limit\n * (chrome 250, safari 150) the information is not collected anymore.\n * The only way to prevent that is to regularly clean the resources\n * whenever it is possible. This is needed only when PerformanceObserver\n * is not available\n */\n clearTimingResources?: boolean;\n /** URLs which should include trace headers when origin doesn't match */\n propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls;\n /**\n * URLs that partially match any regex in ignoreUrls will not be traced.\n * In addition, URLs that are _exact matches_ of strings in ignoreUrls will\n * also not be traced.\n */\n ignoreUrls?: Array<string | RegExp>;\n /** Function for adding custom attributes on the span */\n applyCustomAttributesOnSpan?: XHRCustomAttributeFunction;\n /** Ignore adding network events as span events */\n ignoreNetworkEvents?: boolean;\n /** Measure outgoing request size */\n measureRequestSize?: boolean;\n /** Select the HTTP semantic conventions version(s) used. */\n semconvStabilityOptIn?: string;\n}\n\n/**\n * This class represents a XMLHttpRequest plugin for auto instrumentation\n */\nexport class XMLHttpRequestInstrumentation extends InstrumentationBase<XMLHttpRequestInstrumentationConfig> {\n readonly component: string = 'xml-http-request';\n readonly version: string = VERSION;\n moduleName = this.component;\n\n private _tasksCount = 0;\n private _xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n private _usedResources = new WeakSet<PerformanceResourceTiming>();\n private _semconvStability: SemconvStability;\n\n constructor(config: XMLHttpRequestInstrumentationConfig = {}) {\n super('@opentelemetry/instrumentation-xml-http-request', VERSION, config);\n this._semconvStability = semconvStabilityFromStr(\n 'http',\n config?.semconvStabilityOptIn\n );\n }\n\n init() {}\n\n /**\n * Adds custom headers to XMLHttpRequest\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addHeaders(xhr: XMLHttpRequest, spanUrl: string) {\n const url = parseUrl(spanUrl).href;\n if (\n !shouldPropagateTraceHeaders(\n url,\n this.getConfig().propagateTraceHeaderCorsUrls\n )\n ) {\n const headers: Partial<Record<string, unknown>> = {};\n api.propagation.inject(api.context.active(), headers);\n if (Object.keys(headers).length > 0) {\n this._diag.debug('headers inject skipped due to CORS policy');\n }\n return;\n }\n const headers: { [key: string]: unknown } = {};\n api.propagation.inject(api.context.active(), headers);\n Object.keys(headers).forEach(key => {\n xhr.setRequestHeader(key, String(headers[key]));\n });\n }\n\n /**\n * Add cors pre flight child span\n * @param span\n * @param corsPreFlightRequest\n * @private\n */\n private _addChildSpan(\n span: api.Span,\n corsPreFlightRequest: PerformanceResourceTiming\n ): void {\n api.context.with(api.trace.setSpan(api.context.active(), span), () => {\n const childSpan = this.tracer.startSpan('CORS Preflight', {\n startTime: corsPreFlightRequest[PTN.FETCH_START],\n });\n const skipOldSemconvContentLengthAttrs = !(\n this._semconvStability & SemconvStability.OLD\n );\n addSpanNetworkEvents(\n childSpan,\n corsPreFlightRequest,\n this.getConfig().ignoreNetworkEvents,\n undefined,\n skipOldSemconvContentLengthAttrs\n );\n childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);\n });\n }\n\n /**\n * Add attributes when span is going to end\n * @param span\n * @param xhr\n * @param spanUrl\n * @private\n */\n _addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem, spanUrl?: string) {\n if (this._semconvStability & SemconvStability.OLD) {\n if (xhrMem.status !== undefined) {\n span.setAttribute(ATTR_HTTP_STATUS_CODE, xhrMem.status);\n }\n if (xhrMem.statusText !== undefined) {\n span.setAttribute(AttributeNames.HTTP_STATUS_TEXT, xhrMem.statusText);\n }\n if (typeof spanUrl === 'string') {\n const parsedUrl = parseUrl(spanUrl);\n span.setAttribute(ATTR_HTTP_HOST, parsedUrl.host);\n span.setAttribute(\n ATTR_HTTP_SCHEME,\n parsedUrl.protocol.replace(':', '')\n );\n }\n\n // @TODO do we want to collect this or it will be collected earlier once only or\n // maybe when parent span is not available ?\n span.setAttribute(ATTR_HTTP_USER_AGENT, navigator.userAgent);\n }\n if (this._semconvStability & SemconvStability.STABLE) {\n if (xhrMem.status) {\n // Intentionally exclude status=0, because XHR uses 0 for before a\n // response is received and semconv says to only add the attribute if\n // received a response.\n span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, xhrMem.status);\n }\n }\n }\n\n private _applyAttributesAfterXHR(span: api.Span, xhr: XMLHttpRequest) {\n const applyCustomAttributesOnSpan =\n this.getConfig().applyCustomAttributesOnSpan;\n if (typeof applyCustomAttributesOnSpan === 'function') {\n safeExecuteInTheMiddle(\n () => applyCustomAttributesOnSpan(span, xhr),\n error => {\n if (!error) {\n return;\n }\n\n this._diag.error('applyCustomAttributesOnSpan', error);\n },\n true\n );\n }\n }\n\n /**\n * will collect information about all resources created\n * between \"send\" and \"end\" with additional waiting for main resource\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addResourceObserver(xhr: XMLHttpRequest, spanUrl: string) {\n const xhrMem = this._xhrMem.get(xhr);\n if (\n !xhrMem ||\n typeof PerformanceObserver !== 'function' ||\n typeof PerformanceResourceTiming !== 'function'\n ) {\n return;\n }\n xhrMem.createdResources = {\n observer: new PerformanceObserver(list => {\n const entries = list.getEntries() as PerformanceResourceTiming[];\n const parsedUrl = parseUrl(spanUrl);\n\n entries.forEach(entry => {\n if (\n entry.initiatorType === 'xmlhttprequest' &&\n entry.name === parsedUrl.href\n ) {\n if (xhrMem.createdResources) {\n xhrMem.createdResources.entries.push(entry);\n }\n }\n });\n }),\n entries: [],\n };\n xhrMem.createdResources.observer.observe({\n entryTypes: ['resource'],\n });\n }\n\n /**\n * Clears the resource timings and all resources assigned with spans\n * when {@link XMLHttpRequestInstrumentationConfig.clearTimingResources} is\n * set to true (default false)\n * @private\n */\n private _clearResources() {\n if (this._tasksCount === 0 && this.getConfig().clearTimingResources) {\n (otperformance as unknown as Performance).clearResourceTimings();\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n }\n\n /**\n * Finds appropriate resource and add network events to the span\n * @param span\n */\n private _findResourceAndAddNetworkEvents(\n xhrMem: XhrMem,\n span: api.Span,\n spanUrl?: string,\n startTime?: api.HrTime,\n endTime?: api.HrTime\n ): void {\n if (!spanUrl || !startTime || !endTime || !xhrMem.createdResources) {\n return;\n }\n\n let resources: PerformanceResourceTiming[] =\n xhrMem.createdResources.entries;\n\n if (!resources || !resources.length) {\n // fallback - either Observer is not available or it took longer\n // then OBSERVER_WAIT_TIME_MS and observer didn't collect enough\n // information\n // ts thinks this is the perf_hooks module, but it is the browser performance api\n resources = (otperformance as unknown as Performance).getEntriesByType(\n 'resource'\n ) as PerformanceResourceTiming[];\n }\n\n const resource = getResource(\n parseUrl(spanUrl).href,\n startTime,\n endTime,\n resources,\n this._usedResources\n );\n\n if (resource.mainRequest) {\n const mainRequest = resource.mainRequest;\n this._markResourceAsUsed(mainRequest);\n\n const corsPreFlightRequest = resource.corsPreFlightRequest;\n if (corsPreFlightRequest) {\n this._addChildSpan(span, corsPreFlightRequest);\n this._markResourceAsUsed(corsPreFlightRequest);\n }\n const skipOldSemconvContentLengthAttrs = !(\n this._semconvStability & SemconvStability.OLD\n );\n addSpanNetworkEvents(\n span,\n mainRequest,\n this.getConfig().ignoreNetworkEvents,\n undefined,\n skipOldSemconvContentLengthAttrs\n );\n }\n }\n\n /**\n * Removes the previous information about span.\n * This might happened when the same xhr is used again.\n * @param xhr\n * @private\n */\n private _cleanPreviousSpanInformation(xhr: XMLHttpRequest) {\n const xhrMem = this._xhrMem.get(xhr);\n if (xhrMem) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n if (callbackToRemoveEvents) {\n callbackToRemoveEvents();\n }\n this._xhrMem.delete(xhr);\n }\n }\n\n /**\n * Creates a new span when method \"open\" is called\n * @param xhr\n * @param url\n * @param method\n * @private\n */\n private _createSpan(\n xhr: XMLHttpRequest,\n url: string,\n method: string\n ): api.Span | undefined {\n if (isUrlIgnored(url, this.getConfig().ignoreUrls)) {\n this._diag.debug('ignoring span as url matches ignored url');\n return;\n }\n\n let name = '';\n const parsedUrl = parseUrl(url);\n const attributes = {} as api.Attributes;\n if (this._semconvStability & SemconvStability.OLD) {\n name = method.toUpperCase();\n attributes[ATTR_HTTP_METHOD] = method;\n attributes[ATTR_HTTP_URL] = parsedUrl.toString();\n }\n if (this._semconvStability & SemconvStability.STABLE) {\n const origMethod = method;\n const normMethod = normalizeHttpRequestMethod(method);\n if (!name) {\n // The \"old\" span name wins if emitting both old and stable semconv\n // ('http/dup').\n name = normMethod;\n }\n attributes[ATTR_HTTP_REQUEST_METHOD] = normMethod;\n if (normMethod !== origMethod) {\n attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = origMethod;\n }\n attributes[ATTR_URL_FULL] = parsedUrl.toString();\n attributes[ATTR_SERVER_ADDRESS] = parsedUrl.hostname;\n const serverPort = serverPortFromUrl(parsedUrl);\n if (serverPort) {\n attributes[ATTR_SERVER_PORT] = serverPort;\n }\n }\n\n const currentSpan = this.tracer.startSpan(name, {\n kind: api.SpanKind.CLIENT,\n attributes,\n });\n\n currentSpan.addEvent(EventNames.METHOD_OPEN);\n\n this._cleanPreviousSpanInformation(xhr);\n\n this._xhrMem.set(xhr, {\n span: currentSpan,\n spanUrl: url,\n });\n\n return currentSpan;\n }\n\n /**\n * Marks certain [resource]{@link PerformanceResourceTiming} when information\n * from this is used to add events to span.\n * This is done to avoid reusing the same resource again for next span\n * @param resource\n * @private\n */\n private _markResourceAsUsed(resource: PerformanceResourceTiming) {\n this._usedResources.add(resource);\n }\n\n /**\n * Patches the method open\n * @private\n */\n protected _patchOpen() {\n return (original: OpenFunction): OpenFunction => {\n const plugin = this;\n return function patchOpen(this: XMLHttpRequest, ...args): void {\n const method: string = args[0];\n const url: string = args[1];\n plugin._createSpan(this, url, method);\n\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * Patches the method send\n * @private\n */\n protected _patchSend() {\n const plugin = this;\n\n function endSpanTimeout(\n eventName: string,\n xhrMem: XhrMem,\n performanceEndTime: api.HrTime,\n endTime: number\n ) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n\n if (typeof callbackToRemoveEvents === 'function') {\n callbackToRemoveEvents();\n }\n\n const { span, spanUrl, sendStartTime } = xhrMem;\n\n if (span) {\n plugin._findResourceAndAddNetworkEvents(\n xhrMem,\n span,\n spanUrl,\n sendStartTime,\n performanceEndTime\n );\n span.addEvent(eventName, endTime);\n plugin._addFinalSpanAttributes(span, xhrMem, spanUrl);\n span.end(endTime);\n plugin._tasksCount--;\n }\n plugin._clearResources();\n }\n\n function endSpan(\n eventName: string,\n xhr: XMLHttpRequest,\n isError: boolean,\n errorType?: string\n ) {\n const xhrMem = plugin._xhrMem.get(xhr);\n if (!xhrMem) {\n return;\n }\n xhrMem.status = xhr.status;\n xhrMem.statusText = xhr.statusText;\n plugin._xhrMem.delete(xhr);\n\n if (xhrMem.span) {\n const span = xhrMem.span;\n plugin._applyAttributesAfterXHR(span, xhr);\n\n if (plugin._semconvStability & SemconvStability.STABLE) {\n if (isError) {\n if (errorType) {\n span.setStatus({\n code: api.SpanStatusCode.ERROR,\n message: errorType,\n });\n span.setAttribute(ATTR_ERROR_TYPE, errorType);\n }\n } else if (xhrMem.status && xhrMem.status >= 400) {\n span.setStatus({ code: api.SpanStatusCode.ERROR });\n span.setAttribute(ATTR_ERROR_TYPE, String(xhrMem.status));\n }\n }\n }\n\n const performanceEndTime = hrTime();\n const endTime = Date.now();\n\n // the timeout is needed as observer doesn't have yet information\n // when event \"load\" is called. Also the time may differ depends on\n // browser and speed of computer\n setTimeout(() => {\n endSpanTimeout(eventName, xhrMem, performanceEndTime, endTime);\n }, OBSERVER_WAIT_TIME_MS);\n }\n\n function onError(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ERROR, this, true, 'error');\n }\n\n function onAbort(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ABORT, this, false);\n }\n\n function onTimeout(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_TIMEOUT, this, true, 'timeout');\n }\n\n function onLoad(this: XMLHttpRequest) {\n if (this.status < 299) {\n endSpan(EventNames.EVENT_LOAD, this, false);\n } else {\n endSpan(EventNames.EVENT_ERROR, this, false);\n }\n }\n\n function unregister(xhr: XMLHttpRequest) {\n xhr.removeEventListener('abort', onAbort);\n xhr.removeEventListener('error', onError);\n xhr.removeEventListener('load', onLoad);\n xhr.removeEventListener('timeout', onTimeout);\n const xhrMem = plugin._xhrMem.get(xhr);\n if (xhrMem) {\n xhrMem.callbackToRemoveEvents = undefined;\n }\n }\n\n return (original: SendFunction): SendFunction => {\n return function patchSend(this: XMLHttpRequest, ...args): void {\n const xhrMem = plugin._xhrMem.get(this);\n if (!xhrMem) {\n return original.apply(this, args);\n }\n const currentSpan = xhrMem.span;\n const spanUrl = xhrMem.spanUrl;\n\n if (currentSpan && spanUrl) {\n if (plugin.getConfig().measureRequestSize && args?.[0]) {\n const body = args[0];\n const bodyLength = getXHRBodyLength(body);\n if (bodyLength !== undefined) {\n if (plugin._semconvStability & SemconvStability.OLD) {\n currentSpan.setAttribute(\n ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,\n bodyLength\n );\n }\n if (plugin._semconvStability & SemconvStability.STABLE) {\n currentSpan.setAttribute(\n ATTR_HTTP_REQUEST_BODY_SIZE,\n bodyLength\n );\n }\n }\n }\n\n api.context.with(\n api.trace.setSpan(api.context.active(), currentSpan),\n () => {\n plugin._tasksCount++;\n xhrMem.sendStartTime = hrTime();\n currentSpan.addEvent(EventNames.METHOD_SEND);\n\n this.addEventListener('abort', onAbort);\n this.addEventListener('error', onError);\n this.addEventListener('load', onLoad);\n this.addEventListener('timeout', onTimeout);\n\n xhrMem.callbackToRemoveEvents = () => {\n unregister(this);\n if (xhrMem.createdResources) {\n xhrMem.createdResources.observer.disconnect();\n }\n };\n plugin._addHeaders(this, spanUrl);\n plugin._addResourceObserver(this, spanUrl);\n }\n );\n }\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * implements enable function\n */\n override enable() {\n this._diag.debug('applying patch to', this.moduleName, this.version);\n\n if (isWrapped(XMLHttpRequest.prototype.open)) {\n this._unwrap(XMLHttpRequest.prototype, 'open');\n this._diag.debug('removing previous patch from method open');\n }\n\n if (isWrapped(XMLHttpRequest.prototype.send)) {\n this._unwrap(XMLHttpRequest.prototype, 'send');\n this._diag.debug('removing previous patch from method send');\n }\n\n this._wrap(XMLHttpRequest.prototype, 'open', this._patchOpen());\n this._wrap(XMLHttpRequest.prototype, 'send', this._patchSend());\n }\n\n /**\n * implements disable function\n */\n override disable() {\n this._diag.debug('removing patch from', this.moduleName, this.version);\n\n this._unwrap(XMLHttpRequest.prototype, 'open');\n this._unwrap(XMLHttpRequest.prototype, 'send');\n\n this._tasksCount = 0;\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n}\n"]}
|