@opentelemetry/instrumentation-xml-http-request 0.57.1 → 0.200.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/esm/types.d.ts +6 -6
- package/build/esm/types.js.map +1 -1
- package/build/esm/utils.js +19 -54
- 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 +1 -1
- package/build/esm/xhr.js +100 -133
- package/build/esm/xhr.js.map +1 -1
- package/build/esnext/types.d.ts +6 -6
- package/build/esnext/types.js.map +1 -1
- package/build/esnext/utils.js +10 -7
- 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 +1 -1
- package/build/esnext/xhr.js +7 -7
- package/build/esnext/xhr.js.map +1 -1
- package/build/src/types.d.ts +6 -6
- package/build/src/types.js.map +1 -1
- package/build/src/utils.js +10 -7
- 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 +1 -1
- package/build/src/xhr.js +7 -7
- package/build/src/xhr.js.map +1 -1
- package/package.json +19 -20
package/build/esm/types.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import * as api from '@opentelemetry/api';
|
|
|
2
2
|
/**
|
|
3
3
|
* method "open" from XMLHttpRequest
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type OpenFunction = (method: string, url: string, async?: boolean, user?: string | null, pass?: string | null) => void;
|
|
6
6
|
/**
|
|
7
7
|
* method "send" from XMLHttpRequest
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
10
|
-
export
|
|
9
|
+
export type SendFunction = typeof XMLHttpRequest.prototype.send;
|
|
10
|
+
export type SendBody = string | Document | Blob | ArrayBufferView | ArrayBuffer | FormData | URLSearchParams | ReadableStream<Uint8Array> | null;
|
|
11
11
|
/**
|
|
12
12
|
* interface to store information in weak map about spans, resources and
|
|
13
13
|
* callbacks
|
|
@@ -22,8 +22,8 @@ export interface XhrMem {
|
|
|
22
22
|
observer: PerformanceObserver;
|
|
23
23
|
entries: PerformanceResourceTiming[];
|
|
24
24
|
};
|
|
25
|
-
callbackToRemoveEvents?:
|
|
25
|
+
callbackToRemoveEvents?: () => void;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
28
|
-
export
|
|
27
|
+
export type PropagateTraceHeaderCorsUrl = string | RegExp;
|
|
28
|
+
export type PropagateTraceHeaderCorsUrls = PropagateTraceHeaderCorsUrl | PropagateTraceHeaderCorsUrl[];
|
|
29
29
|
//# sourceMappingURL=types.d.ts.map
|
package/build/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","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';\n\n/**\n * method \"open\" from XMLHttpRequest\n */\nexport type OpenFunction = (\n method: string,\n url: string,\n async?: boolean,\n user?: string | null,\n pass?: string | null\n) => void;\n\n/**\n * method \"send\" from XMLHttpRequest\n */\nexport type SendFunction = typeof XMLHttpRequest.prototype.send;\n\nexport type SendBody =\n | string\n | Document\n | Blob\n | ArrayBufferView\n | ArrayBuffer\n | FormData\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n | URLSearchParams\n | ReadableStream<Uint8Array>\n | null;\n\n/**\n * interface to store information in weak map about spans, resources and\n * callbacks\n */\nexport interface XhrMem {\n status?: number;\n statusText?: string;\n // span assigned to xhr\n span: api.Span;\n // span url - not available on types.Span\n spanUrl?: string;\n // startTime of send function - used to filter cors preflight requests\n sendStartTime?: api.HrTime;\n // resources created between send and end plus some additional timeout\n createdResources?: {\n observer: PerformanceObserver;\n entries: PerformanceResourceTiming[];\n };\n // callback to remove events from xhr once the span ends\n callbackToRemoveEvents?:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","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';\n\n/**\n * method \"open\" from XMLHttpRequest\n */\nexport type OpenFunction = (\n method: string,\n url: string,\n async?: boolean,\n user?: string | null,\n pass?: string | null\n) => void;\n\n/**\n * method \"send\" from XMLHttpRequest\n */\nexport type SendFunction = typeof XMLHttpRequest.prototype.send;\n\nexport type SendBody =\n | string\n | Document\n | Blob\n | ArrayBufferView\n | ArrayBuffer\n | FormData\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n | URLSearchParams\n | ReadableStream<Uint8Array>\n | null;\n\n/**\n * interface to store information in weak map about spans, resources and\n * callbacks\n */\nexport interface XhrMem {\n status?: number;\n statusText?: string;\n // span assigned to xhr\n span: api.Span;\n // span url - not available on types.Span\n spanUrl?: string;\n // startTime of send function - used to filter cors preflight requests\n sendStartTime?: api.HrTime;\n // resources created between send and end plus some additional timeout\n createdResources?: {\n observer: PerformanceObserver;\n entries: PerformanceResourceTiming[];\n };\n // callback to remove events from xhr once the span ends\n callbackToRemoveEvents?: () => void;\n}\n\nexport type PropagateTraceHeaderCorsUrl = string | RegExp;\n\nexport type PropagateTraceHeaderCorsUrls =\n | PropagateTraceHeaderCorsUrl\n | PropagateTraceHeaderCorsUrl[];\n"]}
|
package/build/esm/utils.js
CHANGED
|
@@ -13,93 +13,58 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
var __values = (this && this.__values) || function(o) {
|
|
17
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
18
|
-
if (m) return m.call(o);
|
|
19
|
-
if (o && typeof o.length === "number") return {
|
|
20
|
-
next: function () {
|
|
21
|
-
if (o && i >= o.length) o = void 0;
|
|
22
|
-
return { value: o && o[i++], done: !o };
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
26
|
-
};
|
|
27
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
28
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
29
|
-
if (!m) return o;
|
|
30
|
-
var i = m.call(o), r, ar = [], e;
|
|
31
|
-
try {
|
|
32
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
33
|
-
}
|
|
34
|
-
catch (error) { e = { error: error }; }
|
|
35
|
-
finally {
|
|
36
|
-
try {
|
|
37
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
38
|
-
}
|
|
39
|
-
finally { if (e) throw e.error; }
|
|
40
|
-
}
|
|
41
|
-
return ar;
|
|
42
|
-
};
|
|
43
16
|
// Much of the logic here overlaps with the same utils file in opentelemetry-instrumentation-fetch
|
|
44
17
|
// These may be unified in the future.
|
|
45
18
|
import * as api from '@opentelemetry/api';
|
|
46
|
-
|
|
19
|
+
const DIAG_LOGGER = api.diag.createComponentLogger({
|
|
47
20
|
namespace: '@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils',
|
|
48
21
|
});
|
|
22
|
+
function isDocument(value) {
|
|
23
|
+
return typeof Document !== 'undefined' && value instanceof Document;
|
|
24
|
+
}
|
|
49
25
|
/**
|
|
50
26
|
* Helper function to determine payload content length for XHR requests
|
|
51
27
|
* @param body
|
|
52
28
|
* @returns content length
|
|
53
29
|
*/
|
|
54
30
|
export function getXHRBodyLength(body) {
|
|
55
|
-
if (
|
|
31
|
+
if (isDocument(body)) {
|
|
56
32
|
return new XMLSerializer().serializeToString(document).length;
|
|
57
33
|
}
|
|
58
34
|
// XMLHttpRequestBodyInit expands to the following:
|
|
35
|
+
if (typeof body === 'string') {
|
|
36
|
+
return getByteLength(body);
|
|
37
|
+
}
|
|
59
38
|
if (body instanceof Blob) {
|
|
60
39
|
return body.size;
|
|
61
40
|
}
|
|
62
|
-
// ArrayBuffer | ArrayBufferView
|
|
63
|
-
if (body.byteLength !== undefined) {
|
|
64
|
-
return body.byteLength;
|
|
65
|
-
}
|
|
66
41
|
if (body instanceof FormData) {
|
|
67
42
|
return getFormDataSize(body);
|
|
68
43
|
}
|
|
69
44
|
if (body instanceof URLSearchParams) {
|
|
70
45
|
return getByteLength(body.toString());
|
|
71
46
|
}
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
// ArrayBuffer | ArrayBufferView
|
|
48
|
+
if (body.byteLength !== undefined) {
|
|
49
|
+
return body.byteLength;
|
|
74
50
|
}
|
|
75
51
|
DIAG_LOGGER.warn('unknown body type');
|
|
76
52
|
return undefined;
|
|
77
53
|
}
|
|
78
|
-
|
|
54
|
+
const TEXT_ENCODER = new TextEncoder();
|
|
79
55
|
function getByteLength(s) {
|
|
80
56
|
return TEXT_ENCODER.encode(s).byteLength;
|
|
81
57
|
}
|
|
82
58
|
function getFormDataSize(formData) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
size += key.length;
|
|
89
|
-
if (value instanceof Blob) {
|
|
90
|
-
size += value.size;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
size += value.length;
|
|
94
|
-
}
|
|
59
|
+
let size = 0;
|
|
60
|
+
for (const [key, value] of formData.entries()) {
|
|
61
|
+
size += key.length;
|
|
62
|
+
if (value instanceof Blob) {
|
|
63
|
+
size += value.size;
|
|
95
64
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
finally {
|
|
99
|
-
try {
|
|
100
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
65
|
+
else {
|
|
66
|
+
size += value.length;
|
|
101
67
|
}
|
|
102
|
-
finally { if (e_1) throw e_1.error; }
|
|
103
68
|
}
|
|
104
69
|
return size;
|
|
105
70
|
}
|
package/build/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,kGAAkG;AAClG,sCAAsC;AAEtC,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;IACjD,SAAS,EACP,qEAAqE;CACxE,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,QAAQ,KAAK,WAAW,IAAI,KAAK,YAAY,QAAQ,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAuC;IAEvC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;QACpB,OAAO,IAAI,aAAa,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;KAC/D;IAED,mDAAmD;IACnD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;KAC5B;IAED,IAAI,IAAI,YAAY,IAAI,EAAE;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC;KAClB;IAED,IAAI,IAAI,YAAY,QAAQ,EAAE;QAC5B,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;KAC9B;IAED,IAAI,IAAI,YAAY,eAAe,EAAE;QACnC,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;KACvC;IAED,gCAAgC;IAChC,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC;KACxB;IAED,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACtC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC;AACvC,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;AAC3C,CAAC;AAED,SAAS,eAAe,CAAC,QAAkB;IACzC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE;QAC7C,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC;QACnB,IAAI,KAAK,YAAY,IAAI,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;SACpB;aAAM;YACL,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC;SACtB;KACF;IACD,OAAO,IAAI,CAAC;AACd,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// 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';\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"]}
|
package/build/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.200.0-dev.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,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.200.0-dev.0';\n"]}
|
package/build/esm/xhr.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as api from '@opentelemetry/api';
|
|
2
2
|
import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
3
|
import { OpenFunction, PropagateTraceHeaderCorsUrls, SendFunction, XhrMem } from './types';
|
|
4
|
-
export
|
|
4
|
+
export type XHRCustomAttributeFunction = (span: api.Span, xhr: XMLHttpRequest) => void;
|
|
5
5
|
/**
|
|
6
6
|
* XMLHttpRequest config
|
|
7
7
|
*/
|