@opentelemetry/otlp-exporter-base 0.212.0 → 0.213.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 (223) hide show
  1. package/build/esm/OTLPExporterBase.js +1 -12
  2. package/build/esm/OTLPExporterBase.js.map +1 -1
  3. package/build/esm/bounded-queue-export-promise-handler.js +1 -12
  4. package/build/esm/bounded-queue-export-promise-handler.js.map +1 -1
  5. package/build/esm/configuration/convert-legacy-browser-http-options.js +1 -12
  6. package/build/esm/configuration/convert-legacy-browser-http-options.js.map +1 -1
  7. package/build/esm/configuration/convert-legacy-http-options.js +1 -12
  8. package/build/esm/configuration/convert-legacy-http-options.js.map +1 -1
  9. package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
  10. package/build/esm/configuration/create-legacy-browser-delegate.d.ts +0 -2
  11. package/build/esm/configuration/create-legacy-browser-delegate.js +2 -9
  12. package/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
  13. package/build/esm/configuration/legacy-base-configuration.js.map +1 -1
  14. package/build/esm/configuration/legacy-node-configuration.js +1 -12
  15. package/build/esm/configuration/legacy-node-configuration.js.map +1 -1
  16. package/build/esm/configuration/otlp-http-configuration.js +1 -12
  17. package/build/esm/configuration/otlp-http-configuration.js.map +1 -1
  18. package/build/esm/configuration/otlp-node-http-configuration.js +1 -12
  19. package/build/esm/configuration/otlp-node-http-configuration.js.map +1 -1
  20. package/build/esm/configuration/otlp-node-http-env-configuration.js +1 -12
  21. package/build/esm/configuration/otlp-node-http-env-configuration.js.map +1 -1
  22. package/build/esm/configuration/shared-configuration.js +1 -12
  23. package/build/esm/configuration/shared-configuration.js.map +1 -1
  24. package/build/esm/configuration/shared-env-configuration.js +1 -12
  25. package/build/esm/configuration/shared-env-configuration.js.map +1 -1
  26. package/build/esm/export-response.js +1 -12
  27. package/build/esm/export-response.js.map +1 -1
  28. package/build/esm/exporter-transport.js +1 -12
  29. package/build/esm/exporter-transport.js.map +1 -1
  30. package/build/esm/index-browser-http.d.ts +3 -0
  31. package/build/esm/index-browser-http.js +4 -12
  32. package/build/esm/index-browser-http.js.map +1 -1
  33. package/build/esm/index-node-http.js +1 -12
  34. package/build/esm/index-node-http.js.map +1 -1
  35. package/build/esm/index.js +1 -12
  36. package/build/esm/index.js.map +1 -1
  37. package/build/esm/is-export-retryable.js +1 -12
  38. package/build/esm/is-export-retryable.js.map +1 -1
  39. package/build/esm/logging-response-handler.js +1 -12
  40. package/build/esm/logging-response-handler.js.map +1 -1
  41. package/build/esm/otlp-browser-http-export-delegate.d.ts +3 -0
  42. package/build/esm/otlp-browser-http-export-delegate.js +4 -7
  43. package/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
  44. package/build/esm/otlp-export-delegate.js +1 -12
  45. package/build/esm/otlp-export-delegate.js.map +1 -1
  46. package/build/esm/otlp-http-export-delegate.js +1 -12
  47. package/build/esm/otlp-http-export-delegate.js.map +1 -1
  48. package/build/esm/otlp-network-export-delegate.js +1 -12
  49. package/build/esm/otlp-network-export-delegate.js.map +1 -1
  50. package/build/esm/response-handler.js +1 -12
  51. package/build/esm/response-handler.js.map +1 -1
  52. package/build/esm/retrying-transport.js +1 -12
  53. package/build/esm/retrying-transport.js.map +1 -1
  54. package/build/esm/transport/fetch-transport.js +52 -18
  55. package/build/esm/transport/fetch-transport.js.map +1 -1
  56. package/build/esm/transport/http-exporter-transport.js +1 -12
  57. package/build/esm/transport/http-exporter-transport.js.map +1 -1
  58. package/build/esm/transport/http-transport-types.js +1 -12
  59. package/build/esm/transport/http-transport-types.js.map +1 -1
  60. package/build/esm/transport/http-transport-utils.d.ts +4 -1
  61. package/build/esm/transport/http-transport-utils.js +30 -2
  62. package/build/esm/transport/http-transport-utils.js.map +1 -1
  63. package/build/esm/transport/node-http-transport-types.js +1 -12
  64. package/build/esm/transport/node-http-transport-types.js.map +1 -1
  65. package/build/esm/types.js +1 -12
  66. package/build/esm/types.js.map +1 -1
  67. package/build/esm/util.js +1 -12
  68. package/build/esm/util.js.map +1 -1
  69. package/build/esm/version.d.ts +1 -1
  70. package/build/esm/version.js +1 -1
  71. package/build/esm/version.js.map +1 -1
  72. package/build/esnext/OTLPExporterBase.js +1 -12
  73. package/build/esnext/OTLPExporterBase.js.map +1 -1
  74. package/build/esnext/bounded-queue-export-promise-handler.js +1 -12
  75. package/build/esnext/bounded-queue-export-promise-handler.js.map +1 -1
  76. package/build/esnext/configuration/convert-legacy-browser-http-options.js +1 -12
  77. package/build/esnext/configuration/convert-legacy-browser-http-options.js.map +1 -1
  78. package/build/esnext/configuration/convert-legacy-http-options.js +1 -12
  79. package/build/esnext/configuration/convert-legacy-http-options.js.map +1 -1
  80. package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
  81. package/build/esnext/configuration/create-legacy-browser-delegate.d.ts +0 -2
  82. package/build/esnext/configuration/create-legacy-browser-delegate.js +2 -9
  83. package/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
  84. package/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
  85. package/build/esnext/configuration/legacy-node-configuration.js +1 -12
  86. package/build/esnext/configuration/legacy-node-configuration.js.map +1 -1
  87. package/build/esnext/configuration/otlp-http-configuration.js +1 -12
  88. package/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
  89. package/build/esnext/configuration/otlp-node-http-configuration.js +1 -12
  90. package/build/esnext/configuration/otlp-node-http-configuration.js.map +1 -1
  91. package/build/esnext/configuration/otlp-node-http-env-configuration.js +1 -12
  92. package/build/esnext/configuration/otlp-node-http-env-configuration.js.map +1 -1
  93. package/build/esnext/configuration/shared-configuration.js +1 -12
  94. package/build/esnext/configuration/shared-configuration.js.map +1 -1
  95. package/build/esnext/configuration/shared-env-configuration.js +1 -12
  96. package/build/esnext/configuration/shared-env-configuration.js.map +1 -1
  97. package/build/esnext/export-response.js +1 -12
  98. package/build/esnext/export-response.js.map +1 -1
  99. package/build/esnext/exporter-transport.js +1 -12
  100. package/build/esnext/exporter-transport.js.map +1 -1
  101. package/build/esnext/index-browser-http.d.ts +3 -0
  102. package/build/esnext/index-browser-http.js +4 -12
  103. package/build/esnext/index-browser-http.js.map +1 -1
  104. package/build/esnext/index-node-http.js +1 -12
  105. package/build/esnext/index-node-http.js.map +1 -1
  106. package/build/esnext/index.js +1 -12
  107. package/build/esnext/index.js.map +1 -1
  108. package/build/esnext/is-export-retryable.js +1 -12
  109. package/build/esnext/is-export-retryable.js.map +1 -1
  110. package/build/esnext/logging-response-handler.js +1 -12
  111. package/build/esnext/logging-response-handler.js.map +1 -1
  112. package/build/esnext/otlp-browser-http-export-delegate.d.ts +3 -0
  113. package/build/esnext/otlp-browser-http-export-delegate.js +4 -7
  114. package/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
  115. package/build/esnext/otlp-export-delegate.js +1 -12
  116. package/build/esnext/otlp-export-delegate.js.map +1 -1
  117. package/build/esnext/otlp-http-export-delegate.js +1 -12
  118. package/build/esnext/otlp-http-export-delegate.js.map +1 -1
  119. package/build/esnext/otlp-network-export-delegate.js +1 -12
  120. package/build/esnext/otlp-network-export-delegate.js.map +1 -1
  121. package/build/esnext/response-handler.js +1 -12
  122. package/build/esnext/response-handler.js.map +1 -1
  123. package/build/esnext/retrying-transport.js +1 -12
  124. package/build/esnext/retrying-transport.js.map +1 -1
  125. package/build/esnext/transport/fetch-transport.js +52 -18
  126. package/build/esnext/transport/fetch-transport.js.map +1 -1
  127. package/build/esnext/transport/http-exporter-transport.js +1 -12
  128. package/build/esnext/transport/http-exporter-transport.js.map +1 -1
  129. package/build/esnext/transport/http-transport-types.js +1 -12
  130. package/build/esnext/transport/http-transport-types.js.map +1 -1
  131. package/build/esnext/transport/http-transport-utils.d.ts +4 -1
  132. package/build/esnext/transport/http-transport-utils.js +30 -2
  133. package/build/esnext/transport/http-transport-utils.js.map +1 -1
  134. package/build/esnext/transport/node-http-transport-types.js +1 -12
  135. package/build/esnext/transport/node-http-transport-types.js.map +1 -1
  136. package/build/esnext/types.js +1 -12
  137. package/build/esnext/types.js.map +1 -1
  138. package/build/esnext/util.js +1 -12
  139. package/build/esnext/util.js.map +1 -1
  140. package/build/esnext/version.d.ts +1 -1
  141. package/build/esnext/version.js +1 -1
  142. package/build/esnext/version.js.map +1 -1
  143. package/build/src/OTLPExporterBase.js +1 -12
  144. package/build/src/OTLPExporterBase.js.map +1 -1
  145. package/build/src/bounded-queue-export-promise-handler.js +1 -12
  146. package/build/src/bounded-queue-export-promise-handler.js.map +1 -1
  147. package/build/src/configuration/convert-legacy-browser-http-options.js +1 -12
  148. package/build/src/configuration/convert-legacy-browser-http-options.js.map +1 -1
  149. package/build/src/configuration/convert-legacy-http-options.js +1 -12
  150. package/build/src/configuration/convert-legacy-http-options.js.map +1 -1
  151. package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
  152. package/build/src/configuration/create-legacy-browser-delegate.d.ts +0 -2
  153. package/build/src/configuration/create-legacy-browser-delegate.js +2 -10
  154. package/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
  155. package/build/src/configuration/legacy-base-configuration.js.map +1 -1
  156. package/build/src/configuration/legacy-node-configuration.js +1 -12
  157. package/build/src/configuration/legacy-node-configuration.js.map +1 -1
  158. package/build/src/configuration/otlp-http-configuration.js +1 -12
  159. package/build/src/configuration/otlp-http-configuration.js.map +1 -1
  160. package/build/src/configuration/otlp-node-http-configuration.js +1 -12
  161. package/build/src/configuration/otlp-node-http-configuration.js.map +1 -1
  162. package/build/src/configuration/otlp-node-http-env-configuration.js +1 -12
  163. package/build/src/configuration/otlp-node-http-env-configuration.js.map +1 -1
  164. package/build/src/configuration/shared-configuration.js +1 -12
  165. package/build/src/configuration/shared-configuration.js.map +1 -1
  166. package/build/src/configuration/shared-env-configuration.js +1 -12
  167. package/build/src/configuration/shared-env-configuration.js.map +1 -1
  168. package/build/src/export-response.js +1 -12
  169. package/build/src/export-response.js.map +1 -1
  170. package/build/src/exporter-transport.js +1 -12
  171. package/build/src/exporter-transport.js.map +1 -1
  172. package/build/src/index-browser-http.d.ts +3 -0
  173. package/build/src/index-browser-http.js +4 -12
  174. package/build/src/index-browser-http.js.map +1 -1
  175. package/build/src/index-node-http.js +1 -12
  176. package/build/src/index-node-http.js.map +1 -1
  177. package/build/src/index.js +1 -12
  178. package/build/src/index.js.map +1 -1
  179. package/build/src/is-export-retryable.js +1 -12
  180. package/build/src/is-export-retryable.js.map +1 -1
  181. package/build/src/logging-response-handler.js +1 -12
  182. package/build/src/logging-response-handler.js.map +1 -1
  183. package/build/src/otlp-browser-http-export-delegate.d.ts +3 -0
  184. package/build/src/otlp-browser-http-export-delegate.js +4 -7
  185. package/build/src/otlp-browser-http-export-delegate.js.map +1 -1
  186. package/build/src/otlp-export-delegate.js +1 -12
  187. package/build/src/otlp-export-delegate.js.map +1 -1
  188. package/build/src/otlp-http-export-delegate.js +1 -12
  189. package/build/src/otlp-http-export-delegate.js.map +1 -1
  190. package/build/src/otlp-network-export-delegate.js +1 -12
  191. package/build/src/otlp-network-export-delegate.js.map +1 -1
  192. package/build/src/response-handler.js +1 -12
  193. package/build/src/response-handler.js.map +1 -1
  194. package/build/src/retrying-transport.js +1 -12
  195. package/build/src/retrying-transport.js.map +1 -1
  196. package/build/src/transport/fetch-transport.js +52 -18
  197. package/build/src/transport/fetch-transport.js.map +1 -1
  198. package/build/src/transport/http-exporter-transport.js +1 -12
  199. package/build/src/transport/http-exporter-transport.js.map +1 -1
  200. package/build/src/transport/http-transport-types.js +1 -12
  201. package/build/src/transport/http-transport-types.js.map +1 -1
  202. package/build/src/transport/http-transport-utils.d.ts +4 -1
  203. package/build/src/transport/http-transport-utils.js +30 -2
  204. package/build/src/transport/http-transport-utils.js.map +1 -1
  205. package/build/src/transport/node-http-transport-types.js +1 -12
  206. package/build/src/transport/node-http-transport-types.js.map +1 -1
  207. package/build/src/types.js +1 -12
  208. package/build/src/types.js.map +1 -1
  209. package/build/src/util.js +1 -12
  210. package/build/src/util.js.map +1 -1
  211. package/build/src/version.d.ts +1 -1
  212. package/build/src/version.js +1 -1
  213. package/build/src/version.js.map +1 -1
  214. package/package.json +4 -4
  215. package/build/esm/transport/send-beacon-transport.d.ts +0 -12
  216. package/build/esm/transport/send-beacon-transport.js +0 -47
  217. package/build/esm/transport/send-beacon-transport.js.map +0 -1
  218. package/build/esnext/transport/send-beacon-transport.d.ts +0 -12
  219. package/build/esnext/transport/send-beacon-transport.js +0 -47
  220. package/build/esnext/transport/send-beacon-transport.js.map +0 -1
  221. package/build/src/transport/send-beacon-transport.d.ts +0 -12
  222. package/build/src/transport/send-beacon-transport.js +0 -51
  223. package/build/src/transport/send-beacon-transport.js.map +0 -1
