@opentelemetry/otlp-exporter-base 0.53.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/esm/OTLPExporterBase.d.ts +0 -8
- 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/index.d.ts +3 -1
- package/build/esm/index.js +3 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +4 -3
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js +18 -10
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esm/platform/browser/xhr-transport.js +1 -1
- package/build/esm/platform/browser/xhr-transport.js.map +1 -1
- package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +2 -2
- package/build/esm/platform/node/OTLPExporterNodeBase.js +18 -27
- 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/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 -8
- 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/index.d.ts +3 -1
- package/build/esnext/index.js +3 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +4 -3
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +18 -10
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/esnext/platform/browser/xhr-transport.js +1 -1
- package/build/esnext/platform/browser/xhr-transport.js.map +1 -1
- package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +2 -2
- package/build/esnext/platform/node/OTLPExporterNodeBase.js +18 -27
- 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/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 -8
- 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/index.d.ts +3 -1
- package/build/src/index.js +7 -6
- package/build/src/index.js.map +1 -1
- package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +4 -3
- package/build/src/platform/browser/OTLPExporterBrowserBase.js +18 -10
- package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/src/platform/browser/xhr-transport.js +3 -3
- package/build/src/platform/browser/xhr-transport.js.map +1 -1
- package/build/src/platform/node/OTLPExporterNodeBase.d.ts +2 -2
- package/build/src/platform/node/OTLPExporterNodeBase.js +18 -27
- 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/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 +8 -11
- package/build/esm/platform/node/util.d.ts +0 -3
- package/build/esm/platform/node/util.js +0 -30
- package/build/esm/platform/node/util.js.map +0 -1
- package/build/esnext/platform/node/util.d.ts +0 -3
- package/build/esnext/platform/node/util.js +0 -30
- package/build/esnext/platform/node/util.js.map +0 -1
- package/build/src/platform/node/util.d.ts +0 -3
- package/build/src/platform/node/util.js +0 -34
- package/build/src/platform/node/util.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replicates old config behavior where there's two ways to set keepAlive.
|
|
3
|
+
* This function sets keepAlive in AgentOptions if it is defined. In the future, we will remove
|
|
4
|
+
* this duplicate to only allow setting keepAlive in AgentOptions.
|
|
5
|
+
* @param config
|
|
6
|
+
*/
|
|
7
|
+
export function convertLegacyAgentOptions(config) {
|
|
8
|
+
var _a;
|
|
9
|
+
// populate keepAlive for use with new settings
|
|
10
|
+
if ((config === null || config === void 0 ? void 0 : config.keepAlive) != null) {
|
|
11
|
+
if (config.httpAgentOptions != null) {
|
|
12
|
+
if (config.httpAgentOptions.keepAlive == null) {
|
|
13
|
+
// specific setting is not set, populate with non-specific setting.
|
|
14
|
+
config.httpAgentOptions.keepAlive = config.keepAlive;
|
|
15
|
+
}
|
|
16
|
+
// do nothing, use specific setting otherwise
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// populate specific option if AgentOptions does not exist.
|
|
20
|
+
config.httpAgentOptions = {
|
|
21
|
+
keepAlive: config.keepAlive,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return (_a = config.httpAgentOptions) !== null && _a !== void 0 ? _a : { keepAlive: true };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=convert-legacy-agent-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-legacy-agent-options.js","sourceRoot":"","sources":["../../../../src/platform/node/convert-legacy-agent-options.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAkC;;IAElC,+CAA+C;IAC/C,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,KAAI,IAAI,EAAE;QAC7B,IAAI,MAAM,CAAC,gBAAgB,IAAI,IAAI,EAAE;YACnC,IAAI,MAAM,CAAC,gBAAgB,CAAC,SAAS,IAAI,IAAI,EAAE;gBAC7C,mEAAmE;gBACnE,MAAM,CAAC,gBAAgB,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;aACtD;YACD,6CAA6C;SAC9C;aAAM;YACL,2DAA2D;YAC3D,MAAM,CAAC,gBAAgB,GAAG;gBACxB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC;SACH;KACF;IAED,OAAO,MAAA,MAAM,CAAC,gBAAgB,mCAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACxD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { OTLPExporterNodeConfigBase } from './types';\nimport type * as http from 'http';\nimport type * as https from 'https';\n\n/**\n * Replicates old config behavior where there's two ways to set keepAlive.\n * This function sets keepAlive in AgentOptions if it is defined. In the future, we will remove\n * this duplicate to only allow setting keepAlive in AgentOptions.\n * @param config\n */\nexport function convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): http.AgentOptions | https.AgentOptions {\n // populate keepAlive for use with new settings\n if (config?.keepAlive != null) {\n if (config.httpAgentOptions != null) {\n if (config.httpAgentOptions.keepAlive == null) {\n // specific setting is not set, populate with non-specific setting.\n config.httpAgentOptions.keepAlive = config.keepAlive;\n }\n // do nothing, use specific setting otherwise\n } else {\n // populate specific option if AgentOptions does not exist.\n config.httpAgentOptions = {\n keepAlive: config.keepAlive,\n };\n }\n }\n\n return config.httpAgentOptions ?? { keepAlive: true };\n}\n"]}
|
package/build/esnext/types.d.ts
CHANGED
|
@@ -24,8 +24,7 @@ export interface ExportServiceError {
|
|
|
24
24
|
* Collector Exporter base config
|
|
25
25
|
*/
|
|
26
26
|
export interface OTLPExporterConfigBase {
|
|
27
|
-
headers?:
|
|
28
|
-
hostname?: string;
|
|
27
|
+
headers?: Record<string, string>;
|
|
29
28
|
url?: string;
|
|
30
29
|
concurrencyLimit?: number;
|
|
31
30
|
/** Maximum time the OTLP exporter will wait for each batch export.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAK1C,YAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAW,mBAAmB,CAAC;QAKnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for handling error\n */\nexport class OTLPExporterError extends Error {\n readonly code?: number;\n override readonly name: string = 'OTLPExporterError';\n readonly data?: string;\n\n constructor(message?: string, code?: number, data?: string) {\n super(message);\n this.data = data;\n this.code = code;\n }\n}\n\n/**\n * Interface for handling export service errors\n */\nexport interface ExportServiceError {\n name: string;\n code: number;\n details: string;\n metadata: { [key: string]: unknown };\n message: string;\n stack: string;\n}\n\n/**\n * Collector Exporter base config\n */\nexport interface OTLPExporterConfigBase {\n headers?:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAK1C,YAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAW,mBAAmB,CAAC;QAKnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for handling error\n */\nexport class OTLPExporterError extends Error {\n readonly code?: number;\n override readonly name: string = 'OTLPExporterError';\n readonly data?: string;\n\n constructor(message?: string, code?: number, data?: string) {\n super(message);\n this.data = data;\n this.code = code;\n }\n}\n\n/**\n * Interface for handling export service errors\n */\nexport interface ExportServiceError {\n name: string;\n code: number;\n details: string;\n metadata: { [key: string]: unknown };\n message: string;\n stack: string;\n}\n\n/**\n * Collector Exporter base config\n */\nexport interface OTLPExporterConfigBase {\n headers?: Record<string, string>;\n url?: string;\n concurrencyLimit?: number;\n /** Maximum time the OTLP exporter will wait for each batch export.\n * The default value is 10000ms. */\n timeoutMillis?: number;\n}\n"]}
|
package/build/esnext/util.d.ts
CHANGED
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
export declare const DEFAULT_EXPORT_MAX_ATTEMPTS = 5;
|
|
2
|
-
export declare const DEFAULT_EXPORT_INITIAL_BACKOFF = 1000;
|
|
3
|
-
export declare const DEFAULT_EXPORT_MAX_BACKOFF = 5000;
|
|
4
|
-
export declare const DEFAULT_EXPORT_BACKOFF_MULTIPLIER = 1.5;
|
|
5
1
|
/**
|
|
6
2
|
* Parses headers from config leaving only those that have defined values
|
|
7
3
|
* @param partialHeaders
|
|
8
4
|
*/
|
|
9
|
-
export declare function
|
|
10
|
-
/**
|
|
11
|
-
* Adds path (version + signal) to a no per-signal endpoint
|
|
12
|
-
* @param url
|
|
13
|
-
* @param path
|
|
14
|
-
* @returns url + path
|
|
15
|
-
*/
|
|
16
|
-
export declare function appendResourcePathToUrl(url: string, path: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Adds root path to signal specific endpoint when endpoint contains no path part and no root path
|
|
19
|
-
* @param url
|
|
20
|
-
* @returns url
|
|
21
|
-
*/
|
|
22
|
-
export declare function appendRootPathToUrlIfNeeded(url: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* Configure exporter trace timeout value from passed in value or environment variables
|
|
25
|
-
* @param timeoutMillis
|
|
26
|
-
* @returns timeout value in milliseconds
|
|
27
|
-
*/
|
|
28
|
-
export declare function configureExporterTimeout(timeoutMillis: number | undefined): number;
|
|
29
|
-
export declare function invalidTimeout(timeout: number, defaultTimeout: number): number;
|
|
30
|
-
export declare function isExportRetryable(statusCode: number): boolean;
|
|
31
|
-
export declare function parseRetryAfterToMills(retryAfter?: string | null): number;
|
|
5
|
+
export declare function validateAndNormalizeHeaders(partialHeaders?: Partial<Record<string, unknown>>): Record<string, string>;
|
|
32
6
|
//# sourceMappingURL=util.d.ts.map
|
package/build/esnext/util.js
CHANGED
|
@@ -14,17 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { diag } from '@opentelemetry/api';
|
|
17
|
-
import { getEnv } from '@opentelemetry/core';
|
|
18
|
-
const DEFAULT_TRACE_TIMEOUT = 10000;
|
|
19
|
-
export const DEFAULT_EXPORT_MAX_ATTEMPTS = 5;
|
|
20
|
-
export const DEFAULT_EXPORT_INITIAL_BACKOFF = 1000;
|
|
21
|
-
export const DEFAULT_EXPORT_MAX_BACKOFF = 5000;
|
|
22
|
-
export const DEFAULT_EXPORT_BACKOFF_MULTIPLIER = 1.5;
|
|
23
17
|
/**
|
|
24
18
|
* Parses headers from config leaving only those that have defined values
|
|
25
19
|
* @param partialHeaders
|
|
26
20
|
*/
|
|
27
|
-
export function
|
|
21
|
+
export function validateAndNormalizeHeaders(partialHeaders = {}) {
|
|
28
22
|
const headers = {};
|
|
29
23
|
Object.entries(partialHeaders).forEach(([key, value]) => {
|
|
30
24
|
if (typeof value !== 'undefined') {
|
|
@@ -36,86 +30,4 @@ export function parseHeaders(partialHeaders = {}) {
|
|
|
36
30
|
});
|
|
37
31
|
return headers;
|
|
38
32
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Adds path (version + signal) to a no per-signal endpoint
|
|
41
|
-
* @param url
|
|
42
|
-
* @param path
|
|
43
|
-
* @returns url + path
|
|
44
|
-
*/
|
|
45
|
-
export function appendResourcePathToUrl(url, path) {
|
|
46
|
-
if (!url.endsWith('/')) {
|
|
47
|
-
url = url + '/';
|
|
48
|
-
}
|
|
49
|
-
return url + path;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Adds root path to signal specific endpoint when endpoint contains no path part and no root path
|
|
53
|
-
* @param url
|
|
54
|
-
* @returns url
|
|
55
|
-
*/
|
|
56
|
-
export function appendRootPathToUrlIfNeeded(url) {
|
|
57
|
-
try {
|
|
58
|
-
const parsedUrl = new URL(url);
|
|
59
|
-
if (parsedUrl.pathname === '') {
|
|
60
|
-
parsedUrl.pathname = parsedUrl.pathname + '/';
|
|
61
|
-
}
|
|
62
|
-
return parsedUrl.toString();
|
|
63
|
-
}
|
|
64
|
-
catch (_a) {
|
|
65
|
-
diag.warn(`Could not parse export URL: '${url}'`);
|
|
66
|
-
return url;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Configure exporter trace timeout value from passed in value or environment variables
|
|
71
|
-
* @param timeoutMillis
|
|
72
|
-
* @returns timeout value in milliseconds
|
|
73
|
-
*/
|
|
74
|
-
export function configureExporterTimeout(timeoutMillis) {
|
|
75
|
-
if (typeof timeoutMillis === 'number') {
|
|
76
|
-
if (timeoutMillis <= 0) {
|
|
77
|
-
// OTLP exporter configured timeout - using default value of 10000ms
|
|
78
|
-
return invalidTimeout(timeoutMillis, DEFAULT_TRACE_TIMEOUT);
|
|
79
|
-
}
|
|
80
|
-
return timeoutMillis;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
return getExporterTimeoutFromEnv();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function getExporterTimeoutFromEnv() {
|
|
87
|
-
var _a;
|
|
88
|
-
const definedTimeout = Number((_a = getEnv().OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) !== null && _a !== void 0 ? _a : getEnv().OTEL_EXPORTER_OTLP_TIMEOUT);
|
|
89
|
-
if (definedTimeout <= 0) {
|
|
90
|
-
// OTLP exporter configured timeout - using default value of 10000ms
|
|
91
|
-
return invalidTimeout(definedTimeout, DEFAULT_TRACE_TIMEOUT);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
return definedTimeout;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// OTLP exporter configured timeout - using default value of 10000ms
|
|
98
|
-
export function invalidTimeout(timeout, defaultTimeout) {
|
|
99
|
-
diag.warn('Timeout must be greater than 0', timeout);
|
|
100
|
-
return defaultTimeout;
|
|
101
|
-
}
|
|
102
|
-
export function isExportRetryable(statusCode) {
|
|
103
|
-
const retryCodes = [429, 502, 503, 504];
|
|
104
|
-
return retryCodes.includes(statusCode);
|
|
105
|
-
}
|
|
106
|
-
export function parseRetryAfterToMills(retryAfter) {
|
|
107
|
-
if (retryAfter == null) {
|
|
108
|
-
return -1;
|
|
109
|
-
}
|
|
110
|
-
const seconds = Number.parseInt(retryAfter, 10);
|
|
111
|
-
if (Number.isInteger(seconds)) {
|
|
112
|
-
return seconds > 0 ? seconds * 1000 : -1;
|
|
113
|
-
}
|
|
114
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#directives
|
|
115
|
-
const delay = new Date(retryAfter).getTime() - Date.now();
|
|
116
|
-
if (delay >= 0) {
|
|
117
|
-
return delay;
|
|
118
|
-
}
|
|
119
|
-
return 0;
|
|
120
|
-
}
|
|
121
33
|
//# sourceMappingURL=util.js.map
|
package/build/esnext/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,iBAAmD,EAAE;IAErD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACtD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,IAAI,CAAC,IAAI,CACP,WAAW,GAAG,wBAAwB,KAAK,uBAAuB,CACnE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function validateAndNormalizeHeaders(\n partialHeaders: Partial<Record<string, unknown>> = {}\n): Record<string, string> {\n const headers: Record<string, string> = {};\n Object.entries(partialHeaders).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n headers[key] = String(value);\n } else {\n diag.warn(\n `Header \"${key}\" has invalid value (${value}) and will be ignored`\n );\n }\n });\n return headers;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.54.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.54.0';\n"]}
|
|
@@ -4,12 +4,6 @@ import { OTLPExporterError, OTLPExporterConfigBase } from './types';
|
|
|
4
4
|
* Collector Exporter abstract base class
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem> {
|
|
7
|
-
readonly url: string;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated scheduled for removal. This is only used in tests.
|
|
10
|
-
*/
|
|
11
|
-
readonly hostname: string | undefined;
|
|
12
|
-
readonly timeoutMillis: number;
|
|
13
7
|
protected _concurrencyLimit: number;
|
|
14
8
|
protected _sendingPromises: Promise<unknown>[];
|
|
15
9
|
protected _shutdownOnce: BindOnceFuture<void>;
|
|
@@ -37,8 +31,6 @@ export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase,
|
|
|
37
31
|
*/
|
|
38
32
|
private _shutdown;
|
|
39
33
|
abstract onShutdown(): void;
|
|
40
|
-
abstract onInit(config: T): void;
|
|
41
34
|
abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
42
|
-
abstract getDefaultUrl(config: T): string;
|
|
43
35
|
}
|
|
44
36
|
//# sourceMappingURL=OTLPExporterBase.d.ts.map
|
|
@@ -18,7 +18,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.OTLPExporterBase = void 0;
|
|
19
19
|
const api_1 = require("@opentelemetry/api");
|
|
20
20
|
const core_1 = require("@opentelemetry/core");
|
|
21
|
-
const util_1 = require("./util");
|
|
22
21
|
/**
|
|
23
22
|
* Collector Exporter abstract base class
|
|
24
23
|
*/
|
|
@@ -28,19 +27,12 @@ class OTLPExporterBase {
|
|
|
28
27
|
*/
|
|
29
28
|
constructor(config = {}) {
|
|
30
29
|
this._sendingPromises = [];
|
|
31
|
-
this.url = this.getDefaultUrl(config);
|
|
32
|
-
if (typeof config.hostname === 'string') {
|
|
33
|
-
this.hostname = config.hostname;
|
|
34
|
-
}
|
|
35
30
|
this.shutdown = this.shutdown.bind(this);
|
|
36
31
|
this._shutdownOnce = new core_1.BindOnceFuture(this._shutdown, this);
|
|
37
32
|
this._concurrencyLimit =
|
|
38
33
|
typeof config.concurrencyLimit === 'number'
|
|
39
34
|
? config.concurrencyLimit
|
|
40
35
|
: 30;
|
|
41
|
-
this.timeoutMillis = (0, util_1.configureExporterTimeout)(config.timeoutMillis);
|
|
42
|
-
// platform dependent
|
|
43
|
-
this.onInit(config);
|
|
44
36
|
}
|
|
45
37
|
/**
|
|
46
38
|
* Export items.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,8CAI6B;
|
|
1
|
+
{"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,8CAI6B;AAO7B;;GAEG;AACH,MAAsB,gBAAgB;IAQpC;;OAEG;IACH,YAAY,SAAY,EAAO;QANrB,qBAAgB,GAAuB,EAAE,CAAC;QAOlD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,aAAa,GAAG,IAAI,qBAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE9D,IAAI,CAAC,iBAAiB;YACpB,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ;gBACzC,CAAC,CAAC,MAAM,CAAC,gBAAgB;gBACzB,CAAC,CAAC,EAAE,CAAC;IACX,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,KAAmB,EACnB,cAA8C;QAE9C,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC/B,cAAc,CAAC;gBACb,IAAI,EAAE,uBAAgB,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,uBAAgB,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,GAAG,EAAE;YACT,cAAc,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAyB,EAAE,EAAE;YACnC,cAAc,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,OAAO,CAAC,KAAmB;QACjC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI;gBACF,UAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;gBACtC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aACnC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,CAAC,CAAC,CAAC;aACX;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAClD,6BAA6B;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,SAAS;QACf,UAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CAQF;AAjGD,4CAiGC","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,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.getHttpConfigurationDefaults = exports.mergeOtlpHttpConfigurationWithDefaults = void 0;
|
|
19
|
+
const shared_configuration_1 = require("./shared-configuration");
|
|
20
|
+
const util_1 = require("../util");
|
|
21
|
+
function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
|
|
22
|
+
const requiredHeaders = Object.assign({}, defaultHeaders);
|
|
23
|
+
const headers = {};
|
|
24
|
+
// add fallback ones first
|
|
25
|
+
if (fallbackHeaders != null) {
|
|
26
|
+
Object.assign(headers, fallbackHeaders);
|
|
27
|
+
}
|
|
28
|
+
// override with user-provided ones
|
|
29
|
+
if (userProvidedHeaders != null) {
|
|
30
|
+
Object.assign(headers, userProvidedHeaders);
|
|
31
|
+
}
|
|
32
|
+
// override required ones.
|
|
33
|
+
return Object.assign(headers, requiredHeaders);
|
|
34
|
+
}
|
|
35
|
+
function validateUserProvidedUrl(url) {
|
|
36
|
+
if (url == null) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
new URL(url);
|
|
41
|
+
return url;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
throw new Error(`Configuration: Could not parse user-provided export URL: '${url}'`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @param userProvidedConfiguration Configuration options provided by the user in code.
|
|
49
|
+
* @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
|
|
50
|
+
* @param defaultConfiguration The defaults as defined by the exporter specification
|
|
51
|
+
*/
|
|
52
|
+
function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
return Object.assign(Object.assign({}, (0, shared_configuration_1.mergeOtlpSharedConfigurationWithDefaults)(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration)), { headers: mergeHeaders((0, util_1.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 });
|
|
55
|
+
}
|
|
56
|
+
exports.mergeOtlpHttpConfigurationWithDefaults = mergeOtlpHttpConfigurationWithDefaults;
|
|
57
|
+
function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
|
|
58
|
+
return Object.assign(Object.assign({}, (0, shared_configuration_1.getSharedConfigurationDefaults)()), { headers: requiredHeaders, url: 'http://localhost:4318/' + signalResourcePath });
|
|
59
|
+
}
|
|
60
|
+
exports.getHttpConfigurationDefaults = getHttpConfigurationDefaults;
|
|
61
|
+
//# 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,iEAIgC;AAChC,kCAAsD;AAOtD,SAAS,YAAY,CACnB,mBAA8D,EAC9D,eAA0D,EAC1D,cAAsC;IAEtC,MAAM,eAAe,qBAChB,cAAc,CAClB,CAAC;IACF,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,0BAA0B;IAC1B,IAAI,eAAe,IAAI,IAAI,EAAE;QAC3B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;KACzC;IAED,mCAAmC;IACnC,IAAI,mBAAmB,IAAI,IAAI,EAAE;QAC/B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;KAC7C;IAED,0BAA0B;IAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAuB;IACtD,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,IAAI;QACF,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,6DAA6D,GAAG,GAAG,CACpE,CAAC;KACH;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sCAAsC,CACpD,yBAAyD,EACzD,qBAAqD,EACrD,oBAA2C;;IAE3C,uCACK,IAAA,+DAAwC,EACzC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB,KACD,OAAO,EAAE,YAAY,CACnB,IAAA,kCAA2B,EAAC,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;AArBD,wFAqBC;AAED,SAAgB,4BAA4B,CAC1C,eAAuC,EACvC,kBAA0B;IAE1B,uCACK,IAAA,qDAA8B,GAAE,KACnC,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,wBAAwB,GAAG,kBAAkB,IAClD;AACJ,CAAC;AATD,oEASC","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,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHttpConfigurationFromEnvironment = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright The OpenTelemetry Authors
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const core_1 = require("@opentelemetry/core");
|
|
20
|
+
const api_1 = require("@opentelemetry/api");
|
|
21
|
+
const shared_env_configuration_1 = require("./shared-env-configuration");
|
|
22
|
+
function getHeadersFromEnv(signalIdentifier) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const signalSpecificRawHeaders = (_a = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
25
|
+
const nonSignalSpecificRawHeaders = (_b = process.env['OTEL_EXPORTER_OTLP_HEADERS']) === null || _b === void 0 ? void 0 : _b.trim();
|
|
26
|
+
const signalSpecificHeaders = core_1.baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders);
|
|
27
|
+
const nonSignalSpecificHeaders = core_1.baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
|
|
28
|
+
if (Object.keys(signalSpecificHeaders).length === 0 &&
|
|
29
|
+
Object.keys(nonSignalSpecificHeaders).length === 0) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
// headers are combined instead of overwritten, with the specific headers taking precedence over
|
|
33
|
+
// the non-specific ones.
|
|
34
|
+
return Object.assign({}, core_1.baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders), core_1.baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders));
|
|
35
|
+
}
|
|
36
|
+
function appendRootPathToUrlIfNeeded(url) {
|
|
37
|
+
try {
|
|
38
|
+
const parsedUrl = new URL(url);
|
|
39
|
+
// This will automatically append '/' if there's no root path.
|
|
40
|
+
return parsedUrl.toString();
|
|
41
|
+
}
|
|
42
|
+
catch (_a) {
|
|
43
|
+
api_1.diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function appendResourcePathToUrl(url, path) {
|
|
48
|
+
try {
|
|
49
|
+
// just try to parse, if it fails we catch and warn.
|
|
50
|
+
new URL(url);
|
|
51
|
+
}
|
|
52
|
+
catch (_a) {
|
|
53
|
+
api_1.diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (!url.endsWith('/')) {
|
|
57
|
+
url = url + '/';
|
|
58
|
+
}
|
|
59
|
+
url += path;
|
|
60
|
+
try {
|
|
61
|
+
// just try to parse, if it fails we catch and warn.
|
|
62
|
+
new URL(url);
|
|
63
|
+
}
|
|
64
|
+
catch (_b) {
|
|
65
|
+
api_1.diag.warn(`Configuration: Provided URL appended with '${path}' is not a valid URL, using 'undefined' instead of '${url}'`);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return url;
|
|
69
|
+
}
|
|
70
|
+
function getNonSpecificUrlFromEnv(signalResourcePath) {
|
|
71
|
+
var _a;
|
|
72
|
+
const envUrl = (_a = process.env.OTEL_EXPORTER_OTLP_ENDPOINT) === null || _a === void 0 ? void 0 : _a.trim();
|
|
73
|
+
if (envUrl == null || envUrl === '') {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return appendResourcePathToUrl(envUrl, signalResourcePath);
|
|
77
|
+
}
|
|
78
|
+
function getSpecificUrlFromEnv(signalIdentifier) {
|
|
79
|
+
var _a;
|
|
80
|
+
const envUrl = (_a = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
81
|
+
if (envUrl == null || envUrl === '') {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
return appendRootPathToUrlIfNeeded(envUrl);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Reads and returns configuration from the environment
|
|
88
|
+
*
|
|
89
|
+
* @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)
|
|
90
|
+
* @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)
|
|
91
|
+
*/
|
|
92
|
+
function getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
|
|
93
|
+
var _a;
|
|
94
|
+
return Object.assign(Object.assign({}, (0, shared_env_configuration_1.getSharedConfigurationFromEnvironment)(signalIdentifier)), { url: (_a = getSpecificUrlFromEnv(signalIdentifier)) !== null && _a !== void 0 ? _a : getNonSpecificUrlFromEnv(signalResourcePath), headers: getHeadersFromEnv(signalIdentifier) });
|
|
95
|
+
}
|
|
96
|
+
exports.getHttpConfigurationFromEnvironment = getHttpConfigurationFromEnvironment;
|
|
97
|
+
//# 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,8CAAmD;AACnD,4CAA0C;AAC1C,yEAAmF;AAGnF,SAAS,iBAAiB,CAAC,gBAAwB;;IACjD,MAAM,wBAAwB,GAC5B,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,gBAAgB,UAAU,CAAC,0CAAE,IAAI,EAAE,CAAC;IACxE,MAAM,2BAA2B,GAC/B,MAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,0CAAE,IAAI,EAAE,CAAC;IAEpD,MAAM,qBAAqB,GAAG,mBAAY,CAAC,uBAAuB,CAChE,wBAAwB,CACzB,CAAC;IACF,MAAM,wBAAwB,GAAG,mBAAY,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,mBAAY,CAAC,uBAAuB,CAAC,2BAA2B,CAAC,EACjE,mBAAY,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,CAC/D,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAAC,GAAW;IAC9C,IAAI;QACF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,8DAA8D;QAC9D,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;KAC7B;IAAC,WAAM;QACN,UAAI,CAAC,IAAI,CACP,oEAAoE,GAAG,8BAA8B,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,UAAI,CAAC,IAAI,CACP,oEAAoE,GAAG,8BAA8B,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,UAAI,CAAC,IAAI,CACP,8CAA8C,IAAI,uDAAuD,GAAG,GAAG,CAChH,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,wBAAwB,CAC/B,kBAA0B;;IAE1B,MAAM,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,MAAM,MAAM,GACV,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,gBAAgB,WAAW,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,SAAgB,mCAAmC,CACjD,gBAAwB,EACxB,kBAA0B;;IAE1B,uCACK,IAAA,gEAAqC,EAAC,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;AAXD,kFAWC","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,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.getSharedConfigurationDefaults = exports.mergeOtlpSharedConfigurationWithDefaults = exports.validateTimeoutMillis = void 0;
|
|
19
|
+
function validateTimeoutMillis(timeoutMillis) {
|
|
20
|
+
if (!Number.isNaN(timeoutMillis) &&
|
|
21
|
+
Number.isFinite(timeoutMillis) &&
|
|
22
|
+
timeoutMillis > 0) {
|
|
23
|
+
return timeoutMillis;
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`);
|
|
26
|
+
}
|
|
27
|
+
exports.validateTimeoutMillis = validateTimeoutMillis;
|
|
28
|
+
/**
|
|
29
|
+
* @param userProvidedConfiguration Configuration options provided by the user in code.
|
|
30
|
+
* @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
|
|
31
|
+
* @param defaultConfiguration The defaults as defined by the exporter specification
|
|
32
|
+
*/
|
|
33
|
+
function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f;
|
|
35
|
+
return {
|
|
36
|
+
timeoutMillis: validateTimeoutMillis((_b = (_a = userProvidedConfiguration.timeoutMillis) !== null && _a !== void 0 ? _a : fallbackConfiguration.timeoutMillis) !== null && _b !== void 0 ? _b : defaultConfiguration.timeoutMillis),
|
|
37
|
+
concurrencyLimit: (_d = (_c = userProvidedConfiguration.concurrencyLimit) !== null && _c !== void 0 ? _c : fallbackConfiguration.concurrencyLimit) !== null && _d !== void 0 ? _d : defaultConfiguration.concurrencyLimit,
|
|
38
|
+
compression: (_f = (_e = userProvidedConfiguration.compression) !== null && _e !== void 0 ? _e : fallbackConfiguration.compression) !== null && _f !== void 0 ? _f : defaultConfiguration.compression,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.mergeOtlpSharedConfigurationWithDefaults = mergeOtlpSharedConfigurationWithDefaults;
|
|
42
|
+
function getSharedConfigurationDefaults() {
|
|
43
|
+
return {
|
|
44
|
+
timeoutMillis: 10000,
|
|
45
|
+
concurrencyLimit: 30,
|
|
46
|
+
compression: 'none',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.getSharedConfigurationDefaults = getSharedConfigurationDefaults;
|
|
50
|
+
//# 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,SAAgB,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,qFAAqF,aAAa,IAAI,CACvG,CAAC;AACJ,CAAC;AAXD,sDAWC;AAED;;;;GAIG;AACH,SAAgB,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;AApBD,4FAoBC;AAED,SAAgB,8BAA8B;IAC5C,OAAO;QACL,aAAa,EAAE,KAAK;QACpB,gBAAgB,EAAE,EAAE;QACpB,WAAW,EAAE,MAAM;KACpB,CAAC;AACJ,CAAC;AAND,wEAMC","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"]}
|