@opentelemetry/otlp-exporter-base 0.55.0 → 0.56.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 (309) hide show
  1. package/README.md +1 -7
  2. package/build/esm/OTLPExporterBase.d.ts +7 -28
  3. package/build/esm/OTLPExporterBase.js +6 -69
  4. package/build/esm/OTLPExporterBase.js.map +1 -1
  5. package/build/esm/bounded-queue-export-promise-handler.d.ts +13 -0
  6. package/build/esm/bounded-queue-export-promise-handler.js +96 -0
  7. package/build/esm/bounded-queue-export-promise-handler.js.map +1 -0
  8. package/build/esm/configuration/convert-legacy-browser-http-options.d.ts +11 -0
  9. package/build/esm/configuration/convert-legacy-browser-http-options.js +34 -0
  10. package/build/esm/configuration/convert-legacy-browser-http-options.js.map +1 -0
  11. package/build/esm/configuration/convert-legacy-node-http-options.d.ts +11 -0
  12. package/build/esm/configuration/convert-legacy-node-http-options.js +45 -0
  13. package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -0
  14. package/build/esm/configuration/create-legacy-browser-delegate.d.ts +12 -0
  15. package/build/esm/configuration/create-legacy-browser-delegate.js +20 -0
  16. package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -0
  17. package/build/esm/configuration/legacy-base-configuration.d.ts +9 -0
  18. package/build/esm/configuration/legacy-base-configuration.js +2 -0
  19. package/build/esm/configuration/legacy-base-configuration.js.map +1 -0
  20. package/build/{esnext/platform/node/types.d.ts → esm/configuration/legacy-node-configuration.d.ts} +2 -2
  21. package/build/esm/{platform/node/index.js → configuration/legacy-node-configuration.js} +6 -3
  22. package/build/esm/configuration/legacy-node-configuration.js.map +1 -0
  23. package/build/esm/configuration/otlp-http-configuration.d.ts +5 -1
  24. package/build/esm/configuration/otlp-http-configuration.js +16 -14
  25. package/build/esm/configuration/otlp-http-configuration.js.map +1 -1
  26. package/build/esm/configuration/otlp-http-env-configuration.js +3 -2
  27. package/build/esm/configuration/otlp-http-env-configuration.js.map +1 -1
  28. package/build/esm/configuration/shared-configuration.d.ts +1 -0
  29. package/build/esm/configuration/shared-configuration.js +6 -0
  30. package/build/esm/configuration/shared-configuration.js.map +1 -1
  31. package/build/esm/index-browser-http.d.ts +4 -0
  32. package/build/esm/index-browser-http.js +19 -0
  33. package/build/esm/index-browser-http.js.map +1 -0
  34. package/build/esm/index-node-http.d.ts +4 -0
  35. package/build/esm/index-node-http.js +19 -0
  36. package/build/esm/index-node-http.js.map +1 -0
  37. package/build/esm/index.d.ts +5 -4
  38. package/build/esm/index.js +3 -7
  39. package/build/esm/index.js.map +1 -1
  40. package/build/esm/logging-response-handler.d.ts +6 -0
  41. package/build/esm/logging-response-handler.js +38 -0
  42. package/build/esm/logging-response-handler.js.map +1 -0
  43. package/build/esm/otlp-browser-http-export-delegate.d.ts +6 -0
  44. package/build/esm/otlp-browser-http-export-delegate.js +18 -0
  45. package/build/esm/otlp-browser-http-export-delegate.js.map +1 -0
  46. package/build/esm/otlp-export-delegate.d.ts +24 -0
  47. package/build/esm/otlp-export-delegate.js +155 -0
  48. package/build/esm/otlp-export-delegate.js.map +1 -0
  49. package/build/esm/otlp-http-export-delegate.d.ts +5 -0
  50. package/build/esm/otlp-http-export-delegate.js +29 -0
  51. package/build/esm/otlp-http-export-delegate.js.map +1 -0
  52. package/build/esm/otlp-network-export-delegate.d.ts +6 -0
  53. package/build/esm/otlp-network-export-delegate.js +25 -0
  54. package/build/esm/otlp-network-export-delegate.js.map +1 -0
  55. package/build/esm/response-handler.d.ts +12 -0
  56. package/build/esm/{platform/browser/index.js → response-handler.js} +2 -2
  57. package/build/esm/response-handler.js.map +1 -0
  58. package/build/esm/{platform/node → transport}/http-exporter-transport.d.ts +1 -1
  59. package/build/esm/transport/http-exporter-transport.js.map +1 -0
  60. package/build/{esnext/platform/node → esm/transport}/http-transport-types.d.ts +2 -2
  61. package/build/esm/transport/http-transport-types.js.map +1 -0
  62. package/build/{esnext/platform/node → esm/transport}/http-transport-utils.d.ts +1 -1
  63. package/build/esm/{platform/node → transport}/http-transport-utils.js +4 -4
  64. package/build/esm/transport/http-transport-utils.js.map +1 -0
  65. package/build/esm/{platform/browser → transport}/send-beacon-transport.d.ts +1 -1
  66. package/build/esm/transport/send-beacon-transport.js.map +1 -0
  67. package/build/{esnext/platform/browser → esm/transport}/xhr-transport.d.ts +2 -2
  68. package/build/esm/{platform/browser → transport}/xhr-transport.js +4 -3
  69. package/build/esm/transport/xhr-transport.js.map +1 -0
  70. package/build/esm/types.d.ts +0 -11
  71. package/build/esm/types.js.map +1 -1
  72. package/build/esm/util.d.ts +1 -1
  73. package/build/esm/util.js +14 -12
  74. package/build/esm/util.js.map +1 -1
  75. package/build/esm/version.d.ts +1 -1
  76. package/build/esm/version.js +1 -1
  77. package/build/esm/version.js.map +1 -1
  78. package/build/esnext/OTLPExporterBase.d.ts +7 -28
  79. package/build/esnext/OTLPExporterBase.js +6 -67
  80. package/build/esnext/OTLPExporterBase.js.map +1 -1
  81. package/build/esnext/bounded-queue-export-promise-handler.d.ts +13 -0
  82. package/build/esnext/bounded-queue-export-promise-handler.js +49 -0
  83. package/build/esnext/bounded-queue-export-promise-handler.js.map +1 -0
  84. package/build/esnext/configuration/convert-legacy-browser-http-options.d.ts +11 -0
  85. package/build/esnext/configuration/convert-legacy-browser-http-options.js +34 -0
  86. package/build/esnext/configuration/convert-legacy-browser-http-options.js.map +1 -0
  87. package/build/esnext/configuration/convert-legacy-node-http-options.d.ts +11 -0
  88. package/build/esnext/configuration/convert-legacy-node-http-options.js +45 -0
  89. package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -0
  90. package/build/esnext/configuration/create-legacy-browser-delegate.d.ts +12 -0
  91. package/build/esnext/configuration/create-legacy-browser-delegate.js +20 -0
  92. package/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -0
  93. package/build/esnext/configuration/legacy-base-configuration.d.ts +9 -0
  94. package/build/esnext/configuration/legacy-base-configuration.js +2 -0
  95. package/build/esnext/configuration/legacy-base-configuration.js.map +1 -0
  96. package/build/{src/platform/node/types.d.ts → esnext/configuration/legacy-node-configuration.d.ts} +2 -2
  97. package/build/{esm/platform/index.js → esnext/configuration/legacy-node-configuration.js} +6 -3
  98. package/build/esnext/configuration/legacy-node-configuration.js.map +1 -0
  99. package/build/esnext/configuration/otlp-http-configuration.d.ts +5 -1
  100. package/build/esnext/configuration/otlp-http-configuration.js +16 -14
  101. package/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
  102. package/build/esnext/configuration/otlp-http-env-configuration.js +3 -2
  103. package/build/esnext/configuration/otlp-http-env-configuration.js.map +1 -1
  104. package/build/esnext/configuration/shared-configuration.d.ts +1 -0
  105. package/build/esnext/configuration/shared-configuration.js +6 -0
  106. package/build/esnext/configuration/shared-configuration.js.map +1 -1
  107. package/build/esnext/index-browser-http.d.ts +4 -0
  108. package/build/esnext/index-browser-http.js +19 -0
  109. package/build/esnext/index-browser-http.js.map +1 -0
  110. package/build/esnext/index-node-http.d.ts +4 -0
  111. package/build/esnext/index-node-http.js +19 -0
  112. package/build/esnext/index-node-http.js.map +1 -0
  113. package/build/esnext/index.d.ts +5 -4
  114. package/build/esnext/index.js +3 -7
  115. package/build/esnext/index.js.map +1 -1
  116. package/build/esnext/logging-response-handler.d.ts +6 -0
  117. package/build/esnext/logging-response-handler.js +38 -0
  118. package/build/esnext/logging-response-handler.js.map +1 -0
  119. package/build/esnext/otlp-browser-http-export-delegate.d.ts +6 -0
  120. package/build/esnext/otlp-browser-http-export-delegate.js +18 -0
  121. package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -0
  122. package/build/esnext/otlp-export-delegate.d.ts +24 -0
  123. package/build/esnext/otlp-export-delegate.js +105 -0
  124. package/build/esnext/otlp-export-delegate.js.map +1 -0
  125. package/build/esnext/otlp-http-export-delegate.d.ts +5 -0
  126. package/build/esnext/otlp-http-export-delegate.js +29 -0
  127. package/build/esnext/otlp-http-export-delegate.js.map +1 -0
  128. package/build/esnext/otlp-network-export-delegate.d.ts +6 -0
  129. package/build/esnext/otlp-network-export-delegate.js +25 -0
  130. package/build/esnext/otlp-network-export-delegate.js.map +1 -0
  131. package/build/esnext/response-handler.d.ts +12 -0
  132. package/build/esnext/{platform/browser/index.js → response-handler.js} +2 -2
  133. package/build/esnext/response-handler.js.map +1 -0
  134. package/build/esnext/{platform/node → transport}/http-exporter-transport.d.ts +1 -1
  135. package/build/esnext/transport/http-exporter-transport.js.map +1 -0
  136. package/build/{src/platform/node → esnext/transport}/http-transport-types.d.ts +2 -2
  137. package/build/esnext/transport/http-transport-types.js.map +1 -0
  138. package/build/{esm/platform/node → esnext/transport}/http-transport-utils.d.ts +1 -1
  139. package/build/esnext/{platform/node → transport}/http-transport-utils.js +4 -4
  140. package/build/esnext/transport/http-transport-utils.js.map +1 -0
  141. package/build/{src/platform/browser → esnext/transport}/send-beacon-transport.d.ts +1 -1
  142. package/build/esnext/transport/send-beacon-transport.js.map +1 -0
  143. package/build/{src/platform/browser → esnext/transport}/xhr-transport.d.ts +2 -2
  144. package/build/esnext/{platform/browser → transport}/xhr-transport.js +4 -3
  145. package/build/esnext/transport/xhr-transport.js.map +1 -0
  146. package/build/esnext/types.d.ts +0 -11
  147. package/build/esnext/types.js.map +1 -1
  148. package/build/esnext/util.d.ts +1 -1
  149. package/build/esnext/util.js +14 -11
  150. package/build/esnext/util.js.map +1 -1
  151. package/build/esnext/version.d.ts +1 -1
  152. package/build/esnext/version.js +1 -1
  153. package/build/esnext/version.js.map +1 -1
  154. package/build/src/OTLPExporterBase.d.ts +7 -28
  155. package/build/src/OTLPExporterBase.js +6 -67
  156. package/build/src/OTLPExporterBase.js.map +1 -1
  157. package/build/src/bounded-queue-export-promise-handler.d.ts +13 -0
  158. package/build/src/bounded-queue-export-promise-handler.js +53 -0
  159. package/build/src/bounded-queue-export-promise-handler.js.map +1 -0
  160. package/build/src/configuration/convert-legacy-browser-http-options.d.ts +11 -0
  161. package/build/src/configuration/convert-legacy-browser-http-options.js +38 -0
  162. package/build/src/configuration/convert-legacy-browser-http-options.js.map +1 -0
  163. package/build/src/configuration/convert-legacy-node-http-options.d.ts +11 -0
  164. package/build/src/configuration/convert-legacy-node-http-options.js +49 -0
  165. package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -0
  166. package/build/src/configuration/create-legacy-browser-delegate.d.ts +12 -0
  167. package/build/src/configuration/create-legacy-browser-delegate.js +24 -0
  168. package/build/src/configuration/create-legacy-browser-delegate.js.map +1 -0
  169. package/build/src/configuration/legacy-base-configuration.d.ts +9 -0
  170. package/build/src/configuration/legacy-base-configuration.js +3 -0
  171. package/build/src/configuration/legacy-base-configuration.js.map +1 -0
  172. package/build/{esm/platform/node/types.d.ts → src/configuration/legacy-node-configuration.d.ts} +2 -2
  173. package/build/src/{platform/browser/index.js → configuration/legacy-node-configuration.js} +7 -4
  174. package/build/src/configuration/legacy-node-configuration.js.map +1 -0
  175. package/build/src/configuration/otlp-http-configuration.d.ts +5 -1
  176. package/build/src/configuration/otlp-http-configuration.js +16 -14
  177. package/build/src/configuration/otlp-http-configuration.js.map +1 -1
  178. package/build/src/configuration/otlp-http-env-configuration.js +3 -2
  179. package/build/src/configuration/otlp-http-env-configuration.js.map +1 -1
  180. package/build/src/configuration/shared-configuration.d.ts +1 -0
  181. package/build/src/configuration/shared-configuration.js +8 -1
  182. package/build/src/configuration/shared-configuration.js.map +1 -1
  183. package/build/src/index-browser-http.d.ts +4 -0
  184. package/build/src/index-browser-http.js +26 -0
  185. package/build/src/index-browser-http.js.map +1 -0
  186. package/build/src/index-node-http.d.ts +4 -0
  187. package/build/src/index-node-http.js +25 -0
  188. package/build/src/index-node-http.js.map +1 -0
  189. package/build/src/index.d.ts +5 -4
  190. package/build/src/index.js +5 -19
  191. package/build/src/index.js.map +1 -1
  192. package/build/src/logging-response-handler.d.ts +6 -0
  193. package/build/src/logging-response-handler.js +42 -0
  194. package/build/src/logging-response-handler.js.map +1 -0
  195. package/build/src/otlp-browser-http-export-delegate.d.ts +6 -0
  196. package/build/src/otlp-browser-http-export-delegate.js +23 -0
  197. package/build/src/otlp-browser-http-export-delegate.js.map +1 -0
  198. package/build/src/otlp-export-delegate.d.ts +24 -0
  199. package/build/src/otlp-export-delegate.js +109 -0
  200. package/build/src/otlp-export-delegate.js.map +1 -0
  201. package/build/src/otlp-http-export-delegate.d.ts +5 -0
  202. package/build/src/otlp-http-export-delegate.js +33 -0
  203. package/build/src/otlp-http-export-delegate.js.map +1 -0
  204. package/build/src/otlp-network-export-delegate.d.ts +6 -0
  205. package/build/src/otlp-network-export-delegate.js +29 -0
  206. package/build/src/otlp-network-export-delegate.js.map +1 -0
  207. package/build/src/response-handler.d.ts +12 -0
  208. package/build/src/response-handler.js +18 -0
  209. package/build/src/response-handler.js.map +1 -0
  210. package/build/src/{platform/node → transport}/http-exporter-transport.d.ts +1 -1
  211. package/build/src/transport/http-exporter-transport.js.map +1 -0
  212. package/build/{esm/platform/node → src/transport}/http-transport-types.d.ts +2 -2
  213. package/build/src/transport/http-transport-types.js.map +1 -0
  214. package/build/src/{platform/node → transport}/http-transport-utils.d.ts +1 -1
  215. package/build/src/{platform/node → transport}/http-transport-utils.js +4 -4
  216. package/build/src/transport/http-transport-utils.js.map +1 -0
  217. package/build/{esnext/platform/browser → src/transport}/send-beacon-transport.d.ts +1 -1
  218. package/build/src/transport/send-beacon-transport.js.map +1 -0
  219. package/build/{esm/platform/browser → src/transport}/xhr-transport.d.ts +2 -2
  220. package/build/src/{platform/browser → transport}/xhr-transport.js +4 -3
  221. package/build/src/transport/xhr-transport.js.map +1 -0
  222. package/build/src/types.d.ts +0 -11
  223. package/build/src/types.js.map +1 -1
  224. package/build/src/util.d.ts +1 -1
  225. package/build/src/util.js +14 -11
  226. package/build/src/util.js.map +1 -1
  227. package/build/src/version.d.ts +1 -1
  228. package/build/src/version.js +1 -1
  229. package/build/src/version.js.map +1 -1
  230. package/package.json +38 -11
  231. package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +0 -21
  232. package/build/esm/platform/browser/OTLPExporterBrowserBase.js +0 -118
  233. package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +0 -1
  234. package/build/esm/platform/browser/index.d.ts +0 -2
  235. package/build/esm/platform/browser/index.js.map +0 -1
  236. package/build/esm/platform/browser/send-beacon-transport.js.map +0 -1
  237. package/build/esm/platform/browser/xhr-transport.js.map +0 -1
  238. package/build/esm/platform/index.d.ts +0 -3
  239. package/build/esm/platform/index.js.map +0 -1
  240. package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +0 -16
  241. package/build/esm/platform/node/OTLPExporterNodeBase.js +0 -109
  242. package/build/esm/platform/node/OTLPExporterNodeBase.js.map +0 -1
  243. package/build/esm/platform/node/convert-legacy-agent-options.d.ts +0 -12
  244. package/build/esm/platform/node/convert-legacy-agent-options.js +0 -27
  245. package/build/esm/platform/node/convert-legacy-agent-options.js.map +0 -1
  246. package/build/esm/platform/node/http-exporter-transport.js.map +0 -1
  247. package/build/esm/platform/node/http-transport-types.js.map +0 -1
  248. package/build/esm/platform/node/http-transport-utils.js.map +0 -1
  249. package/build/esm/platform/node/index.d.ts +0 -3
  250. package/build/esm/platform/node/index.js.map +0 -1
  251. package/build/esm/platform/node/types.js +0 -6
  252. package/build/esm/platform/node/types.js.map +0 -1
  253. package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +0 -21
  254. package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +0 -97
  255. package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +0 -1
  256. package/build/esnext/platform/browser/index.d.ts +0 -2
  257. package/build/esnext/platform/browser/index.js.map +0 -1
  258. package/build/esnext/platform/browser/send-beacon-transport.js.map +0 -1
  259. package/build/esnext/platform/browser/xhr-transport.js.map +0 -1
  260. package/build/esnext/platform/index.d.ts +0 -3
  261. package/build/esnext/platform/index.js +0 -18
  262. package/build/esnext/platform/index.js.map +0 -1
  263. package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +0 -16
  264. package/build/esnext/platform/node/OTLPExporterNodeBase.js +0 -88
  265. package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +0 -1
  266. package/build/esnext/platform/node/convert-legacy-agent-options.d.ts +0 -12
  267. package/build/esnext/platform/node/convert-legacy-agent-options.js +0 -27
  268. package/build/esnext/platform/node/convert-legacy-agent-options.js.map +0 -1
  269. package/build/esnext/platform/node/http-exporter-transport.js.map +0 -1
  270. package/build/esnext/platform/node/http-transport-types.js.map +0 -1
  271. package/build/esnext/platform/node/http-transport-utils.js.map +0 -1
  272. package/build/esnext/platform/node/index.d.ts +0 -3
  273. package/build/esnext/platform/node/index.js +0 -18
  274. package/build/esnext/platform/node/index.js.map +0 -1
  275. package/build/esnext/platform/node/types.js +0 -6
  276. package/build/esnext/platform/node/types.js.map +0 -1
  277. package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +0 -21
  278. package/build/src/platform/browser/OTLPExporterBrowserBase.js +0 -101
  279. package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +0 -1
  280. package/build/src/platform/browser/index.d.ts +0 -2
  281. package/build/src/platform/browser/index.js.map +0 -1
  282. package/build/src/platform/browser/send-beacon-transport.js.map +0 -1
  283. package/build/src/platform/browser/xhr-transport.js.map +0 -1
  284. package/build/src/platform/index.d.ts +0 -3
  285. package/build/src/platform/index.js +0 -24
  286. package/build/src/platform/index.js.map +0 -1
  287. package/build/src/platform/node/OTLPExporterNodeBase.d.ts +0 -16
  288. package/build/src/platform/node/OTLPExporterNodeBase.js +0 -92
  289. package/build/src/platform/node/OTLPExporterNodeBase.js.map +0 -1
  290. package/build/src/platform/node/convert-legacy-agent-options.d.ts +0 -12
  291. package/build/src/platform/node/convert-legacy-agent-options.js +0 -31
  292. package/build/src/platform/node/convert-legacy-agent-options.js.map +0 -1
  293. package/build/src/platform/node/http-exporter-transport.js.map +0 -1
  294. package/build/src/platform/node/http-transport-types.js.map +0 -1
  295. package/build/src/platform/node/http-transport-utils.js.map +0 -1
  296. package/build/src/platform/node/index.d.ts +0 -3
  297. package/build/src/platform/node/index.js +0 -23
  298. package/build/src/platform/node/index.js.map +0 -1
  299. package/build/src/platform/node/types.js +0 -9
  300. package/build/src/platform/node/types.js.map +0 -1
  301. /package/build/esm/{platform/node → transport}/http-exporter-transport.js +0 -0
  302. /package/build/esm/{platform/node → transport}/http-transport-types.js +0 -0
  303. /package/build/esm/{platform/browser → transport}/send-beacon-transport.js +0 -0
  304. /package/build/esnext/{platform/node → transport}/http-exporter-transport.js +0 -0
  305. /package/build/esnext/{platform/node → transport}/http-transport-types.js +0 -0
  306. /package/build/esnext/{platform/browser → transport}/send-beacon-transport.js +0 -0
  307. /package/build/src/{platform/node → transport}/http-exporter-transport.js +0 -0
  308. /package/build/src/{platform/node → transport}/http-transport-types.js +0 -0
  309. /package/build/src/{platform/browser → transport}/send-beacon-transport.js +0 -0
