@opentelemetry/otlp-exporter-base 0.212.0 → 0.214.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.
Files changed (283) hide show
  1. package/build/esm/OTLPExporterBase.d.ts +2 -2
  2. package/build/esm/OTLPExporterBase.js +1 -12
  3. package/build/esm/OTLPExporterBase.js.map +1 -1
  4. package/build/esm/bounded-queue-export-promise-handler.js +1 -12
  5. package/build/esm/bounded-queue-export-promise-handler.js.map +1 -1
  6. package/build/esm/configuration/convert-legacy-browser-http-options.d.ts +2 -2
  7. package/build/esm/configuration/convert-legacy-browser-http-options.js +0 -15
  8. package/build/esm/configuration/convert-legacy-browser-http-options.js.map +1 -1
  9. package/build/esm/configuration/convert-legacy-http-options.d.ts +2 -2
  10. package/build/esm/configuration/convert-legacy-http-options.js +1 -12
  11. package/build/esm/configuration/convert-legacy-http-options.js.map +1 -1
  12. package/build/esm/configuration/convert-legacy-node-http-options.d.ts +2 -2
  13. package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
  14. package/build/esm/configuration/create-legacy-browser-delegate.d.ts +3 -5
  15. package/build/esm/configuration/create-legacy-browser-delegate.js +2 -9
  16. package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
  17. package/build/esm/configuration/legacy-base-configuration.d.ts +1 -1
  18. package/build/esm/configuration/legacy-base-configuration.js.map +1 -1
  19. package/build/esm/configuration/legacy-node-configuration.js +1 -12
  20. package/build/esm/configuration/legacy-node-configuration.js.map +1 -1
  21. package/build/esm/configuration/otlp-http-configuration.d.ts +1 -1
  22. package/build/esm/configuration/otlp-http-configuration.js +1 -12
  23. package/build/esm/configuration/otlp-http-configuration.js.map +1 -1
  24. package/build/esm/configuration/otlp-node-http-configuration.d.ts +1 -1
  25. package/build/esm/configuration/otlp-node-http-configuration.js +0 -15
  26. package/build/esm/configuration/otlp-node-http-configuration.js.map +1 -1
  27. package/build/esm/configuration/otlp-node-http-env-configuration.d.ts +1 -1
  28. package/build/esm/configuration/otlp-node-http-env-configuration.js +2 -13
  29. package/build/esm/configuration/otlp-node-http-env-configuration.js.map +1 -1
  30. package/build/esm/configuration/shared-configuration.d.ts +1 -1
  31. package/build/esm/configuration/shared-configuration.js +1 -12
  32. package/build/esm/configuration/shared-configuration.js.map +1 -1
  33. package/build/esm/configuration/shared-env-configuration.d.ts +1 -1
  34. package/build/esm/configuration/shared-env-configuration.js +1 -12
  35. package/build/esm/configuration/shared-env-configuration.js.map +1 -1
  36. package/build/esm/export-response.js +1 -12
  37. package/build/esm/export-response.js.map +1 -1
  38. package/build/esm/exporter-transport.d.ts +1 -1
  39. package/build/esm/exporter-transport.js +1 -12
  40. package/build/esm/exporter-transport.js.map +1 -1
  41. package/build/esm/index-browser-http.d.ts +3 -0
  42. package/build/esm/index-browser-http.js +4 -12
  43. package/build/esm/index-browser-http.js.map +1 -1
  44. package/build/esm/index-node-http.js +1 -12
  45. package/build/esm/index-node-http.js.map +1 -1
  46. package/build/esm/index.js +1 -12
  47. package/build/esm/index.js.map +1 -1
  48. package/build/esm/is-export-retryable.js +1 -12
  49. package/build/esm/is-export-retryable.js.map +1 -1
  50. package/build/esm/logging-response-handler.d.ts +1 -1
  51. package/build/esm/logging-response-handler.js +1 -12
  52. package/build/esm/logging-response-handler.js.map +1 -1
  53. package/build/esm/otlp-browser-http-export-delegate.d.ts +6 -3
  54. package/build/esm/otlp-browser-http-export-delegate.js +4 -7
  55. package/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
  56. package/build/esm/otlp-export-delegate.d.ts +4 -4
  57. package/build/esm/otlp-export-delegate.js +1 -12
  58. package/build/esm/otlp-export-delegate.js.map +1 -1
  59. package/build/esm/otlp-http-export-delegate.d.ts +3 -3
  60. package/build/esm/otlp-http-export-delegate.js +1 -16
  61. package/build/esm/otlp-http-export-delegate.js.map +1 -1
  62. package/build/esm/otlp-network-export-delegate.d.ts +4 -4
  63. package/build/esm/otlp-network-export-delegate.js +2 -13
  64. package/build/esm/otlp-network-export-delegate.js.map +1 -1
  65. package/build/esm/response-handler.js +1 -12
  66. package/build/esm/response-handler.js.map +1 -1
  67. package/build/esm/retrying-transport.d.ts +1 -1
  68. package/build/esm/retrying-transport.js +1 -12
  69. package/build/esm/retrying-transport.js.map +1 -1
  70. package/build/esm/transport/fetch-transport.d.ts +2 -2
  71. package/build/esm/transport/fetch-transport.js +52 -18
  72. package/build/esm/transport/fetch-transport.js.map +1 -1
  73. package/build/esm/transport/http-exporter-transport.d.ts +2 -2
  74. package/build/esm/transport/http-exporter-transport.js +2 -17
  75. package/build/esm/transport/http-exporter-transport.js.map +1 -1
  76. package/build/esm/transport/http-transport-types.d.ts +1 -1
  77. package/build/esm/transport/http-transport-types.js +1 -12
  78. package/build/esm/transport/http-transport-types.js.map +1 -1
  79. package/build/esm/transport/http-transport-utils.d.ts +6 -4
  80. package/build/esm/transport/http-transport-utils.js +86 -56
  81. package/build/esm/transport/http-transport-utils.js.map +1 -1
  82. package/build/esm/transport/node-http-transport-types.d.ts +2 -2
  83. package/build/esm/transport/node-http-transport-types.js +1 -12
  84. package/build/esm/transport/node-http-transport-types.js.map +1 -1
  85. package/build/esm/types.js +1 -12
  86. package/build/esm/types.js.map +1 -1
  87. package/build/esm/util.js +1 -12
  88. package/build/esm/util.js.map +1 -1
  89. package/build/esm/version.d.ts +1 -1
  90. package/build/esm/version.js +2 -13
  91. package/build/esm/version.js.map +1 -1
  92. package/build/esnext/OTLPExporterBase.d.ts +2 -2
  93. package/build/esnext/OTLPExporterBase.js +1 -12
  94. package/build/esnext/OTLPExporterBase.js.map +1 -1
  95. package/build/esnext/bounded-queue-export-promise-handler.js +1 -12
  96. package/build/esnext/bounded-queue-export-promise-handler.js.map +1 -1
  97. package/build/esnext/configuration/convert-legacy-browser-http-options.d.ts +2 -2
  98. package/build/esnext/configuration/convert-legacy-browser-http-options.js +0 -15
  99. package/build/esnext/configuration/convert-legacy-browser-http-options.js.map +1 -1
  100. package/build/esnext/configuration/convert-legacy-http-options.d.ts +2 -2
  101. package/build/esnext/configuration/convert-legacy-http-options.js +1 -12
  102. package/build/esnext/configuration/convert-legacy-http-options.js.map +1 -1
  103. package/build/esnext/configuration/convert-legacy-node-http-options.d.ts +2 -2
  104. package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
  105. package/build/esnext/configuration/create-legacy-browser-delegate.d.ts +3 -5
  106. package/build/esnext/configuration/create-legacy-browser-delegate.js +2 -9
  107. package/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
  108. package/build/esnext/configuration/legacy-base-configuration.d.ts +1 -1
  109. package/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
  110. package/build/esnext/configuration/legacy-node-configuration.js +1 -12
  111. package/build/esnext/configuration/legacy-node-configuration.js.map +1 -1
  112. package/build/esnext/configuration/otlp-http-configuration.d.ts +1 -1
  113. package/build/esnext/configuration/otlp-http-configuration.js +1 -12
  114. package/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
  115. package/build/esnext/configuration/otlp-node-http-configuration.d.ts +1 -1
  116. package/build/esnext/configuration/otlp-node-http-configuration.js +0 -15
  117. package/build/esnext/configuration/otlp-node-http-configuration.js.map +1 -1
  118. package/build/esnext/configuration/otlp-node-http-env-configuration.d.ts +1 -1
  119. package/build/esnext/configuration/otlp-node-http-env-configuration.js +2 -13
  120. package/build/esnext/configuration/otlp-node-http-env-configuration.js.map +1 -1
  121. package/build/esnext/configuration/shared-configuration.d.ts +1 -1
  122. package/build/esnext/configuration/shared-configuration.js +1 -12
  123. package/build/esnext/configuration/shared-configuration.js.map +1 -1
  124. package/build/esnext/configuration/shared-env-configuration.d.ts +1 -1
  125. package/build/esnext/configuration/shared-env-configuration.js +1 -12
  126. package/build/esnext/configuration/shared-env-configuration.js.map +1 -1
  127. package/build/esnext/export-response.js +1 -12
  128. package/build/esnext/export-response.js.map +1 -1
  129. package/build/esnext/exporter-transport.d.ts +1 -1
  130. package/build/esnext/exporter-transport.js +1 -12
  131. package/build/esnext/exporter-transport.js.map +1 -1
  132. package/build/esnext/index-browser-http.d.ts +3 -0
  133. package/build/esnext/index-browser-http.js +4 -12
  134. package/build/esnext/index-browser-http.js.map +1 -1
  135. package/build/esnext/index-node-http.js +1 -12
  136. package/build/esnext/index-node-http.js.map +1 -1
  137. package/build/esnext/index.js +1 -12
  138. package/build/esnext/index.js.map +1 -1
  139. package/build/esnext/is-export-retryable.js +1 -12
  140. package/build/esnext/is-export-retryable.js.map +1 -1
  141. package/build/esnext/logging-response-handler.d.ts +1 -1
  142. package/build/esnext/logging-response-handler.js +1 -12
  143. package/build/esnext/logging-response-handler.js.map +1 -1
  144. package/build/esnext/otlp-browser-http-export-delegate.d.ts +6 -3
  145. package/build/esnext/otlp-browser-http-export-delegate.js +4 -7
  146. package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
  147. package/build/esnext/otlp-export-delegate.d.ts +4 -4
  148. package/build/esnext/otlp-export-delegate.js +1 -12
  149. package/build/esnext/otlp-export-delegate.js.map +1 -1
  150. package/build/esnext/otlp-http-export-delegate.d.ts +3 -3
  151. package/build/esnext/otlp-http-export-delegate.js +1 -16
  152. package/build/esnext/otlp-http-export-delegate.js.map +1 -1
  153. package/build/esnext/otlp-network-export-delegate.d.ts +4 -4
  154. package/build/esnext/otlp-network-export-delegate.js +2 -13
  155. package/build/esnext/otlp-network-export-delegate.js.map +1 -1
  156. package/build/esnext/response-handler.js +1 -12
  157. package/build/esnext/response-handler.js.map +1 -1
  158. package/build/esnext/retrying-transport.d.ts +1 -1
  159. package/build/esnext/retrying-transport.js +1 -12
  160. package/build/esnext/retrying-transport.js.map +1 -1
  161. package/build/esnext/transport/fetch-transport.d.ts +2 -2
  162. package/build/esnext/transport/fetch-transport.js +52 -18
  163. package/build/esnext/transport/fetch-transport.js.map +1 -1
  164. package/build/esnext/transport/http-exporter-transport.d.ts +2 -2
  165. package/build/esnext/transport/http-exporter-transport.js +2 -17
  166. package/build/esnext/transport/http-exporter-transport.js.map +1 -1
  167. package/build/esnext/transport/http-transport-types.d.ts +1 -1
  168. package/build/esnext/transport/http-transport-types.js +1 -12
  169. package/build/esnext/transport/http-transport-types.js.map +1 -1
  170. package/build/esnext/transport/http-transport-utils.d.ts +6 -4
  171. package/build/esnext/transport/http-transport-utils.js +86 -56
  172. package/build/esnext/transport/http-transport-utils.js.map +1 -1
  173. package/build/esnext/transport/node-http-transport-types.d.ts +2 -2
  174. package/build/esnext/transport/node-http-transport-types.js +1 -12
  175. package/build/esnext/transport/node-http-transport-types.js.map +1 -1
  176. package/build/esnext/types.js +1 -12
  177. package/build/esnext/types.js.map +1 -1
  178. package/build/esnext/util.js +1 -12
  179. package/build/esnext/util.js.map +1 -1
  180. package/build/esnext/version.d.ts +1 -1
  181. package/build/esnext/version.js +2 -13
  182. package/build/esnext/version.js.map +1 -1
  183. package/build/src/OTLPExporterBase.d.ts +2 -2
  184. package/build/src/OTLPExporterBase.js +1 -12
  185. package/build/src/OTLPExporterBase.js.map +1 -1
  186. package/build/src/bounded-queue-export-promise-handler.js +1 -12
  187. package/build/src/bounded-queue-export-promise-handler.js.map +1 -1
  188. package/build/src/configuration/convert-legacy-browser-http-options.d.ts +2 -2
  189. package/build/src/configuration/convert-legacy-browser-http-options.js +0 -15
  190. package/build/src/configuration/convert-legacy-browser-http-options.js.map +1 -1
  191. package/build/src/configuration/convert-legacy-http-options.d.ts +2 -2
  192. package/build/src/configuration/convert-legacy-http-options.js +1 -12
  193. package/build/src/configuration/convert-legacy-http-options.js.map +1 -1
  194. package/build/src/configuration/convert-legacy-node-http-options.d.ts +2 -2
  195. package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
  196. package/build/src/configuration/create-legacy-browser-delegate.d.ts +3 -5
  197. package/build/src/configuration/create-legacy-browser-delegate.js +2 -10
  198. package/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
  199. package/build/src/configuration/legacy-base-configuration.d.ts +1 -1
  200. package/build/src/configuration/legacy-base-configuration.js.map +1 -1
  201. package/build/src/configuration/legacy-node-configuration.js +1 -12
  202. package/build/src/configuration/legacy-node-configuration.js.map +1 -1
  203. package/build/src/configuration/otlp-http-configuration.d.ts +1 -1
  204. package/build/src/configuration/otlp-http-configuration.js +1 -12
  205. package/build/src/configuration/otlp-http-configuration.js.map +1 -1
  206. package/build/src/configuration/otlp-node-http-configuration.d.ts +1 -1
  207. package/build/src/configuration/otlp-node-http-configuration.js +0 -15
  208. package/build/src/configuration/otlp-node-http-configuration.js.map +1 -1
  209. package/build/src/configuration/otlp-node-http-env-configuration.d.ts +1 -1
  210. package/build/src/configuration/otlp-node-http-env-configuration.js +1 -12
  211. package/build/src/configuration/otlp-node-http-env-configuration.js.map +1 -1
  212. package/build/src/configuration/shared-configuration.d.ts +1 -1
  213. package/build/src/configuration/shared-configuration.js +1 -12
  214. package/build/src/configuration/shared-configuration.js.map +1 -1
  215. package/build/src/configuration/shared-env-configuration.d.ts +1 -1
  216. package/build/src/configuration/shared-env-configuration.js +1 -12
  217. package/build/src/configuration/shared-env-configuration.js.map +1 -1
  218. package/build/src/export-response.js +1 -12
  219. package/build/src/export-response.js.map +1 -1
  220. package/build/src/exporter-transport.d.ts +1 -1
  221. package/build/src/exporter-transport.js +1 -12
  222. package/build/src/exporter-transport.js.map +1 -1
  223. package/build/src/index-browser-http.d.ts +3 -0
  224. package/build/src/index-browser-http.js +4 -12
  225. package/build/src/index-browser-http.js.map +1 -1
  226. package/build/src/index-node-http.js +1 -12
  227. package/build/src/index-node-http.js.map +1 -1
  228. package/build/src/index.js +1 -12
  229. package/build/src/index.js.map +1 -1
  230. package/build/src/is-export-retryable.js +1 -12
  231. package/build/src/is-export-retryable.js.map +1 -1
  232. package/build/src/logging-response-handler.d.ts +1 -1
  233. package/build/src/logging-response-handler.js +1 -12
  234. package/build/src/logging-response-handler.js.map +1 -1
  235. package/build/src/otlp-browser-http-export-delegate.d.ts +6 -3
  236. package/build/src/otlp-browser-http-export-delegate.js +4 -7
  237. package/build/src/otlp-browser-http-export-delegate.js.map +1 -1
  238. package/build/src/otlp-export-delegate.d.ts +4 -4
  239. package/build/src/otlp-export-delegate.js +1 -12
  240. package/build/src/otlp-export-delegate.js.map +1 -1
  241. package/build/src/otlp-http-export-delegate.d.ts +3 -3
  242. package/build/src/otlp-http-export-delegate.js +0 -15
  243. package/build/src/otlp-http-export-delegate.js.map +1 -1
  244. package/build/src/otlp-network-export-delegate.d.ts +4 -4
  245. package/build/src/otlp-network-export-delegate.js +1 -12
  246. package/build/src/otlp-network-export-delegate.js.map +1 -1
  247. package/build/src/response-handler.js +1 -12
  248. package/build/src/response-handler.js.map +1 -1
  249. package/build/src/retrying-transport.d.ts +1 -1
  250. package/build/src/retrying-transport.js +1 -12
  251. package/build/src/retrying-transport.js.map +1 -1
  252. package/build/src/transport/fetch-transport.d.ts +2 -2
  253. package/build/src/transport/fetch-transport.js +52 -18
  254. package/build/src/transport/fetch-transport.js.map +1 -1
  255. package/build/src/transport/http-exporter-transport.d.ts +2 -2
  256. package/build/src/transport/http-exporter-transport.js +2 -17
  257. package/build/src/transport/http-exporter-transport.js.map +1 -1
  258. package/build/src/transport/http-transport-types.d.ts +1 -1
  259. package/build/src/transport/http-transport-types.js +1 -12
  260. package/build/src/transport/http-transport-types.js.map +1 -1
  261. package/build/src/transport/http-transport-utils.d.ts +6 -4
  262. package/build/src/transport/http-transport-utils.js +86 -56
  263. package/build/src/transport/http-transport-utils.js.map +1 -1
  264. package/build/src/transport/node-http-transport-types.d.ts +2 -2
  265. package/build/src/transport/node-http-transport-types.js +1 -12
  266. package/build/src/transport/node-http-transport-types.js.map +1 -1
  267. package/build/src/types.js +1 -12
  268. package/build/src/types.js.map +1 -1
  269. package/build/src/util.js +1 -12
  270. package/build/src/util.js.map +1 -1
  271. package/build/src/version.d.ts +1 -1
  272. package/build/src/version.js +2 -13
  273. package/build/src/version.js.map +1 -1
  274. package/package.json +6 -6
  275. package/build/esm/transport/send-beacon-transport.d.ts +0 -12
  276. package/build/esm/transport/send-beacon-transport.js +0 -47
  277. package/build/esm/transport/send-beacon-transport.js.map +0 -1
  278. package/build/esnext/transport/send-beacon-transport.d.ts +0 -12
  279. package/build/esnext/transport/send-beacon-transport.js +0 -47
  280. package/build/esnext/transport/send-beacon-transport.js.map +0 -1
  281. package/build/src/transport/send-beacon-transport.d.ts +0 -12
  282. package/build/src/transport/send-beacon-transport.js +0 -51
  283. package/build/src/transport/send-beacon-transport.js.map +0 -1