@@ -10,7 +10,10 @@ 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
19
  * @param onDone
@@ -36,7 +39,7 @@ function sendWithHttp(request, url, headers, compression, userAgent, agent, data
36
39
  const responseData = [];
37
40
  res.on('data', chunk => responseData.push(chunk));
38
41
  res.on('end', () => {
39
- if (res.statusCode && res.statusCode < 299) {
42
+ if (res.statusCode && res.statusCode <= 299) {
40
43
  onDone({
41
44
  status: 'success',
42
45
  data: Buffer.concat(responseData),
@@ -56,6 +59,31 @@ function sendWithHttp(request, url, headers, compression, userAgent, agent, data
56
59
  });
57
60
  }
58
61
  });
62
+ res.on('error', (error) => {
63
+ // Note: 'end' may still be emitted after 'error' on the same response object.
64
+ // However, since onDone maps to a Promise resolve/reject, only the first call takes effect.
65
+ // This will be addressed in https://github.com/open-telemetry/opentelemetry-js/issues/5990
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
+ onDone({
70
+ status: 'success',
71
+ });
72
+ }
73
+ else if (res.statusCode && (0, is_export_retryable_1.isExportHTTPErrorRetryable)(res.statusCode)) {
74
+ onDone({
75
+ status: 'retryable',
76
+ error: error,
77
+ retryInMillis: (0, is_export_retryable_1.parseRetryAfterToMills)(res.headers['retry-after']),
78
+ });
79
+ }
80
+ else {
81
+ onDone({
82
+ status: 'failure',
83
+ error,
84
+ });
85
+ }
86
+ });
59
87
  });