@@ -16,23 +16,9 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.OTLPExporterBase = void 0;
19
- const api_1 = require("@opentelemetry/api");
20
- const core_1 = require("@opentelemetry/core");
21
- /**
22
- * Collector Exporter abstract base class
23
- */
24
19
  class OTLPExporterBase {
25
- /**
26
- * @param config
27
- */
28
- constructor(config = {}) {
29
- this._sendingPromises = [];
30
- this.shutdown = this.shutdown.bind(this);
31
- this._shutdownOnce = new core_1.BindOnceFuture(this._shutdown, this);
32
- this._concurrencyLimit =
33
- typeof config.concurrencyLimit === 'number'
34
- ? config.concurrencyLimit
35
- : 30;
20
+ constructor(_delegate) {
21
+ this._delegate = _delegate;
36
22
  }
37
23
  /**
38
24
  * Export items.
@@ -40,60 +26,13 @@ class OTLPExporterBase {
40
26
  * @param resultCallback
41
27
  */
42
28
  export(items, resultCallback) {
43
- if (this._shutdownOnce.isCalled) {
44
- resultCallback({
45
- code: core_1.ExportResultCode.FAILED,
46
- error: new Error('Exporter has been shutdown'),
47
- });
48
- return;
49
- }
50
- if (this._sendingPromises.length >= this._concurrencyLimit) {
51
- resultCallback({
52
- code: core_1.ExportResultCode.FAILED,
53
- error: new Error('Concurrent export limit reached'),
54
- });
55
- return;
56
- }
57
- this._export(items)
58
- .then(() => {
59
- resultCallback({ code: core_1.ExportResultCode.SUCCESS });
60
- })
61
- .catch((error) => {
62
- resultCallback({ code: core_1.ExportResultCode.FAILED, error });
63
- });
64
- }
65
- _export(items) {
66
- return new Promise((resolve, reject) => {
67
- try {
68
- api_1.diag.debug('items to be sent', items);
69
- this.send(items, resolve, reject);
70
- }
71
- catch (e) {
72
- reject(e);
73
- }
74
- });
29
+ this._delegate.export(items, resultCallback);
75
30
  }
76
- /**
77
- * Shutdown the exporter.
78
- */
79
- shutdown() {
80
- return this._shutdownOnce.call();
81
- }
82
- /**
83
- * Exports any pending spans in the exporter
84
- */
85
31
  forceFlush() {
86
- return Promise.all(this._sendingPromises).then(() => {
87
- /** ignore resolved values */
88
- });
32
+ return this._delegate.forceFlush();
89
33
  }
90
- /**
91
- * Called by _shutdownOnce with BindOnceFuture
92
- */
93
- _shutdown() {
94
- api_1.diag.debug('shutdown started');
95
- this.onShutdown();
96
- return this.forceFlush();
34
+ shutdown() {
35
+ return this._delegate.shutdown();
97
36
  }
98
37
  }
99
38
  exports.OTLPExporterBase = OTLPExporterBase;
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,8CAI6B;AAO7B;;GAEG;AACH,MAAsB,gBAAgB;IAQpC;;OAEG;IACH,YAAY,SAAY,EAAO;QANrB,qBAAgB,GAAuB,EAAE,CAAC;QAOlD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,aAAa,GAAG,IAAI,qBAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE9D,IAAI,CAAC,iBAAiB;YACpB,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ;gBACzC,CAAC,CAAC,MAAM,CAAC,gBAAgB;gBACzB,CAAC,CAAC,EAAE,CAAC;IACX,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,KAAmB,EACnB,cAA8C;QAE9C,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC/B,cAAc,CAAC;gBACb,IAAI,EAAE,uBAAgB,CAAC,MAAM;gBAC7B,KAAK,EAAE,IAAI,KAAK,CAAC,4BAA4B,CAAC;aAC/C,CAAC,CAAC;YACH,OAAO;SACR;QAED,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1D,cAAc,CAAC;gBACb,IAAI,EAAE,uBAAgB,CAAC,MAAM;gBAC7B,KAAK,EAAE,IAAI,KAAK,CAAC,iCAAiC,CAAC;aACpD,CAAC,CAAC;YACH,OAAO;SACR;QAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;aAChB,IAAI,CAAC,GAAG,EAAE;YACT,cAAc,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAyB,EAAE,EAAE;YACnC,cAAc,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,OAAO,CAAC,KAAmB;QACjC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI;gBACF,UAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;gBACtC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aACnC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,CAAC,CAAC,CAAC;aACX;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAClD,6BAA6B;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,SAAS;QACf,UAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CAQF;AAjGD,4CAiGC","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';\nimport {\n ExportResult,\n ExportResultCode,\n BindOnceFuture,\n} from '@opentelemetry/core';\nimport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\n\n/**\n * Collector Exporter abstract base class\n */\nexport abstract class OTLPExporterBase<\n T extends OTLPExporterConfigBase,\n ExportItem,\n> {\n protected _concurrencyLimit: number;\n protected _sendingPromises: Promise<unknown>[] = [];\n protected _shutdownOnce: BindOnceFuture<void>;\n\n /**\n * @param config\n */\n constructor(config: T = {} as T) {\n this.shutdown = this.shutdown.bind(this);\n this._shutdownOnce = new BindOnceFuture(this._shutdown, this);\n\n this._concurrencyLimit =\n typeof config.concurrencyLimit === 'number'\n ? config.concurrencyLimit\n : 30;\n }\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(\n items: ExportItem[],\n resultCallback: (result: ExportResult) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been shutdown'),\n });\n return;\n }\n\n if (this._sendingPromises.length >= this._concurrencyLimit) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Concurrent export limit reached'),\n });\n return;\n }\n\n this._export(items)\n .then(() => {\n resultCallback({ code: ExportResultCode.SUCCESS });\n })\n .catch((error: ExportServiceError) => {\n resultCallback({ code: ExportResultCode.FAILED, error });\n });\n }\n\n private _export(items: ExportItem[]): Promise<unknown> {\n return new Promise<void>((resolve, reject) => {\n try {\n diag.debug('items to be sent', items);\n this.send(items, resolve, reject);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Shutdown the exporter.\n */\n shutdown(): Promise<void> {\n return this._shutdownOnce.call();\n }\n\n /**\n * Exports any pending spans in the exporter\n */\n forceFlush(): Promise<void> {\n return Promise.all(this._sendingPromises).then(() => {\n /** ignore resolved values */\n });\n }\n\n /**\n * Called by _shutdownOnce with BindOnceFuture\n */\n private _shutdown(): Promise<void> {\n diag.debug('shutdown started');\n this.onShutdown();\n return this.forceFlush();\n }\n\n abstract onShutdown(): void;\n abstract send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void;\n}\n"]}
1
+ {"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH,MAAa,gBAAgB;IAC3B,YAAoB,SAAwC;QAAxC,cAAS,GAAT,SAAS,CAA+B;IAAG,CAAC;IAEhE;;;;OAIG;IACH,MAAM,CACJ,KAAe,EACf,cAA8C;QAE9C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACF;AAtBD,4CAsBC","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 { ExportResult } from '@opentelemetry/core';\nimport { IOtlpExportDelegate } from './otlp-export-delegate';\n\nexport class OTLPExporterBase<Internal> {\n constructor(private _delegate: IOtlpExportDelegate<Internal>) {}\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(\n items: Internal,\n resultCallback: (result: ExportResult) => void\n ): void {\n this._delegate.export(items, resultCallback);\n }\n\n forceFlush(): Promise<void> {\n return this._delegate.forceFlush();\n }\n\n shutdown(): Promise<void> {\n return this._delegate.shutdown();\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ export interface IExportPromiseHandler {
2
+ pushPromise(promise: Promise<void>): void;
3
+ hasReachedLimit(): boolean;
4
+ awaitAll(): Promise<void>;
5
+ }
6
+ /**
7
+ * Promise queue for keeping track of export promises. Finished promises will be auto-dequeued.
8
+ * Allows for awaiting all promises in the queue.
9
+ */
10
+ export declare function createBoundedQueueExportPromiseHandler(options: {
11
+ concurrencyLimit: number;
12
+ }): IExportPromiseHandler;
13
+ //# sourceMappingURL=bounded-queue-export-promise-handler.d.ts.map
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright The OpenTelemetry Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.createBoundedQueueExportPromiseHandler = void 0;
19
+ class BoundedQueueExportPromiseHandler {
20
+ /**
21
+ * @param concurrencyLimit maximum promises allowed in a queue at the same time.
22
+ */
23
+ constructor(concurrencyLimit) {
24
+ this._sendingPromises = [];
25
+ this._concurrencyLimit = concurrencyLimit;
26
+ }
27
+ pushPromise(promise) {
28
+ if (this.hasReachedLimit()) {
29
+ throw new Error('Concurrency Limit reached');
30
+ }
31
+ this._sendingPromises.push(promise);
32
+ const popPromise = () => {
33
+ const index = this._sendingPromises.indexOf(promise);
34
+ this._sendingPromises.splice(index, 1);
35
+ };
36
+ promise.then(popPromise, popPromise);
37
+ }
38
+ hasReachedLimit() {
39
+ return this._sendingPromises.length >= this._concurrencyLimit;
40
+ }
41
+ async awaitAll() {
42
+ await Promise.all(this._sendingPromises);
43
+ }
44
+ }
45
+ /**
46
+ * Promise queue for keeping track of export promises. Finished promises will be auto-dequeued.
47
+ * Allows for awaiting all promises in the queue.
48
+ */
49
+ function createBoundedQueueExportPromiseHandler(options) {
50
+ return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);
51
+ }
52
+ exports.createBoundedQueueExportPromiseHandler = createBoundedQueueExportPromiseHandler;
53
+ //# sourceMappingURL=bounded-queue-export-promise-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-queue-export-promise-handler.js","sourceRoot":"","sources":["../../src/bounded-queue-export-promise-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAQH,MAAM,gCAAgC;IAIpC;;OAEG;IACH,YAAY,gBAAwB;QAL5B,qBAAgB,GAAuB,EAAE,CAAC;QAMhD,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC5C,CAAC;IAEM,WAAW,CAAC,OAAsB;QACvC,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QAED,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,GAAG,EAAE;YACtB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IAEM,eAAe;QACpB,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAI,IAAI,CAAC,iBAAiB,CAAC;IAChE,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC3C,CAAC;CACF;AAED;;;GAGG;AACH,SAAgB,sCAAsC,CAAC,OAEtD;IACC,OAAO,IAAI,gCAAgC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACxE,CAAC;AAJD,wFAIC","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\nexport interface IExportPromiseHandler {\n pushPromise(promise: Promise<void>): void;\n hasReachedLimit(): boolean;\n awaitAll(): Promise<void>;\n}\n\nclass BoundedQueueExportPromiseHandler implements IExportPromiseHandler {\n private readonly _concurrencyLimit: number;\n private _sendingPromises: Promise<unknown>[] = [];\n\n /**\n * @param concurrencyLimit maximum promises allowed in a queue at the same time.\n */\n constructor(concurrencyLimit: number) {\n this._concurrencyLimit = concurrencyLimit;\n }\n\n public pushPromise(promise: Promise<void>): void {\n if (this.hasReachedLimit()) {\n throw new Error('Concurrency Limit reached');\n }\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n };\n promise.then(popPromise, popPromise);\n }\n\n public hasReachedLimit(): boolean {\n return this._sendingPromises.length >= this._concurrencyLimit;\n }\n\n public async awaitAll(): Promise<void> {\n await Promise.all(this._sendingPromises);\n }\n}\n\n/**\n * Promise queue for keeping track of export promises. Finished promises will be auto-dequeued.\n * Allows for awaiting all promises in the queue.\n */\nexport function createBoundedQueueExportPromiseHandler(options: {\n concurrencyLimit: number;\n}): IExportPromiseHandler {\n return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { OtlpHttpConfiguration } from './otlp-http-configuration';
2
+ import { OTLPExporterNodeConfigBase } from './legacy-node-configuration';
3
+ /**
4
+ * @deprecated this will be removed in 2.0
5
+ *
6
+ * @param config
7
+ * @param signalResourcePath
8
+ * @param requiredHeaders
9
+ */
10
+ export declare function convertLegacyBrowserHttpOptions(config: OTLPExporterNodeConfigBase, signalResourcePath: string, requiredHeaders: Record<string, string>): OtlpHttpConfiguration;
11
+ //# sourceMappingURL=convert-legacy-browser-http-options.d.ts.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertLegacyBrowserHttpOptions = void 0;
4
+ /*
5
+ * Copyright The OpenTelemetry Authors
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * https://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const otlp_http_configuration_1 = require("./otlp-http-configuration");
20
+ const shared_configuration_1 = require("./shared-configuration");
21
+ /**
22
+ * @deprecated this will be removed in 2.0
23
+ *
24
+ * @param config
25
+ * @param signalResourcePath
26
+ * @param requiredHeaders
27
+ */
28
+ function convertLegacyBrowserHttpOptions(config, signalResourcePath, requiredHeaders) {
29
+ return (0, otlp_http_configuration_1.mergeOtlpHttpConfigurationWithDefaults)({
30
+ url: config.url,
31
+ timeoutMillis: config.timeoutMillis,
32
+ headers: (0, shared_configuration_1.wrapStaticHeadersInFunction)(config.headers),
33
+ concurrencyLimit: config.concurrencyLimit,
34
+ }, {}, // no fallback for browser case
35
+ (0, otlp_http_configuration_1.getHttpConfigurationDefaults)(requiredHeaders, signalResourcePath));
36
+ }
37
+ exports.convertLegacyBrowserHttpOptions = convertLegacyBrowserHttpOptions;
38
+ //# sourceMappingURL=convert-legacy-browser-http-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-legacy-browser-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-browser-http-options.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,uEAImC;AAEnC,iEAAqE;AAErE;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAC7C,MAAkC,EAClC,kBAA0B,EAC1B,eAAuC;IAEvC,OAAO,IAAA,gEAAsC,EAC3C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,OAAO,EAAE,IAAA,kDAA2B,EAAC,MAAM,CAAC,OAAO,CAAC;QACpD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,EACD,EAAE,EAAE,+BAA+B;IACnC,IAAA,sDAA4B,EAAC,eAAe,EAAE,kBAAkB,CAAC,CAClE,CAAC;AACJ,CAAC;AAfD,0EAeC","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 {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n OtlpHttpConfiguration,\n} from './otlp-http-configuration';\nimport { OTLPExporterNodeConfigBase } from './legacy-node-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\n\n/**\n * @deprecated this will be removed in 2.0\n *\n * @param config\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function convertLegacyBrowserHttpOptions(\n config: OTLPExporterNodeConfigBase,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): OtlpHttpConfiguration {\n return mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n timeoutMillis: config.timeoutMillis,\n headers: wrapStaticHeadersInFunction(config.headers),\n concurrencyLimit: config.concurrencyLimit,\n },\n {}, // no fallback for browser case\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { OTLPExporterNodeConfigBase } from './legacy-node-configuration';
2
+ import { OtlpHttpConfiguration } from './otlp-http-configuration';
3
+ /**
4
+ * @deprecated this will be removed in 2.0
5
+ * @param config
6
+ * @param signalIdentifier
7
+ * @param signalResourcePath
8
+ * @param requiredHeaders
9
+ */
10
+ export declare function convertLegacyHttpOptions(config: OTLPExporterNodeConfigBase, signalIdentifier: string, signalResourcePath: string, requiredHeaders: Record<string, string>): OtlpHttpConfiguration;
11
+ //# sourceMappingURL=convert-legacy-node-http-options.d.ts.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertLegacyHttpOptions = void 0;
4
+ const otlp_http_configuration_1 = require("./otlp-http-configuration");
5
+ const otlp_http_env_configuration_1 = require("./otlp-http-env-configuration");
6
+ const api_1 = require("@opentelemetry/api");
7
+ const shared_configuration_1 = require("./shared-configuration");
8
+ function convertLegacyAgentOptions(config) {
9
+ // populate keepAlive for use with new settings
10
+ if ((config === null || config === void 0 ? void 0 : config.keepAlive) != null) {
11
+ if (config.httpAgentOptions != null) {
12
+ if (config.httpAgentOptions.keepAlive == null) {
13
+ // specific setting is not set, populate with non-specific setting.
14
+ config.httpAgentOptions.keepAlive = config.keepAlive;
15
+ }
16
+ // do nothing, use specific setting otherwise
17
+ }
18
+ else {
19
+ // populate specific option if AgentOptions does not exist.
20
+ config.httpAgentOptions = {
21
+ keepAlive: config.keepAlive,
22
+ };
23
+ }
24
+ }
25
+ return config.httpAgentOptions;
26
+ }
27
+ /**
28
+ * @deprecated this will be removed in 2.0
29
+ * @param config
30
+ * @param signalIdentifier
31
+ * @param signalResourcePath
32
+ * @param requiredHeaders
33
+ */
34
+ function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath, requiredHeaders) {
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ if (config.metadata) {
37
+ api_1.diag.warn('Metadata cannot be set when using http');
38
+ }
39
+ return (0, otlp_http_configuration_1.mergeOtlpHttpConfigurationWithDefaults)({
40
+ url: config.url,
41
+ headers: (0, shared_configuration_1.wrapStaticHeadersInFunction)(config.headers),
42
+ concurrencyLimit: config.concurrencyLimit,
43
+ timeoutMillis: config.timeoutMillis,
44
+ compression: config.compression,
45
+ agentOptions: convertLegacyAgentOptions(config),
46
+ }, (0, otlp_http_env_configuration_1.getHttpConfigurationFromEnvironment)(signalIdentifier, signalResourcePath), (0, otlp_http_configuration_1.getHttpConfigurationDefaults)(requiredHeaders, signalResourcePath));
47
+ }
48
+ exports.convertLegacyHttpOptions = convertLegacyHttpOptions;
49
+ //# sourceMappingURL=convert-legacy-node-http-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":";;;AAgBA,uEAImC;AACnC,+EAAoF;AAGpF,4CAA0C;AAC1C,iEAAqE;AAErE,SAAS,yBAAyB,CAChC,MAAkC;IAElC,+CAA+C;IAC/C,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,KAAI,IAAI,EAAE;QAC7B,IAAI,MAAM,CAAC,gBAAgB,IAAI,IAAI,EAAE;YACnC,IAAI,MAAM,CAAC,gBAAgB,CAAC,SAAS,IAAI,IAAI,EAAE;gBAC7C,mEAAmE;gBACnE,MAAM,CAAC,gBAAgB,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;aACtD;YACD,6CAA6C;SAC9C;aAAM;YACL,2DAA2D;YAC3D,MAAM,CAAC,gBAAgB,GAAG;gBACxB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC;SACH;KACF;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,MAAkC,EAClC,gBAAwB,EACxB,kBAA0B,EAC1B,eAAuC;IAEvC,8DAA8D;IAC9D,IAAK,MAAc,CAAC,QAAQ,EAAE;QAC5B,UAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;KACrD;IAED,OAAO,IAAA,gEAAsC,EAC3C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,IAAA,kDAA2B,EAAC,MAAM,CAAC,OAAO,CAAC;QACpD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,yBAAyB,CAAC,MAAM,CAAC;KAChD,EACD,IAAA,iEAAmC,EAAC,gBAAgB,EAAE,kBAAkB,CAAC,EACzE,IAAA,sDAA4B,EAAC,eAAe,EAAE,kBAAkB,CAAC,CAClE,CAAC;AACJ,CAAC;AAvBD,4DAuBC","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 { OTLPExporterNodeConfigBase } from './legacy-node-configuration';\nimport {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n OtlpHttpConfiguration,\n} from './otlp-http-configuration';\nimport { getHttpConfigurationFromEnvironment } from './otlp-http-env-configuration';\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport { diag } from '@opentelemetry/api';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\n\nfunction convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): http.AgentOptions | https.AgentOptions | undefined {\n // populate keepAlive for use with new settings\n if (config?.keepAlive != null) {\n if (config.httpAgentOptions != null) {\n if (config.httpAgentOptions.keepAlive == null) {\n // specific setting is not set, populate with non-specific setting.\n config.httpAgentOptions.keepAlive = config.keepAlive;\n }\n // do nothing, use specific setting otherwise\n } else {\n // populate specific option if AgentOptions does not exist.\n config.httpAgentOptions = {\n keepAlive: config.keepAlive,\n };\n }\n }\n\n return config.httpAgentOptions;\n}\n\n/**\n * @deprecated this will be removed in 2.0\n * @param config\n * @param signalIdentifier\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function convertLegacyHttpOptions(\n config: OTLPExporterNodeConfigBase,\n signalIdentifier: string,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): OtlpHttpConfiguration {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((config as any).metadata) {\n diag.warn('Metadata cannot be set when using http');\n }\n\n return mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: wrapStaticHeadersInFunction(config.headers),\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n agentOptions: convertLegacyAgentOptions(config),\n },\n getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath),\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { ISerializer } from '@opentelemetry/otlp-transformer';
2
+ import { IOtlpExportDelegate } from '../otlp-export-delegate';
3
+ import { OTLPExporterConfigBase } from './legacy-base-configuration';
4
+ /**
5
+ * @deprecated
6
+ * @param config
7
+ * @param serializer
8
+ * @param signalResourcePath
9
+ * @param requiredHeaders
10
+ */
11
+ export declare function createLegacyOtlpBrowserExportDelegate<Internal, Response>(config: OTLPExporterConfigBase, serializer: ISerializer<Internal, Response>, signalResourcePath: string, requiredHeaders: Record<string, string>): IOtlpExportDelegate<Internal>;
12
+ //# sourceMappingURL=create-legacy-browser-delegate.d.ts.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLegacyOtlpBrowserExportDelegate = void 0;
4
+ const otlp_browser_http_export_delegate_1 = require("../otlp-browser-http-export-delegate");
5
+ const convert_legacy_browser_http_options_1 = require("./convert-legacy-browser-http-options");
6
+ /**
7
+ * @deprecated
8
+ * @param config
9
+ * @param serializer
10
+ * @param signalResourcePath
11
+ * @param requiredHeaders
12
+ */
13
+ function createLegacyOtlpBrowserExportDelegate(config, serializer, signalResourcePath, requiredHeaders) {
14
+ const useXhr = !!config.headers || typeof navigator.sendBeacon !== 'function';
15
+ const options = (0, convert_legacy_browser_http_options_1.convertLegacyBrowserHttpOptions)(config, signalResourcePath, requiredHeaders);
16
+ if (useXhr) {
17
+ return (0, otlp_browser_http_export_delegate_1.createOtlpXhrExportDelegate)(options, serializer);
18
+ }
19
+ else {
20
+ return (0, otlp_browser_http_export_delegate_1.createOtlpSendBeaconExportDelegate)(options, serializer);
21
+ }
22
+ }
23
+ exports.createLegacyOtlpBrowserExportDelegate = createLegacyOtlpBrowserExportDelegate;
24
+ //# sourceMappingURL=create-legacy-browser-delegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-legacy-browser-delegate.js","sourceRoot":"","sources":["../../../src/configuration/create-legacy-browser-delegate.ts"],"names":[],"mappings":";;;AAgBA,4FAG8C;AAC9C,+FAAwF;AAIxF;;;;;;GAMG;AACH,SAAgB,qCAAqC,CACnD,MAA8B,EAC9B,UAA2C,EAC3C,kBAA0B,EAC1B,eAAuC;IAEvC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;IAE9E,MAAM,OAAO,GAAG,IAAA,qEAA+B,EAC7C,MAAM,EACN,kBAAkB,EAClB,eAAe,CAChB,CAAC;IAEF,IAAI,MAAM,EAAE;QACV,OAAO,IAAA,+DAA2B,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;KACzD;SAAM;QACL,OAAO,IAAA,sEAAkC,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;KAChE;AACH,CAAC;AAnBD,sFAmBC","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 { ISerializer } from '@opentelemetry/otlp-transformer';\nimport {\n createOtlpSendBeaconExportDelegate,\n createOtlpXhrExportDelegate,\n} from '../otlp-browser-http-export-delegate';\nimport { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';\nimport { IOtlpExportDelegate } from '../otlp-export-delegate';\nimport { OTLPExporterConfigBase } from './legacy-base-configuration';\n\n/**\n * @deprecated\n * @param config\n * @param serializer\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function createLegacyOtlpBrowserExportDelegate<Internal, Response>(\n config: OTLPExporterConfigBase,\n serializer: ISerializer<Internal, Response>,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): IOtlpExportDelegate<Internal> {\n const useXhr = !!config.headers || typeof navigator.sendBeacon !== 'function';\n\n const options = convertLegacyBrowserHttpOptions(\n config,\n signalResourcePath,\n requiredHeaders\n );\n\n if (useXhr) {\n return createOtlpXhrExportDelegate(options, serializer);\n } else {\n return createOtlpSendBeaconExportDelegate(options, serializer);\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export interface OTLPExporterConfigBase {
2
+ headers?: Record<string, string>;
3
+ url?: string;
4
+ concurrencyLimit?: number;
5
+ /** Maximum time the OTLP exporter will wait for each batch export.
6
+ * The default value is 10000ms. */
7
+ timeoutMillis?: number;
8
+ }
9
+ //# sourceMappingURL=legacy-base-configuration.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=legacy-base-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-base-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-base-configuration.ts"],"names":[],"mappings":"","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 */\nexport interface OTLPExporterConfigBase {\n headers?: Record<string, string>;\n url?: string;\n concurrencyLimit?: number;\n /** Maximum time the OTLP exporter will wait for each batch export.\n * The default value is 10000ms. */\n timeoutMillis?: number;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type * as http from 'http';
3
3
  import type * as https from 'https';