@@ -1,20 +1,33 @@
1
1
  /*
2
2
  * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
3
+ * SPDX-License-Identifier: Apache-2.0
15
4
  */
16
5
  import { diag } from '@opentelemetry/api';
17
6
  import { isExportHTTPErrorRetryable, parseRetryAfterToMills, } from '../is-export-retryable';
7
+ /**
8
+ * Maximum total body size for concurrent keepalive requests.
9
+ * Browsers enforce a 64KiB cumulative limit across all pending keepalive requests.
10
+ * We use 60KB to leave headroom for headers.
11
+ * @see https://github.com/whatwg/fetch/issues/679
12
+ * @see https://blog.huli.tw/2025/01/06/en/navigator-sendbeacon-64kib-and-source-code/
13
+ */
14
+ const MAX_KEEPALIVE_BODY_SIZE = 60 * 1024;
15
+ /**
16
+ * Maximum concurrent keepalive requests.
17
+ * Chrome enforces 9 concurrent keepalive fetch requests per renderer process.
18
+ * @see https://github.com/whatwg/fetch/issues/679
19
+ * Quote: "If the renderer process is processing more than 9 requests with keepalive set, we reject a new request"
20
+ */
21
+ const MAX_KEEPALIVE_REQUESTS = 9;
22
+ /**
23
+ * Track cumulative pending body size across all in-flight keepalive requests.
24
+ * This is necessary because the 64KiB limit is cumulative, not per-request.
25
+ */
26
+ let pendingBodySize = 0;
27
+ /**
28
+ * Track number of pending keepalive requests.
29
+ */
30
+ let pendingKeepaliveCount = 0;
18
31
  class FetchTransport {
19
32
  _parameters;
20
33
  constructor(parameters) {
@@ -35,37 +48,53 @@ class FetchTransport {
35
48
  // @ts-expect-error -- fetch could be wrapped
36
49
  fetchApi = fetchApi.__original;
37
50
  }
51
+ const requestSize = data.byteLength;
52
+ // Determine if we can use keepalive based on cumulative browser limits.
53
+ // We must check BEFORE adding to pending totals to avoid exceeding limits.
54
+ const wouldExceedSize = pendingBodySize + requestSize > MAX_KEEPALIVE_BODY_SIZE;
55
+ const wouldExceedCount = pendingKeepaliveCount >= MAX_KEEPALIVE_REQUESTS;
56
+ const useKeepalive = !wouldExceedSize && !wouldExceedCount;
57
+ if (useKeepalive) {
58
+ pendingBodySize += requestSize;
59
+ pendingKeepaliveCount++;
60
+ }
61
+ else {
62
+ const reason = wouldExceedSize ? 'size limit' : 'count limit';
63
+ diag.debug(`keepalive disabled: ${(requestSize / 1024).toFixed(1)}KB payload, ${pendingKeepaliveCount} pending (${reason})`);
64
+ }
38
65
  try {
39
- const isBrowserEnvironment = !!globalThis.location;
40
66
  const url = new URL(this._parameters.url);
41
67
  const response = await fetchApi(url.href, {
42
68
  method: 'POST',
43
69
  headers: await this._parameters.headers(),
44
70
  body: data,
45
71
  signal: abortController.signal,
46
- keepalive: isBrowserEnvironment,
47
- mode: isBrowserEnvironment
48
- ? globalThis.location?.origin === url.origin
72
+ keepalive: useKeepalive,
73
+ mode: globalThis.location
74
+ ? globalThis.location.origin === url.origin
49
75
  ? 'same-origin'
50
76
  : 'cors'
51
77
  : 'no-cors',
52
78
  });
53
79
  if (response.status >= 200 && response.status <= 299) {
54
- diag.debug('response success');
80
+ diag.debug(`export response success (status: ${response.status})`);
55
81
  return { status: 'success' };
56
82
  }
57
83
  else if (isExportHTTPErrorRetryable(response.status)) {
84
+ diag.warn(`export response retryable (status: ${response.status})`);
58
85
  const retryAfter = response.headers.get('Retry-After');
59
86
  const retryInMillis = parseRetryAfterToMills(retryAfter);
60
87
  return { status: 'retryable', retryInMillis };
61
88
  }
89
+ diag.error(`export response failure (status: ${response.status})`);
62
90
  return {
63
91
  status: 'failure',
64
- error: new Error('Fetch request failed with non-retryable status'),
92
+ error: new Error(`Fetch request failed with non-retryable status ${response.status}`),
65
93
  };
66
94
  }
67
95
  catch (error) {
68
96
  if (isFetchNetworkErrorRetryable(error)) {
97
+ diag.warn(`export request retryable (network error: ${error})`);
69
98
  return {
70
99
  status: 'retryable',
71
100
  error: new Error('Fetch request encountered a network error', {
@@ -73,6 +102,7 @@ class FetchTransport {
73
102
  }),
74
103
  };
75
104
  }
105
+ diag.error(`export request failure (error: ${error})`);
76
106
  return {
77
107
  status: 'failure',
78
108
  error: new Error('Fetch request errored', { cause: error }),
@@ -80,6 +110,10 @@ class FetchTransport {
80
110
  }
81
111
  finally {
82
112
  clearTimeout(timeout);
113
+ if (useKeepalive) {
114
+ pendingBodySize -= requestSize;
115
+ pendingKeepaliveCount--;
116
+ }
83
117
  }
84
118
  }
85
119
  shutdown() {
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../../../src/transport/fetch-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAQhC,MAAM,cAAc;IACV,WAAW,CAA2B;IAE9C,YAAY,UAAoC;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,EAA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CAAC;gBACvD,MAAM,aAAa,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;gBACzD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;aAC/C;YACD,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,gDAAgD,CAAC;aACnE,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,4BAA4B,CAAC,KAAK,CAAC,EAAE;gBACvC,OAAO;oBACL,MAAM,EAAE,WAAW;oBACnB,KAAK,EAAE,IAAI,KAAK,CAAC,2CAA2C,EAAE;wBAC5D,KAAK,EAAE,KAAK;qBACb,CAAC;iBACH,CAAC;aACH;YACD,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;aAC5D,CAAC;SACH;gBAAS;YACR,YAAY,CAAC,OAAO,CAAC,CAAC;SACvB;IACH,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAoC;IAEpC,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAc;IAClD,OAAO,KAAK,YAAY,SAAS,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;AACpD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { IExporterTransport } from '../exporter-transport';\nimport { ExportResponse } from '../export-response';\nimport { diag } from '@opentelemetry/api';\nimport {\n isExportHTTPErrorRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { HeadersFactory } from '../configuration/otlp-http-configuration';\n\nexport interface FetchTransportParameters {\n url: string;\n headers: HeadersFactory;\n}\n\nclass FetchTransport implements IExporterTransport {\n private _parameters: FetchTransportParameters;\n\n constructor(parameters: FetchTransportParameters) {\n this._parameters = parameters;\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const abortController = new AbortController();\n const timeout = setTimeout(() => abortController.abort(), timeoutMillis);\n // Fetch API may be wrapped by an instrumentation like `@opentelemetry/instrumentation-fetch`.\n // In that case the instrumentation would create a new Span for this request\n // because the context manager cannot keep the context after `await` calls.\n // This creates an indirect endless loop Export -> Span -> Export\n // By using the `__original` function the instrumentation can't intercept the call\n // and no Span will be created breaking the vicious cycle\n let fetchApi = globalThis.fetch;\n // @ts-expect-error -- fetch could be wrapped\n if (typeof fetchApi.__original === 'function') {\n // @ts-expect-error -- fetch could be wrapped\n fetchApi = fetchApi.__original;\n }\n\n try {\n const isBrowserEnvironment = !!globalThis.location;\n const url = new URL(this._parameters.url);\n const response = await fetchApi(url.href, {\n method: 'POST',\n headers: await this._parameters.headers(),\n body: data,\n signal: abortController.signal,\n keepalive: isBrowserEnvironment,\n mode: isBrowserEnvironment\n ? globalThis.location?.origin === url.origin\n ? 'same-origin'\n : 'cors'\n : 'no-cors',\n });\n\n if (response.status >= 200 && response.status <= 299) {\n diag.debug('response success');\n return { status: 'success' };\n } else if (isExportHTTPErrorRetryable(response.status)) {\n const retryAfter = response.headers.get('Retry-After');\n const retryInMillis = parseRetryAfterToMills(retryAfter);\n return { status: 'retryable', retryInMillis };\n }\n return {\n status: 'failure',\n error: new Error('Fetch request failed with non-retryable status'),\n };\n } catch (error) {\n if (isFetchNetworkErrorRetryable(error)) {\n return {\n status: 'retryable',\n error: new Error('Fetch request encountered a network error', {\n cause: error,\n }),\n };\n }\n return {\n status: 'failure',\n error: new Error('Fetch request errored', { cause: error }),\n };\n } finally {\n clearTimeout(timeout);\n }\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * Creates an exporter transport that uses `fetch` to send the data\n * @param parameters applied to each request made by transport\n */\nexport function createFetchTransport(\n parameters: FetchTransportParameters\n): IExporterTransport {\n return new FetchTransport(parameters);\n}\n\nfunction isFetchNetworkErrorRetryable(error: unknown): boolean {\n return error instanceof TypeError && !error.cause;\n}\n"]}
1
+ {"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../../../src/transport/fetch-transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC;;;GAGG;AACH,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;GAEG;AACH,IAAI,qBAAqB,GAAG,CAAC,CAAC;AAO9B,MAAM,cAAc;IACV,WAAW,CAA2B;IAE9C,YAAY,UAAoC;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,aAAa,CAAC,CAAC;QACzE,8FAA8F;QAC9F,4EAA4E;QAC5E,2EAA2E;QAC3E,iEAAiE;QACjE,kFAAkF;QAClF,yDAAyD;QACzD,IAAI,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC;QA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EAAE,KAAK,EAAE,CAAC;aAC5D,CAAC;SACH;gBAAS;YACR,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,YAAY,EAAE;gBAChB,eAAe,IAAI,WAAW,CAAC;gBAC/B,qBAAqB,EAAE,CAAC;aACzB;SACF;IACH,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAoC;IAEpC,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAc;IAClD,OAAO,KAAK,YAAY,SAAS,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;AACpD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { IExporterTransport } from '../exporter-transport';\nimport type { ExportResponse } from '../export-response';\nimport { diag } from '@opentelemetry/api';\nimport {\n isExportHTTPErrorRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport type { HeadersFactory } from '../configuration/otlp-http-configuration';\n\n/**\n * Maximum total body size for concurrent keepalive requests.\n * Browsers enforce a 64KiB cumulative limit across all pending keepalive requests.\n * We use 60KB to leave headroom for headers.\n * @see https://github.com/whatwg/fetch/issues/679\n * @see https://blog.huli.tw/2025/01/06/en/navigator-sendbeacon-64kib-and-source-code/\n */\nconst MAX_KEEPALIVE_BODY_SIZE = 60 * 1024;\n\n/**\n * Maximum concurrent keepalive requests.\n * Chrome enforces 9 concurrent keepalive fetch requests per renderer process.\n * @see https://github.com/whatwg/fetch/issues/679\n * Quote: \"If the renderer process is processing more than 9 requests with keepalive set, we reject a new request\"\n */\nconst MAX_KEEPALIVE_REQUESTS = 9;\n\n/**\n * Track cumulative pending body size across all in-flight keepalive requests.\n * This is necessary because the 64KiB limit is cumulative, not per-request.\n */\nlet pendingBodySize = 0;\n\n/**\n * Track number of pending keepalive requests.\n */\nlet pendingKeepaliveCount = 0;\n\nexport interface FetchTransportParameters {\n url: string;\n headers: HeadersFactory;\n}\n\nclass FetchTransport implements IExporterTransport {\n private _parameters: FetchTransportParameters;\n\n constructor(parameters: FetchTransportParameters) {\n this._parameters = parameters;\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const abortController = new AbortController();\n const timeout = setTimeout(() => abortController.abort(), timeoutMillis);\n // Fetch API may be wrapped by an instrumentation like `@opentelemetry/instrumentation-fetch`.\n // In that case the instrumentation would create a new Span for this request\n // because the context manager cannot keep the context after `await` calls.\n // This creates an indirect endless loop Export -> Span -> Export\n // By using the `__original` function the instrumentation can't intercept the call\n // and no Span will be created breaking the vicious cycle\n let fetchApi = globalThis.fetch;\n // @ts-expect-error -- fetch could be wrapped\n if (typeof fetchApi.__original === 'function') {\n // @ts-expect-error -- fetch could be wrapped\n fetchApi = fetchApi.__original;\n }\n\n const requestSize = data.byteLength;\n\n // Determine if we can use keepalive based on cumulative browser limits.\n // We must check BEFORE adding to pending totals to avoid exceeding limits.\n const wouldExceedSize =\n pendingBodySize + requestSize > MAX_KEEPALIVE_BODY_SIZE;\n const wouldExceedCount = pendingKeepaliveCount >= MAX_KEEPALIVE_REQUESTS;\n const useKeepalive = !wouldExceedSize && !wouldExceedCount;\n\n if (useKeepalive) {\n pendingBodySize += requestSize;\n pendingKeepaliveCount++;\n } else {\n const reason = wouldExceedSize ? 'size limit' : 'count limit';\n diag.debug(\n `keepalive disabled: ${(requestSize / 1024).toFixed(1)}KB payload, ${pendingKeepaliveCount} pending (${reason})`\n );\n }\n\n try {\n const url = new URL(this._parameters.url);\n const response = await fetchApi(url.href, {\n method: 'POST',\n headers: await this._parameters.headers(),\n body: data,\n signal: abortController.signal,\n keepalive: useKeepalive,\n mode: globalThis.location\n ? globalThis.location.origin === url.origin\n ? 'same-origin'\n : 'cors'\n : 'no-cors',\n });\n\n if (response.status >= 200 && response.status <= 299) {\n diag.debug(`export response success (status: ${response.status})`);\n return { status: 'success' };\n } else if (isExportHTTPErrorRetryable(response.status)) {\n diag.warn(`export response retryable (status: ${response.status})`);\n const retryAfter = response.headers.get('Retry-After');\n const retryInMillis = parseRetryAfterToMills(retryAfter);\n return { status: 'retryable', retryInMillis };\n }\n diag.error(`export response failure (status: ${response.status})`);\n return {\n status: 'failure',\n error: new Error(\n `Fetch request failed with non-retryable status ${response.status}`\n ),\n };\n } catch (error) {\n if (isFetchNetworkErrorRetryable(error)) {\n diag.warn(`export request retryable (network error: ${error})`);\n return {\n status: 'retryable',\n error: new Error('Fetch request encountered a network error', {\n cause: error,\n }),\n };\n }\n diag.error(`export request failure (error: ${error})`);\n return {\n status: 'failure',\n error: new Error('Fetch request errored', { cause: error }),\n };\n } finally {\n clearTimeout(timeout);\n if (useKeepalive) {\n pendingBodySize -= requestSize;\n pendingKeepaliveCount--;\n }\n }\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * Creates an exporter transport that uses `fetch` to send the data\n * @param parameters applied to each request made by transport\n */\nexport function createFetchTransport(\n parameters: FetchTransportParameters\n): IExporterTransport {\n return new FetchTransport(parameters);\n}\n\nfunction isFetchNetworkErrorRetryable(error: unknown): boolean {\n return error instanceof TypeError && !error.cause;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { IExporterTransport } from '../exporter-transport';
2
- import { NodeHttpRequestParameters } from './node-http-transport-types';
1
+ import type { IExporterTransport } from '../exporter-transport';
2
+ import type { NodeHttpRequestParameters } from './node-http-transport-types';
3
3
  export declare function createHttpExporterTransport(parameters: NodeHttpRequestParameters): IExporterTransport;
4
4
  //# sourceMappingURL=http-exporter-transport.d.ts.map
@@ -1,17 +1,6 @@
1
1
  /*
2
2
  * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
3
+ * SPDX-License-Identifier: Apache-2.0
15
4
  */
16
5
  import { sendWithHttp } from './http-transport-utils';
17
6
  class HttpExporterTransport {
@@ -23,11 +12,7 @@ class HttpExporterTransport {
23
12
  async send(data, timeoutMillis) {
24
13
  const { agent, request } = await this._loadUtils();
25
14
  const headers = await this._parameters.headers();
26
- return new Promise(resolve => {
27
- sendWithHttp(request, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, result => {
28
- resolve(result);
29
- }, timeoutMillis);
30
- });
15
+ return sendWithHttp(request, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, timeoutMillis);
31
16
  }
32
17
  shutdown() {
33
18
  // intentionally left empty, nothing to do.
@@ -1 +1 @@
1
- {"version":3,"file":"http-exporter-transport.js","sourceRoot":"","sources":["../../../src/transport/http-exporter-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQtD,MAAM,qBAAqB;IACjB,MAAM,GAAiB,IAAI,CAAC;IAC5B,WAAW,CAA4B;IAE/C,YAAY,UAAqC;QAC/C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAEjD,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,YAAY,CACV,OAAO,EACP,IAAI,CAAC,WAAW,CAAC,GAAG,EACpB,OAAO,EACP,IAAI,CAAC,WAAW,CAAC,WAAW,EAC5B,IAAI,CAAC,WAAW,CAAC,SAAS,EAC1B,KAAK,EACL,IAAI,EACJ,MAAM,CAAC,EAAE;gBACP,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,EACD,aAAa,CACd,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;IAEO,KAAK,CAAC,UAAU;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAExB,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;YACxD,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACzC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC;gBACvC,sBAAsB,CAAC,QAAQ,CAAC;aACjC,CAAC,CAAC;YACH,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SAC1C;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,KAAK,UAAU,sBAAsB,CACnC,QAAgB;IAEhB,MAAM,MAAM,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,UAAqC;IAErC,OAAO,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC/C,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// NOTE: do not change these type imports to actual imports. Doing so WILL break `@opentelemetry/instrumentation-http`,\n// as they'd be imported before the http/https modules can be wrapped.\nimport type * as https from 'https';\nimport type * as http from 'http';\nimport { ExportResponse } from '../export-response';\nimport { IExporterTransport } from '../exporter-transport';\nimport { sendWithHttp } from './http-transport-utils';\nimport { NodeHttpRequestParameters } from './node-http-transport-types';\n\ninterface Utils {\n agent: http.Agent | https.Agent;\n request: typeof http.request | typeof https.request;\n}\n\nclass HttpExporterTransport implements IExporterTransport {\n private _utils: Utils | null = null;\n private _parameters: NodeHttpRequestParameters;\n\n constructor(parameters: NodeHttpRequestParameters) {\n this._parameters = parameters;\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const { agent, request } = await this._loadUtils();\n const headers = await this._parameters.headers();\n\n return new Promise<ExportResponse>(resolve => {\n sendWithHttp(\n request,\n this._parameters.url,\n headers,\n this._parameters.compression,\n this._parameters.userAgent,\n agent,\n data,\n result => {\n resolve(result);\n },\n timeoutMillis\n );\n });\n }\n\n shutdown() {\n // intentionally left empty, nothing to do.\n }\n\n private async _loadUtils(): Promise<Utils> {\n let utils = this._utils;\n\n if (utils === null) {\n const protocol = new URL(this._parameters.url).protocol;\n const [agent, request] = await Promise.all([\n this._parameters.agentFactory(protocol),\n requestFunctionFactory(protocol),\n ]);\n utils = this._utils = { agent, request };\n }\n\n return utils;\n }\n}\n\nasync function requestFunctionFactory(\n protocol: string\n): Promise<typeof http.request | typeof https.request> {\n const module = protocol === 'http:' ? import('http') : import('https');\n const { request } = await module;\n return request;\n}\n\nexport function createHttpExporterTransport(\n parameters: NodeHttpRequestParameters\n): IExporterTransport {\n return new HttpExporterTransport(parameters);\n}\n"]}
1
+ {"version":3,"file":"http-exporter-transport.js","sourceRoot":"","sources":["../../../src/transport/http-exporter-transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQtD,MAAM,qBAAqB;IACjB,MAAM,GAAiB,IAAI,CAAC;IAC5B,WAAW,CAA4B;IAE/C,YAAY,UAAqC;QAC/C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAEjD,OAAO,YAAY,CACjB,OAAO,EACP,IAAI,CAAC,WAAW,CAAC,GAAG,EACpB,OAAO,EACP,IAAI,CAAC,WAAW,CAAC,WAAW,EAC5B,IAAI,CAAC,WAAW,CAAC,SAAS,EAC1B,KAAK,EACL,IAAI,EACJ,aAAa,CACd,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;IAEO,KAAK,CAAC,UAAU;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAExB,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;YACxD,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACzC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC;gBACvC,sBAAsB,CAAC,QAAQ,CAAC;aACjC,CAAC,CAAC;YACH,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SAC1C;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,KAAK,UAAU,sBAAsB,CACnC,QAAgB;IAEhB,MAAM,MAAM,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,UAAqC;IAErC,OAAO,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// NOTE: do not change these type imports to actual imports. Doing so WILL break `@opentelemetry/instrumentation-http`,\n// as they'd be imported before the http/https modules can be wrapped.\nimport type * as https from 'https';\nimport type * as http from 'http';\nimport type { ExportResponse } from '../export-response';\nimport type { IExporterTransport } from '../exporter-transport';\nimport { sendWithHttp } from './http-transport-utils';\nimport type { NodeHttpRequestParameters } from './node-http-transport-types';\n\ninterface Utils {\n agent: http.Agent | https.Agent;\n request: typeof http.request | typeof https.request;\n}\n\nclass HttpExporterTransport implements IExporterTransport {\n private _utils: Utils | null = null;\n private _parameters: NodeHttpRequestParameters;\n\n constructor(parameters: NodeHttpRequestParameters) {\n this._parameters = parameters;\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n const { agent, request } = await this._loadUtils();\n const headers = await this._parameters.headers();\n\n return sendWithHttp(\n request,\n this._parameters.url,\n headers,\n this._parameters.compression,\n this._parameters.userAgent,\n agent,\n data,\n timeoutMillis\n );\n }\n\n shutdown() {\n // intentionally left empty, nothing to do.\n }\n\n private async _loadUtils(): Promise<Utils> {\n let utils = this._utils;\n\n if (utils === null) {\n const protocol = new URL(this._parameters.url).protocol;\n const [agent, request] = await Promise.all([\n this._parameters.agentFactory(protocol),\n requestFunctionFactory(protocol),\n ]);\n utils = this._utils = { agent, request };\n }\n\n return utils;\n }\n}\n\nasync function requestFunctionFactory(\n protocol: string\n): Promise<typeof http.request | typeof https.request> {\n const module = protocol === 'http:' ? import('http') : import('https');\n const { request } = await module;\n return request;\n}\n\nexport function createHttpExporterTransport(\n parameters: NodeHttpRequestParameters\n): IExporterTransport {\n return new HttpExporterTransport(parameters);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { HeadersFactory } from '../configuration/otlp-http-configuration';
1
+ import type { HeadersFactory } from '../configuration/otlp-http-configuration';
2
2
  export interface HttpRequestParameters {
3
3
  url: string;
4
4
  headers: HeadersFactory;
@@ -1,17 +1,6 @@
1
1
  /*
2
2
  * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
3
+ * SPDX-License-Identifier: Apache-2.0
15
4
  */
16
5
  export {};
17
6
  //# sourceMappingURL=http-transport-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-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 { HeadersFactory } from '../configuration/otlp-http-configuration';\n\nexport interface HttpRequestParameters {\n url: string;\n headers: HeadersFactory;\n compression: 'gzip' | 'none';\n userAgent?: string;\n}\n"]}
1
+ {"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { HeadersFactory } from '../configuration/otlp-http-configuration';\n\nexport interface HttpRequestParameters {\n url: string;\n headers: HeadersFactory;\n compression: 'gzip' | 'none';\n userAgent?: string;\n}\n"]}
@@ -2,16 +2,18 @@
2
2
  /// <reference types="node" />
3
3
  import type * as http from 'http';
4
4
  import type * as https from 'https';
5
- import { ExportResponse } from '../export-response';
5
+ import type { ExportResponse } from '../export-response';
6
6
  /**
7
7
  * Sends data using http
8
8
  * @param request
9
- * @param params
9
+ * @param url
10
+ * @param headers
11
+ * @param compression
12
+ * @param userAgent
10
13
  * @param agent
11
14
  * @param data
12
- * @param onDone
13
15
  * @param timeoutMillis
14
16
  */
15
- export declare function sendWithHttp(request: typeof https.request | typeof http.request, url: string, headers: Record<string, string>, compression: 'gzip' | 'none', userAgent: string | undefined, agent: http.Agent | https.Agent, data: Uint8Array, onDone: (response: ExportResponse) => void, timeoutMillis: number): void;
17
+ export declare function sendWithHttp(request: typeof https.request | typeof http.request, url: string, headers: Record<string, string>, compression: 'gzip' | 'none', userAgent: string | undefined, agent: http.Agent | https.Agent, data: Uint8Array, timeoutMillis: number): Promise<ExportResponse>;
16
18
  export declare function compressAndSend(req: http.ClientRequest, compression: 'gzip' | 'none', data: Uint8Array, onError: (error: Error) => void): void;
17
19
  //# sourceMappingURL=http-transport-utils.d.ts.map
@@ -7,78 +7,108 @@ const DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;
7
7
  /**
8
8
  * Sends data using http
9
9
  * @param request
10
- * @param params
10
+ * @param url
11
+ * @param headers
12
+ * @param compression
13
+ * @param userAgent
11
14
  * @param agent
12
15
  * @param data
13
- * @param onDone
14
16
  * @param timeoutMillis
15
17
  */
16
- export function sendWithHttp(request, url, headers, compression, userAgent, agent, data, onDone, timeoutMillis) {
17
- const parsedUrl = new URL(url);
18
- if (userAgent) {
19
- headers['User-Agent'] = `${userAgent} ${DEFAULT_USER_AGENT}`;
20
- }
21
- else {
22
- headers['User-Agent'] = DEFAULT_USER_AGENT;
23
- }
24
- const options = {
25
- hostname: parsedUrl.hostname,
26
- port: parsedUrl.port,
27
- path: parsedUrl.pathname,
28
- method: 'POST',
29
- headers,
30
- agent,
31
- };
32
- const req = request(options, (res) => {
33
- const responseData = [];
34
- res.on('data', chunk => responseData.push(chunk));
35
- res.on('end', () => {
36
- if (res.statusCode && res.statusCode < 299) {
37
- onDone({
38
- status: 'success',
39
- data: Buffer.concat(responseData),
40
- });
41
- }
42
- else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
43
- onDone({
18
+ export function sendWithHttp(request, url, headers, compression, userAgent, agent, data, timeoutMillis) {
19
+ return new Promise(resolve => {
20
+ const parsedUrl = new URL(url);
21
+ if (userAgent) {
22
+ headers['User-Agent'] = `${userAgent} ${DEFAULT_USER_AGENT}`;
23
+ }
24
+ else {
25
+ headers['User-Agent'] = DEFAULT_USER_AGENT;
26
+ }
27
+ const options = {
28
+ hostname: parsedUrl.hostname,
29
+ port: parsedUrl.port,
30
+ path: parsedUrl.pathname,
31
+ method: 'POST',
32
+ headers,
33
+ agent,
34
+ };
35
+ const req = request(options, (res) => {
36
+ const responseData = [];
37
+ res.on('data', chunk => responseData.push(chunk));
38
+ res.on('end', () => {
39
+ if (res.statusCode && res.statusCode <= 299) {
40
+ resolve({
41
+ status: 'success',
42
+ data: Buffer.concat(responseData),
43
+ });
44
+ }
45
+ else if (res.statusCode &&
46
+ isExportHTTPErrorRetryable(res.statusCode)) {
47
+ resolve({
48
+ status: 'retryable',
49
+ retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),
50
+ });
51
+ }
52
+ else {
53
+ const error = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
54
+ resolve({
55
+ status: 'failure',
56
+ error,
57
+ });
58
+ }
59
+ });
60
+ res.on('error', (error) => {
61
+ // Note: 'end' may still be emitted after 'error' on the same response object, since we're resolving a promise,
62
+ // the first call to resolve() will determine the final state.
63
+ if (res.statusCode && res.statusCode <= 299) {
64
+ // If the response is successful but an error occurs while reading the response,
65
+ // we consider it a success since the data has been sent successfully.
66
+ resolve({
67
+ status: 'success',
68
+ });
69
+ }
70
+ else if (res.statusCode &&
71
+ isExportHTTPErrorRetryable(res.statusCode)) {
72
+ resolve({
73
+ status: 'retryable',
74
+ error: error,
75
+ retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),
76
+ });
77
+ }
78
+ else {
79
+ resolve({
80
+ status: 'failure',
81
+ error,
82
+ });
83
+ }
84
+ });
85
+ });
86
+ req.setTimeout(timeoutMillis, () => {
87
+ req.destroy();
88
+ resolve({
89
+ status: 'retryable',
90
+ error: new Error('Request timed out'),
91
+ });
92
+ });
93
+ req.on('error', (error) => {
94
+ if (isHttpTransportNetworkErrorRetryable(error)) {
95
+ resolve({
44
96
  status: 'retryable',
45
- retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),
97
+ error,
46
98
  });
47
99
  }
48
100
  else {
49
- const error = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
50
- onDone({
101
+ resolve({
51
102
  status: 'failure',
52
103
  error,
53
104
  });
54
105
  }
55
106
  });
56
- });
57
- req.setTimeout(timeoutMillis, () => {
58
- req.destroy();
59
- onDone({
60
- status: 'retryable',
61
- error: new Error('Request timed out'),
62
- });
63
- });
64
- req.on('error', (error) => {
65
- if (isHttpTransportNetworkErrorRetryable(error)) {
66
- onDone({
67
- status: 'retryable',
68
- error,
69
- });
70
- }
71
- else {
72
- onDone({
107
+ compressAndSend(req, compression, data, (error) => {
108
+ resolve({
73
109
  status: 'failure',
74
110
  error,
75
111
  });
76
- }
77
- });
78
- compressAndSend(req, compression, data, (error) => {
79
- onDone({
80
- status: 'failure',
81
- error,
82
112
  });
83
113
  });
84
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,kBAAkB,GAAG,iCAAiC,OAAO,EAAE,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAmD,EACnD,GAAW,EACX,OAA+B,EAC/B,WAA4B,EAC5B,SAA6B,EAC7B,KAA+B,EAC/B,IAAgB,EAChB,MAA0C,EAC1C,aAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,SAAS,EAAE;QACb,OAAO,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,IAAI,kBAAkB,EAAE,CAAC;KAC9D;SAAM;QACL,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,CAAC;KAC5C;IAED,MAAM,OAAO,GAA+C;QAC1D,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,IAAI,EAAE,SAAS,CAAC,QAAQ;QACxB,MAAM,EAAE,MAAM;QACd,OAAO;QACP,KAAK;KACN,CAAC;IAEF,MAAM,GAAG,GAAG,OAAO,C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C;QAC5C,YAAY;QACZ,cAAc;QACd,OAAO;QACP,WAAW;QACX,WAAW;QACX,WAAW;QACX,aAAa;QACb,cAAc;KACf,CAAC,CAAC;IAEH,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;QACrD,OAAO,6BAA6B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACtD;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { ExportResponse } from '../export-response';\nimport {\n isExportHTTPErrorRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { OTLPExporterError } from '../types';\nimport { VERSION } from '../version';\n\nconst DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;\n\n/**\n * Sends data using http\n * @param request\n * @param params\n * @param agent\n * @param data\n * @param onDone\n * @param timeoutMillis\n */\nexport function sendWithHttp(\n request: typeof https.request | typeof http.request,\n url: string,\n headers: Record<string, string>,\n compression: 'gzip' | 'none',\n userAgent: string | undefined,\n agent: http.Agent | https.Agent,\n data: Uint8Array,\n onDone: (response: ExportResponse) => void,\n timeoutMillis: number\n): void {\n const parsedUrl = new URL(url);\n\n if (userAgent) {\n headers['User-Agent'] = `${userAgent} ${DEFAULT_USER_AGENT}`;\n } else {\n headers['User-Agent'] = DEFAULT_USER_AGENT;\n }\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers,\n agent,\n };\n\n const req = request(options, (res: http.IncomingMessage) => {\n const responseData: Buffer[] = [];\n res.on('data', chunk => responseData.push(chunk));\n\n res.on('end', () => {\n if (res.statusCode && res.statusCode < 299) {\n onDone({\n status: 'success',\n data: Buffer.concat(responseData),\n });\n } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {\n onDone({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n Buffer.concat(responseData).toString()\n );\n onDone({\n status: 'failure',\n error,\n });\n }\n });\n });\n\n req.setTimeout(timeoutMillis, () => {\n req.destroy();\n onDone({\n status: 'retryable',\n error: new Error('Request timed out'),\n });\n });\n\n req.on('error', (error: Error) => {\n if (isHttpTransportNetworkErrorRetryable(error)) {\n onDone({\n status: 'retryable',\n error,\n });\n } else {\n onDone({\n status: 'failure',\n error,\n });\n }\n });\n\n compressAndSend(req, compression, data, (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n}\n\nexport function compressAndSend(\n req: http.ClientRequest,\n compression: 'gzip' | 'none',\n data: Uint8Array,\n onError: (error: Error) => void\n) {\n let dataStream = readableFromUint8Array(data);\n\n if (compression === 'gzip') {\n req.setHeader('Content-Encoding', 'gzip');\n dataStream = dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError);\n }\n\n dataStream.pipe(req).on('error', onError);\n}\n\nfunction readableFromUint8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nfunction isHttpTransportNetworkErrorRetryable(error: Error): boolean {\n const RETRYABLE_NETWORK_ERROR_CODES = new Set([\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'EAI_AGAIN',\n 'ENOTFOUND',\n 'ENETUNREACH',\n 'EHOSTUNREACH',\n ]);\n\n if ('code' in error && typeof error.code === 'string') {\n return RETRYABLE_NETWORK_ERROR_CODES.has(error.code);\n }\n\n return false;\n}\n"]}
1
+ {"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,kBAAkB,GAAG,iCAAiC,OAAO,EAAE,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAmD,EACnD,GAAW,EACX,OAA+B,EAC/B,WAA4B,EAC5B,SAA6B,EAC7B,KAA+B,EAC/B,IAAgB,EAChB,aAAqB;IAErB,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;QAC3C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAE/B,IAAI,SAAS,EAAE;YACb,OAAO,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,IAAI,kBAAkB,EAAE,CAAC;SAC9D;aAAM;YACL,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,CAAC;SAC5C;QAED,MAAM,OAAO,GAA+C;YAC1D,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,IAAI,EAAE,SAAS,CAAC,QAAQ;YACxB,MAAM,EAAE,MAAM;YACd,OAAO;YACP,KAAK;SACN,CAAC;QAEF,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,GAAyB,EAAE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MAAM,EAAE;QAC1B,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC1C,UAAU,GAAG,UAAU;aACpB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;aACvB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACzB;IAED,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,oCAAoC,CAAC,KAAY;IACxD,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAC;QAC5C,YAAY;QACZ,cAAc;QACd,OAAO;QACP,WAAW;QACX,WAAW;QACX,WAAW;QACX,aAAa;QACb,cAAc;KACf,CAAC,CAAC;IAEH,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;QACrD,OAAO,6BAA6B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACtD;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport type { ExportResponse } from '../export-response';\nimport {\n isExportHTTPErrorRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { OTLPExporterError } from '../types';\nimport { VERSION } from '../version';\n\nconst DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;\n\n/**\n * Sends data using http\n * @param request\n * @param url\n * @param headers\n * @param compression\n * @param userAgent\n * @param agent\n * @param data\n * @param timeoutMillis\n */\nexport function sendWithHttp(\n request: typeof https.request | typeof http.request,\n url: string,\n headers: Record<string, string>,\n compression: 'gzip' | 'none',\n userAgent: string | undefined,\n agent: http.Agent | https.Agent,\n data: Uint8Array,\n timeoutMillis: number\n): Promise<ExportResponse> {\n return new Promise<ExportResponse>(resolve => {\n const parsedUrl = new URL(url);\n\n if (userAgent) {\n headers['User-Agent'] = `${userAgent} ${DEFAULT_USER_AGENT}`;\n } else {\n headers['User-Agent'] = DEFAULT_USER_AGENT;\n }\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers,\n agent,\n };\n\n const req = request(options, (res: http.IncomingMessage) => {\n const responseData: Buffer[] = [];\n res.on('data', chunk => responseData.push(chunk));\n\n res.on('end', () => {\n if (res.statusCode && res.statusCode <= 299) {\n resolve({\n status: 'success',\n data: Buffer.concat(responseData),\n });\n } else if (\n res.statusCode &&\n isExportHTTPErrorRetryable(res.statusCode)\n ) {\n resolve({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n Buffer.concat(responseData).toString()\n );\n resolve({\n status: 'failure',\n error,\n });\n }\n });\n\n res.on('error', (error: Error) => {\n // Note: 'end' may still be emitted after 'error' on the same response object, since we're resolving a promise,\n // the first call to resolve() will determine the final state.\n if (res.statusCode && res.statusCode <= 299) {\n // If the response is successful but an error occurs while reading the response,\n // we consider it a success since the data has been sent successfully.\n resolve({\n status: 'success',\n });\n } else if (\n res.statusCode &&\n isExportHTTPErrorRetryable(res.statusCode)\n ) {\n resolve({\n status: 'retryable',\n error: error,\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\n resolve({\n status: 'failure',\n error,\n });\n }\n });\n });\n\n req.setTimeout(timeoutMillis, () => {\n req.destroy();\n resolve({\n status: 'retryable',\n error: new Error('Request timed out'),\n });\n });\n\n req.on('error', (error: Error) => {\n if (isHttpTransportNetworkErrorRetryable(error)) {\n resolve({\n status: 'retryable',\n error,\n });\n } else {\n resolve({\n status: 'failure',\n error,\n });\n }\n });\n\n compressAndSend(req, compression, data, (error: Error) => {\n resolve({\n status: 'failure',\n error,\n });\n });\n });\n}\n\nexport function compressAndSend(\n req: http.ClientRequest,\n compression: 'gzip' | 'none',\n data: Uint8Array,\n onError: (error: Error) => void\n) {\n let dataStream = readableFromUint8Array(data);\n\n if (compression === 'gzip') {\n req.setHeader('Content-Encoding', 'gzip');\n dataStream = dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError);\n }\n\n dataStream.pipe(req).on('error', onError);\n}\n\nfunction readableFromUint8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nfunction isHttpTransportNetworkErrorRetryable(error: Error): boolean {\n const RETRYABLE_NETWORK_ERROR_CODES = new Set([\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'EAI_AGAIN',\n 'ENOTFOUND',\n 'ENETUNREACH',\n 'EHOSTUNREACH',\n ]);\n\n if ('code' in error && typeof error.code === 'string') {\n return RETRYABLE_NETWORK_ERROR_CODES.has(error.code);\n }\n\n return false;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { HttpAgentFactory } from '../configuration/otlp-node-http-configuration';
2
- import { HttpRequestParameters } from './http-transport-types';
1
+ import type { HttpAgentFactory } from '../configuration/otlp-node-http-configuration';
2
+ import type { HttpRequestParameters } from './http-transport-types';
3
3
  export interface NodeHttpRequestParameters extends HttpRequestParameters {
4
4
  agentFactory: HttpAgentFactory;
5
5
  }
@@ -1,17 +1,6 @@
1
1
  /*
2
2
  * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
3
+ * SPDX-License-Identifier: Apache-2.0
15
4
  */
16
5
  export {};
17
6
  //# sourceMappingURL=node-http-transport-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/node-http-transport-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 { HttpAgentFactory } from '../configuration/otlp-node-http-configuration';\nimport { HttpRequestParameters } from './http-transport-types';\n\nexport interface NodeHttpRequestParameters extends HttpRequestParameters {\n agentFactory: HttpAgentFactory;\n}\n"]}
1
+ {"version":3,"file":"node-http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/node-http-transport-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { HttpAgentFactory } from '../configuration/otlp-node-http-configuration';\nimport type { HttpRequestParameters } from './http-transport-types';\n\nexport interface NodeHttpRequestParameters extends HttpRequestParameters {\n agentFactory: HttpAgentFactory;\n}\n"]}
@@ -1,17 +1,6 @@
1
1
  /*
2
2
  * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
3
+ * SPDX-License-Identifier: Apache-2.0
15
4
  */
16
5
  /**
17
6
  * Interface for handling error
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,IAAI,CAAU;IACL,IAAI,GAAW,mBAAmB,CAAC;IAC5C,IAAI,CAAU;IAEvB,YAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","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 * Interface for handling error\n */\nexport class OTLPExporterError extends Error {\n readonly code?: number;\n override readonly name: string = 'OTLPExporterError';\n readonly data?: string;\n\n constructor(message?: string, code?: number, data?: string) {\n super(message);\n this.data = data;\n this.code = code;\n }\n}\n\n/**\n * Interface for handling export service errors\n */\nexport interface ExportServiceError {\n name: string;\n code: number;\n details: string;\n metadata: { [key: string]: unknown };\n message: string;\n stack: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,IAAI,CAAU;IACL,IAAI,GAAW,mBAAmB,CAAC;IAC5C,IAAI,CAAU;IAEvB,YAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Interface for handling error\n */\nexport class OTLPExporterError extends Error {\n readonly code?: number;\n override readonly name: string = 'OTLPExporterError';\n readonly data?: string;\n\n constructor(message?: string, code?: number, data?: string) {\n super(message);\n this.data = data;\n this.code = code;\n }\n}\n\n/**\n * Interface for handling export service errors\n */\nexport interface ExportServiceError {\n name: string;\n code: number;\n details: string;\n metadata: { [key: string]: unknown };\n message: string;\n stack: string;\n}\n"]}
package/build/esm/util.js CHANGED
@@ -1,17 +1,6 @@
1
1
  /*
2
2
  * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
3
+ * SPDX-License-Identifier: Apache-2.0
15
4
  */
16
5
  import { diag } from '@opentelemetry/api';
17
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,cAAkD;IAElD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC5D,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,IAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function validateAndNormalizeHeaders(\n partialHeaders: Record<string, string> | undefined\n): Record<string, string> {\n const headers: Record<string, string> = {};\n Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n headers[key] = String(value);\n } else {\n diag.warn(\n `Header \"${key}\" has invalid value (${value}) and will be ignored`\n );\n }\n });\n return headers;\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,cAAkD;IAElD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC5D,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,IAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { diag } from '@opentelemetry/api';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function validateAndNormalizeHeaders(\n partialHeaders: Record<string, string> | undefined\n): Record<string, string> {\n const headers: Record<string, string> = {};\n Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n headers[key] = String(value);\n } else {\n diag.warn(\n `Header \"${key}\" has invalid value (${value}) and will be ignored`\n );\n }\n });\n return headers;\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.212.0";
1
+ export declare const VERSION = "0.214.0";
2
2
  //# sourceMappingURL=version.d.ts.map