@opentelemetry/otlp-exporter-base 0.53.0 → 0.54.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 (121) hide show
  1. package/build/esm/OTLPExporterBase.d.ts +0 -8
  2. package/build/esm/OTLPExporterBase.js +0 -8
  3. package/build/esm/OTLPExporterBase.js.map +1 -1
  4. package/build/esm/configuration/otlp-http-configuration.d.ts +13 -0
  5. package/build/esm/configuration/otlp-http-configuration.js +67 -0
  6. package/build/esm/configuration/otlp-http-configuration.js.map +1 -0
  7. package/build/esm/configuration/otlp-http-env-configuration.d.ts +9 -0
  8. package/build/esm/configuration/otlp-http-env-configuration.js +104 -0
  9. package/build/esm/configuration/otlp-http-env-configuration.js.map +1 -0
  10. package/build/esm/configuration/shared-configuration.d.ts +22 -0
  11. package/build/esm/configuration/shared-configuration.js +44 -0
  12. package/build/esm/configuration/shared-configuration.js.map +1 -0
  13. package/build/esm/configuration/shared-env-configuration.d.ts +3 -0
  14. package/build/esm/configuration/shared-env-configuration.js +44 -0
  15. package/build/esm/configuration/shared-env-configuration.js.map +1 -0
  16. package/build/esm/index.d.ts +3 -1
  17. package/build/esm/index.js +3 -1
  18. package/build/esm/index.js.map +1 -1
  19. package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +4 -3
  20. package/build/esm/platform/browser/OTLPExporterBrowserBase.js +18 -10
  21. package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
  22. package/build/esm/platform/browser/xhr-transport.js +1 -1
  23. package/build/esm/platform/browser/xhr-transport.js.map +1 -1
  24. package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +2 -2
  25. package/build/esm/platform/node/OTLPExporterNodeBase.js +18 -27
  26. package/build/esm/platform/node/OTLPExporterNodeBase.js.map +1 -1
  27. package/build/esm/platform/node/convert-legacy-agent-options.d.ts +12 -0
  28. package/build/esm/platform/node/convert-legacy-agent-options.js +27 -0
  29. package/build/esm/platform/node/convert-legacy-agent-options.js.map +1 -0
  30. package/build/esm/types.d.ts +1 -2
  31. package/build/esm/types.js.map +1 -1
  32. package/build/esm/util.d.ts +1 -27
  33. package/build/esm/util.js +1 -89
  34. package/build/esm/util.js.map +1 -1
  35. package/build/esm/version.d.ts +1 -1
  36. package/build/esm/version.js +1 -1
  37. package/build/esm/version.js.map +1 -1
  38. package/build/esnext/OTLPExporterBase.d.ts +0 -8
  39. package/build/esnext/OTLPExporterBase.js +0 -8
  40. package/build/esnext/OTLPExporterBase.js.map +1 -1
  41. package/build/esnext/configuration/otlp-http-configuration.d.ts +13 -0
  42. package/build/esnext/configuration/otlp-http-configuration.js +56 -0
  43. package/build/esnext/configuration/otlp-http-configuration.js.map +1 -0
  44. package/build/esnext/configuration/otlp-http-env-configuration.d.ts +9 -0
  45. package/build/esnext/configuration/otlp-http-env-configuration.js +93 -0
  46. package/build/esnext/configuration/otlp-http-env-configuration.js.map +1 -0
  47. package/build/esnext/configuration/shared-configuration.d.ts +22 -0
  48. package/build/esnext/configuration/shared-configuration.js +44 -0
  49. package/build/esnext/configuration/shared-configuration.js.map +1 -0
  50. package/build/esnext/configuration/shared-env-configuration.d.ts +3 -0
  51. package/build/esnext/configuration/shared-env-configuration.js +44 -0
  52. package/build/esnext/configuration/shared-env-configuration.js.map +1 -0
  53. package/build/esnext/index.d.ts +3 -1
  54. package/build/esnext/index.js +3 -1
  55. package/build/esnext/index.js.map +1 -1
  56. package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +4 -3
  57. package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +18 -10
  58. package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
  59. package/build/esnext/platform/browser/xhr-transport.js +1 -1
  60. package/build/esnext/platform/browser/xhr-transport.js.map +1 -1
  61. package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +2 -2
  62. package/build/esnext/platform/node/OTLPExporterNodeBase.js +18 -27
  63. package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +1 -1
  64. package/build/esnext/platform/node/convert-legacy-agent-options.d.ts +12 -0
  65. package/build/esnext/platform/node/convert-legacy-agent-options.js +27 -0
  66. package/build/esnext/platform/node/convert-legacy-agent-options.js.map +1 -0
  67. package/build/esnext/types.d.ts +1 -2
  68. package/build/esnext/types.js.map +1 -1
  69. package/build/esnext/util.d.ts +1 -27
  70. package/build/esnext/util.js +1 -89
  71. package/build/esnext/util.js.map +1 -1
  72. package/build/esnext/version.d.ts +1 -1
  73. package/build/esnext/version.js +1 -1
  74. package/build/esnext/version.js.map +1 -1
  75. package/build/src/OTLPExporterBase.d.ts +0 -8
  76. package/build/src/OTLPExporterBase.js +0 -8
  77. package/build/src/OTLPExporterBase.js.map +1 -1
  78. package/build/src/configuration/otlp-http-configuration.d.ts +13 -0
  79. package/build/src/configuration/otlp-http-configuration.js +61 -0
  80. package/build/src/configuration/otlp-http-configuration.js.map +1 -0
  81. package/build/src/configuration/otlp-http-env-configuration.d.ts +9 -0
  82. package/build/src/configuration/otlp-http-env-configuration.js +97 -0
  83. package/build/src/configuration/otlp-http-env-configuration.js.map +1 -0
  84. package/build/src/configuration/shared-configuration.d.ts +22 -0
  85. package/build/src/configuration/shared-configuration.js +50 -0
  86. package/build/src/configuration/shared-configuration.js.map +1 -0
  87. package/build/src/configuration/shared-env-configuration.d.ts +3 -0
  88. package/build/src/configuration/shared-env-configuration.js +48 -0
  89. package/build/src/configuration/shared-env-configuration.js.map +1 -0
  90. package/build/src/index.d.ts +3 -1
  91. package/build/src/index.js +7 -6
  92. package/build/src/index.js.map +1 -1
  93. package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +4 -3
  94. package/build/src/platform/browser/OTLPExporterBrowserBase.js +18 -10
  95. package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
  96. package/build/src/platform/browser/xhr-transport.js +3 -3
  97. package/build/src/platform/browser/xhr-transport.js.map +1 -1
  98. package/build/src/platform/node/OTLPExporterNodeBase.d.ts +2 -2
  99. package/build/src/platform/node/OTLPExporterNodeBase.js +18 -27
  100. package/build/src/platform/node/OTLPExporterNodeBase.js.map +1 -1
  101. package/build/src/platform/node/convert-legacy-agent-options.d.ts +12 -0
  102. package/build/src/platform/node/convert-legacy-agent-options.js +31 -0
  103. package/build/src/platform/node/convert-legacy-agent-options.js.map +1 -0
  104. package/build/src/types.d.ts +1 -2
  105. package/build/src/types.js.map +1 -1
  106. package/build/src/util.d.ts +1 -27
  107. package/build/src/util.js +3 -97
  108. package/build/src/util.js.map +1 -1
  109. package/build/src/version.d.ts +1 -1
  110. package/build/src/version.js +1 -1
  111. package/build/src/version.js.map +1 -1
  112. package/package.json +8 -11
  113. package/build/esm/platform/node/util.d.ts +0 -3
  114. package/build/esm/platform/node/util.js +0 -30
  115. package/build/esm/platform/node/util.js.map +0 -1
  116. package/build/esnext/platform/node/util.d.ts +0 -3
  117. package/build/esnext/platform/node/util.js +0 -30
  118. package/build/esnext/platform/node/util.js.map +0 -1
  119. package/build/src/platform/node/util.d.ts +0 -3
  120. package/build/src/platform/node/util.js +0 -34
  121. package/build/src/platform/node/util.js.map +0 -1