4
- import { OTLPExporterConfigBase } from '../../types';
4
+ import { OTLPExporterConfigBase } from './legacy-base-configuration';
5
5
  /**
6
6
  * Collector Exporter node base config
7
7
  */
@@ -14,4 +14,4 @@ export declare enum CompressionAlgorithm {
14
14
  NONE = "none",
15
15
  GZIP = "gzip"
16
16
  }
17
- //# sourceMappingURL=types.d.ts.map
17
+ //# sourceMappingURL=legacy-node-configuration.d.ts.map
@@ -15,7 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.OTLPExporterBrowserBase = void 0;
19
- var OTLPExporterBrowserBase_1 = require("./OTLPExporterBrowserBase");
20
- Object.defineProperty(exports, "OTLPExporterBrowserBase", { enumerable: true, get: function () { return OTLPExporterBrowserBase_1.OTLPExporterBrowserBase; } });
21
- //# sourceMappingURL=index.js.map
18
+ exports.CompressionAlgorithm = void 0;
19
+ var CompressionAlgorithm;
20
+ (function (CompressionAlgorithm) {
21
+ CompressionAlgorithm["NONE"] = "none";
22
+ CompressionAlgorithm["GZIP"] = "gzip";
23
+ })(CompressionAlgorithm = exports.CompressionAlgorithm || (exports.CompressionAlgorithm = {}));
24
+ //# sourceMappingURL=legacy-node-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAiBH,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAG/B","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 imports to be actual imports, otherwise they WILL break `@opentelemetry/instrumentation-http`\nimport type * as http from 'http';\nimport type * as https from 'https';\n\nimport { OTLPExporterConfigBase } from './legacy-base-configuration';\n\n/**\n * Collector Exporter node base config\n */\nexport interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {\n keepAlive?: boolean;\n compression?: CompressionAlgorithm;\n httpAgentOptions?: http.AgentOptions | https.AgentOptions;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip',\n}\n"]}
@@ -1,7 +1,11 @@
1
+ /// <reference types="node" />
1
2
  import { OtlpSharedConfiguration } from './shared-configuration';
