@opentelemetry/otlp-exporter-base 0.53.0 → 0.54.1

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
@@ -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
  */
@@ -26,19 +25,12 @@ var OTLPExporterBase = /** @class */ (function () {
26
25
  function OTLPExporterBase(config) {
27
26
  if (config === void 0) { config = {}; }
28
27
  this._sendingPromises = [];
29
- this.url = this.getDefaultUrl(config);
30
- if (typeof config.hostname === 'string') {
31
- this.hostname = config.hostname;
32
- }
33
28
  this.shutdown = this.shutdown.bind(this);
34
29
  this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
35
30
  this._concurrencyLimit =
36
31
  typeof config.concurrencyLimit === 'number'
37
32
  ? config.concurrencyLimit
38
33
  : 30;
39
- this.timeoutMillis = configureExporterTimeout(config.timeoutMillis);
40
- // platform dependent
41
- this.onInit(config);
42
34
  }
43
35
  /**
44
36
  * 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;IAcE;;OAEG;IACH,0BAAY,MAAmB;QAAnB,uBAAA,EAAA,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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,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,kCAAO,GAAf,UAAgB,KAAmB;QAAnC,iBASC;QARC,OAAO,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;YACvC,IAAI;gBACF,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;gBACtC,KAAI,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,mCAAQ,GAAR;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,qCAAU,GAAV;QACE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC;YAC7C,6BAA6B;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,oCAAS,GAAjB;QACE,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAUH,uBAAC;AAAD,CAAC,AAnHD,IAmHC","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;IAQE;;OAEG;IACH,0BAAY,MAAmB;QAAnB,uBAAA,EAAA,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,iCAAM,GAAN,UACE,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,C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IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAQH,uBAAC;AAAD,CAAC,AAjGD,IAiGC","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,67 @@
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
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ import { getSharedConfigurationDefaults, mergeOtlpSharedConfigurationWithDefaults, } from './shared-configuration';
28
+ import { validateAndNormalizeHeaders } from '../util';
29
+ function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
30
+ var requiredHeaders = __assign({}, defaultHeaders);
31
+ var headers = {};
32
+ // add fallback ones first
33
+ if (fallbackHeaders != null) {
34
+ Object.assign(headers, fallbackHeaders);
35
+ }
36
+ // override with user-provided ones
37
+ if (userProvidedHeaders != null) {
38
+ Object.assign(headers, userProvidedHeaders);
39
+ }
40
+ // override required ones.
41
+ return Object.assign(headers, requiredHeaders);
42
+ }
43
+ function validateUserProvidedUrl(url) {
44
+ if (url == null) {
45
+ return undefined;
46
+ }
47
+ try {
48
+ new URL(url);
49
+ return url;
50
+ }
51
+ catch (e) {
52
+ throw new Error("Configuration: Could not parse user-provided export URL: '" + url + "'");
53
+ }
54
+ }
55
+ /**
56
+ * @param userProvidedConfiguration Configuration options provided by the user in code.
57
+ * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
58
+ * @param defaultConfiguration The defaults as defined by the exporter specification
59
+ */
60
+ export function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
61
+ var _a, _b;
62
+ return __assign(__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 });
63
+ }
64
+ export function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
65
+ return __assign(__assign({}, getSharedConfigurationDefaults()), { headers: requiredHeaders, url: 'http://localhost:4318/' + signalResourcePath });
66
+ }
67
+ //# 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,IAAM,eAAe,gBAChB,cAAc,CAClB,CAAC;IACF,IAAM,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,+DAA6D,GAAG,MAAG,CACpE,CAAC;KACH;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sCAAsC,CACpD,yBAAyD,EACzD,qBAAqD,EACrD,oBAA2C;;IAE3C,6BACK,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,6BACK,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
@@ -0,0 +1,104 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ /*
13
+ * Copyright The OpenTelemetry Authors
14
+ *
15
+ * Licensed under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License.
17
+ * You may obtain a copy of the License at
18
+ *
19
+ * https://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software
22
+ * distributed under the License is distributed on an "AS IS" BASIS,
23
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ * See the License for the specific language governing permissions and
25
+ * limitations under the License.
26
+ */
27
+ import { baggageUtils } from '@opentelemetry/core';
28
+ import { diag } from '@opentelemetry/api';
29
+ import { getSharedConfigurationFromEnvironment } from './shared-env-configuration';
30
+ function getHeadersFromEnv(signalIdentifier) {
31
+ var _a, _b;
32
+ var signalSpecificRawHeaders = (_a = process.env["OTEL_EXPORTER_OTLP_" + signalIdentifier + "_HEADERS"]) === null || _a === void 0 ? void 0 : _a.trim();
33
+ var nonSignalSpecificRawHeaders = (_b = process.env['OTEL_EXPORTER_OTLP_HEADERS']) === null || _b === void 0 ? void 0 : _b.trim();
34
+ var signalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders);
35
+ var nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
36
+ if (Object.keys(signalSpecificHeaders).length === 0 &&
37
+ Object.keys(nonSignalSpecificHeaders).length === 0) {
38
+ return undefined;
39
+ }
40
+ // headers are combined instead of overwritten, with the specific headers taking precedence over
41
+ // the non-specific ones.
42
+ return Object.assign({}, baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders), baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders));
43
+ }
44
+ function appendRootPathToUrlIfNeeded(url) {
45
+ try {
46
+ var parsedUrl = new URL(url);
47
+ // This will automatically append '/' if there's no root path.
48
+ return parsedUrl.toString();
49
+ }
50
+ catch (_a) {
51
+ diag.warn("Configuration: Could not parse environment-provided export URL: '" + url + "', falling back to undefined");
52
+ return undefined;
53
+ }
54
+ }
55
+ function appendResourcePathToUrl(url, path) {
56
+ try {
57
+ // just try to parse, if it fails we catch and warn.
58
+ new URL(url);
59
+ }
60
+ catch (_a) {
61
+ diag.warn("Configuration: Could not parse environment-provided export URL: '" + url + "', falling back to undefined");
62
+ return undefined;
63
+ }
64
+ if (!url.endsWith('/')) {
65
+ url = url + '/';
66
+ }
67
+ url += path;
68
+ try {
69
+ // just try to parse, if it fails we catch and warn.
70
+ new URL(url);
71
+ }
72
+ catch (_b) {
73
+ diag.warn("Configuration: Provided URL appended with '" + path + "' is not a valid URL, using 'undefined' instead of '" + url + "'");
74
+ return undefined;
75
+ }
76
+ return url;
77
+ }
78
+ function getNonSpecificUrlFromEnv(signalResourcePath) {
79
+ var _a;
80
+ var envUrl = (_a = process.env.OTEL_EXPORTER_OTLP_ENDPOINT) === null || _a === void 0 ? void 0 : _a.trim();
81
+ if (envUrl == null || envUrl === '') {
82
+ return undefined;
83
+ }
84
+ return appendResourcePathToUrl(envUrl, signalResourcePath);
85
+ }
86
+ function getSpecificUrlFromEnv(signalIdentifier) {
87
+ var _a;
88
+ var envUrl = (_a = process.env["OTEL_EXPORTER_OTLP_" + signalIdentifier + "_ENDPOINT"]) === null || _a === void 0 ? void 0 : _a.trim();
89
+ if (envUrl == null || envUrl === '') {
90
+ return undefined;
91
+ }
92
+ return appendRootPathToUrlIfNeeded(envUrl);
93
+ }
94
+ /**
95
+ * Reads and returns configuration from the environment
96
+ *
97
+ * @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)
98
+ * @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)
99
+ */
100
+ export function getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
101
+ var _a;
102
+ return __assign(__assign({}, getSharedConfigurationFromEnvironment(signalIdentifier)), { url: (_a = getSpecificUrlFromEnv(signalIdentifier)) !== null && _a !== void 0 ? _a : getNonSpecificUrlFromEnv(signalResourcePath), headers: getHeadersFromEnv(signalIdentifier) });
103
+ }
104
+ //# sourceMappingURL=otlp-http-env-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otlp-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-http-env-configuration.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AAGnF,SAAS,iBAAiB,CAAC,gBAAwB;;IACjD,IAAM,wBAAwB,GAC5B,MAAA,OAAO,CAAC,GAAG,CAAC,wBAAsB,gBAAgB,aAAU,CAAC,0CAAE,IAAI,EAAE,CAAC;IACxE,IAAM,2BAA2B,GA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AEZ,IAAI;QACF,oDAAoD;QACpD,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;KACd;IAAC,WAAM;QACN,IAAI,CAAC,IAAI,CACP,gDAA8C,IAAI,4DAAuD,GAAG,MAAG,CAChH,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,wBAAwB,CAC/B,kBAA0B;;IAE1B,IAAM,MAAM,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,2BAA2B,0CAAE,IAAI,EAAE,CAAC;IAC/D,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,EAAE,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,qBAAqB,CAAC,gBAAwB;;IACrD,IAAM,MAAM,GACV,MAAA,OAAO,CAAC,GAAG,CAAC,wBAAsB,gBAAgB,cAAW,CAAC,0CAAE,IAAI,EAAE,CAAC;IACzE,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,EAAE,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,kBAA0B;;IAE1B,6BACK,qCAAqC,CAAC,gBAAgB,CAAC,KAC1D,GAAG,EACD,MAAA,qBAAqB,CAAC,gBAAgB,CAAC,mCACvC,wBAAwB,CAAC,kBAAkB,CAAC,EAC9C,OAAO,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,IAC5C;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 */\nimport { baggageUtils } from '@opentelemetry/core';\nimport { diag } from '@opentelemetry/api';\nimport { getSharedConfigurationFromEnvironment } from './shared-env-configuration';\nimport { OtlpHttpConfiguration } from './otlp-http-configuration';\n\nfunction getHeadersFromEnv(signalIdentifier: string) {\n const signalSpecificRawHeaders =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();\n const nonSignalSpecificRawHeaders =\n process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();\n\n const signalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n nonSignalSpecificRawHeaders\n );\n\n if (\n Object.keys(signalSpecificHeaders).length === 0 &&\n Object.keys(nonSignalSpecificHeaders).length === 0\n ) {\n return undefined;\n }\n\n // headers are combined instead of overwritten, with the specific headers taking precedence over\n // the non-specific ones.\n return Object.assign(\n {},\n baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders),\n baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders)\n );\n}\n\nfunction appendRootPathToUrlIfNeeded(url: string): string | undefined {\n try {\n const parsedUrl = new URL(url);\n // This will automatically append '/' if there's no root path.\n return parsedUrl.toString();\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n}\n\nfunction appendResourcePathToUrl(\n url: string,\n path: string\n): string | undefined {\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`\n );\n return undefined;\n }\n\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n url += path;\n\n try {\n // just try to parse, if it fails we catch and warn.\n new URL(url);\n } catch {\n diag.warn(\n `Configuration: Provided URL appended with '${path}' is not a valid URL, using 'undefined' instead of '${url}'`\n );\n return undefined;\n }\n\n return url;\n}\n\nfunction getNonSpecificUrlFromEnv(\n signalResourcePath: string\n): string | undefined {\n const envUrl = process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();\n if (envUrl == null || envUrl === '') {\n return undefined;\n }\n return appendResourcePathToUrl(envUrl, signalResourcePath);\n}\n\nfunction getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {\n const envUrl =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();\n if (envUrl == null || envUrl === '') {\n return undefined;\n }\n return appendRootPathToUrlIfNeeded(envUrl);\n}\n\n/**\n * Reads and returns configuration from the environment\n *\n * @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)\n * @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)\n */\nexport function getHttpConfigurationFromEnvironment(\n signalIdentifier: string,\n signalResourcePath: string\n): Partial<OtlpHttpConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n url:\n getSpecificUrlFromEnv(signalIdentifier) ??\n getNonSpecificUrlFromEnv(signalResourcePath),\n headers: getHeadersFromEnv(signalIdentifier),\n };\n}\n"]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Configuration shared across all OTLP exporters
3
+ *
4
+ * Implementation note: anything added here MUST be
5
+ * - platform-agnostic
6
+ * - signal-agnostic
7
+ * - transport-agnostic
8
+ */
9
+ export interface OtlpSharedConfiguration {
10
+ timeoutMillis: number;
11
+ concurrencyLimit: number;
12
+ compression: 'gzip' | 'none';
13
+ }
14
+ export declare function validateTimeoutMillis(timeoutMillis: number): number;
15
+ /**
16
+ * @param userProvidedConfiguration Configuration options provided by the user in code.
17
+ * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
18
+ * @param defaultConfiguration The defaults as defined by the exporter specification
19
+ */
20
+ export declare function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration: Partial<OtlpSharedConfiguration>, fallbackConfiguration: Partial<OtlpSharedConfiguration>, defaultConfiguration: OtlpSharedConfiguration): OtlpSharedConfiguration;
21
+ export declare function getSharedConfigurationDefaults(): OtlpSharedConfiguration;
22
+ //# sourceMappingURL=shared-configuration.d.ts.map
@@ -0,0 +1,44 @@
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
+ export function validateTimeoutMillis(timeoutMillis) {
17
+ if (!Number.isNaN(timeoutMillis) &&
18
+ Number.isFinite(timeoutMillis) &&
19
+ timeoutMillis > 0) {
20
+ return timeoutMillis;
21
+ }
22
+ throw new Error("Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '" + timeoutMillis + "')");
23
+ }
24
+ /**
25
+ * @param userProvidedConfiguration Configuration options provided by the user in code.
26
+ * @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
27
+ * @param defaultConfiguration The defaults as defined by the exporter specification
28
+ */
29
+ export function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
30
+ var _a, _b, _c, _d, _e, _f;
31
+ return {
32
+ timeoutMillis: validateTimeoutMillis((_b = (_a = userProvidedConfiguration.timeoutMillis) !== null && _a !== void 0 ? _a : fallbackConfiguration.timeoutMillis) !== null && _b !== void 0 ? _b : defaultConfiguration.timeoutMillis),
33
+ concurrencyLimit: (_d = (_c = userProvidedConfiguration.concurrencyLimit) !== null && _c !== void 0 ? _c : fallbackConfiguration.concurrencyLimit) !== null && _d !== void 0 ? _d : defaultConfiguration.concurrencyLimit,
34
+ compression: (_f = (_e = userProvidedConfiguration.compression) !== null && _e !== void 0 ? _e : fallbackConfiguration.compression) !== null && _f !== void 0 ? _f : defaultConfiguration.compression,
35
+ };
36
+ }
37
+ export function getSharedConfigurationDefaults() {
38
+ return {
39
+ timeoutMillis: 10000,
40
+ concurrencyLimit: 30,
41
+ compression: 'none',
42
+ };
43
+ }
44
+ //# sourceMappingURL=shared-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-configuration.js","sourceRoot":"","sources":["../../../src/configuration/shared-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgBH,MAAM,UAAU,qBAAqB,CAAC,aAAqB;IACzD,IACE,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC;QAC5B,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC9B,aAAa,GAAG,CAAC,EACjB;QACA,OAAO,aAAa,CAAC;KACtB;IACD,MAAM,IAAI,KAAK,CACb,uFAAqF,aAAa,OAAI,CACvG,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CACtD,yBAA2D,EAC3D,qBAAuD,EACvD,oBAA6C;;IAE7C,OAAO;QACL,aAAa,EAAE,qBAAqB,CAClC,MAAA,MAAA,yBAAyB,CAAC,aAAa,mCACrC,qBAAqB,CAAC,aAAa,mCACnC,oBAAoB,CAAC,aAAa,CACrC;QACD,gBAAgB,EACd,MAAA,MAAA,yBAAyB,CAAC,gBAAgB,mCAC1C,qBAAqB,CAAC,gBAAgB,mCACtC,oBAAoB,CAAC,gBAAgB;QACvC,WAAW,EACT,MAAA,MAAA,yBAAyB,CAAC,WAAW,mCACrC,qBAAqB,CAAC,WAAW,mCACjC,oBAAoB,CAAC,WAAW;KACnC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,OAAO;QACL,aAAa,EAAE,KAAK;QACpB,gBAAgB,EAAE,EAAE;QACpB,WAAW,EAAE,MAAM;KACpB,CAAC;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\n/**\n * Configuration shared across all OTLP exporters\n *\n * Implementation note: anything added here MUST be\n * - platform-agnostic\n * - signal-agnostic\n * - transport-agnostic\n */\nexport interface OtlpSharedConfiguration {\n timeoutMillis: number;\n concurrencyLimit: number;\n compression: 'gzip' | 'none';\n}\n\nexport function validateTimeoutMillis(timeoutMillis: number) {\n if (\n !Number.isNaN(timeoutMillis) &&\n Number.isFinite(timeoutMillis) &&\n timeoutMillis > 0\n ) {\n return timeoutMillis;\n }\n throw new Error(\n `Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`\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 mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpSharedConfiguration>,\n fallbackConfiguration: Partial<OtlpSharedConfiguration>,\n defaultConfiguration: OtlpSharedConfiguration\n): OtlpSharedConfiguration {\n return {\n timeoutMillis: validateTimeoutMillis(\n userProvidedConfiguration.timeoutMillis ??\n fallbackConfiguration.timeoutMillis ??\n defaultConfiguration.timeoutMillis\n ),\n concurrencyLimit:\n userProvidedConfiguration.concurrencyLimit ??\n fallbackConfiguration.concurrencyLimit ??\n defaultConfiguration.concurrencyLimit,\n compression:\n userProvidedConfiguration.compression ??\n fallbackConfiguration.compression ??\n defaultConfiguration.compression,\n };\n}\n\nexport function getSharedConfigurationDefaults(): OtlpSharedConfiguration {\n return {\n timeoutMillis: 10000,\n concurrencyLimit: 30,\n compression: 'none',\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { OtlpSharedConfiguration } from './shared-configuration';
2
+ export declare function getSharedConfigurationFromEnvironment(signalIdentifier: string): Partial<OtlpSharedConfiguration>;
3
+ //# sourceMappingURL=shared-env-configuration.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { diag } from '@opentelemetry/api';
2
+ function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
3
+ var _a;
4
+ var envTimeout = (_a = process.env[timeoutEnvVar]) === null || _a === void 0 ? void 0 : _a.trim();
5
+ if (envTimeout != null && envTimeout !== '') {
6
+ var definedTimeout = Number(envTimeout);
7
+ if (!Number.isNaN(definedTimeout) &&
8
+ Number.isFinite(definedTimeout) &&
9
+ definedTimeout > 0) {
10
+ return definedTimeout;
11
+ }
12
+ diag.warn("Configuration: " + timeoutEnvVar + " is invalid, expected number greater than 0 (actual: " + envTimeout + ")");
13
+ }
14
+ return undefined;
15
+ }
16
+ function getTimeoutFromEnv(signalIdentifier) {
17
+ var specificTimeout = parseAndValidateTimeoutFromEnv("OTEL_EXPORTER_OTLP_" + signalIdentifier + "_TIMEOUT");
18
+ var nonSpecificTimeout = parseAndValidateTimeoutFromEnv('OTEL_EXPORTER_OTLP_TIMEOUT');
19
+ return specificTimeout !== null && specificTimeout !== void 0 ? specificTimeout : nonSpecificTimeout;
20
+ }
21
+ function parseAndValidateCompressionFromEnv(compressionEnvVar) {
22
+ var _a;
23
+ var compression = (_a = process.env[compressionEnvVar]) === null || _a === void 0 ? void 0 : _a.trim();
24
+ if (compression === '') {
25
+ return undefined;
26
+ }
27
+ if (compression == null || compression === 'none' || compression === 'gzip') {
28
+ return compression;
29
+ }
30
+ diag.warn("Configuration: " + compressionEnvVar + " is invalid, expected 'none' or 'gzip' (actual: '" + compression + "')");
31
+ return undefined;
32
+ }
33
+ function getCompressionFromEnv(signalIdentifier) {
34
+ var specificCompression = parseAndValidateCompressionFromEnv("OTEL_EXPORTER_OTLP_" + signalIdentifier + "_COMPRESSION");
35
+ var nonSpecificCompression = parseAndValidateCompressionFromEnv('OTEL_EXPORTER_OTLP_COMPRESSION');
36
+ return specificCompression !== null && specificCompression !== void 0 ? specificCompression : nonSpecificCompression;
37
+ }
38
+ export function getSharedConfigurationFromEnvironment(signalIdentifier) {
39
+ return {
40
+ timeoutMillis: getTimeoutFromEnv(signalIdentifier),
41
+ compression: getCompressionFromEnv(signalIdentifier),
42
+ };
43
+ }
44
+ //# sourceMappingURL=shared-env-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/shared-env-configuration.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,SAAS,8BAA8B,CACrC,aAAqB;;IAErB,IAAM,UAAU,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,0CAAE,IAAI,EAAE,CAAC;IACtD,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU,KAAK,EAAE,EAAE;QAC3C,IAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QAC1C,IACE,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;YAC7B,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;YAC/B,cAAc,GAAG,CAAC,EAClB;YACA,OAAO,cAAc,CAAC;SACvB;QACD,IAAI,CAAC,IAAI,CACP,oBAAkB,aAAa,6DAAwD,UAAU,MAAG,CACrG,CAAC;KACH;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,iBAAiB,CAAC,gBAAwB;IACjD,IAAM,eAAe,GAAG,8BAA8B,CACpD,wBAAsB,gBAAgB,aAAU,CACjD,CAAC;IACF,IAAM,kBAAkB,GAAG,8BAA8B,CACvD,4BAA4B,CAC7B,CAAC;IAEF,OAAO,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,kBAAkB,CAAC;AAC/C,CAAC;AAED,SAAS,kCAAkC,CACzC,iBAAyB;;IAEzB,IAAM,WAAW,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,0CAAE,IAAI,EAAE,CAAC;IAC3D,IAAI,WAAW,KAAK,EAAE,EAAE;QACtB,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,WAAW,IAAI,IAAI,IAAI,WAAW,KAAK,MAAM,IAAI,WAAW,KAAK,MAAM,EAAE;QAC3E,OAAO,WAAW,CAAC;KACpB;IAED,IAAI,CAAC,IAAI,CACP,oBAAkB,iBAAiB,yDAAoD,WAAW,OAAI,CACvG,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,qBAAqB,CAC5B,gBAAwB;IAExB,IAAM,mBAAmB,GAAG,kCAAkC,CAC5D,wBAAsB,gBAAgB,iBAAc,CACrD,CAAC;IACF,IAAM,sBAAsB,GAAG,kCAAkC,CAC/D,gCAAgC,CACjC,CAAC;IAEF,OAAO,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,sBAAsB,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,qCAAqC,CACnD,gBAAwB;IAExB,OAAO;QACL,aAAa,EAAE,iBAAiB,CAAC,gBAAgB,CAAC;QAClD,WAAW,EAAE,qBAAqB,CAAC,gBAAgB,CAAC;KACrD,CAAC;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 */\nimport { OtlpSharedConfiguration } from './shared-configuration';\nimport { diag } from '@opentelemetry/api';\n\nfunction parseAndValidateTimeoutFromEnv(\n timeoutEnvVar: string\n): number | undefined {\n const envTimeout = process.env[timeoutEnvVar]?.trim();\n if (envTimeout != null && envTimeout !== '') {\n const definedTimeout = Number(envTimeout);\n if (\n !Number.isNaN(definedTimeout) &&\n Number.isFinite(definedTimeout) &&\n definedTimeout > 0\n ) {\n return definedTimeout;\n }\n diag.warn(\n `Configuration: ${timeoutEnvVar} is invalid, expected number greater than 0 (actual: ${envTimeout})`\n );\n }\n return undefined;\n}\n\nfunction getTimeoutFromEnv(signalIdentifier: string) {\n const specificTimeout = parseAndValidateTimeoutFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_TIMEOUT`\n );\n const nonSpecificTimeout = parseAndValidateTimeoutFromEnv(\n 'OTEL_EXPORTER_OTLP_TIMEOUT'\n );\n\n return specificTimeout ?? nonSpecificTimeout;\n}\n\nfunction parseAndValidateCompressionFromEnv(\n compressionEnvVar: string\n): 'none' | 'gzip' | undefined {\n const compression = process.env[compressionEnvVar]?.trim();\n if (compression === '') {\n return undefined;\n }\n\n if (compression == null || compression === 'none' || compression === 'gzip') {\n return compression;\n }\n\n diag.warn(\n `Configuration: ${compressionEnvVar} is invalid, expected 'none' or 'gzip' (actual: '${compression}')`\n );\n return undefined;\n}\n\nfunction getCompressionFromEnv(\n signalIdentifier: string\n): 'none' | 'gzip' | undefined {\n const specificCompression = parseAndValidateCompressionFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_COMPRESSION`\n );\n const nonSpecificCompression = parseAndValidateCompressionFromEnv(\n 'OTEL_EXPORTER_OTLP_COMPRESSION'\n );\n\n return specificCompression ?? nonSpecificCompression;\n}\n\nexport function getSharedConfigurationFromEnvironment(\n signalIdentifier: string\n): Partial<OtlpSharedConfiguration> {\n return {\n timeoutMillis: getTimeoutFromEnv(signalIdentifier),\n compression: getCompressionFromEnv(signalIdentifier),\n };\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  export * from './platform';
2
2
  export { OTLPExporterBase } from './OTLPExporterBase';
