@opentelemetry/instrumentation-fetch 0.57.2 → 0.200.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/build/esm/fetch.d.ts +6 -0
- package/build/esm/fetch.js +110 -154
- package/build/esm/fetch.js.map +1 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/utils.js +38 -123
- 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/esnext/fetch.d.ts +6 -0
- package/build/esnext/fetch.js +21 -11
- package/build/esnext/fetch.js.map +1 -1
- package/build/esnext/index.d.ts +1 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/utils.js +12 -9
- 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/src/fetch.d.ts +6 -0
- package/build/src/fetch.js +21 -11
- package/build/src/fetch.js.map +1 -1
- package/build/src/index.d.ts +1 -1
- package/build/src/index.js.map +1 -1
- package/build/src/utils.js +12 -9
- 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/package.json +25 -20
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,6GAA6G;AAC7G,sCAAsC;AAEtC,0CAA0C;AAE1C,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;IACjD,SAAS,EAAE,0DAA0D;CACtE,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,kBAAkB,CAAC,GA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I,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-xml-http-request\n// These may be unified in the future.\n\nimport * as api from '@opentelemetry/api';\n\nconst DIAG_LOGGER = api.diag.createComponentLogger({\n namespace: '@opentelemetry/opentelemetry-instrumentation-fetch/utils',\n});\n\n/**\n * Helper function to determine payload content length for fetch requests\n *\n * The fetch API is kinda messy: there are a couple of ways the body can be passed in.\n *\n * In all cases, the body param can be some variation of ReadableStream,\n * and ReadableStreams can only be read once! We want to avoid consuming the body here,\n * because that would mean that the body never gets sent with the actual fetch request.\n *\n * Either the first arg is a Request object, which can be cloned\n * so we can clone that object and read the body of the clone\n * without disturbing the original argument\n * However, reading the body here can only be done async; the body() method returns a promise\n * this means this entire function has to return a promise\n *\n * OR the first arg is a url/string\n * in which case the second arg has type RequestInit\n * RequestInit is NOT cloneable, but RequestInit.body is writable\n * so we can chain it into ReadableStream.pipeThrough()\n *\n * ReadableStream.pipeThrough() lets us process a stream and returns a new stream\n * So we can measure the body length as it passes through the pie, but need to attach\n * the new stream to the original request\n * so that the browser still has access to the body.\n *\n * @param body\n * @returns promise that resolves to the content length of the body\n */\nexport function getFetchBodyLength(...args: Parameters<typeof fetch>) {\n if (args[0] instanceof URL || typeof args[0] === 'string') {\n const requestInit = args[1];\n if (!requestInit?.body) {\n return Promise.resolve();\n }\n if (requestInit.body instanceof ReadableStream) {\n const { body, length } = _getBodyNonDestructively(requestInit.body);\n requestInit.body = body;\n\n return length;\n } else {\n return Promise.resolve(getXHRBodyLength(requestInit.body));\n }\n } else {\n const info = args[0];\n if (!info?.body) {\n return Promise.resolve();\n }\n\n return info\n .clone()\n .text()\n .then(t => getByteLength(t));\n }\n}\n\nfunction _getBodyNonDestructively(body: ReadableStream) {\n // can't read a ReadableStream without destroying it\n // but we CAN pipe it through and return a new ReadableStream\n\n // some (older) platforms don't expose the pipeThrough method and in that scenario, we're out of luck;\n // there's no way to read the stream without consuming it.\n if (!body.pipeThrough) {\n DIAG_LOGGER.warn('Platform has ReadableStream but not pipeThrough!');\n return {\n body,\n length: Promise.resolve(undefined),\n };\n }\n\n let length = 0;\n let resolveLength: (l: number) => void;\n const lengthPromise = new Promise<number>(resolve => {\n resolveLength = resolve;\n });\n\n const transform = new TransformStream({\n start() {},\n async transform(chunk, controller) {\n const bytearray = (await chunk) as Uint8Array;\n length += bytearray.byteLength;\n\n controller.enqueue(chunk);\n },\n flush() {\n resolveLength(length);\n },\n });\n\n return {\n body: body.pipeThrough(transform),\n length: lengthPromise,\n };\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/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.200.0-dev.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.VERSION = void 0;
|
|
19
19
|
// this is autogenerated file, see scripts/version-update.js
|
|
20
|
-
exports.VERSION = '0.
|
|
20
|
+
exports.VERSION = '0.200.0-dev.1';
|
|
21
21
|
//# sourceMappingURL=version.js.map
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,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.1';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/instrumentation-fetch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.200.0-dev.1",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for fetch http client in web browsers",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"module": "build/esm/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"author": "OpenTelemetry Authors",
|
|
35
35
|
"license": "Apache-2.0",
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
37
|
+
"node": "^18.19.0 || >=20.6.0"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
40
|
"build/esm/**/*.js",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@babel/core": "7.26.
|
|
58
|
-
"@babel/preset-env": "7.26.
|
|
57
|
+
"@babel/core": "7.26.9",
|
|
58
|
+
"@babel/preset-env": "7.26.9",
|
|
59
59
|
"@opentelemetry/api": "1.9.0",
|
|
60
|
-
"@opentelemetry/context-zone": "
|
|
61
|
-
"@opentelemetry/propagator-b3": "
|
|
62
|
-
"@opentelemetry/sdk-trace-base": "
|
|
60
|
+
"@opentelemetry/context-zone": "2.0.0-dev.1",
|
|
61
|
+
"@opentelemetry/propagator-b3": "2.0.0-dev.1",
|
|
62
|
+
"@opentelemetry/sdk-trace-base": "2.0.0-dev.1",
|
|
63
63
|
"@types/mocha": "10.0.10",
|
|
64
64
|
"@types/node": "18.6.5",
|
|
65
|
-
"@types/sinon": "17.0.
|
|
65
|
+
"@types/sinon": "17.0.4",
|
|
66
66
|
"@types/webpack-env": "1.16.3",
|
|
67
|
-
"babel-loader": "
|
|
67
|
+
"babel-loader": "9.2.1",
|
|
68
68
|
"babel-plugin-istanbul": "7.0.0",
|
|
69
69
|
"cross-var": "1.1.0",
|
|
70
70
|
"karma": "6.4.4",
|
|
@@ -74,25 +74,30 @@
|
|
|
74
74
|
"karma-spec-reporter": "0.0.36",
|
|
75
75
|
"karma-webpack": "5.0.1",
|
|
76
76
|
"lerna": "6.6.2",
|
|
77
|
-
"mocha": "
|
|
78
|
-
"
|
|
77
|
+
"mocha": "11.1.0",
|
|
78
|
+
"msw": "^2.7.0",
|
|
79
|
+
"nyc": "17.1.0",
|
|
79
80
|
"sinon": "15.1.2",
|
|
80
|
-
"ts-loader": "9.5.
|
|
81
|
-
"typescript": "
|
|
81
|
+
"ts-loader": "9.5.2",
|
|
82
|
+
"typescript": "5.0.4",
|
|
82
83
|
"webpack": "5.96.1",
|
|
83
|
-
"webpack-cli": "
|
|
84
|
-
"webpack-merge": "5.10.0"
|
|
84
|
+
"webpack-cli": "6.0.1"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@opentelemetry/api": "^1.3.0"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@opentelemetry/core": "
|
|
91
|
-
"@opentelemetry/instrumentation": "0.
|
|
92
|
-
"@opentelemetry/sdk-trace-web": "
|
|
93
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
90
|
+
"@opentelemetry/core": "2.0.0-dev.1",
|
|
91
|
+
"@opentelemetry/instrumentation": "0.200.0-dev.1",
|
|
92
|
+
"@opentelemetry/sdk-trace-web": "2.0.0-dev.1",
|
|
93
|
+
"@opentelemetry/semantic-conventions": "^1.29.0"
|
|
94
94
|
},
|
|
95
95
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch",
|
|
96
96
|
"sideEffects": false,
|
|
97
|
-
"
|
|
97
|
+
"msw": {
|
|
98
|
+
"workerDirectory": [
|
|
99
|
+
"test"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"gitHead": "92fde6aa77e464ee85c4a18f279fe12294f625d1"
|
|
98
103
|
}
|