3
+ import type * as http from 'http';
4
+ import type * as https from 'https';
2
5
  export interface OtlpHttpConfiguration extends OtlpSharedConfiguration {
3
6
  url: string;
4
- headers: Record<string, string>;
7
+ headers: () => Record<string, string>;
8
+ agentOptions: http.AgentOptions | https.AgentOptions;
5
9
  }
6
10
  /**
7
11
  * @param userProvidedConfiguration Configuration options provided by the user in code.
@@ -19,18 +19,20 @@ exports.getHttpConfigurationDefaults = exports.mergeOtlpHttpConfigurationWithDef
19
19
  const shared_configuration_1 = require("./shared-configuration");
20
20
  const util_1 = require("../util");
21
21
  function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
22
- const requiredHeaders = Object.assign({}, defaultHeaders);
22
+ const requiredHeaders = Object.assign({}, defaultHeaders());
23
23
  const headers = {};
24
- // add fallback ones first
25
- if (fallbackHeaders != null) {
26
- Object.assign(headers, fallbackHeaders);
27
- }
28
- // override with user-provided ones
29
- if (userProvidedHeaders != null) {
30
- Object.assign(headers, userProvidedHeaders);
31
- }
32
- // override required ones.
33
- return Object.assign(headers, requiredHeaders);
24
+ return () => {
25
+ // add fallback ones first
26
+ if (fallbackHeaders != null) {
27
+ Object.assign(headers, fallbackHeaders());
28
+ }
29
+ // override with user-provided ones
30
+ if (userProvidedHeaders != null) {
31
+ Object.assign(headers, userProvidedHeaders());
32
+ }
33
+ // override required ones.
34
+ return Object.assign(headers, requiredHeaders);
35
+ };
34
36
  }
35
37
  function validateUserProvidedUrl(url) {
36
38
  if (url == null) {
@@ -50,12 +52,12 @@ function validateUserProvidedUrl(url) {
50
52
  * @param defaultConfiguration The defaults as defined by the exporter specification
51
53
  */