3
3
  export { OTLPExporterError, OTLPExporterConfigBase, ExportServiceError, } from './types';
4
- export { parseHeaders, appendResourcePathToUrl, appendRootPathToUrlIfNeeded, configureExporterTimeout, invalidTimeout, } from './util';
4
+ export { validateAndNormalizeHeaders } from './util';
5
5
  export { ExportResponse, ExportResponseFailure, ExportResponseSuccess, ExportResponseRetryable, } from './export-response';
6
6
  export { IExporterTransport } from './exporter-transport';
7
+ export { OtlpSharedConfiguration, mergeOtlpSharedConfigurationWithDefaults, getSharedConfigurationDefaults, } from './configuration/shared-configuration';
8
+ export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -19,5 +19,7 @@
19
19
  export * from './platform';
20
20
  export { OTLPExporterBase } from './OTLPExporterBase';
21
21
  export { OTLPExporterError, } from './types';
22
- export { parseHeaders, appendResourcePathToUrl, appendRootPathToUrlIfNeeded, configureExporterTimeout, invalidTimeout, } from './util';
22
+ export { validateAndNormalizeHeaders } from './util';
23
+ export { mergeOtlpSharedConfigurationWithDefaults, getSharedConfigurationDefaults, } from './configuration/shared-configuration';
24
+ export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
23
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,iBAAiB,GAGlB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,EACxB,cAAc,GACf,MAAM,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/* eslint no-restricted-syntax: [\"warn\", \"ExportAllDeclaration\"] --\n * TODO: Replace export * with named exports before next major version\n */\nexport * from './platform';\nexport { OTLPExporterBase } from './OTLPExporterBase';\nexport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\nexport {\n parseHeaders,\n appendResourcePathToUrl,\n appendRootPathToUrlIfNeeded,\n configureExporterTimeout,\n invalidTimeout,\n} from './util';\n\nexport {\n ExportResponse,\n ExportResponseFailure,\n ExportResponseSuccess,\n ExportResponseRetryable,\n} from './export-response';\n\nexport { IExporterTransport } from './exporter-transport';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,iBAAiB,GAGlB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAWrD,OAAO,EAEL,wCAAwC,EACxC,8BAA8B,GAC/B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,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/* eslint no-restricted-syntax: [\"warn\", \"ExportAllDeclaration\"] --\n * TODO: Replace export * with named exports before next major version\n */\nexport * from './platform';\nexport { OTLPExporterBase } from './OTLPExporterBase';\nexport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\nexport { validateAndNormalizeHeaders } from './util';\n\nexport {\n ExportResponse,\n ExportResponseFailure,\n ExportResponseSuccess,\n ExportResponseRetryable,\n} from './export-response';\n\nexport { IExporterTransport } from './exporter-transport';\n\nexport {\n OtlpSharedConfiguration,\n mergeOtlpSharedConfigurationWithDefaults,\n getSharedConfigurationDefaults,\n} from './configuration/shared-configuration';\n\nexport { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';\n"]}
@@ -7,13 +7,14 @@ import { ISerializer } from '@opentelemetry/otlp-transformer';
7
7
  export declare abstract class OTLPExporterBrowserBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {
8
8
  private _serializer;
9
9
  private _transport;
10
+ private _timeoutMillis;
10
11
  /**
11
12
  * @param config
12
13
  * @param serializer
13
- * @param contentType
14
+ * @param requiredHeaders
15
+ * @param signalResourcePath
14
16
  */
15
- constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, contentType: string);
16
- onInit(): void;
17
+ constructor(config: OTLPExporterConfigBase | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, requiredHeaders: Record<string, string>, signalResourcePath: string);
17
18
  onShutdown(): void;
18
19
  send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
19
20
  }