60
88
  req.setTimeout(timeoutMillis, () => {
61
89
  req.destroy();
@@ -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,CAAC,GAAG,kBAAkB,CAAC;KAC5C;IAED,MAAM,OAAO,GAA+C;QAC1D,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,IAAI,EAAE,SAAS,CAAC,QAAQ;QACxB,MAAM,EAAE,MAAM;QACd,OAAO;QACP,KAAK;KACN,CAAC;IAEF,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,GAAyB,EAAE,EAAE;QACzD,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE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AAC,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;;;;;;;;;;;GAWG;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,CAAC,GAAG,kBAAkB,CAAC;KAC5C;IAED,MAAM,OAAO,GAA+C;QAC1D,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,IAAI,EAAE,SAAS,CAAC,QAAQ;QACxB,MAAM,EAAE,MAAM;QACd,OAAO;QACP,KAAK;KACN,CAAC;IAEF,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,GAAyB,EAAE,EAAE;QACzD,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACjB,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,EAAE;gBAC3C,MAAM,CAAC;oBACL,MAAM,EAAE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E,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 { 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 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 res.on('error', (error: Error) => {\n // Note: 'end' may still be emitted after 'error' on the same response object.\n // However, since onDone maps to a Promise resolve/reject, only the first call takes effect.\n // This will be addressed in https://github.com/open-telemetry/opentelemetry-js/issues/5990\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 onDone({\n status: 'success',\n });\n } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {\n onDone({\n status: 'retryable',\n error: error,\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\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,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 { 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,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"]}
package/build/src/util.js CHANGED
@@ -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.validateAndNormalizeHeaders = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAE1C;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,cAAkD;IAElD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC5D,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,UAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,kEAcC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function validateAndNormalizeHeaders(\n partialHeaders: Record<string, string> | undefined\n): Record<string, string> {\n const headers: Record<string, string> = {};\n Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n headers[key] = String(value);\n } else {\n diag.warn(\n `Header \"${key}\" has invalid value (${value}) and will be ignored`\n );\n }\n });\n return headers;\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAA0C;AAE1C;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,cAAkD;IAElD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC5D,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,UAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,kEAcC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { diag } from '@opentelemetry/api';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function validateAndNormalizeHeaders(\n partialHeaders: Record<string, string> | undefined\n): Record<string, string> {\n const headers: Record<string, string> = {};\n Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n headers[key] = String(value);\n } else {\n diag.warn(\n `Header \"${key}\" has invalid value (${value}) and will be ignored`\n );\n }\n });\n return headers;\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.212.0";
1
+ export declare const VERSION = "0.213.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.212.0';
20
+ exports.VERSION = '0.213.0';
21
21
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.212.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.213.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/otlp-exporter-base",
3
- "version": "0.212.0",
3
+ "version": "0.213.0",
4
4
  "description": "OpenTelemetry OTLP Exporter base (for internal use only)",
5
5
  "main": "build/src/index.js",
6
6
  "module": "build/esm/index.js",
@@ -74,8 +74,8 @@
74
74
  "access": "public"
75
75
  },