52
54
  function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
53
- var _a, _b;
54
- return Object.assign(Object.assign({}, (0, shared_configuration_1.mergeOtlpSharedConfigurationWithDefaults)(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration)), { headers: mergeHeaders((0, util_1.validateAndNormalizeHeaders)(userProvidedConfiguration.headers), fallbackConfiguration.headers, defaultConfiguration.headers), url: (_b = (_a = validateUserProvidedUrl(userProvidedConfiguration.url)) !== null && _a !== void 0 ? _a : fallbackConfiguration.url) !== null && _b !== void 0 ? _b : defaultConfiguration.url });
55
+ var _a, _b, _c, _d;
56
+ return Object.assign(Object.assign({}, (0, shared_configuration_1.mergeOtlpSharedConfigurationWithDefaults)(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration)), { headers: mergeHeaders((0, util_1.validateAndNormalizeHeaders)(userProvidedConfiguration.headers), fallbackConfiguration.headers, defaultConfiguration.headers), url: (_b = (_a = validateUserProvidedUrl(userProvidedConfiguration.url)) !== null && _a !== void 0 ? _a : fallbackConfiguration.url) !== null && _b !== void 0 ? _b : defaultConfiguration.url, agentOptions: (_d = (_c = userProvidedConfiguration.agentOptions) !== null && _c !== void 0 ? _c : fallbackConfiguration.agentOptions) !== null && _d !== void 0 ? _d : defaultConfiguration.agentOptions });
55
57
  }
