@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 +1 @@
1
- {"version":3,"file":"retrying-transport.js","sourceRoot":"","sources":["../../src/retrying-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,4CAA0C;AAE1C,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB;;GAEG;AACH,SAAS,SAAS;IAChB,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAC/C,CAAC;AAED,MAAM,iBAAiB;IACb,UAAU,CAAqB;IAEvC,YAAY,SAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEO,KAAK,CACX,IAAgB,EAChB,aAAqB,EACrB,QAAgB;QAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAClE,CAAC,EAAE,QAAQ,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB,EAAE,aAAqB;QAChD,IAAI,QAAQ,GA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M,CAAC,MAAM,KAAK,WAAW,EAAE;YACxC,UAAI,CAAC,IAAI,CACP,+CAA+C,YAAY,IAAI,CAChE,CAAC;SACH;aAAM;YACL,UAAI,CAAC,IAAI,CAAC,2CAA2C,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;SACtE;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAGvC;IACC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AALD,0DAKC","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';\n\nconst MAX_ATTEMPTS = 5;\nconst INITIAL_BACKOFF = 1000;\nconst MAX_BACKOFF = 5000;\nconst BACKOFF_MULTIPLIER = 1.5;\nconst JITTER = 0.2;\n\n/**\n * Get a pseudo-random jitter that falls in the range of [-JITTER, +JITTER]\n */\nfunction getJitter() {\n return Math.random() * (2 * JITTER) - JITTER;\n}\n\nclass RetryingTransport implements IExporterTransport {\n private _transport: IExporterTransport;\n\n constructor(transport: IExporterTransport) {\n this._transport = transport;\n }\n\n private retry(\n data: Uint8Array,\n timeoutMillis: number,\n inMillis: number\n ): Promise<ExportResponse> {\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n this._transport.send(data, timeoutMillis).then(resolve, reject);\n }, inMillis);\n });\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n let attempts = MAX_ATTEMPTS;\n let nextBackoff = INITIAL_BACKOFF;\n\n const deadline = Date.now() + timeoutMillis;\n let result = await this._transport.send(data, timeoutMillis);\n\n while (result.status === 'retryable' && attempts > 0) {\n attempts--;\n\n // use maximum of computed backoff and 0 to avoid negative timeouts\n const backoff = Math.max(\n Math.min(nextBackoff * (1 + getJitter()), MAX_BACKOFF),\n 0\n );\n nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;\n const retryInMillis = result.retryInMillis ?? backoff;\n\n // return when expected retry time is after the export deadline.\n const remainingTimeoutMillis = deadline - Date.now();\n if (retryInMillis > remainingTimeoutMillis) {\n diag.info(\n `Export retry time ${Math.round(retryInMillis)}ms exceeds remaining timeout ${Math.round(\n remainingTimeoutMillis\n )}ms, not retrying further.`\n );\n return result;\n }\n\n diag.verbose(`Scheduling export retry in ${Math.round(retryInMillis)}ms`);\n result = await this.retry(data, remainingTimeoutMillis, retryInMillis);\n }\n\n if (result.status === 'success') {\n diag.verbose(\n `Export succeeded after ${MAX_ATTEMPTS - attempts} retry attempts.`\n );\n } else if (result.status === 'retryable') {\n diag.info(\n `Export failed after maximum retry attempts (${MAX_ATTEMPTS}).`\n );\n } else {\n diag.info(`Export failed with non-retryable error: ${result.error}`);\n }\n\n return result;\n }\n\n shutdown() {\n return this._transport.shutdown();\n }\n}\n\n/**\n * Creates an Exporter Transport that retries on 'retryable' response.\n */\nexport function createRetryingTransport(options: {\n // Underlying transport to wrap.\n transport: IExporterTransport;\n}): IExporterTransport {\n return new RetryingTransport(options.transport);\n}\n"]}
1
+ {"version":3,"file":"retrying-transport.js","sourceRoot":"","sources":["../../src/retrying-transport.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,4CAA0C;AAE1C,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM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-Identifier: Apache-2.0\n */\n\nimport type { IExporterTransport } from './exporter-transport';\nimport type { ExportResponse } from './export-response';\nimport { diag } from '@opentelemetry/api';\n\nconst MAX_ATTEMPTS = 5;\nconst INITIAL_BACKOFF = 1000;\nconst MAX_BACKOFF = 5000;\nconst BACKOFF_MULTIPLIER = 1.5;\nconst JITTER = 0.2;\n\n/**\n * Get a pseudo-random jitter that falls in the range of [-JITTER, +JITTER]\n */\nfunction getJitter() {\n return Math.random() * (2 * JITTER) - JITTER;\n}\n\nclass RetryingTransport implements IExporterTransport {\n private _transport: IExporterTransport;\n\n constructor(transport: IExporterTransport) {\n this._transport = transport;\n }\n\n private retry(\n data: Uint8Array,\n timeoutMillis: number,\n inMillis: number\n ): Promise<ExportResponse> {\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n this._transport.send(data, timeoutMillis).then(resolve, reject);\n }, inMillis);\n });\n }\n\n async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n let attempts = MAX_ATTEMPTS;\n let nextBackoff = INITIAL_BACKOFF;\n\n const deadline = Date.now() + timeoutMillis;\n let result = await this._transport.send(data, timeoutMillis);\n\n while (result.status === 'retryable' && attempts > 0) {\n attempts--;\n\n // use maximum of computed backoff and 0 to avoid negative timeouts\n const backoff = Math.max(\n Math.min(nextBackoff * (1 + getJitter()), MAX_BACKOFF),\n 0\n );\n nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;\n const retryInMillis = result.retryInMillis ?? backoff;\n\n // return when expected retry time is after the export deadline.\n const remainingTimeoutMillis = deadline - Date.now();\n if (retryInMillis > remainingTimeoutMillis) {\n diag.info(\n `Export retry time ${Math.round(retryInMillis)}ms exceeds remaining timeout ${Math.round(\n remainingTimeoutMillis\n )}ms, not retrying further.`\n );\n return result;\n }\n\n diag.verbose(`Scheduling export retry in ${Math.round(retryInMillis)}ms`);\n result = await this.retry(data, remainingTimeoutMillis, retryInMillis);\n }\n\n if (result.status === 'success') {\n diag.verbose(\n `Export succeeded after ${MAX_ATTEMPTS - attempts} retry attempts.`\n );\n } else if (result.status === 'retryable') {\n diag.info(\n `Export failed after maximum retry attempts (${MAX_ATTEMPTS}).`\n );\n } else {\n diag.info(`Export failed with non-retryable error: ${result.error}`);\n }\n\n return result;\n }\n\n shutdown() {\n return this._transport.shutdown();\n }\n}\n\n/**\n * Creates an Exporter Transport that retries on 'retryable' response.\n */\nexport function createRetryingTransport(options: {\n // Underlying transport to wrap.\n transport: IExporterTransport;\n}): IExporterTransport {\n return new RetryingTransport(options.transport);\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { IExporterTransport } from '../exporter-transport';
2
- import { HeadersFactory } from '../configuration/otlp-http-configuration';
1
+ import type { IExporterTransport } from '../exporter-transport';
2
+ import type { HeadersFactory } from '../configuration/otlp-http-configuration';
3
3
  export interface FetchTransportParameters {
4
4
  url: string;
5
5
  headers: HeadersFactory;
@@ -1,23 +1,36 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.createFetchTransport = void 0;
19
8
  const api_1 = require("@opentelemetry/api");
20
9
  const is_export_retryable_1 = require("../is-export-retryable");
10
+ /**
11
+ * Maximum total body size for concurrent keepalive requests.
12
+ * Browsers enforce a 64KiB cumulative limit across all pending keepalive requests.
13
+ * We use 60KB to leave headroom for headers.
14
+ * @see https://github.com/whatwg/fetch/issues/679
15
+ * @see https://blog.huli.tw/2025/01/06/en/navigator-sendbeacon-64kib-and-source-code/
16
+ */
17
+ const MAX_KEEPALIVE_BODY_SIZE = 60 * 1024;
18
+ /**
19
+ * Maximum concurrent keepalive requests.
20
+ * Chrome enforces 9 concurrent keepalive fetch requests per renderer process.
21
+ * @see https://github.com/whatwg/fetch/issues/679
22
+ * Quote: "If the renderer process is processing more than 9 requests with keepalive set, we reject a new request"
23
+ */
24
+ const MAX_KEEPALIVE_REQUESTS = 9;
25
+ /**
26
+ * Track cumulative pending body size across all in-flight keepalive requests.
27
+ * This is necessary because the 64KiB limit is cumulative, not per-request.
28
+ */
29
+ let pendingBodySize = 0;
30
+ /**
31
+ * Track number of pending keepalive requests.
32
+ */
33
+ let pendingKeepaliveCount = 0;
21
34
  class FetchTransport {
22
35
  _parameters;
23
36
  constructor(parameters) {
@@ -38,37 +51,53 @@ class FetchTransport {
38
51
  // @ts-expect-error -- fetch could be wrapped
39
52
  fetchApi = fetchApi.__original;
40
53
  }
54
+ const requestSize = data.byteLength;
55
+ // Determine if we can use keepalive based on cumulative browser limits.
56
+ // We must check BEFORE adding to pending totals to avoid exceeding limits.
57
+ const wouldExceedSize = pendingBodySize + requestSize > MAX_KEEPALIVE_BODY_SIZE;
58
+ const wouldExceedCount = pendingKeepaliveCount >= MAX_KEEPALIVE_REQUESTS;
59
+ const useKeepalive = !wouldExceedSize && !wouldExceedCount;
60
+ if (useKeepalive) {
61
+ pendingBodySize += requestSize;
62
+ pendingKeepaliveCount++;
63
+ }
64
+ else {
65
+ const reason = wouldExceedSize ? 'size limit' : 'count limit';
66
+ api_1.diag.debug(`keepalive disabled: ${(requestSize / 1024).toFixed(1)}KB payload, ${pendingKeepaliveCount} pending (${reason})`);
67
+ }
41
68
  try {
42
- const isBrowserEnvironment = !!globalThis.location;
43
69
  const url = new URL(this._parameters.url);
44
70
  const response = await fetchApi(url.href, {
45
71
  method: 'POST',
46
72
  headers: await this._parameters.headers(),
47
73
  body: data,
48
74
  signal: abortController.signal,
49
- keepalive: isBrowserEnvironment,
50
- mode: isBrowserEnvironment
51
- ? globalThis.location?.origin === url.origin
75
+ keepalive: useKeepalive,
76
+ mode: globalThis.location
77
+ ? globalThis.location.origin === url.origin
52
78
  ? 'same-origin'
53
79
  : 'cors'
54
80
  : 'no-cors',
55
81
  });
56
82
  if (response.status >= 200 && response.status <= 299) {
57
- api_1.diag.debug('response success');
83
+ api_1.diag.debug(`export response success (status: ${response.status})`);
58
84
  return { status: 'success' };
59
85
  }
60
86
  else if ((0, is_export_retryable_1.isExportHTTPErrorRetryable)(response.status)) {
87
+ api_1.diag.warn(`export response retryable (status: ${response.status})`);
61
88
  const retryAfter = response.headers.get('Retry-After');
62
89
  const retryInMillis = (0, is_export_retryable_1.parseRetryAfterToMills)(retryAfter);
63
90
  return { status: 'retryable', retryInMillis };
64
91
  }
92
+ api_1.diag.error(`export response failure (status: ${response.status})`);
65
93
  return {
66
94
  status: 'failure',
67
- error: new Error('Fetch request failed with non-retryable status'),
95
+ error: new Error(`Fetch request failed with non-retryable status ${response.status}`),
68
96
  };
69
97
  }
70
98
  catch (error) {
71
99
  if (isFetchNetworkErrorRetryable(error)) {
100
+ api_1.diag.warn(`export request retryable (network error: ${error})`);
72
101
  return {
73
102
  status: 'retryable',
74
103
  error: new Error('Fetch request encountered a network error', {
@@ -76,6 +105,7 @@ class FetchTransport {
76
105
  }),
77
106
  };
78
107
  }
108
+ api_1.diag.error(`export request failure (error: ${error})`);
79
109
  return {
80
110
  status: 'failure',
81
111
  error: new Error('Fetch request errored', { cause: error }),
@@ -83,6 +113,10 @@ class FetchTransport {
83
113
  }
84
114
  finally {
85
115
  clearTimeout(timeout);
116
+ if (useKeepalive) {
117
+ pendingBodySize -= requestSize;
118
+ pendingKeepaliveCount--;
119
+ }
86
120
  }
87
121
  }
88
122
  shutdown() {
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../../../src/transport/fetch-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;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AK,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,4CAA0C;AAC1C,gEAGgC;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,EAA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ACnB,KAAK,EAAE,IAAI,KAAK,CAAC,2CAA2C,EAAE;wBAC5D,KAAK,EAAE,KAAK;qBACb,CAAC;iBACH,CAAC;aACH;YACD,UAAI,CAAC,KAAK,CAAC,kCAAkC,KAAK,GAAG,CAAC,CAAC;YACvD,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;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,SAAgB,oBAAoB,CAClC,UAAoC;IAEpC,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAJD,oDAIC;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,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.createHttpExporterTransport = void 0;
@@ -26,11 +15,7 @@ class HttpExporterTransport {
26
15
  async send(data, timeoutMillis) {
27
16
  const { agent, request } = await this._loadUtils();
28
17
  const headers = await this._parameters.headers();
29
- return new Promise(resolve => {
30
- (0, http_transport_utils_1.sendWithHttp)(request, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, result => {
31
- resolve(result);
32
- }, timeoutMillis);
33
- });
18
+ return (0, http_transport_utils_1.sendWithHttp)(request, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, timeoutMillis);
34
19
  }
35
20
  shutdown() {
36
21
  // 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,iEAAsD;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,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C,OAAO,CAAC,CAAC;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,2BAA2B,CACzC,UAAqC;IAErC,OAAO,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC/C,CAAC;AAJD,kEAIC","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,iEAAsD;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,IAAA,mCAAY,EACjB,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,SAAgB,2BAA2B,CACzC,UAAqC;IAErC,OAAO,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC/C,CAAC;AAJD,kEAIC","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,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  //# 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
@@ -10,78 +10,108 @@ const DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${version_1.VERSION}`;
10
10
  /**
11
11
  * Sends data using http
12
12
  * @param request
13
- * @param params
13
+ * @param url
14
+ * @param headers
15
+ * @param compression
16
+ * @param userAgent
14
17
  * @param agent
15
18
  * @param data
16
- * @param onDone
17
19
  * @param timeoutMillis
18
20
  */
19
- function sendWithHttp(request, url, headers, compression, userAgent, agent, data, onDone, timeoutMillis) {
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
- onDone({
41
- status: 'success',
42
- data: Buffer.concat(responseData),
43
- });
44
- }
45
- else if (res.statusCode && (0, is_export_retryable_1.isExportHTTPErrorRetryable)(res.statusCode)) {
46
- onDone({
21
+ function sendWithHttp(request, url, headers, compression, userAgent, agent, data, timeoutMillis) {
22
+ return new Promise(resolve => {
23
+ const parsedUrl = new URL(url);
24
+ if (userAgent) {
25
+ headers['User-Agent'] = `${userAgent} ${DEFAULT_USER_AGENT}`;
26
+ }
27
+ else {
28
+ headers['User-Agent'] = DEFAULT_USER_AGENT;
29
+ }
30
+ const options = {
31
+ hostname: parsedUrl.hostname,
32
+ port: parsedUrl.port,
33
+ path: parsedUrl.pathname,
34
+ method: 'POST',
35
+ headers,
36
+ agent,
37
+ };
38
+ const req = request(options, (res) => {
39
+ const responseData = [];
40
+ res.on('data', chunk => responseData.push(chunk));
41
+ res.on('end', () => {
42
+ if (res.statusCode && res.statusCode <= 299) {
43
+ resolve({
44
+ status: 'success',
45
+ data: Buffer.concat(responseData),
46
+ });
47
+ }
48
+ else if (res.statusCode &&
49
+ (0, is_export_retryable_1.isExportHTTPErrorRetryable)(res.statusCode)) {
50
+ resolve({
51
+ status: 'retryable',
52
+ retryInMillis: (0, is_export_retryable_1.parseRetryAfterToMills)(res.headers['retry-after']),
53
+ });
54
+ }
55
+ else {
56
+ const error = new types_1.OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
57
+ resolve({
58
+ status: 'failure',
59
+ error,
60
+ });
61
+ }
62
+ });
63
+ res.on('error', (error) => {
64
+ // Note: 'end' may still be emitted after 'error' on the same response object, since we're resolving a promise,
65
+ // the first call to resolve() will determine the final state.
66
+ if (res.statusCode && res.statusCode <= 299) {
67
+ // If the response is successful but an error occurs while reading the response,
68
+ // we consider it a success since the data has been sent successfully.
69
+ resolve({
70
+ status: 'success',
71
+ });
72
+ }
73
+ else if (res.statusCode &&
74
+ (0, is_export_retryable_1.isExportHTTPErrorRetryable)(res.statusCode)) {
75
+ resolve({
76
+ status: 'retryable',
77
+ error: error,
78
+ retryInMillis: (0, is_export_retryable_1.parseRetryAfterToMills)(res.headers['retry-after']),
79
+ });
80
+ }
81
+ else {
82
+ resolve({
83
+ status: 'failure',
84
+ error,
85
+ });
86
+ }
87
+ });
88
+ });
89
+ req.setTimeout(timeoutMillis, () => {
90
+ req.destroy();
91
+ resolve({
92
+ status: 'retryable',
93
+ error: new Error('Request timed out'),
94
+ });
95
+ });
96
+ req.on('error', (error) => {
97
+ if (isHttpTransportNetworkErrorRetryable(error)) {
98
+ resolve({
47
99
  status: 'retryable',
48
- retryInMillis: (0, is_export_retryable_1.parseRetryAfterToMills)(res.headers['retry-after']),
100
+ error,
49
101
  });
50
102
  }
51
103
  else {
52
- const error = new types_1.OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
53
- onDone({
104
+ resolve({
54
105
  status: 'failure',
55
106
  error,
56
107
  });
57
108
  }
58
109
  });
59
- });
60
- req.setTimeout(timeoutMillis, () => {
61
- req.destroy();
62
- onDone({
63
- status: 'retryable',
64
- error: new Error('Request timed out'),
65
- });
66
- });
67
- req.on('error', (error) => {
68
- if (isHttpTransportNetworkErrorRetryable(error)) {
69
- onDone({
70
- status: 'retryable',
71
- error,
72
- });
73
- }
74
- else {
75
- onDone({
110
+ compressAndSend(req, compression, data, (error) => {
111
+ resolve({
76
112
  status: 'failure',
77
113
  error,
78
114
  });
79
- }
80
- });
81
- compressAndSend(req, compression, data, (error) => {
82
- onDone({
83
- status: 'failure',
84
- error,
85
115
  });
86
116
  });
87
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":";;;AAiBA,6BAA6B;AAC7B,mCAAkC;AAElC,gEAGgC;AAChC,oCAA6C;AAC7C,wCAAqC;AAErC,MAAM,kBAAkB,GAAG,iCAAiC,iBAAO,EAAE,CAAC;AAEtE;;;;;;;;GAQG;AACH,SAAgB,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,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BC;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,iBAAQ,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 *\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,6BAA6B;AAC7B,mCAAkC;AAElC,gEAGgC;AAChC,oCAA6C;AAC7C,wCAAqC;AAErC,MAAM,kBAAkB,GAAG,iCAAiC,iBAAO,EAAE,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,SAAgB,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,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,eAAe,CAC7B,GAAuB,EACvB,WAA4B,EAC5B,IAAgB,EAChB,OAA+B;IAE/B,IAAI,UAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE9C,IAAI,WAAW,KAAK,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;AAjBD,0CAiBC;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,iBAAQ,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,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  //# 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,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.OTLPExporterError = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;GAEG;AACH,MAAa,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;AAVD,8CAUC","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,MAAa,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;AAVD,8CAUC","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"]}