@@ -30,12 +30,11 @@ var __extends = (this && this.__extends) || (function () {
30
30
  })();
31
31
  import { OTLPExporterBase } from '../../OTLPExporterBase';
32
32
  import { OTLPExporterError } from '../../types';
33
- import { parseHeaders } from '../../util';
34
33
  import { diag } from '@opentelemetry/api';
35
- import { getEnv, baggageUtils } from '@opentelemetry/core';
36
34
  import { createXhrTransport } from './xhr-transport';
37
35
  import { createSendBeaconTransport } from './send-beacon-transport';
38
36
  import { createRetryingTransport } from '../../retrying-transport';
37
+ import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from '../../configuration/otlp-http-configuration';
39
38
  /**
40
39
  * Collector Metric Exporter abstract base class
41
40
  */
@@ -44,31 +43,40 @@ var OTLPExporterBrowserBase = /** @class */ (function (_super) {
44
43
  /**
45
44
  * @param config
46
45
  * @param serializer
47
- * @param contentType
46
+ * @param requiredHeaders
47
+ * @param signalResourcePath
48
48
  */
49
- function OTLPExporterBrowserBase(config, serializer, contentType) {
49
+ function OTLPExporterBrowserBase(config, serializer, requiredHeaders, signalResourcePath) {
50
50
  if (config === void 0) { config = {}; }
51
51
  var _this = _super.call(this, config) || this;
52
52
  _this._serializer = serializer;
53
53
  var useXhr = !!config.headers || typeof navigator.sendBeacon !== 'function';
54
+ var actualConfig = mergeOtlpHttpConfigurationWithDefaults({
55
+ url: config.url,
56
+ timeoutMillis: config.timeoutMillis,
57
+ headers: config.headers,
58
+ concurrencyLimit: config.concurrencyLimit,
59
+ }, {}, // no fallback for browser case
60
+ getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
61
+ _this._timeoutMillis = actualConfig.timeoutMillis;
62
+ _this._concurrencyLimit = actualConfig.concurrencyLimit;
54
63
  if (useXhr) {
55
64
  _this._transport = createRetryingTransport({
56
65
  transport: createXhrTransport({
57
- headers: Object.assign({}, parseHeaders(config.headers), baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS), { 'Content-Type': contentType }),
58
- url: _this.url,
66
+ headers: actualConfig.headers,
67
+ url: actualConfig.url,
59
68
  }),
60
69
  });
61
70
  }
62
71
  else {
63
72
  // sendBeacon has no way to signal retry, so we do not wrap it in a RetryingTransport
64
73
  _this._transport = createSendBeaconTransport({
65
- url: _this.url,
66
- blobType: contentType,
74
+ url: actualConfig.url,
75
+ blobType: actualConfig.headers['Content-Type'],
67
76
  });
68
77
  }
69
78
  return _this;
70
79
  }
71
- OTLPExporterBrowserBase.prototype.onInit = function () { };
72
80
  OTLPExporterBrowserBase.prototype.onShutdown = function () { };
73
81
  OTLPExporterBrowserBase.prototype.send = function (objects, onSuccess, onError) {
74
82
  var _this = this;
@@ -82,7 +90,7 @@ var OTLPExporterBrowserBase = /** @class */ (function (_super) {
82
90
  return;
83
91
  }
84
92
  var promise = this._transport
85
- .send(data, this.timeoutMillis)
93
+ .send(data, this._timeoutMillis)
86
94
  .then(function (response) {
87
95
  if (response.status === 'success') {
88
96
  onSuccess();
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAA0B,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;GAEG;AACH;IAGU,2CAAoD;IAI5D;;;;OAIG;IAC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OAAO;SACR;QAED,IAAM,OAAO,GAAG,IAAI,CAAC,UAAU;aAC5B,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC;aAC9B,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;IACH,8BAAC;AAAD,CAAC,AAtFD,CAGU,gBAAgB,GAmFzB","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 { OTLPExporterConfigBase, OTLPExporterError } from '../../types';\nimport { parseHeaders } 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 { createXhrTransport } from './xhr-transport';\nimport { createSendBeaconTransport } from './send-beacon-transport';\nimport { createRetryingTransport } from '../../retrying-transport';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterBrowserBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _transport: IExporterTransport;\n\n /**\n * @param config\n * @param serializer\n * @param contentType\n */\n constructor(\n config: OTLPExporterConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n contentType: string\n ) {\n super(config);\n this._serializer = serializer;\n const useXhr =\n !!config.headers || typeof navigator.sendBeacon !== 'function';\n if (useXhr) {\n this._transport = createRetryingTransport({\n transport: createXhrTransport({\n headers: Object.assign(\n {},\n parseHeaders(config.headers),\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_HEADERS\n ),\n { 'Content-Type': contentType }\n ),\n url: this.url,\n }),\n });\n } else {\n // sendBeacon has no way to signal retry, so we do not wrap it in a RetryingTransport\n this._transport = createSendBeaconTransport({\n url: this.url,\n blobType: contentType,\n });\n }\n }\n\n onInit(): void {}\n\n onShutdown(): 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"]}
1
+ {"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAA0B,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GACvC,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH;IAGU,2CAAoD;IAK5D;;;;;OAKG;IACH,iCACE,MAAmC,EACnC,UAAsD,EACtD,eAAuC,EACvC,kBAA0B;QAH1B,uBAAA,EAAA,WAAmC;QADrC,YAME,kBAAM,MAAM,CAAC,SAiCd;QAhCC,KAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAM,MAAM,GACV,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;QAEjE,IAAM,YAAY,GAAG,sCAAsC,CACzD;YACE,GAAG,EAAE,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,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;IACH,8BAAC;AAAD,CAAC,AA/FD,CAGU,gBAAgB,GA4FzB","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 { OTLPExporterConfigBase, OTLPExporterError } from '../../types';\nimport { diag } from '@opentelemetry/api';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from '../../exporter-transport';\nimport { createXhrTransport } from './xhr-transport';\nimport { createSendBeaconTransport } from './send-beacon-transport';\nimport { createRetryingTransport } from '../../retrying-transport';\nimport {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n} from '../../configuration/otlp-http-configuration';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterBrowserBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem> {\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _transport: IExporterTransport;\n private _timeoutMillis: number;\n\n /**\n * @param config\n * @param serializer\n * @param requiredHeaders\n * @param signalResourcePath\n */\n constructor(\n config: OTLPExporterConfigBase = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n ) {\n super(config);\n this._serializer = serializer;\n const useXhr =\n !!config.headers || typeof navigator.sendBeacon !== 'function';\n\n const actualConfig = mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n timeoutMillis: config.timeoutMillis,\n headers: config.headers,\n concurrencyLimit: config.concurrencyLimit,\n },\n {}, // no fallback for browser case\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n\n this._timeoutMillis = actualConfig.timeoutMillis;\n this._concurrencyLimit = actualConfig.concurrencyLimit;\n\n if (useXhr) {\n this._transport = createRetryingTransport({\n transport: createXhrTransport({\n headers: actualConfig.headers,\n url: actualConfig.url,\n }),\n });\n } else {\n // sendBeacon has no way to signal retry, so we do not wrap it in a RetryingTransport\n this._transport = createSendBeaconTransport({\n url: actualConfig.url,\n blobType: actualConfig.headers['Content-Type'],\n });\n }\n }\n\n onShutdown(): 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"]}