56
58
  exports.mergeOtlpHttpConfigurationWithDefaults = mergeOtlpHttpConfigurationWithDefaults;
57
59
  function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
58
- return Object.assign(Object.assign({}, (0, shared_configuration_1.getSharedConfigurationDefaults)()), { headers: requiredHeaders, url: 'http://localhost:4318/' + signalResourcePath });
60
+ return Object.assign(Object.assign({}, (0, shared_configuration_1.getSharedConfigurationDefaults)()), { headers: () => requiredHeaders, url: 'http://localhost:4318/' + signalResourcePath, agentOptions: { keepAlive: true } });
59
61
  }
60
62
  exports.getHttpConfigurationDefaults = getHttpConfigurationDefaults;
61
63
  //# sourceMappingURL=otlp-http-configuration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"otlp-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iEAIgC;AAChC,kCAAsD;AAOtD,SAAS,YAAY,CACnB,mBAA8D,EAC9D,eAA0D,EAC1D,cAAsC;IAEtC,MAAM,eAAe,qBAChB,cAAc,CAClB,CAAC;IACF,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,0BAA0B;IAC1B,IAAI,eAAe,IAAI,IAAI,EAAE;QAC3B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;KACzC;IAED,mCAAmC;IACnC,IAAI,mBAAmB,IAAI,IAAI,EAAE;QAC/B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;KAC7C;IAED,0BAA0B;IAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAuB;IACtD,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,IAAI;QACF,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,6DAA6D,GAAG,GAAG,CACpE,CAAC;KACH;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sCAAsC,CACpD,yBAAyD,EACzD,qBAAqD,EACrD,oBAA2C;;IAE3C,uCACK,IAAA,+DAAwC,EACzC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB,KACD,OAAO,EAAE,YAAY,CACnB,IAAA,kCAA2B,EAAC,yBAAyB,CAAC,OAAO,CAAC,EAC9D,qBAAqB,CAAC,OAAO,EAC7B,oBAAoB,CAAC,OAAO,CAC7B,EACD,GAAG,EACD,MAAA,MAAA,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,CAAC,mCACtD,qBAAqB,CAAC,GAAG,mCACzB,oBAAoB,CAAC,GAAG,IAC1B;AACJ,CAAC;AArBD,wFAqBC;AAED,SAAgB,4BAA4B,CAC1C,eAAuC,EACvC,kBAA0B;IAE1B,uCACK,IAAA,qDAA8B,GAAE,KACnC,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,wBAAwB,GAAG,kBAAkB,IAClD;AACJ,CAAC;AATD,oEASC","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 {\n getSharedConfigurationDefaults,\n mergeOtlpSharedConfigurationWithDefaults,\n OtlpSharedConfiguration,\n} from './shared-configuration';\nimport { validateAndNormalizeHeaders } from '../util';\n\nexport interface OtlpHttpConfiguration extends OtlpSharedConfiguration {\n url: string;\n headers: Record<string, string>;\n}\n\nfunction mergeHeaders(\n userProvidedHeaders: Record<string, string> | undefined | null,\n fallbackHeaders: Record<string, string> | undefined | null,\n defaultHeaders: Record<string, string>\n): Record<string, string> {\n const requiredHeaders = {\n ...defaultHeaders,\n };\n const headers = {};\n\n // add fallback ones first\n if (fallbackHeaders != null) {\n Object.assign(headers, fallbackHeaders);\n }\n\n // override with user-provided ones\n if (userProvidedHeaders != null) {\n Object.assign(headers, userProvidedHeaders);\n }\n\n // override required ones.\n return Object.assign(headers, requiredHeaders);\n}\n\nfunction validateUserProvidedUrl(url: string | undefined): string | undefined {\n if (url == null) {\n return undefined;\n }\n try {\n new URL(url);\n return url;\n } catch (e) {\n throw new Error(\n `Configuration: Could not parse user-provided export URL: '${url}'`\n );\n }\n}\n\n/**\n * @param userProvidedConfiguration Configuration options provided by the user in code.\n * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.\n * @param defaultConfiguration The defaults as defined by the exporter specification\n */\nexport function mergeOtlpHttpConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpHttpConfiguration>,\n fallbackConfiguration: Partial<OtlpHttpConfiguration>,\n defaultConfiguration: OtlpHttpConfiguration\n): OtlpHttpConfiguration {\n return {\n ...mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n headers: mergeHeaders(\n validateAndNormalizeHeaders(userProvidedConfiguration.headers),\n fallbackConfiguration.headers,\n defaultConfiguration.headers\n ),\n url:\n validateUserProvidedUrl(userProvidedConfiguration.url) ??\n fallbackConfiguration.url ??\n defaultConfiguration.url,\n };\n}\n\nexport function getHttpConfigurationDefaults(\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n): OtlpHttpConfiguration {\n return {\n ...getSharedConfigurationDefaults(),\n headers: requiredHeaders,\n url: 'http://localhost:4318/' + signalResourcePath,\n };\n}\n"]}