76
76
  "dependencies": {
77
- "@opentelemetry/core": "2.5.1",
78
- "@opentelemetry/otlp-transformer": "0.212.0"
77
+ "@opentelemetry/core": "2.6.0",
78
+ "@opentelemetry/otlp-transformer": "0.213.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@babel/core": "7.27.1",
@@ -104,5 +104,5 @@
104
104
  },
105
105
  "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-exporter-base",
106
106
  "sideEffects": false,
107
- "gitHead": "ad92be4c2c1094745a85b0b7eeff1444a11b1b4a"
107
+ "gitHead": "541e1b4ad83ad2093459794a18283228fe58d199"
108
108
  }
@@ -1,12 +0,0 @@
1
- import { IExporterTransport } from '../exporter-transport';
2
- import { HeadersFactory } from '../configuration/otlp-http-configuration';
3
- export interface SendBeaconParameters {
4
- url: string;
5
- /**
6
- * Only `Content-Type` will be used, sendBeacon does not support custom headers
7
- * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
8
- */
9
- headers: HeadersFactory;
10
- }
11
- export declare function createSendBeaconTransport(parameters: SendBeaconParameters): IExporterTransport;
12
- //# sourceMappingURL=send-beacon-transport.d.ts.map
@@ -1,47 +0,0 @@
1
- /*
2
- * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { diag } from '@opentelemetry/api';
17
- class SendBeaconTransport {
18
- _params;
19
- constructor(params) {
20
- this._params = params;
21
- }
22
- async send(data) {
23
- const blobType = (await this._params.headers())['Content-Type'];
24
- return new Promise(resolve => {
25
- if (navigator.sendBeacon(this._params.url, new Blob([data], { type: blobType }))) {
26
- // no way to signal retry, treat everything as success
27
- diag.debug('SendBeacon success');
28
- resolve({
29
- status: 'success',
30
- });
31
- }
32
- else {
33
- resolve({
34
- status: 'failure',
35
- error: new Error('SendBeacon failed'),
36
- });
37
- }
38
- });
39
- }
40
- shutdown() {
41
- // Intentionally left empty, nothing to do.
42
- }
43
- }
44
- export function createSendBeaconTransport(parameters) {
45
- return new SendBeaconTransport(parameters);
46
- }
47
- //# sourceMappingURL=send-beacon-transport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../src/transport/send-beacon-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAY1C,MAAM,mBAAmB;IACf,OAAO,CAAuB;IACtC,YAAY,MAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB;QACzB,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;QAChE,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,IACE,SAAS,CAAC,UAAU,CAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAChB,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CACrC,EACD;gBACA,sDAAsD;gBACtD,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBACjC,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,mBAAmB,CAAC;iBACtC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CACvC,UAAgC;IAEhC,OAAO,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7C,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 { HeadersFactory } from '../configuration/otlp-http-configuration';\n\nexport interface SendBeaconParameters {\n url: string;\n /**\n * Only `Content-Type` will be used, sendBeacon does not support custom headers\n * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon\n */\n headers: HeadersFactory;\n}\n\nclass SendBeaconTransport implements IExporterTransport {\n private _params: SendBeaconParameters;\n constructor(params: SendBeaconParameters) {\n this._params = params;\n }\n\n async send(data: Uint8Array): Promise<ExportResponse> {\n const blobType = (await this._params.headers())['Content-Type'];\n return new Promise<ExportResponse>(resolve => {\n if (\n navigator.sendBeacon(\n this._params.url,\n new Blob([data], { type: blobType })\n )\n ) {\n // no way to signal retry, treat everything as success\n diag.debug('SendBeacon success');\n resolve({\n status: 'success',\n });\n } else {\n resolve({\n status: 'failure',\n error: new Error('SendBeacon failed'),\n });\n }\n });\n }\n\n shutdown(): void {\n // Intentionally left empty, nothing to do.\n }\n}\n\nexport function createSendBeaconTransport(\n parameters: SendBeaconParameters\n): IExporterTransport {\n return new SendBeaconTransport(parameters);\n}\n"]}
@@ -1,12 +0,0 @@
1
- import { IExporterTransport } from '../exporter-transport';
2
- import { HeadersFactory } from '../configuration/otlp-http-configuration';
3
- export interface SendBeaconParameters {
4
- url: string;
5
- /**
6
- * Only `Content-Type` will be used, sendBeacon does not support custom headers
7
- * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
8
- */
9
- headers: HeadersFactory;
10
- }
11
- export declare function createSendBeaconTransport(parameters: SendBeaconParameters): IExporterTransport;
12
- //# sourceMappingURL=send-beacon-transport.d.ts.map
@@ -1,47 +0,0 @@
1
- /*
2
- * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { diag } from '@opentelemetry/api';
17
- class SendBeaconTransport {
18
- _params;
19
- constructor(params) {
20
- this._params = params;
21
- }
22
- async send(data) {
23
- const blobType = (await this._params.headers())['Content-Type'];
24
- return new Promise(resolve => {
25
- if (navigator.sendBeacon(this._params.url, new Blob([data], { type: blobType }))) {
26
- // no way to signal retry, treat everything as success
27
- diag.debug('SendBeacon success');
28
- resolve({
29
- status: 'success',
30
- });
31
- }
32
- else {
33
- resolve({
34
- status: 'failure',
35
- error: new Error('SendBeacon failed'),
36
- });
37
- }
38
- });
39
- }
40
- shutdown() {
41
- // Intentionally left empty, nothing to do.
42
- }
43
- }
44
- export function createSendBeaconTransport(parameters) {
45
- return new SendBeaconTransport(parameters);
46
- }
47
- //# sourceMappingURL=send-beacon-transport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../src/transport/send-beacon-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAY1C,MAAM,mBAAmB;IACf,OAAO,CAAuB;IACtC,YAAY,MAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB;QACzB,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;QAChE,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,IACE,SAAS,CAAC,UAAU,CAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAChB,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CACrC,EACD;gBACA,sDAAsD;gBACtD,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBACjC,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,mBAAmB,CAAC;iBACtC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CACvC,UAAgC;IAEhC,OAAO,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7C,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 { HeadersFactory } from '../configuration/otlp-http-configuration';\n\nexport interface SendBeaconParameters {\n url: string;\n /**\n * Only `Content-Type` will be used, sendBeacon does not support custom headers\n * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon\n */\n headers: HeadersFactory;\n}\n\nclass SendBeaconTransport implements IExporterTransport {\n private _params: SendBeaconParameters;\n constructor(params: SendBeaconParameters) {\n this._params = params;\n }\n\n async send(data: Uint8Array): Promise<ExportResponse> {\n const blobType = (await this._params.headers())['Content-Type'];\n return new Promise<ExportResponse>(resolve => {\n if (\n navigator.sendBeacon(\n this._params.url,\n new Blob([data], { type: blobType })\n )\n ) {\n // no way to signal retry, treat everything as success\n diag.debug('SendBeacon success');\n resolve({\n status: 'success',\n });\n } else {\n resolve({\n status: 'failure',\n error: new Error('SendBeacon failed'),\n });\n }\n });\n }\n\n shutdown(): void {\n // Intentionally left empty, nothing to do.\n }\n}\n\nexport function createSendBeaconTransport(\n parameters: SendBeaconParameters\n): IExporterTransport {\n return new SendBeaconTransport(parameters);\n}\n"]}
@@ -1,12 +0,0 @@
1
- import { IExporterTransport } from '../exporter-transport';
2
- import { HeadersFactory } from '../configuration/otlp-http-configuration';
3
- export interface SendBeaconParameters {
4
- url: string;
5
- /**
6
- * Only `Content-Type` will be used, sendBeacon does not support custom headers
7
- * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
8
- */
9
- headers: HeadersFactory;
10
- }
11
- export declare function createSendBeaconTransport(parameters: SendBeaconParameters): IExporterTransport;
12
- //# sourceMappingURL=send-beacon-transport.d.ts.map
@@ -1,51 +0,0 @@
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.createSendBeaconTransport = void 0;
19
- const api_1 = require("@opentelemetry/api");
20
- class SendBeaconTransport {
21
- _params;
22
- constructor(params) {
23
- this._params = params;
24
- }
25
- async send(data) {
26
- const blobType = (await this._params.headers())['Content-Type'];
27
- return new Promise(resolve => {
28
- if (navigator.sendBeacon(this._params.url, new Blob([data], { type: blobType }))) {
29
- // no way to signal retry, treat everything as success
30
- api_1.diag.debug('SendBeacon success');
31
- resolve({
32
- status: 'success',
33
- });
34
- }
35
- else {
36
- resolve({
37
- status: 'failure',
38
- error: new Error('SendBeacon failed'),
39
- });
40
- }
41
- });
42
- }
43
- shutdown() {
44
- // Intentionally left empty, nothing to do.
45
- }
46
- }
47
- function createSendBeaconTransport(parameters) {
48
- return new SendBeaconTransport(parameters);
49
- }
50
- exports.createSendBeaconTransport = createSendBeaconTransport;
51
- //# sourceMappingURL=send-beacon-transport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-beacon-transport.js","sourceRoot":"","sources":["../../../src/transport/send-beacon-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,4CAA0C;AAY1C,MAAM,mBAAmB;IACf,OAAO,CAAuB;IACtC,YAAY,MAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB;QACzB,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;QAChE,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,IACE,SAAS,CAAC,UAAU,CAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAChB,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CACrC,EACD;gBACA,sDAAsD;gBACtD,UAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBACjC,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,mBAAmB,CAAC;iBACtC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,2CAA2C;IAC7C,CAAC;CACF;AAED,SAAgB,yBAAyB,CACvC,UAAgC;IAEhC,OAAO,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7C,CAAC;AAJD,8DAIC","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 { HeadersFactory } from '../configuration/otlp-http-configuration';\n\nexport interface SendBeaconParameters {\n url: string;\n /**\n * Only `Content-Type` will be used, sendBeacon does not support custom headers\n * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon\n */\n headers: HeadersFactory;\n}\n\nclass SendBeaconTransport implements IExporterTransport {\n private _params: SendBeaconParameters;\n constructor(params: SendBeaconParameters) {\n this._params = params;\n }\n\n async send(data: Uint8Array): Promise<ExportResponse> {\n const blobType = (await this._params.headers())['Content-Type'];\n return new Promise<ExportResponse>(resolve => {\n if (\n navigator.sendBeacon(\n this._params.url,\n new Blob([data], { type: blobType })\n )\n ) {\n // no way to signal retry, treat everything as success\n diag.debug('SendBeacon success');\n resolve({\n status: 'success',\n });\n } else {\n resolve({\n status: 'failure',\n error: new Error('SendBeacon failed'),\n });\n }\n });\n }\n\n shutdown(): void {\n // Intentionally left empty, nothing to do.\n }\n}\n\nexport function createSendBeaconTransport(\n parameters: SendBeaconParameters\n): IExporterTransport {\n return new SendBeaconTransport(parameters);\n}\n"]}