@opentelemetry/otlp-exporter-base 0.52.1 → 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.
- package/build/esm/OTLPExporterBase.d.ts +0 -5
- package/build/esm/OTLPExporterBase.js +0 -8
- package/build/esm/OTLPExporterBase.js.map +1 -1
- package/build/esm/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/esm/configuration/otlp-http-configuration.js +67 -0
- package/build/esm/configuration/otlp-http-configuration.js.map +1 -0
- package/build/esm/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/esm/configuration/otlp-http-env-configuration.js +104 -0
- package/build/esm/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/esm/configuration/shared-configuration.d.ts +22 -0
- package/build/esm/configuration/shared-configuration.js +44 -0
- package/build/esm/configuration/shared-configuration.js.map +1 -0
- package/build/esm/configuration/shared-env-configuration.d.ts +3 -0
- package/build/esm/configuration/shared-env-configuration.js +44 -0
- package/build/esm/configuration/shared-env-configuration.js.map +1 -0
- package/build/esm/export-response.d.ts +14 -0
- package/build/esm/export-response.js +17 -0
- package/build/esm/export-response.js.map +1 -0
- package/build/esm/exporter-transport.d.ts +6 -0
- package/build/esm/exporter-transport.js +17 -0
- package/build/esm/exporter-transport.js.map +1 -0
- package/build/esm/index.d.ts +5 -1
- package/build/esm/index.js +6 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/is-export-retryable.d.ts +3 -0
- package/build/esm/is-export-retryable.js +35 -0
- package/build/esm/is-export-retryable.js.map +1 -0
- package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js +49 -32
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esm/platform/browser/index.d.ts +0 -1
- package/build/esm/platform/browser/index.js +0 -1
- package/build/esm/platform/browser/index.js.map +1 -1
- package/build/esm/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/esm/platform/browser/send-beacon-transport.js +47 -0
- package/build/esm/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/esm/platform/browser/xhr-transport.d.ts +11 -0
- package/build/esm/platform/browser/xhr-transport.js +101 -0
- package/build/esm/platform/browser/xhr-transport.js.map +1 -0
- package/build/esm/platform/index.d.ts +2 -2
- package/build/esm/platform/index.js +2 -2
- package/build/esm/platform/index.js.map +1 -1
- package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/esm/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/esm/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esm/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/esm/platform/node/convert-legacy-agent-options.js +27 -0
- package/build/esm/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/esm/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/esm/platform/node/http-exporter-transport.js +87 -0
- package/build/esm/platform/node/http-exporter-transport.js.map +1 -0
- package/build/esm/platform/node/http-transport-types.d.ts +12 -0
- package/build/esm/platform/node/http-transport-types.js +17 -0
- package/build/esm/platform/node/http-transport-types.js.map +1 -0
- package/build/esm/platform/node/http-transport-utils.d.ts +16 -0
- package/build/esm/platform/node/http-transport-utils.js +127 -0
- package/build/esm/platform/node/http-transport-utils.js.map +1 -0
- package/build/esm/platform/node/index.d.ts +0 -1
- package/build/esm/platform/node/index.js +0 -1
- package/build/esm/platform/node/index.js.map +1 -1
- package/build/esm/retrying-transport.d.ts +8 -0
- package/build/esm/retrying-transport.js +119 -0
- package/build/esm/retrying-transport.js.map +1 -0
- package/build/esm/types.d.ts +1 -2
- package/build/esm/types.js.map +1 -1
- package/build/esm/util.d.ts +1 -27
- package/build/esm/util.js +1 -89
- package/build/esm/util.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esnext/OTLPExporterBase.d.ts +0 -5
- package/build/esnext/OTLPExporterBase.js +0 -8
- package/build/esnext/OTLPExporterBase.js.map +1 -1
- package/build/esnext/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/esnext/configuration/otlp-http-configuration.js +56 -0
- package/build/esnext/configuration/otlp-http-configuration.js.map +1 -0
- package/build/esnext/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/esnext/configuration/otlp-http-env-configuration.js +93 -0
- package/build/esnext/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/esnext/configuration/shared-configuration.d.ts +22 -0
- package/build/esnext/configuration/shared-configuration.js +44 -0
- package/build/esnext/configuration/shared-configuration.js.map +1 -0
- package/build/esnext/configuration/shared-env-configuration.d.ts +3 -0
- package/build/esnext/configuration/shared-env-configuration.js +44 -0
- package/build/esnext/configuration/shared-env-configuration.js.map +1 -0
- package/build/esnext/export-response.d.ts +14 -0
- package/build/esnext/export-response.js +17 -0
- package/build/esnext/export-response.js.map +1 -0
- package/build/esnext/exporter-transport.d.ts +6 -0
- package/build/esnext/exporter-transport.js +17 -0
- package/build/esnext/exporter-transport.js.map +1 -0
- package/build/esnext/index.d.ts +5 -1
- package/build/esnext/index.js +6 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/is-export-retryable.d.ts +3 -0
- package/build/esnext/is-export-retryable.js +35 -0
- package/build/esnext/is-export-retryable.js.map +1 -0
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +49 -21
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esnext/platform/browser/index.d.ts +0 -1
- package/build/esnext/platform/browser/index.js +0 -1
- package/build/esnext/platform/browser/index.js.map +1 -1
- package/build/esnext/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/esnext/platform/browser/send-beacon-transport.js +45 -0
- package/build/esnext/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/esnext/platform/browser/xhr-transport.d.ts +11 -0
- package/build/esnext/platform/browser/xhr-transport.js +82 -0
- package/build/esnext/platform/browser/xhr-transport.js.map +1 -0
- package/build/esnext/platform/index.d.ts +2 -2
- package/build/esnext/platform/index.js +2 -2
- package/build/esnext/platform/index.js.map +1 -1
- package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/esnext/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/esnext/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/esnext/platform/node/convert-legacy-agent-options.js +27 -0
- package/build/esnext/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/esnext/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/esnext/platform/node/http-exporter-transport.js +47 -0
- package/build/esnext/platform/node/http-exporter-transport.js.map +1 -0
- package/build/esnext/platform/node/http-transport-types.d.ts +12 -0
- package/build/esnext/platform/node/http-transport-types.js +17 -0
- package/build/esnext/platform/node/http-transport-types.js.map +1 -0
- package/build/esnext/platform/node/http-transport-utils.d.ts +16 -0
- package/build/esnext/platform/node/http-transport-utils.js +116 -0
- package/build/esnext/platform/node/http-transport-utils.js.map +1 -0
- package/build/esnext/platform/node/index.d.ts +0 -1
- package/build/esnext/platform/node/index.js +0 -1
- package/build/esnext/platform/node/index.js.map +1 -1
- package/build/esnext/retrying-transport.d.ts +8 -0
- package/build/esnext/retrying-transport.js +69 -0
- package/build/esnext/retrying-transport.js.map +1 -0
- package/build/esnext/types.d.ts +1 -2
- package/build/esnext/types.js.map +1 -1
- package/build/esnext/util.d.ts +1 -27
- package/build/esnext/util.js +1 -89
- package/build/esnext/util.js.map +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/src/OTLPExporterBase.d.ts +0 -5
- package/build/src/OTLPExporterBase.js +0 -8
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/configuration/otlp-http-configuration.d.ts +13 -0
- package/build/src/configuration/otlp-http-configuration.js +61 -0
- package/build/src/configuration/otlp-http-configuration.js.map +1 -0
- package/build/src/configuration/otlp-http-env-configuration.d.ts +9 -0
- package/build/src/configuration/otlp-http-env-configuration.js +97 -0
- package/build/src/configuration/otlp-http-env-configuration.js.map +1 -0
- package/build/src/configuration/shared-configuration.d.ts +22 -0
- package/build/src/configuration/shared-configuration.js +50 -0
- package/build/src/configuration/shared-configuration.js.map +1 -0
- package/build/src/configuration/shared-env-configuration.d.ts +3 -0
- package/build/src/configuration/shared-env-configuration.js +48 -0
- package/build/src/configuration/shared-env-configuration.js.map +1 -0
- package/build/src/export-response.d.ts +14 -0
- package/build/src/export-response.js +18 -0
- package/build/src/export-response.js.map +1 -0
- package/build/src/exporter-transport.d.ts +6 -0
- package/build/src/exporter-transport.js +18 -0
- package/build/src/exporter-transport.js.map +1 -0
- package/build/src/index.d.ts +5 -1
- package/build/src/index.js +21 -17
- package/build/src/index.js.map +1 -1
- package/build/src/is-export-retryable.d.ts +3 -0
- package/build/src/is-export-retryable.js +40 -0
- package/build/src/is-export-retryable.js.map +1 -0
- package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +7 -9
- package/build/src/platform/browser/OTLPExporterBrowserBase.js +49 -21
- package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/src/platform/browser/index.d.ts +0 -1
- package/build/src/platform/browser/index.js +1 -3
- package/build/src/platform/browser/index.js.map +1 -1
- package/build/src/platform/browser/send-beacon-transport.d.ts +10 -0
- package/build/src/platform/browser/send-beacon-transport.js +49 -0
- package/build/src/platform/browser/send-beacon-transport.js.map +1 -0
- package/build/src/platform/browser/xhr-transport.d.ts +11 -0
- package/build/src/platform/browser/xhr-transport.js +86 -0
- package/build/src/platform/browser/xhr-transport.js.map +1 -0
- package/build/src/platform/index.d.ts +2 -2
- package/build/src/platform/index.js +1 -5
- package/build/src/platform/index.js.map +1 -1
- package/build/src/platform/node/OTLPExporterNodeBase.d.ts +6 -13
- package/build/src/platform/node/OTLPExporterNodeBase.js +45 -14
- package/build/src/platform/node/OTLPExporterNodeBase.js.map +1 -1
- package/build/src/platform/node/convert-legacy-agent-options.d.ts +12 -0
- package/build/src/platform/node/convert-legacy-agent-options.js +31 -0
- package/build/src/platform/node/convert-legacy-agent-options.js.map +1 -0
- package/build/src/platform/node/http-exporter-transport.d.ts +4 -0
- package/build/src/platform/node/http-exporter-transport.js +51 -0
- package/build/src/platform/node/http-exporter-transport.js.map +1 -0
- package/build/src/platform/node/http-transport-types.d.ts +12 -0
- package/build/src/platform/node/http-transport-types.js +18 -0
- package/build/src/platform/node/http-transport-types.js.map +1 -0
- package/build/src/platform/node/http-transport-utils.d.ts +16 -0
- package/build/src/platform/node/http-transport-utils.js +121 -0
- package/build/src/platform/node/http-transport-utils.js.map +1 -0
- package/build/src/platform/node/index.d.ts +0 -1
- package/build/src/platform/node/index.js +1 -5
- package/build/src/platform/node/index.js.map +1 -1
- package/build/src/retrying-transport.d.ts +8 -0
- package/build/src/retrying-transport.js +73 -0
- package/build/src/retrying-transport.js.map +1 -0
- package/build/src/types.d.ts +1 -2
- package/build/src/types.js.map +1 -1
- package/build/src/util.d.ts +1 -27
- package/build/src/util.js +3 -97
- package/build/src/util.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +13 -17
- package/build/esm/platform/browser/util.d.ts +0 -21
- package/build/esm/platform/browser/util.js +0 -152
- package/build/esm/platform/browser/util.js.map +0 -1
- package/build/esm/platform/node/util.d.ts +0 -19
- package/build/esm/platform/node/util.js +0 -194
- package/build/esm/platform/node/util.js.map +0 -1
- package/build/esnext/platform/browser/util.d.ts +0 -21
- package/build/esnext/platform/browser/util.js +0 -122
- package/build/esnext/platform/browser/util.js.map +0 -1
- package/build/esnext/platform/node/util.d.ts +0 -19
- package/build/esnext/platform/node/util.js +0 -181
- package/build/esnext/platform/node/util.js.map +0 -1
- package/build/src/platform/browser/util.d.ts +0 -21
- package/build/src/platform/browser/util.js +0 -127
- package/build/src/platform/browser/util.js.map +0 -1
- package/build/src/platform/node/util.d.ts +0 -19
- package/build/src/platform/node/util.js +0 -187
- package/build/src/platform/node/util.js.map +0 -1
|
@@ -4,9 +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
|
-
readonly hostname: string | undefined;
|
|
9
|
-
readonly timeoutMillis: number;
|
|
10
7
|
protected _concurrencyLimit: number;
|
|
11
8
|
protected _sendingPromises: Promise<unknown>[];
|
|
12
9
|
protected _shutdownOnce: BindOnceFuture<void>;
|
|
@@ -34,8 +31,6 @@ export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase,
|
|
|
34
31
|
*/
|
|
35
32
|
private _shutdown;
|
|
36
33
|
abstract onShutdown(): void;
|
|
37
|
-
abstract onInit(config: T): void;
|
|
38
34
|
abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
39
|
-
abstract getDefaultUrl(config: T): string;
|
|
40
35
|
}
|
|
41
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;
|
|
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,CAAC,4BAA4B,CAAC;aAC/C,CAAC,CAAC;YACH,OAAO;SACR;QAED,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1D,cAAc,CAAC;gBACb,IAAI,EAAE,gBAAgB,CAAC,MAAM;gBAC7B,KAAK,EAAE,IAAI,KAAK,CAAC,iCAAiC,CAAC;aACpD,CAAC,CAAC;YACH,OAAO;SACR;QAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;aAChB,IAAI,CAAC;YACJ,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,CAAC,CAAC;aACD,KAAK,CAAC,UAAC,KAAyB;YAC/B,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,KAAK,OAAA,EAAE,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;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,GAC/B,MAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,0CAAE,IAAI,EAAE,CAAC;IAEpD,IAAM,qBAAqB,GAAG,YAAY,CAAC,uBAAuB,CAChE,wBAAwB,CACzB,CAAC;IACF,IAAM,wBAAwB,GAAG,YAAY,CAAC,uBAAuB,CACnE,2BAA2B,CAC5B,CAAC;IAEF,IACE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,KAAK,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,MAAM,KAAK,CAAC,EAClD;QACA,OAAO,SAAS,CAAC;KAClB;IAED,gGAAgG;IAChG,yBAAyB;IACzB,OAAO,MAAM,CAAC,MAAM,CAClB,EAAE,EACF,YAAY,CAAC,uBAAuB,CAAC,2BAA2B,CAAC,EACjE,YAAY,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,CAC/D,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAAC,GAAW;IAC9C,IAAI;QACF,IAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,8DAA8D;QAC9D,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;KAC7B;IAAC,WAAM;QACN,IAAI,CAAC,IAAI,CACP,sEAAoE,GAAG,iCAA8B,CACtG,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,GAAW,EACX,IAAY;IAEZ,IAAI;QACF,oDAAoD;QACpD,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;KACd;IAAC,WAAM;QACN,IAAI,CAAC,IAAI,CACP,sEAAoE,GAAG,iCAA8B,CACtG,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KACjB;IACD,GAAG,IAAI,IAAI,CAAC;IAEZ,IAAI;QACF,oDAAoD;QACpD,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;KACd;IAAC,WAAM;QACN,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,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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ExportResponseSuccess {
|
|
2
|
+
status: 'success';
|
|
3
|
+
data?: Uint8Array;
|
|
4
|
+
}
|
|
5
|
+
export interface ExportResponseFailure {
|
|
6
|
+
status: 'failure';
|
|
7
|
+
error: Error;
|
|
8
|
+
}
|
|
9
|
+
export interface ExportResponseRetryable {
|
|
10
|
+
status: 'retryable';
|
|
11
|
+
retryInMillis?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare type ExportResponse = ExportResponseSuccess | ExportResponseFailure | ExportResponseRetryable;
|
|
14
|
+
//# sourceMappingURL=export-response.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
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 {};
|
|
17
|
+
//# sourceMappingURL=export-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-response.js","sourceRoot":"","sources":["../../src/export-response.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface ExportResponseSuccess {\n status: 'success';\n data?: Uint8Array;\n}\n\nexport interface ExportResponseFailure {\n status: 'failure';\n error: Error;\n}\n\nexport interface ExportResponseRetryable {\n status: 'retryable';\n retryInMillis?: number;\n}\n\nexport type ExportResponse =\n | ExportResponseSuccess\n | ExportResponseFailure\n | ExportResponseRetryable;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 {};
|
|
17
|
+
//# sourceMappingURL=exporter-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter-transport.js","sourceRoot":"","sources":["../../src/exporter-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExportResponse } from './export-response';\n\nexport interface IExporterTransport {\n send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse>;\n shutdown(): void;\n}\n"]}
|
package/build/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from './platform';
|
|
2
2
|
export { OTLPExporterBase } from './OTLPExporterBase';
|
|
3
3
|
export { OTLPExporterError, OTLPExporterConfigBase, ExportServiceError, } from './types';
|
|
4
|
-
export {
|
|
4
|
+
export { validateAndNormalizeHeaders } from './util';
|
|
5
|
+
export { ExportResponse, ExportResponseFailure, ExportResponseSuccess, ExportResponseRetryable, } from './export-response';
|
|
6
|
+
export { IExporterTransport } from './exporter-transport';
|
|
7
|
+
export { OtlpSharedConfiguration, mergeOtlpSharedConfigurationWithDefaults, getSharedConfigurationDefaults, } from './configuration/shared-configuration';
|
|
8
|
+
export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
package/build/esm/index.js
CHANGED
|
@@ -13,8 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
|
|
17
|
+
* TODO: Replace export * with named exports before next major version
|
|
18
|
+
*/
|
|
16
19
|
export * from './platform';
|
|
17
20
|
export { OTLPExporterBase } from './OTLPExporterBase';
|
|
18
21
|
export { OTLPExporterError, } from './types';
|
|
19
|
-
export {
|
|
22
|
+
export { validateAndNormalizeHeaders } from './util';
|
|
23
|
+
export { mergeOtlpSharedConfigurationWithDefaults, getSharedConfigurationDefaults, } from './configuration/shared-configuration';
|
|
24
|
+
export { getSharedConfigurationFromEnvironment } from './configuration/shared-env-configuration';
|
|
20
25
|
//# sourceMappingURL=index.js.map
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,iBAAiB,GAGlB,MAAM,SAAS,CAAC;AACjB,OAAO,
|
|
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"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 isExportRetryable(statusCode) {
|
|
17
|
+
var retryCodes = [429, 502, 503, 504];
|
|
18
|
+
return retryCodes.includes(statusCode);
|
|
19
|
+
}
|
|
20
|
+
export function parseRetryAfterToMills(retryAfter) {
|
|
21
|
+
if (retryAfter == null) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
var seconds = Number.parseInt(retryAfter, 10);
|
|
25
|
+
if (Number.isInteger(seconds)) {
|
|
26
|
+
return seconds > 0 ? seconds * 1000 : -1;
|
|
27
|
+
}
|
|
28
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#directives
|
|
29
|
+
var delay = new Date(retryAfter).getTime() - Date.now();
|
|
30
|
+
if (delay >= 0) {
|
|
31
|
+
return delay;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=is-export-retryable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-export-retryable.js","sourceRoot":"","sources":["../../src/is-export-retryable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,IAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,UAAsC;IAEtC,IAAI,UAAU,IAAI,IAAI,EAAE;QACtB,OAAO,SAAS,CAAC;KAClB;IAED,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\nexport function isExportRetryable(statusCode: number): boolean {\n const retryCodes = [429, 502, 503, 504];\n return retryCodes.includes(statusCode);\n}\n\nexport function parseRetryAfterToMills(\n retryAfter?: string | undefined | null\n): number | undefined {\n if (retryAfter == null) {\n return undefined;\n }\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"]}
|