1
+ {"version":3,"file":"otlp-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iEAIgC;AAChC,kCAAsD;AAYtD,SAAS,YAAY,CACnB,mBAAsE,EACtE,eAAkE,EAClE,cAA4C;IAE5C,MAAM,eAAe,qBAChB,cAAc,EAAE,CACpB,CAAC;IACF,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,OAAO,GAAG,EAAE;QACV,0BAA0B;QAC1B,IAAI,eAAe,IAAI,IAAI,EAAE;YAC3B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;SAC3C;QAED,mCAAmC;QACnC,IAAI,mBAAmB,IAAI,IAAI,EAAE;YAC/B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC;SAC/C;QAED,0BAA0B;QAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAuB;IACtD,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,IAAI;QACF,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,6DAA6D,GAAG,GAAG,CACpE,CAAC;KACH;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sCAAsC,CACpD,yBAAyD,EACzD,qBAAqD,EACrD,oBAA2C;;IAE3C,uCACK,IAAA,+DAAwC,EACzC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB,KACD,OAAO,EAAE,YAAY,CACnB,IAAA,kCAA2B,EAAC,yBAAyB,CAAC,OAAO,CAAC,EAC9D,qBAAqB,CAAC,OAAO,EAC7B,oBAAoB,CAAC,OAAO,CAC7B,EACD,GAAG,EACD,MAAA,MAAA,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,CAAC,mCACtD,qBAAqB,CAAC,GAAG,mCACzB,oBAAoB,CAAC,GAAG,EAC1B,YAAY,EACV,MAAA,MAAA,yBAAyB,CAAC,YAAY,mCACtC,qBAAqB,CAAC,YAAY,mCAClC,oBAAoB,CAAC,YAAY,IACnC;AACJ,CAAC;AAzBD,wFAyBC;AAED,SAAgB,4BAA4B,CAC1C,eAAuC,EACvC,kBAA0B;IAE1B,uCACK,IAAA,qDAA8B,GAAE,KACnC,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,EAC9B,GAAG,EAAE,wBAAwB,GAAG,kBAAkB,EAClD,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IACjC;AACJ,CAAC;AAVD,oEAUC","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 {\n getSharedConfigurationDefaults,\n mergeOtlpSharedConfigurationWithDefaults,\n OtlpSharedConfiguration,\n} from './shared-configuration';\nimport { validateAndNormalizeHeaders } from '../util';\n\n// NOTE: do not change these imports to be actual imports, otherwise they WILL break `@opentelemetry/instrumentation-http`\nimport type * as http from 'http';\nimport type * as https from 'https';\n\nexport interface OtlpHttpConfiguration extends OtlpSharedConfiguration {\n url: string;\n headers: () => Record<string, string>;\n agentOptions: http.AgentOptions | https.AgentOptions;\n}\n\nfunction mergeHeaders(\n userProvidedHeaders: (() => Record<string, string>) | undefined | null,\n fallbackHeaders: (() => Record<string, string>) | undefined | null,\n defaultHeaders: () => Record<string, string>\n): () => Record<string, string> {\n const requiredHeaders = {\n ...defaultHeaders(),\n };\n const headers = {};\n\n return () => {\n // add fallback ones first\n if (fallbackHeaders != null) {\n Object.assign(headers, fallbackHeaders());\n }\n\n // override with user-provided ones\n if (userProvidedHeaders != null) {\n Object.assign(headers, userProvidedHeaders());\n }\n\n // override required ones.\n return Object.assign(headers, requiredHeaders);\n };\n}\n\nfunction validateUserProvidedUrl(url: string | undefined): string | undefined {\n if (url == null) {\n return undefined;\n }\n try {\n new URL(url);\n return url;\n } catch (e) {\n throw new Error(\n `Configuration: Could not parse user-provided export URL: '${url}'`\n );\n }\n}\n\n/**\n * @param userProvidedConfiguration Configuration options provided by the user in code.\n * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.\n * @param defaultConfiguration The defaults as defined by the exporter specification\n */\nexport function mergeOtlpHttpConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpHttpConfiguration>,\n fallbackConfiguration: Partial<OtlpHttpConfiguration>,\n defaultConfiguration: OtlpHttpConfiguration\n): OtlpHttpConfiguration {\n return {\n ...mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n headers: mergeHeaders(\n validateAndNormalizeHeaders(userProvidedConfiguration.headers),\n fallbackConfiguration.headers,\n defaultConfiguration.headers\n ),\n url:\n validateUserProvidedUrl(userProvidedConfiguration.url) ??\n fallbackConfiguration.url ??\n defaultConfiguration.url,\n agentOptions:\n userProvidedConfiguration.agentOptions ??\n fallbackConfiguration.agentOptions ??\n defaultConfiguration.agentOptions,\n };\n}\n\nexport function getHttpConfigurationDefaults(\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n): OtlpHttpConfiguration {\n return {\n ...getSharedConfigurationDefaults(),\n headers: () => requiredHeaders,\n url: 'http://localhost:4318/' + signalResourcePath,\n agentOptions: { keepAlive: true },\n };\n}\n"]}
@@ -19,7 +19,8 @@ exports.getHttpConfigurationFromEnvironment = void 0;
19
19
  const core_1 = require("@opentelemetry/core");
20
20
  const api_1 = require("@opentelemetry/api");
21
21
  const shared_env_configuration_1 = require("./shared-env-configuration");
