@opentelemetry/otlp-exporter-base 0.51.1 → 0.52.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 (49) hide show
  1. package/build/esm/OTLPExporterBase.d.ts +1 -2
  2. package/build/esm/OTLPExporterBase.js.map +1 -1
  3. package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +7 -2
  4. package/build/esm/platform/browser/OTLPExporterBrowserBase.js +20 -5
  5. package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
  6. package/build/esm/platform/browser/util.d.ts +2 -2
  7. package/build/esm/platform/browser/util.js.map +1 -1
  8. package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +5 -2
  9. package/build/esm/platform/node/OTLPExporterNodeBase.js +5 -3
  10. package/build/esm/platform/node/OTLPExporterNodeBase.js.map +1 -1
  11. package/build/esm/platform/node/util.d.ts +1 -1
  12. package/build/esm/platform/node/util.js +3 -3
  13. package/build/esm/platform/node/util.js.map +1 -1
  14. package/build/esm/version.d.ts +1 -1
  15. package/build/esm/version.js +1 -1
  16. package/build/esm/version.js.map +1 -1
  17. package/build/esnext/OTLPExporterBase.d.ts +1 -2
  18. package/build/esnext/OTLPExporterBase.js.map +1 -1
  19. package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +7 -2
  20. package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +9 -5
  21. package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
  22. package/build/esnext/platform/browser/util.d.ts +2 -2
  23. package/build/esnext/platform/browser/util.js.map +1 -1
  24. package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +5 -2
  25. package/build/esnext/platform/node/OTLPExporterNodeBase.js +5 -3
  26. package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +1 -1
  27. package/build/esnext/platform/node/util.d.ts +1 -1
  28. package/build/esnext/platform/node/util.js +3 -3
  29. package/build/esnext/platform/node/util.js.map +1 -1
  30. package/build/esnext/version.d.ts +1 -1
  31. package/build/esnext/version.js +1 -1
  32. package/build/esnext/version.js.map +1 -1
  33. package/build/src/OTLPExporterBase.d.ts +1 -2
  34. package/build/src/OTLPExporterBase.js.map +1 -1
  35. package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +7 -2
  36. package/build/src/platform/browser/OTLPExporterBrowserBase.js +9 -5
  37. package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
  38. package/build/src/platform/browser/util.d.ts +2 -2
  39. package/build/src/platform/browser/util.js.map +1 -1
  40. package/build/src/platform/node/OTLPExporterNodeBase.d.ts +5 -2
  41. package/build/src/platform/node/OTLPExporterNodeBase.js +5 -3
  42. package/build/src/platform/node/OTLPExporterNodeBase.js.map +1 -1
  43. package/build/src/platform/node/util.d.ts +1 -1
  44. package/build/src/platform/node/util.js +3 -3
  45. package/build/src/platform/node/util.js.map +1 -1
  46. package/build/src/version.d.ts +1 -1
  47. package/build/src/version.js +1 -1
  48. package/build/src/version.js.map +1 -1
  49. package/package.json +13 -11
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/node/util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2BAA2B;AAC3B,6BAA6B;AAC7B,+BAA+B;AAC/B,6BAA6B;AAC7B,mCAAkC;AAGlC,4CAA0C;AAC1C,mCAA+C;AAC/C,8CAA6C;AAC7C,uCAAgD;AAChD,qCAOoB;AAEpB;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,SAA2D,EAC3D,IAAqB,EACrB,WAAmB,EACnB,SAAqB,EACrB,OAA2C;IAE3C,MAAM,eAAe,GAAG,SAAS,CAAC,aAAa,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,K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DAAwD,GAAG,CAAC,OAAO,EAAE,CACtE,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AApBD,0CAoBC;AAED,SAAgB,oBAAoB,CAClC,WAA6C;IAE7C,IAAI,WAAW,EAAE;QACf,OAAO,WAAW,CAAC;KACpB;SAAM;QACL,MAAM,kBAAkB,GACtB,IAAA,aAAM,GAAE,CAAC,qCAAqC;YAC9C,IAAA,aAAM,GAAE,CAAC,8BAA8B,CAAC;QAC1C,OAAO,kBAAkB,KAAK,4BAAoB,CAAC,IAAI;YACrD,CAAC,CAAC,4BAAoB,CAAC,IAAI;YAC3B,CAAC,CAAC,4BAAoB,CAAC,IAAI,CAAC;KAC/B;AACH,CAAC;AAbD,oDAaC","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 * as url from 'url';\nimport * as http from 'http';\nimport * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { OTLPExporterNodeBase } from './OTLPExporterNodeBase';\nimport { OTLPExporterNodeConfigBase } from '.';\nimport { diag } from '@opentelemetry/api';\nimport { CompressionAlgorithm } from './types';\nimport { getEnv } from '@opentelemetry/core';\nimport { OTLPExporterError } from '../../types';\nimport {\n DEFAULT_EXPORT_MAX_ATTEMPTS,\n DEFAULT_EXPORT_INITIAL_BACKOFF,\n DEFAULT_EXPORT_BACKOFF_MULTIPLIER,\n DEFAULT_EXPORT_MAX_BACKOFF,\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../../util';\n\n/**\n * Sends data using http\n * @param collector\n * @param data\n * @param contentType\n * @param onSuccess\n * @param onError\n */\nexport function sendWithHttp<ExportItem, ServiceRequest>(\n collector: OTLPExporterNodeBase<ExportItem, ServiceRequest>,\n data: string | Buffer,\n contentType: string,\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n const exporterTimeout = collector.timeoutMillis;\n const parsedUrl = new url.URL(collector.url);\n const nodeVersion = Number(process.versions.node.split('.')[0]);\n let retryTimer: ReturnType<typeof setTimeout>;\n let req: http.ClientRequest;\n let reqIsDestroyed = false;\n\n const exporterTimer = setTimeout(() => {\n clearTimeout(retryTimer);\n reqIsDestroyed = true;\n\n if (req.destroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n } else {\n // req.abort() was deprecated since v14\n nodeVersion >= 14 ? req.destroy() : req.abort();\n }\n }, exporterTimeout);\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 'Content-Type': contentType,\n ...collector.headers,\n },\n agent: collector.agent,\n };\n\n const request = parsedUrl.protocol === 'http:' ? http.request : https.request;\n\n const sendWithRetry = (\n retries = DEFAULT_EXPORT_MAX_ATTEMPTS,\n minDelay = DEFAULT_EXPORT_INITIAL_BACKOFF\n ) => {\n req = request(options, (res: http.IncomingMessage) => {\n let responseData = '';\n res.on('data', chunk => (responseData += chunk));\n\n res.on('aborted', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n });\n\n res.on('end', () => {\n if (reqIsDestroyed === false) {\n if (res.statusCode && res.statusCode < 299) {\n diag.debug(`statusCode: ${res.statusCode}`, responseData);\n onSuccess();\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n } else if (\n res.statusCode &&\n isExportRetryable(res.statusCode) &&\n retries > 0\n ) {\n let retryTime: number;\n minDelay = DEFAULT_EXPORT_BACKOFF_MULTIPLIER * minDelay;\n\n // retry after interval specified in Retry-After header\n if (res.headers['retry-after']) {\n retryTime = parseRetryAfterToMills(res.headers['retry-after']!);\n } else {\n // exponential backoff with jitter\n retryTime = Math.round(\n Math.random() * (DEFAULT_EXPORT_MAX_BACKOFF - minDelay) +\n minDelay\n );\n }\n\n retryTimer = setTimeout(() => {\n sendWithRetry(retries - 1, minDelay);\n }, retryTime);\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n responseData\n );\n onError(error);\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n }\n }\n });\n });\n\n req.on('error', (error: Error | any) => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout', error.code);\n onError(err);\n } else {\n onError(error);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n req.on('abort', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n switch (collector.compression) {\n case CompressionAlgorithm.GZIP: {\n req.setHeader('Content-Encoding', 'gzip');\n const dataStream = readableFromBuffer(data);\n dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError)\n .pipe(req);\n\n break;\n }\n default:\n req.end(data);\n break;\n }\n };\n sendWithRetry();\n}\n\nfunction readableFromBuffer(buff: string | Buffer): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nexport function createHttpAgent(\n config: OTLPExporterNodeConfigBase\n): http.Agent | https.Agent | undefined {\n if (config.httpAgentOptions && config.keepAlive === false) {\n diag.warn('httpAgentOptions is used only when keepAlive is true');\n return undefined;\n }\n\n if (config.keepAlive === false || !config.url) return undefined;\n\n try {\n const parsedUrl = new url.URL(config.url as string);\n const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;\n return new Agent({ keepAlive: true, ...config.httpAgentOptions });\n } catch (err) {\n diag.error(\n `collector exporter failed to create http agent. err: ${err.message}`\n );\n return undefined;\n }\n}\n\nexport function configureCompression(\n compression: CompressionAlgorithm | undefined\n): CompressionAlgorithm {\n if (compression) {\n return compression;\n } else {\n const definedCompression =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ||\n getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n return definedCompression === CompressionAlgorithm.GZIP\n ? CompressionAlgorithm.GZIP\n : CompressionAlgorithm.NONE;\n }\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/node/util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2BAA2B;AAC3B,6BAA6B;AAC7B,+BAA+B;AAC/B,6BAA6B;AAC7B,mCAAkC;AAGlC,4CAA0C;AAC1C,mCAA+C;AAC/C,8CAA6C;AAC7C,uCAAgD;AAChD,qCAOoB;AAEpB;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,SAA4D,EAC5D,IAAyB,EACzB,WAAmB,EACnB,SAAqB,EACrB,OAA2C;IAE3C,MAAM,eAAe,GAAG,SAAS,CAAC,aAAa,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,IAAI,UAAyC,CAAC;IAC9C,IAAI,GAAuB,CAAC;IAC5B,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE;QACpC,YAAY,CAAC,UAAU,CAAC,CAAC;QACzB,cAAc,GAAG,IAAI,CAAC;QAEtB,IAAI,GAAG,CAAC,SAAS,EAAE;YACjB,MAAM,GAAG,GAAG,IAAI,yBAAiB,CAAC,iBAAiB,CAAC,CAAC;YACrD,OAAO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I;YACrD,CAAC,CAAC,4BAAoB,CAAC,IAAI;YAC3B,CAAC,CAAC,4BAAoB,CAAC,IAAI,CAAC;KAC/B;AACH,CAAC;AAbD,oDAaC","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 * as url from 'url';\nimport * as http from 'http';\nimport * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { OTLPExporterNodeBase } from './OTLPExporterNodeBase';\nimport { OTLPExporterNodeConfigBase } from '.';\nimport { diag } from '@opentelemetry/api';\nimport { CompressionAlgorithm } from './types';\nimport { getEnv } from '@opentelemetry/core';\nimport { OTLPExporterError } from '../../types';\nimport {\n DEFAULT_EXPORT_MAX_ATTEMPTS,\n DEFAULT_EXPORT_INITIAL_BACKOFF,\n DEFAULT_EXPORT_BACKOFF_MULTIPLIER,\n DEFAULT_EXPORT_MAX_BACKOFF,\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../../util';\n\n/**\n * Sends data using http\n * @param collector\n * @param data\n * @param contentType\n * @param onSuccess\n * @param onError\n */\nexport function sendWithHttp<ExportItem, ServiceResponse>(\n collector: OTLPExporterNodeBase<ExportItem, ServiceResponse>,\n data: string | Uint8Array,\n contentType: string,\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n const exporterTimeout = collector.timeoutMillis;\n const parsedUrl = new url.URL(collector.url);\n const nodeVersion = Number(process.versions.node.split('.')[0]);\n let retryTimer: ReturnType<typeof setTimeout>;\n let req: http.ClientRequest;\n let reqIsDestroyed = false;\n\n const exporterTimer = setTimeout(() => {\n clearTimeout(retryTimer);\n reqIsDestroyed = true;\n\n if (req.destroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n } else {\n // req.abort() was deprecated since v14\n nodeVersion >= 14 ? req.destroy() : req.abort();\n }\n }, exporterTimeout);\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 'Content-Type': contentType,\n ...collector.headers,\n },\n agent: collector.agent,\n };\n\n const request = parsedUrl.protocol === 'http:' ? http.request : https.request;\n\n const sendWithRetry = (\n retries = DEFAULT_EXPORT_MAX_ATTEMPTS,\n minDelay = DEFAULT_EXPORT_INITIAL_BACKOFF\n ) => {\n req = request(options, (res: http.IncomingMessage) => {\n let responseData = '';\n res.on('data', chunk => (responseData += chunk));\n\n res.on('aborted', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n });\n\n res.on('end', () => {\n if (reqIsDestroyed === false) {\n if (res.statusCode && res.statusCode < 299) {\n diag.debug(`statusCode: ${res.statusCode}`, responseData);\n onSuccess();\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n } else if (\n res.statusCode &&\n isExportRetryable(res.statusCode) &&\n retries > 0\n ) {\n let retryTime: number;\n minDelay = DEFAULT_EXPORT_BACKOFF_MULTIPLIER * minDelay;\n\n // retry after interval specified in Retry-After header\n if (res.headers['retry-after']) {\n retryTime = parseRetryAfterToMills(res.headers['retry-after']!);\n } else {\n // exponential backoff with jitter\n retryTime = Math.round(\n Math.random() * (DEFAULT_EXPORT_MAX_BACKOFF - minDelay) +\n minDelay\n );\n }\n\n retryTimer = setTimeout(() => {\n sendWithRetry(retries - 1, minDelay);\n }, retryTime);\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n responseData\n );\n onError(error);\n // clear all timers since request was completed and promise was resolved\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n }\n }\n });\n });\n\n req.on('error', (error: Error | any) => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout', error.code);\n onError(err);\n } else {\n onError(error);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n req.on('abort', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError('Request Timeout');\n onError(err);\n }\n clearTimeout(exporterTimer);\n clearTimeout(retryTimer);\n });\n\n switch (collector.compression) {\n case CompressionAlgorithm.GZIP: {\n req.setHeader('Content-Encoding', 'gzip');\n const dataStream = readableFromUnit8Array(data);\n dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError)\n .pipe(req);\n\n break;\n }\n default:\n req.end(Buffer.from(data));\n break;\n }\n };\n sendWithRetry();\n}\n\nfunction readableFromUnit8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nexport function createHttpAgent(\n config: OTLPExporterNodeConfigBase\n): http.Agent | https.Agent | undefined {\n if (config.httpAgentOptions && config.keepAlive === false) {\n diag.warn('httpAgentOptions is used only when keepAlive is true');\n return undefined;\n }\n\n if (config.keepAlive === false || !config.url) return undefined;\n\n try {\n const parsedUrl = new url.URL(config.url as string);\n const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;\n return new Agent({ keepAlive: true, ...config.httpAgentOptions });\n } catch (err) {\n diag.error(\n `collector exporter failed to create http agent. err: ${err.message}`\n );\n return undefined;\n }\n}\n\nexport function configureCompression(\n compression: CompressionAlgorithm | undefined\n): CompressionAlgorithm {\n if (compression) {\n return compression;\n } else {\n const definedCompression =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ||\n getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n return definedCompression === CompressionAlgorithm.GZIP\n ? CompressionAlgorithm.GZIP\n : CompressionAlgorithm.NONE;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.51.1";
1
+ export declare const VERSION = "0.52.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.51.1';
20
+ exports.VERSION = '0.52.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,QAAQ,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.51.1';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,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.52.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/otlp-exporter-base",
3
- "version": "0.51.1",
3
+ "version": "0.52.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",
@@ -28,7 +28,8 @@
28
28
  "version": "node ../../../scripts/version-update.js",
29
29
  "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
30
30
  "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
31
- "prewatch": "npm run precompile"
31
+ "prewatch": "npm run precompile",
32
+ "align-api-deps": "node ../../../scripts/align-api-deps.js"
32
33
  },
33
34
  "keywords": [
34
35
  "opentelemetry",
@@ -61,29 +62,30 @@
61
62
  "access": "public"
62
63
  },
63
64
  "dependencies": {
64
- "@opentelemetry/core": "1.24.1"
65
+ "@opentelemetry/core": "1.25.0",
66
+ "@opentelemetry/otlp-transformer": "0.52.0"
65
67
  },
66
68
  "devDependencies": {
67
- "@babel/core": "7.23.6",
68
- "@babel/preset-env": "7.22.20",
69
- "@opentelemetry/api": "1.8.0",
69
+ "@babel/core": "7.24.6",
70
+ "@babel/preset-env": "7.24.6",
71
+ "@opentelemetry/api": "1.9.0",
70
72
  "@types/mocha": "10.0.6",
71
73
  "@types/node": "18.6.5",
72
- "@types/sinon": "10.0.20",
74
+ "@types/sinon": "17.0.3",
73
75
  "babel-plugin-istanbul": "6.1.1",
74
76
  "codecov": "3.8.3",
75
77
  "cross-var": "1.1.0",
76
- "karma": "6.4.2",
78
+ "karma": "6.4.3",
77
79
  "karma-chrome-launcher": "3.1.0",
78
80
  "karma-coverage": "2.2.1",
79
81
  "karma-mocha": "2.0.1",
80
82
  "karma-spec-reporter": "0.0.36",
81
- "karma-webpack": "4.0.2",
83
+ "karma-webpack": "5.0.1",
82
84
  "lerna": "6.6.2",
83
85
  "mocha": "10.2.0",
84
86
  "nyc": "15.1.0",
85
87
  "sinon": "15.1.2",
86
- "ts-loader": "8.4.0",
88
+ "ts-loader": "9.5.1",
87
89
  "ts-mocha": "10.0.0",
88
90
  "typescript": "4.4.4",
89
91
  "webpack": "5.89.0",
@@ -95,5 +97,5 @@
95
97
  },
96
98
  "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-exporter-base",
97
99
  "sideEffects": false,
98
- "gitHead": "41c2626fe0ed03e2e83bd79ee43c9bdf0ffd80d8"
100
+ "gitHead": "c4d3351b6b3f5593c8d7cbfec97b45cea9fe1511"
99
101
  }