@@ -29,8 +29,8 @@ var __read = (this && this.__read) || function (o, n) {
29
29
  }
30
30
  return ar;
31
31
  };
32
- import { isExportRetryable, parseRetryAfterToMills } from '../../util';
33
32
  import { diag } from '@opentelemetry/api';
33
+ import { isExportRetryable, parseRetryAfterToMills, } from '../../is-export-retryable';
34
34
  var XhrTransport = /** @class */ (function () {
35
35
  function XhrTransport(_parameters) {
36
36
  this._parameters = _parameters;
@@ -1 +1 @@
1
- {"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../../src/platform/browser/xhr-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;AAIH,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAO1C;IACE,sBAAoB,W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AG,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC3B,OAAO,CAAC;wBACN,MAAM,EAAE,SAAS;wBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,8CAA8C,CAAC;qBACjE,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,OAAO,GAAG;gBACZ,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YACF,GAAG,CAAC,OAAO,GAAG;gBACZ,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,GAAG,CAAC,IAAI,CACN,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAI,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CACrE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,+BAAQ,GAAR;QACE,2CAA2C;IAC7C,CAAC;IACH,mBAAC;AAAD,CAAC,AA9DD,IA8DC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAgC;IAEhC,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;AACtC,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 { isExportRetryable, parseRetryAfterToMills } from '../../util';\nimport { diag } from '@opentelemetry/api';\n\nexport interface XhrRequestParameters {\n url: string;\n headers: Record<string, string>;\n}\n\nclass XhrTransport implements IExporterTransport {\n constructor(private _parameters: XhrRequestParameters) {}\n\n send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n return new Promise<ExportResponse>(resolve => {\n const xhr = new XMLHttpRequest();\n xhr.timeout = timeoutMillis;\n xhr.open('POST', this._parameters.url);\n Object.entries(this._parameters.headers).forEach(([k, v]) => {\n xhr.setRequestHeader(k, v);\n });\n\n xhr.ontimeout = _ => {\n resolve({\n status: 'failure',\n error: new Error('XHR request timed out'),\n });\n };\n\n xhr.onreadystatechange = () => {\n if (xhr.status >= 200 && xhr.status <= 299) {\n diag.debug('XHR success');\n resolve({\n status: 'success',\n });\n } else if (xhr.status && isExportRetryable(xhr.status)) {\n resolve({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(\n xhr.getResponseHeader('Retry-After')\n ),\n });\n } else if (xhr.status !== 0) {\n resolve({\n status: 'failure',\n error: new Error('XHR request failed with non-retryable status'),\n });\n }\n };\n\n xhr.onabort = () => {\n resolve({\n status: 'failure',\n error: new Error('XHR request aborted'),\n });\n };\n xhr.onerror = () => {\n resolve({\n status: 'failure',\n error: new Error('XHR request errored'),\n });\n };\n\n xhr.send(\n new Blob([data], { type: this._parameters.headers['Content-Type'] })\n );\n });\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * Creates an exporter transport that uses XHR to send the data\n * @param parameters applied to each request made by transport\n */\nexport function createXhrTransport(\n parameters: XhrRequestParameters\n): IExporterTransport {\n return new XhrTransport(parameters);\n}\n"]}
1
+ {"version":3,"file":"xhr-transport.js","sourceRoot":"","sources":["../../../../src/platform/browser/xhr-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;AAIH,OAAO,EAAE,IAAI,EAAE,MAA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EAAE,sBAAsB,CACnC,GAAG,CAAC,iBAAiB,CAAC,aAAa,CAAC,CACrC;qBACF,CAAC,CAAC;iBACJ;qBAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC3B,OAAO,CAAC;wBACN,MAAM,EAAE,SAAS;wBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,8CAA8C,CAAC;qBACjE,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,OAAO,GAAG;gBACZ,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YACF,GAAG,CAAC,OAAO,GAAG;gBACZ,OAAO,CAAC;oBACN,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,GAAG,CAAC,IAAI,CACN,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAI,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CACrE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,+BAAQ,GAAR;QACE,2CAA2C;IAC7C,CAAC;IACH,mBAAC;AAAD,CAAC,AA9DD,IA8DC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAgC;IAEhC,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { IExporterTransport } from '../../exporter-transport';\nimport { ExportResponse } from '../../export-response';\nimport { diag } from '@opentelemetry/api';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../../is-export-retryable';\n\nexport interface XhrRequestParameters {\n url: string;\n headers: Record<string, string>;\n}\n\nclass XhrTransport implements IExporterTransport {\n constructor(private _parameters: XhrRequestParameters) {}\n\n send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {\n return new Promise<ExportResponse>(resolve => {\n const xhr = new XMLHttpRequest();\n xhr.timeout = timeoutMillis;\n xhr.open('POST', this._parameters.url);\n Object.entries(this._parameters.headers).forEach(([k, v]) => {\n xhr.setRequestHeader(k, v);\n });\n\n xhr.ontimeout = _ => {\n resolve({\n status: 'failure',\n error: new Error('XHR request timed out'),\n });\n };\n\n xhr.onreadystatechange = () => {\n if (xhr.status >= 200 && xhr.status <= 299) {\n diag.debug('XHR success');\n resolve({\n status: 'success',\n });\n } else if (xhr.status && isExportRetryable(xhr.status)) {\n resolve({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(\n xhr.getResponseHeader('Retry-After')\n ),\n });\n } else if (xhr.status !== 0) {\n resolve({\n status: 'failure',\n error: new Error('XHR request failed with non-retryable status'),\n });\n }\n };\n\n xhr.onabort = () => {\n resolve({\n status: 'failure',\n error: new Error('XHR request aborted'),\n });\n };\n xhr.onerror = () => {\n resolve({\n status: 'failure',\n error: new Error('XHR request errored'),\n });\n };\n\n xhr.send(\n new Blob([data], { type: this._parameters.headers['Content-Type'] })\n );\n });\n }\n\n shutdown() {\n // Intentionally left empty, nothing to do.\n }\n}\n\n/**\n * Creates an exporter transport that uses XHR to send the data\n * @param parameters applied to each request made by transport\n */\nexport function createXhrTransport(\n parameters: XhrRequestParameters\n): IExporterTransport {\n return new XhrTransport(parameters);\n}\n"]}
@@ -8,8 +8,8 @@ import { OTLPExporterError } from '../../types';
8
8
  export declare abstract class OTLPExporterNodeBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {
9
9
  private _serializer;
10
10
  private _transport;
11
- constructor(config: OTLPExporterNodeConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, signalSpecificHeaders: Record<string, string>);
12
- onInit(_config: OTLPExporterNodeConfigBase): void;
11
+ private _timeoutMillis;
12
+ constructor(config: OTLPExporterNodeConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, requiredHeaders: Record<string, string>, signalIdentifier: string, signalResourcePath: string);
13
13
  send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
14
14
  onShutdown(): void;
15
15
  }
@@ -29,54 +29,45 @@ var __extends = (this && this.__extends) || (function () {
29
29
  };
30
30
  })();
31
31
  import { OTLPExporterBase } from '../../OTLPExporterBase';
32
- import { configureCompression } from './util';
33
32
  import { diag } from '@opentelemetry/api';
34
- import { getEnv, baggageUtils } from '@opentelemetry/core';
35
33
  import { createHttpExporterTransport } from './http-exporter-transport';
36
34
  import { OTLPExporterError } from '../../types';
37
35
  import { createRetryingTransport } from '../../retrying-transport';
36
+ import { convertLegacyAgentOptions } from './convert-legacy-agent-options';
37
+ import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from '../../configuration/otlp-http-configuration';
38
+ import { getHttpConfigurationFromEnvironment } from '../../configuration/otlp-http-env-configuration';
38
39
  /**
39
40
  * Collector Metric Exporter abstract base class
40
41
  */
41
42
  var OTLPExporterNodeBase = /** @class */ (function (_super) {
42
43
  __extends(OTLPExporterNodeBase, _super);
43
- function OTLPExporterNodeBase(config, serializer, signalSpecificHeaders) {
44
+ function OTLPExporterNodeBase(config, serializer, requiredHeaders, signalIdentifier, signalResourcePath) {
44
45
  if (config === void 0) { config = {}; }
45
- var _a;
46
46
  var _this = _super.call(this, config) || this;
47
+ var actualConfig = mergeOtlpHttpConfigurationWithDefaults({
48
+ url: config.url,
49
+ headers: config.headers,
50
+ concurrencyLimit: config.concurrencyLimit,
51
+ timeoutMillis: config.timeoutMillis,
52
+ compression: config.compression,
53
+ }, getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
54
+ _this._timeoutMillis = actualConfig.timeoutMillis;
55
+ _this._concurrencyLimit = actualConfig.concurrencyLimit;
47
56
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
57
  if (config.metadata) {
49
58
  diag.warn('Metadata cannot be set when using http');
50
59
  }
51
60
  _this._serializer = serializer;
52
- // populate keepAlive for use with new settings
53
- if ((config === null || config === void 0 ? void 0 : config.keepAlive) != null) {
54
- if (config.httpAgentOptions != null) {
55
- if (config.httpAgentOptions.keepAlive == null) {
56
- // specific setting is not set, populate with non-specific setting.
57
- config.httpAgentOptions.keepAlive = config.keepAlive;
58
- }
59
- // do nothing, use specific setting otherwise
60
- }
61
- else {
62
- // populate specific option if AgentOptions does not exist.
63
- config.httpAgentOptions = {
64
- keepAlive: config.keepAlive,
65
- };
66
- }
67
- }
68
- var nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS);
69
61
  _this._transport = createRetryingTransport({
70
62
  transport: createHttpExporterTransport({
71
- agentOptions: (_a = config.httpAgentOptions) !== null && _a !== void 0 ? _a : { keepAlive: true },
72
- compression: configureCompression(config.compression),
73
- headers: Object.assign({}, nonSignalSpecificHeaders, signalSpecificHeaders),
74
- url: _this.url,
63
+ agentOptions: convertLegacyAgentOptions(config),
64
+ compression: actualConfig.compression,
65
+ headers: actualConfig.headers,
66
+ url: actualConfig.url,
75
67
  }),
76
68
  });
77
69
  return _this;
78
70
  }
79
- OTLPExporterNodeBase.prototype.onInit = function (_config) { };
80
71
  OTLPExporterNodeBase.prototype.send = function (objects, onSuccess, onError) {
81
72
  var _this = this;
82
73
  if (this._shutdownOnce.isCalled) {
@@ -89,7 +80,7 @@ var OTLPExporterNodeBase = /** @class */ (function (_super) {
89
80
  return;
90
81
  }
91
82
  var promise = this._transport
92
- .send(data, this.timeoutMillis)
83
+ .send(data, this._timeoutMillis)
93
84
  .then(function (response) {
94
85
  if (response.status === 'success') {
95
86
  onSuccess();
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPExporterNodeBase.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPExporterNodeBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;GAEG;AACH;IAGU,wCAAwD;IAIhE,8BACE,MAAuC,EACvC,UAAsD,EACtD,qBAA6C;QAF7C,uBAAA,EAAA,WAAuC;;QADzC,YAKE,kBAAM,MAAM,CAAC,SAsCd;QArCC,8DAA8D;QAC9D,IAAK,MAAc,CAAC,QAAQ,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;SACrD;QACD,KAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,+CAA+C;QAC/C,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,KAAI,IAAI,EAAE;YAC7B,IAAI,MAAM,CAAC,gBAAgB,IAAI,IAAI,EAAE;gBACnC,IAAI,MAAM,CAAC,gBAAgB,CAAC,SAAS,IAAI,IAAI,EAAE;oBAC7C,mEAA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CAAC,UAAA,QAAQ;YACZ,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE;gBACjC,SAAS,EAAE,CAAC;aACb;iBAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,EAAE;gBAC1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;aACzB;iBAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,EAAE;gBAC1C,OAAO,CAAC,IAAI,iBAAiB,CAAC,qCAAqC,CAAC,CAAC,CAAC;aACvE;iBAAM;gBACL,OAAO,CAAC,IAAI,iBAAiB,CAAC,kCAAkC,CAAC,CAAC,CAAC;aACpE;QACH,CAAC,EAAE,OAAO,CAAC,CAAC;QAEd,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG;YACjB,IAAM,KAAK,GAAG,KAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACrD,KAAI,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;IAED,yCAAU,GAAV,cAAoB,CAAC;IACvB,2BAAC;AAAD,CAAC,AA9FD,CAGU,gBAAgB,GA2FzB","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 { OTLPExporterBase } from '../../OTLPExporterBase';\nimport { OTLPExporterNodeConfigBase } from './types';\nimport { configureCompression } from './util';\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from '../../exporter-transport';\nimport { createHttpExporterTransport } from './http-exporter-transport';\nimport { OTLPExporterError } from '../../types';\nimport { createRetryingTransport } from '../../retrying-transport';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterNodeBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _transport: IExporterTransport;\n\n constructor(\n config: OTLPExporterNodeConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n signalSpecificHeaders: Record<string, string>\n ) {\n super(config);\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 this._serializer = serializer;\n\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 const nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_HEADERS\n );\n\n this._transport = createRetryingTransport({\n transport: createHttpExporterTransport({\n agentOptions: config.httpAgentOptions ?? { keepAlive: true },\n compression: configureCompression(config.compression),\n headers: Object.assign(\n {},\n nonSignalSpecificHeaders,\n signalSpecificHeaders\n ),\n url: this.url,\n }),\n });\n }\n\n onInit(_config: OTLPExporterNodeConfigBase): void {}\n\n send(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n\n const data = this._serializer.serializeRequest(objects);\n\n if (data == null) {\n onError(new Error('Could not serialize message'));\n return;\n }\n\n const promise = this._transport\n .send(data, this.timeoutMillis)\n .then(response => {\n if (response.status === 'success') {\n onSuccess();\n } else if (response.status === 'failure' && response.error) {\n onError(response.error);\n } else if (response.status === 'retryable') {\n onError(new OTLPExporterError('Export failed with retryable status'));\n } else {\n onError(new OTLPExporterError('Export failed with unknown error'));\n }\n }, onError);\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 onShutdown(): void {}\n}\n"]}
1
+ {"version":3,"file":"OTLPExporterNodeBase.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPExporterNodeBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GACvC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,iDAAiD,CAAC;AAEtG;;GAEG;AACH;IAGU,wCAAwD;IAKhE,8BACE,MAAuC,EACvC,UAAsD,EACtD,eAAuC,EACvC,gBAAwB,EACxB,kBAA0B;QAJ1B,uBAAA,EAAA,WAAuC;QADzC,YAOE,kBAAM,MAAM,CAAC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AC,6BAA6B,CAAC,CAAC,CAAC;YAClD,OAAO;SACR;QAED,IAAM,OAAO,GAAG,IAAI,CAAC,UAAU;aAC5B,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC;aAC/B,IAAI,CAAC,UAAA,QAAQ;YACZ,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE;gBACjC,SAAS,EAAE,CAAC;aACb;iBAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,EAAE;gBAC1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;aACzB;iBAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,EAAE;gBAC1C,OAAO,CAAC,IAAI,iBAAiB,CAAC,qCAAqC,CAAC,CAAC,CAAC;aACvE;iBAAM;gBACL,OAAO,CAAC,IAAI,iBAAiB,CAAC,kCAAkC,CAAC,CAAC,CAAC;aACpE;QACH,CAAC,EAAE,OAAO,CAAC,CAAC;QAEd,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG;YACjB,IAAM,KAAK,GAAG,KAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACrD,KAAI,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;IAED,yCAAU,GAAV,cAAoB,CAAC;IACvB,2BAAC;AAAD,CAAC,AAvFD,CAGU,gBAAgB,GAoFzB","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 { OTLPExporterBase } from '../../OTLPExporterBase';\nimport { OTLPExporterNodeConfigBase } from './types';\nimport { diag } from '@opentelemetry/api';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from '../../exporter-transport';\nimport { createHttpExporterTransport } from './http-exporter-transport';\nimport { OTLPExporterError } from '../../types';\nimport { createRetryingTransport } from '../../retrying-transport';\nimport { convertLegacyAgentOptions } from './convert-legacy-agent-options';\nimport {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n} from '../../configuration/otlp-http-configuration';\nimport { getHttpConfigurationFromEnvironment } from '../../configuration/otlp-http-env-configuration';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterNodeBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterNodeConfigBase, ExportItem> {\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _transport: IExporterTransport;\n private _timeoutMillis: number;\n\n constructor(\n config: OTLPExporterNodeConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n requiredHeaders: Record<string, string>,\n signalIdentifier: string,\n signalResourcePath: string\n ) {\n super(config);\n const actualConfig = mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: config.headers,\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n },\n getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath),\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n\n this._timeoutMillis = actualConfig.timeoutMillis;\n this._concurrencyLimit = actualConfig.concurrencyLimit;\n\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 this._serializer = serializer;\n\n this._transport = createRetryingTransport({\n transport: createHttpExporterTransport({\n agentOptions: convertLegacyAgentOptions(config),\n compression: actualConfig.compression,\n headers: actualConfig.headers,\n url: actualConfig.url,\n }),\n });\n }\n\n send(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n\n const data = this._serializer.serializeRequest(objects);\n\n if (data == null) {\n onError(new Error('Could not serialize message'));\n return;\n }\n\n const promise = this._transport\n .send(data, this._timeoutMillis)\n .then(response => {\n if (response.status === 'success') {\n onSuccess();\n } else if (response.status === 'failure' && response.error) {\n onError(response.error);\n } else if (response.status === 'retryable') {\n onError(new OTLPExporterError('Export failed with retryable status'));\n } else {\n onError(new OTLPExporterError('Export failed with unknown error'));\n }\n }, onError);\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 onShutdown(): void {}\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { OTLPExporterNodeConfigBase } from './types';
3
+ import type * as http from 'http';
4
+ import type * as https from 'https';
5
+ /**
6
+ * Replicates old config behavior where there's two ways to set keepAlive.
7
+ * This function sets keepAlive in AgentOptions if it is defined. In the future, we will remove
8
+ * this duplicate to only allow setting keepAlive in AgentOptions.
9
+ * @param config
10
+ */
11
+ export declare function convertLegacyAgentOptions(config: OTLPExporterNodeConfigBase): http.AgentOptions | https.AgentOptions;
12
+ //# sourceMappingURL=convert-legacy-agent-options.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Replicates old config behavior where there's two ways to set keepAlive.
3
+ * This function sets keepAlive in AgentOptions if it is defined. In the future, we will remove
4
+ * this duplicate to only allow setting keepAlive in AgentOptions.
5
+ * @param config
6
+ */
7
+ export function convertLegacyAgentOptions(config) {
8
+ var _a;
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 (_a = config.httpAgentOptions) !== null && _a !== void 0 ? _a : { keepAlive: true };
26
+ }
27
+ //# sourceMappingURL=convert-legacy-agent-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-legacy-agent-options.js","sourceRoot":"","sources":["../../../../src/platform/node/convert-legacy-agent-options.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,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,MAAA,MAAM,CAAC,gBAAgB,mCAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACxD,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 { OTLPExporterNodeConfigBase } from './types';\nimport type * as http from 'http';\nimport type * as https from 'https';\n\n/**\n * Replicates old config behavior where there's two ways to set keepAlive.\n * This function sets keepAlive in AgentOptions if it is defined. In the future, we will remove\n * this duplicate to only allow setting keepAlive in AgentOptions.\n * @param config\n */\nexport function convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): http.AgentOptions | https.AgentOptions {\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 ?? { keepAlive: true };\n}\n"]}
@@ -24,8 +24,7 @@ export interface ExportServiceError {
24
24
  * Collector Exporter base config
25
25
  */
26
26
  export interface OTLPExporterConfigBase {
27
- headers?: Partial<Record<string, unknown>>;
28
- hostname?: string;
27
+ headers?: Record<string, string>;
29
28
  url?: string;
30
29
  concurrencyLimit?: number;
31
30
  /** Maximum time the OTLP exporter will wait for each batch export.
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH;;GAEG;AACH;IAAuC,qCAAK;IAK1C,2BAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QAA1D,YACE,kBAAM,OAAO,CAAC,SAGf;QAPiB,UAAI,GAAW,mBAAmB,CAAC;QAKnD,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IACH,wBAAC;AAAD,CAAC,AAVD,CAAuC,KAAK,GAU3C","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\n/**\n * Collector Exporter base config\n */\nexport interface OTLPExporterConfigBase {\n headers?: Partial<Record<string, unknown>>;\n hostname?: 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
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH;;GAEG;AACH;IAAuC,qCAAK;IAK1C,2BAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QAA1D,YACE,kBAAM,OAAO,CAAC,SAGf;QAPiB,UAAI,GAAW,mBAAmB,CAAC;QAKnD,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IACH,wBAAC;AAAD,CAAC,AAVD,CAAuC,KAAK,GAU3C","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\n/**\n * Collector Exporter base config\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,32 +1,6 @@
1
- export declare const DEFAULT_EXPORT_MAX_ATTEMPTS = 5;
2
- export declare const DEFAULT_EXPORT_INITIAL_BACKOFF = 1000;
3
- export declare const DEFAULT_EXPORT_MAX_BACKOFF = 5000;
4
- export declare const DEFAULT_EXPORT_BACKOFF_MULTIPLIER = 1.5;
5
1
  /**
6
2
  * Parses headers from config leaving only those that have defined values
7
3
  * @param partialHeaders
8
4
  */
9
- export declare function parseHeaders(partialHeaders?: Partial<Record<string, unknown>>): Record<string, string>;
10
- /**
11
- * Adds path (version + signal) to a no per-signal endpoint
12
- * @param url
13
- * @param path
14
- * @returns url + path
15
- */
16
- export declare function appendResourcePathToUrl(url: string, path: string): string;
17
- /**
18
- * Adds root path to signal specific endpoint when endpoint contains no path part and no root path
19
- * @param url
20
- * @returns url
21
- */
22
- export declare function appendRootPathToUrlIfNeeded(url: string): string;
23
- /**
24
- * Configure exporter trace timeout value from passed in value or environment variables
25
- * @param timeoutMillis
26
- * @returns timeout value in milliseconds
27
- */
28
- export declare function configureExporterTimeout(timeoutMillis: number | undefined): number;
29
- export declare function invalidTimeout(timeout: number, defaultTimeout: number): number;
30
- export declare function isExportRetryable(statusCode: number): boolean;
31
- export declare function parseRetryAfterToMills(retryAfter?: string | null): number;
5
+ export declare function validateAndNormalizeHeaders(partialHeaders?: Partial<Record<string, unknown>>): Record<string, string>;
32
6
  //# sourceMappingURL=util.d.ts.map
package/build/esm/util.js CHANGED
@@ -30,17 +30,11 @@ var __read = (this && this.__read) || function (o, n) {
30
30
  return ar;
31
31
  };
32
32
  import { diag } from '@opentelemetry/api';
33
- import { getEnv } from '@opentelemetry/core';
34
- var DEFAULT_TRACE_TIMEOUT = 10000;
35
- export var DEFAULT_EXPORT_MAX_ATTEMPTS = 5;
36
- export var DEFAULT_EXPORT_INITIAL_BACKOFF = 1000;
37
- export var DEFAULT_EXPORT_MAX_BACKOFF = 5000;
38
- export var DEFAULT_EXPORT_BACKOFF_MULTIPLIER = 1.5;
39
33
  /**
40
34
  * Parses headers from config leaving only those that have defined values
41
35
  * @param partialHeaders
42
36
  */
43
- export function parseHeaders(partialHeaders) {
37
+ export function validateAndNormalizeHeaders(partialHeaders) {
44
38
  if (partialHeaders === void 0) { partialHeaders = {}; }
45
39
  var headers = {};
46
40
  Object.entries(partialHeaders).forEach(function (_a) {
@@ -54,86 +48,4 @@ export function parseHeaders(partialHeaders) {
54
48
  });
55
49
  return headers;
56
50
  }
57
- /**
58
- * Adds path (version + signal) to a no per-signal endpoint
59
- * @param url
60
- * @param path
61
- * @returns url + path
62
- */
63
- export function appendResourcePathToUrl(url, path) {
64
- if (!url.endsWith('/')) {
65
- url = url + '/';
66
- }
67
- return url + path;
68
- }
69
- /**
70
- * Adds root path to signal specific endpoint when endpoint contains no path part and no root path
71
- * @param url
72
- * @returns url
73
- */
74
- export function appendRootPathToUrlIfNeeded(url) {
75
- try {
76
- var parsedUrl = new URL(url);
77
- if (parsedUrl.pathname === '') {
78
- parsedUrl.pathname = parsedUrl.pathname + '/';
79
- }
80
- return parsedUrl.toString();
81
- }
82
- catch (_a) {
83
- diag.warn("Could not parse export URL: '" + url + "'");
84
- return url;
85
- }
86
- }
87
- /**
88
- * Configure exporter trace timeout value from passed in value or environment variables
89
- * @param timeoutMillis
90
- * @returns timeout value in milliseconds
91
- */
92
- export function configureExporterTimeout(timeoutMillis) {
93
- if (typeof timeoutMillis === 'number') {
94
- if (timeoutMillis <= 0) {
95
- // OTLP exporter configured timeout - using default value of 10000ms
96
- return invalidTimeout(timeoutMillis, DEFAULT_TRACE_TIMEOUT);
97
- }
98
- return timeoutMillis;
99
- }
100
- else {
101
- return getExporterTimeoutFromEnv();
102
- }
103
- }
104
- function getExporterTimeoutFromEnv() {
105
- var _a;
106
- var definedTimeout = Number((_a = getEnv().OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) !== null && _a !== void 0 ? _a : getEnv().OTEL_EXPORTER_OTLP_TIMEOUT);
107
- if (definedTimeout <= 0) {
108
- // OTLP exporter configured timeout - using default value of 10000ms
109
- return invalidTimeout(definedTimeout, DEFAULT_TRACE_TIMEOUT);
110
- }
111
- else {
112
- return definedTimeout;
113
- }
114
- }
115
- // OTLP exporter configured timeout - using default value of 10000ms
116
- export function invalidTimeout(timeout, defaultTimeout) {
117
- diag.warn('Timeout must be greater than 0', timeout);
118
- return defaultTimeout;
119
- }
120
- export function isExportRetryable(statusCode) {
121
- var retryCodes = [429, 502, 503, 504];
122
- return retryCodes.includes(statusCode);
123
- }
124
- export function parseRetryAfterToMills(retryAfter) {
125
- if (retryAfter == null) {
126
- return -1;
127
- }
128
- var seconds = Number.parseInt(retryAfter, 10);
129
- if (Number.isInteger(seconds)) {
130
- return seconds > 0 ? seconds * 1000 : -1;
131
- }
132
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#directives
133
- var delay = new Date(retryAfter).getTime() - Date.now();
134
- if (delay >= 0) {
135
- return delay;
136
- }
137
- return 0;
138
- }
139
51
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,IAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,MAAM,CAAC,IAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,IAAM,8BAA8B,GAAG,IAAI,CAAC;AACnD,MAAM,CAAC,IAAM,0BAA0B,GAAG,IAAI,CAAC;AAC/C,MAAM,CAAC,IAAM,iCAAiC,GAAG,GAAG,CAAC;AAErD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,cAAqD;IAArD,+BAAA,EAAA,mBAAqD;IAErD,IAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,UAAC,EAAY;YAAZ,KAAA,aAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QACjD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,IAAI,CAAC,IAAI,CACP,cAAW,GAAG,8BAAwB,KAAK,0BAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW,EAAE,IAAY;IAC/D,IAAI,CAAC,GAAG,CAAC,QAAQ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E,OAAO,CAAC,CAAC;IAErD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,IAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAExC,OAAO,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,UAA0B;IAC/D,IAAI,UAAU,IAAI,IAAI,EAAE;QACtB,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC7B,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC1C;IACD,mFAAmF;IACnF,IAAM,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE1D,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\nimport { getEnv } from '@opentelemetry/core';\n\nconst DEFAULT_TRACE_TIMEOUT = 10000;\nexport const DEFAULT_EXPORT_MAX_ATTEMPTS = 5;\nexport const DEFAULT_EXPORT_INITIAL_BACKOFF = 1000;\nexport const DEFAULT_EXPORT_MAX_BACKOFF = 5000;\nexport const DEFAULT_EXPORT_BACKOFF_MULTIPLIER = 1.5;\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function parseHeaders(\n partialHeaders: Partial<Record<string, unknown>> = {}\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\n/**\n * Adds path (version + signal) to a no per-signal endpoint\n * @param url\n * @param path\n * @returns url + path\n */\nexport function appendResourcePathToUrl(url: string, path: string): string {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n return url + path;\n}\n\n/**\n * Adds root path to signal specific endpoint when endpoint contains no path part and no root path\n * @param url\n * @returns url\n */\nexport function appendRootPathToUrlIfNeeded(url: string): string {\n try {\n const parsedUrl = new URL(url);\n if (parsedUrl.pathname === '') {\n parsedUrl.pathname = parsedUrl.pathname + '/';\n }\n return parsedUrl.toString();\n } catch {\n diag.warn(`Could not parse export URL: '${url}'`);\n return url;\n }\n}\n\n/**\n * Configure exporter trace timeout value from passed in value or environment variables\n * @param timeoutMillis\n * @returns timeout value in milliseconds\n */\nexport function configureExporterTimeout(\n timeoutMillis: number | undefined\n): number {\n if (typeof timeoutMillis === 'number') {\n if (timeoutMillis <= 0) {\n // OTLP exporter configured timeout - using default value of 10000ms\n return invalidTimeout(timeoutMillis, DEFAULT_TRACE_TIMEOUT);\n }\n return timeoutMillis;\n } else {\n return getExporterTimeoutFromEnv();\n }\n}\n\nfunction getExporterTimeoutFromEnv(): number {\n const definedTimeout = Number(\n getEnv().OTEL_EXPORTER_OTLP_TRACES_TIMEOUT ??\n getEnv().OTEL_EXPORTER_OTLP_TIMEOUT\n );\n\n if (definedTimeout <= 0) {\n // OTLP exporter configured timeout - using default value of 10000ms\n return invalidTimeout(definedTimeout, DEFAULT_TRACE_TIMEOUT);\n } else {\n return definedTimeout;\n }\n}\n\n// OTLP exporter configured timeout - using default value of 10000ms\nexport function invalidTimeout(\n timeout: number,\n defaultTimeout: number\n): number {\n diag.warn('Timeout must be greater than 0', timeout);\n\n return defaultTimeout;\n}\n\nexport function isExportRetryable(statusCode: number): boolean {\n const retryCodes = [429, 502, 503, 504];\n\n return retryCodes.includes(statusCode);\n}\n\nexport function parseRetryAfterToMills(retryAfter?: string | null): number {\n if (retryAfter == null) {\n return -1;\n }\n const seconds = Number.parseInt(retryAfter, 10);\n if (Number.isInteger(seconds)) {\n return seconds > 0 ? seconds * 1000 : -1;\n }\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#directives\n const delay = new Date(retryAfter).getTime() - Date.now();\n\n if (delay >= 0) {\n return delay;\n }\n return 0;\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,cAAqD;IAArD,+BAAA,EAAA,mBAAqD;IAErD,IAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,UAAC,EAAY;YAAZ,KAAA,aAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QACjD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,IAAI,CAAC,IAAI,CACP,cAAW,GAAG,8BAAwB,KAAK,0BAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function validateAndNormalizeHeaders(\n partialHeaders: Partial<Record<string, unknown>> = {}\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.53.0";
1
+ export declare const VERSION = "0.54.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // this is autogenerated file, see scripts/version-update.js
17
- export var VERSION = '0.53.0';
17
+ export var VERSION = '0.54.0';
18
18
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,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.53.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,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.54.0';\n"]}
@@ -4,12 +4,6 @@ import { OTLPExporterError, OTLPExporterConfigBase } from './types';
4
4
  * Collector Exporter abstract base class
5
5
  */
6
6
  export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem> {
7
- readonly url: string;
8
- /**
9
- * @deprecated scheduled for removal. This is only used in tests.
10
- */
11
- readonly hostname: string | undefined;
12
- readonly timeoutMillis: number;
13
7
  protected _concurrencyLimit: number;
14
8
  protected _sendingPromises: Promise<unknown>[];
15
9
  protected _shutdownOnce: BindOnceFuture<void>;
@@ -37,8 +31,6 @@ export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase,
37
31
  */
38
32
  private _shutdown;
39
33
  abstract onShutdown(): void;
40
- abstract onInit(config: T): void;
41
34
  abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
42
- abstract getDefaultUrl(config: T): string;
43
35
  }
44
36
  //# sourceMappingURL=OTLPExporterBase.d.ts.map
@@ -15,7 +15,6 @@
15
15
  */
16
16
  import { diag } from '@opentelemetry/api';
17
17
  import { ExportResultCode, BindOnceFuture, } from '@opentelemetry/core';
18
- import { configureExporterTimeout } from './util';
19
18
  /**
20
19
  * Collector Exporter abstract base class
21
20
  */
@@ -25,19 +24,12 @@ export class OTLPExporterBase {
25
24
  */
26
25
  constructor(config = {}) {
27
26
  this._sendingPromises = [];
28
- this.url = this.getDefaultUrl(config);
29
- if (typeof config.hostname === 'string') {
30
- this.hostname = config.hostname;
31
- }
32
27
  this.shutdown = this.shutdown.bind(this);
33
28
  this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
34
29
  this._concurrencyLimit =
35
30
  typeof config.concurrencyLimit === 'number'
36
31
  ? config.concurrencyLimit
37
32
  : 30;
38
- this.timeoutMillis = configureExporterTimeout(config.timeoutMillis);
39
- // platform dependent
40
- this.onInit(config);
41
33
  }
42
34
  /**
43
35
  * Export items.
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAEL,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAElD;;GAEG;AACH,MAAM,OAAgB,gBAAgB;IAcpC;;OAEG;IACH,YAAY,SAAY,EAAO;QANrB,qBAAgB,GAAuB,EAAE,CAAC;QAOlD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;YACvC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;SACjC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,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O,OAAO,CAAC,KAAmB;QACjC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI;gBACF,IAAI,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,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CAUF","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';\nimport { configureExporterTimeout } from './util';\n\n/**\n * Collector Exporter abstract base class\n */\nexport abstract class OTLPExporterBase<\n T extends OTLPExporterConfigBase,\n ExportItem,\n> {\n public readonly url: string;\n /**\n * @deprecated scheduled for removal. This is only used in tests.\n */\n public readonly hostname: string | undefined;\n public readonly timeoutMillis: number;\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.url = this.getDefaultUrl(config);\n if (typeof config.hostname === 'string') {\n this.hostname = config.hostname;\n }\n\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 this.timeoutMillis = configureExporterTimeout(config.timeoutMillis);\n\n // platform dependent\n this.onInit(config);\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 onInit(config: T): void;\n abstract send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void;\n abstract getDefaultUrl(config: T): string;\n}\n"]}
1
+ {"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAEL,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAO7B;;GAEG;AACH,MAAM,OAAgB,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,cAAc,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,gBAAgB,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,iB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C;IAC3B,CAAC;CAQF","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"]}
@@ -0,0 +1,13 @@
1
+ import { OtlpSharedConfiguration } from './shared-configuration';
2
+ export interface OtlpHttpConfiguration extends OtlpSharedConfiguration {
3
+ url: string;
4
+ headers: Record<string, string>;
5
+ }
6
+ /**
7
+ * @param userProvidedConfiguration Configuration options provided by the user in code.
8
+ * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
9
+ * @param defaultConfiguration The defaults as defined by the exporter specification
10
+ */
11
+ export declare function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration: Partial<OtlpHttpConfiguration>, fallbackConfiguration: Partial<OtlpHttpConfiguration>, defaultConfiguration: OtlpHttpConfiguration): OtlpHttpConfiguration;
12
+ export declare function getHttpConfigurationDefaults(requiredHeaders: Record<string, string>, signalResourcePath: string): OtlpHttpConfiguration;
13
+ //# sourceMappingURL=otlp-http-configuration.d.ts.map
@@ -0,0 +1,56 @@
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 { getSharedConfigurationDefaults, mergeOtlpSharedConfigurationWithDefaults, } from './shared-configuration';
17
+ import { validateAndNormalizeHeaders } from '../util';
18
+ function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
19
+ const requiredHeaders = Object.assign({}, defaultHeaders);
20
+ const headers = {};
21
+ // add fallback ones first
22
+ if (fallbackHeaders != null) {
23
+ Object.assign(headers, fallbackHeaders);
24
+ }
25
+ // override with user-provided ones
26
+ if (userProvidedHeaders != null) {
27
+ Object.assign(headers, userProvidedHeaders);
28
+ }
29
+ // override required ones.
30
+ return Object.assign(headers, requiredHeaders);
31
+ }
32
+ function validateUserProvidedUrl(url) {
33
+ if (url == null) {
34
+ return undefined;
35
+ }
36
+ try {
37
+ new URL(url);
38
+ return url;
39
+ }
40
+ catch (e) {
41
+ throw new Error(`Configuration: Could not parse user-provided export URL: '${url}'`);
42
+ }
43
+ }
44
+ /**
45
+ * @param userProvidedConfiguration Configuration options provided by the user in code.
46
+ * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
47
+ * @param defaultConfiguration The defaults as defined by the exporter specification
48
+ */
49
+ export function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
50
+ var _a, _b;
51
+ return Object.assign(Object.assign({}, mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration)), { headers: mergeHeaders(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 });
52
+ }
53
+ export function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
54
+ return Object.assign(Object.assign({}, getSharedConfigurationDefaults()), { headers: requiredHeaders, url: 'http://localhost:4318/' + signalResourcePath });
55
+ }
56
+ //# sourceMappingURL=otlp-http-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otlp-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,GAEzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;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,MAAM,UAAU,sCAAsC,CACpD,yBAAyD,EACzD,qBAAqD,EACrD,oBAA2C;;IAE3C,uCACK,wCAAwC,CACzC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB,KACD,OAAO,EAAE,YAAY,CACnB,2BAA2B,CAAC,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;AAED,MAAM,UAAU,4BAA4B,CAC1C,eAAuC,EACvC,kBAA0B;IAE1B,uCACK,8BAA8B,EAAE,KACnC,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,wBAAwB,GAAG,kBAAkB,IAClD;AACJ,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 {\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"]}
@@ -0,0 +1,9 @@
1
+ import { OtlpHttpConfiguration } from './otlp-http-configuration';
2
+ /**
3
+ * Reads and returns configuration from the environment
4
+ *
5
+ * @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)
6
+ * @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)
7
+ */
8
+ export declare function getHttpConfigurationFromEnvironment(signalIdentifier: string, signalResourcePath: string): Partial<OtlpHttpConfiguration>;
9
+ //# sourceMappingURL=otlp-http-env-configuration.d.ts.map