22
- function getHeadersFromEnv(signalIdentifier) {
22
+ const shared_configuration_1 = require("./shared-configuration");
23
+ function getStaticHeadersFromEnv(signalIdentifier) {
23
24
  var _a, _b;
24
25
  const signalSpecificRawHeaders = (_a = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]) === null || _a === void 0 ? void 0 : _a.trim();
25
26
  const nonSignalSpecificRawHeaders = (_b = process.env['OTEL_EXPORTER_OTLP_HEADERS']) === null || _b === void 0 ? void 0 : _b.trim();
@@ -91,7 +92,7 @@ function getSpecificUrlFromEnv(signalIdentifier) {
91
92
  */
92
93
  function getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
93
94
  var _a;
94
- return Object.assign(Object.assign({}, (0, shared_env_configuration_1.getSharedConfigurationFromEnvironment)(signalIdentifier)), { url: (_a = getSpecificUrlFromEnv(signalIdentifier)) !== null && _a !== void 0 ? _a : getNonSpecificUrlFromEnv(signalResourcePath), headers: getHeadersFromEnv(signalIdentifier) });
95
+ return Object.assign(Object.assign({}, (0, shared_env_configuration_1.getSharedConfigurationFromEnvironment)(signalIdentifier)), { url: (_a = getSpecificUrlFromEnv(signalIdentifier)) !== null && _a !== void 0 ? _a : getNonSpecificUrlFromEnv(signalResourcePath), headers: (0, shared_configuration_1.wrapStaticHeadersInFunction)(getStaticHeadersFromEnv(signalIdentifier)) });
95
96
  }
96
97
  exports.getHttpConfigurationFromEnvironment = getHttpConfigurationFromEnvironment;
97
98
  //# sourceMappingURL=otlp-http-env-configuration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"otlp-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-env-configuration.ts"],"names":[],"mappings":"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","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 { baggageUtils } from '@opentelemetry/core';\nimport { diag } from '@opentelemetry/api';\nimport { getSharedConfigurationFromEnvironment } from './shared-env-configuration';\nimport { OtlpHttpConfiguration } from './otlp-http-configuration';\n\nfunction getHeadersFromEnv(signalIdentifier: string) {\n const signalSpecificRawHeaders =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();\n const nonSignalSpecificRawHeaders =\n process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();\n\n const signalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n nonSignalSpecificRawHeaders\n );\n\n if (\n Object.keys(signalSpecificHeaders).length === 0 &&\n Object.keys(nonSignalSpecificHeaders).length === 0\n ) {\n return undefined;\n }\n\n // headers are combined instead of overwritten, with the specific headers taking precedence over\n // the non-specific ones.\n return Object.assign(\n {},\n baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders),\n baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders)\n );\n}\n\nfunction appendRootPathToUrlIfNeeded(url: string): string | undefined {\n try {\n const parsedUrl = new URL(url);\n // This will automatically append '/' if there's no root path.\n return parsedUrl.toString();\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n}\n\nfunction appendResourcePathToUrl(\n url: string,\n path: string\n): string | undefined {\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n url += path;\n\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Provided URL appended with '${path}' is not a valid URL, using 'undefined' instead of '${url}'`\n );\n return undefined;\n }\n\n return url;\n}\n\nfunction getNonSpecificUrlFromEnv(\n signalResourcePath: string\n): string | undefined {\n const envUrl = process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();\n if (envUrl == null || envUrl === '') {\n return undefined;\n }\n return appendResourcePathToUrl(envUrl, signalResourcePath);\n}\n\nfunction getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {\n const envUrl =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();\n if (envUrl == null || envUrl === '') {\n return undefined;\n }\n return appendRootPathToUrlIfNeeded(envUrl);\n}\n\n/**\n * Reads and returns configuration from the environment\n *\n * @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)\n * @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)\n */\nexport function getHttpConfigurationFromEnvironment(\n signalIdentifier: string,\n signalResourcePath: string\n): Partial<OtlpHttpConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n url:\n getSpecificUrlFromEnv(signalIdentifier) ??\n getNonSpecificUrlFromEnv(signalResourcePath),\n headers: getHeadersFromEnv(signalIdentifier),\n };\n}\n"]}
1
+ {"version":3,"file":"otlp-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-env-configuration.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,8CAAmD;AACnD,4CAA0C;AAC1C,yEAAmF;AAEnF,iEAAqE;AAErE,SAAS,uBAAuB,CAC9B,gBAAwB;;IAExB,MAAM,wBAAwB,GAC5B,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,gBAAgB,UAAU,CAAC,0CAAE,IAAI,EAAE,CAAC;IACxE,MAAM,2BAA2B,GAC/B,MAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,0CAAE,IAAI,EAAE,CAAC;IAEpD,MAAM,qBAAqB,GAAG,mBAAY,CAAC,uBAAuB,CAChE,wBAAwB,CACzB,CAAC;IACF,MAAM,wBAAwB,GAAG,mBAAY,CAAC,uBAAuB,CACnE,2BAA2B,CAC5B,CAAC;IAEF,IACE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,KAAK,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,MAAM,KAAK,CAAC,EAClD;QACA,OAAO,SAAS,CAAC;KAClB;IAED,gGAAgG;IAChG,yBAAyB;IACzB,OAAO,MAAM,CAAC,MAAM,CAClB,EAAE,EACF,mBAAY,CAAC,uBAAuB,CAAC,2BAA2B,CAAC,EACjE,mBAAY,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,CAC/D,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAAC,GAAW;IAC9C,IAAI;QACF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,8DAA8D;QAC9D,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;KAC7B;IAAC,WAAM;QACN,UAAI,CAAC,IAAI,CACP,oEAAoE,GAAG,8BAA8B,CACtG,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,GAAW,EACX,IAAY;IAEZ,IAAI;QACF,oDAAoD;QACpD,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;KACd;IAAC,WAAM;QACN,UAAI,CAAC,IAAI,CACP,oEAAoE,GAAG,8BAA8B,CACtG,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KACjB;IACD,GAAG,IAAI,IAAI,CAAC;IAEZ,IAAI;QACF,oDAAoD;QACpD,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;KACd;IAAC,WAAM;QACN,UAAI,CAAC,IAAI,CACP,8CAA8C,IAAI,uDAAuD,GAAG,GAAG,CAChH,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,wBAAwB,CAC/B,kBAA0B;;IAE1B,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,2BAA2B,0CAAE,IAAI,EAAE,CAAC;IAC/D,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,EAAE,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,qBAAqB,CAAC,gBAAwB;;IACrD,MAAM,MAAM,GACV,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,gBAAgB,WAAW,CAAC,0CAAE,IAAI,EAAE,CAAC;IACzE,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,EAAE,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mCAAmC,CACjD,gBAAwB,EACxB,kBAA0B;;IAE1B,uCACK,IAAA,gEAAqC,EAAC,gBAAgB,CAAC,KAC1D,GAAG,EACD,MAAA,qBAAqB,CAAC,gBAAgB,CAAC,mCACvC,wBAAwB,CAAC,kBAAkB,CAAC,EAC9C,OAAO,EAAE,IAAA,kDAA2B,EAClC,uBAAuB,CAAC,gBAAgB,CAAC,CAC1C,IACD;AACJ,CAAC;AAbD,kFAaC","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 { baggageUtils } from '@opentelemetry/core';\nimport { diag } from '@opentelemetry/api';\nimport { getSharedConfigurationFromEnvironment } from './shared-env-configuration';\nimport { OtlpHttpConfiguration } from './otlp-http-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\n\nfunction getStaticHeadersFromEnv(\n signalIdentifier: string\n): Record<string, string> | undefined {\n const signalSpecificRawHeaders =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();\n const nonSignalSpecificRawHeaders =\n process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();\n\n const signalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n nonSignalSpecificRawHeaders\n );\n\n if (\n Object.keys(signalSpecificHeaders).length === 0 &&\n Object.keys(nonSignalSpecificHeaders).length === 0\n ) {\n return undefined;\n }\n\n // headers are combined instead of overwritten, with the specific headers taking precedence over\n // the non-specific ones.\n return Object.assign(\n {},\n baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders),\n baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders)\n );\n}\n\nfunction appendRootPathToUrlIfNeeded(url: string): string | undefined {\n try {\n const parsedUrl = new URL(url);\n // This will automatically append '/' if there's no root path.\n return parsedUrl.toString();\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n}\n\nfunction appendResourcePathToUrl(\n url: string,\n path: string\n): string | undefined {\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n url += path;\n\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Provided URL appended with '${path}' is not a valid URL, using 'undefined' instead of '${url}'`\n );\n return undefined;\n }\n\n return url;\n}\n\nfunction getNonSpecificUrlFromEnv(\n signalResourcePath: string\n): string | undefined {\n const envUrl = process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();\n if (envUrl == null || envUrl === '') {\n return undefined;\n }\n return appendResourcePathToUrl(envUrl, signalResourcePath);\n}\n\nfunction getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {\n const envUrl =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();\n if (envUrl == null || envUrl === '') {\n return undefined;\n }\n return appendRootPathToUrlIfNeeded(envUrl);\n}\n\n/**\n * Reads and returns configuration from the environment\n *\n * @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)\n * @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)\n */\nexport function getHttpConfigurationFromEnvironment(\n signalIdentifier: string,\n signalResourcePath: string\n): Partial<OtlpHttpConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n url:\n getSpecificUrlFromEnv(signalIdentifier) ??\n getNonSpecificUrlFromEnv(signalResourcePath),\n headers: wrapStaticHeadersInFunction(\n getStaticHeadersFromEnv(signalIdentifier)\n ),\n };\n}\n"]}
@@ -12,6 +12,7 @@ export interface OtlpSharedConfiguration {
12
12
  compression: 'gzip' | 'none';
13
13
  }
14
14
  export declare function validateTimeoutMillis(timeoutMillis: number): number;
15
+ export declare function wrapStaticHeadersInFunction(headers: Record<string, string> | undefined): (() => Record<string, string>) | undefined;
15
16
  /**
16
17
  * @param userProvidedConfiguration Configuration options provided by the user in code.
17
18
  * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getSharedConfigurationDefaults = exports.mergeOtlpSharedConfigurationWithDefaults = exports.validateTimeoutMillis = void 0;
18
+ exports.getSharedConfigurationDefaults = exports.mergeOtlpSharedConfigurationWithDefaults = exports.wrapStaticHeadersInFunction = exports.validateTimeoutMillis = void 0;
19
19
  function validateTimeoutMillis(timeoutMillis) {
20
20
  if (!Number.isNaN(timeoutMillis) &&
21
21
  Number.isFinite(timeoutMillis) &&
@@ -25,6 +25,13 @@ function validateTimeoutMillis(timeoutMillis) {
25
25
  throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`);
26
26
  }
27
27
  exports.validateTimeoutMillis = validateTimeoutMillis;
28
+ function wrapStaticHeadersInFunction(headers) {
29
+ if (headers == null) {
30
+ return undefined;
31
+ }
32
+ return () => headers;
33
+ }
34
+ exports.wrapStaticHeadersInFunction = wrapStaticHeadersInFunction;
28
35
  /**
29
36
  * @param userProvidedConfiguration Configuration options provided by the user in code.
30
37
  * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.