feat: Complete zCode CLI X with Telegram bot integration

- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

View File

@@ -0,0 +1,11 @@
import { OtlpHttpConfiguration } from './otlp-http-configuration';
import { OTLPExporterNodeConfigBase } from './legacy-node-configuration';
/**
* @deprecated this will be removed in 2.0
*
* @param config
* @param signalResourcePath
* @param requiredHeaders
*/
export declare function convertLegacyBrowserHttpOptions(config: OTLPExporterNodeConfigBase, signalResourcePath: string, requiredHeaders: Record<string, string>): OtlpHttpConfiguration;
//# sourceMappingURL=convert-legacy-browser-http-options.d.ts.map

View File

@@ -0,0 +1,34 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from './otlp-http-configuration';
import { wrapStaticHeadersInFunction } from './shared-configuration';
/**
* @deprecated this will be removed in 2.0
*
* @param config
* @param signalResourcePath
* @param requiredHeaders
*/
export function convertLegacyBrowserHttpOptions(config, signalResourcePath, requiredHeaders) {
return mergeOtlpHttpConfigurationWithDefaults({
url: config.url,
timeoutMillis: config.timeoutMillis,
headers: wrapStaticHeadersInFunction(config.headers),
concurrencyLimit: config.concurrencyLimit,
}, {}, // no fallback for browser case
getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
}
//# sourceMappingURL=convert-legacy-browser-http-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"convert-legacy-browser-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-browser-http-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GAEvC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAC7C,MAAkC,EAClC,kBAA0B,EAC1B,eAAuC;IAEvC,OAAO,sCAAsC,CAC3C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,OAAO,CAAC;QACpD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,EACD,EAAE,EAAE,+BAA+B;IACnC,4BAA4B,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAClE,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 {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n OtlpHttpConfiguration,\n} from './otlp-http-configuration';\nimport { OTLPExporterNodeConfigBase } from './legacy-node-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\n\n/**\n * @deprecated this will be removed in 2.0\n *\n * @param config\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function convertLegacyBrowserHttpOptions(\n config: OTLPExporterNodeConfigBase,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): OtlpHttpConfiguration {\n return mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n timeoutMillis: config.timeoutMillis,\n headers: wrapStaticHeadersInFunction(config.headers),\n concurrencyLimit: config.concurrencyLimit,\n },\n {}, // no fallback for browser case\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}

View File

@@ -0,0 +1,11 @@
import { OTLPExporterNodeConfigBase } from './legacy-node-configuration';
import { OtlpHttpConfiguration } from './otlp-http-configuration';
/**
* @deprecated this will be removed in 2.0
* @param config
* @param signalIdentifier
* @param signalResourcePath
* @param requiredHeaders
*/
export declare function convertLegacyHttpOptions(config: OTLPExporterNodeConfigBase, signalIdentifier: string, signalResourcePath: string, requiredHeaders: Record<string, string>): OtlpHttpConfiguration;
//# sourceMappingURL=convert-legacy-node-http-options.d.ts.map

View File

@@ -0,0 +1,45 @@
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from './otlp-http-configuration';
import { getHttpConfigurationFromEnvironment } from './otlp-http-env-configuration';
import { diag } from '@opentelemetry/api';
import { wrapStaticHeadersInFunction } from './shared-configuration';
function convertLegacyAgentOptions(config) {
// populate keepAlive for use with new settings
if ((config === null || config === void 0 ? void 0 : config.keepAlive) != null) {
if (config.httpAgentOptions != null) {
if (config.httpAgentOptions.keepAlive == null) {
// specific setting is not set, populate with non-specific setting.
config.httpAgentOptions.keepAlive = config.keepAlive;
}
// do nothing, use specific setting otherwise
}
else {
// populate specific option if AgentOptions does not exist.
config.httpAgentOptions = {
keepAlive: config.keepAlive,
};
}
}
return config.httpAgentOptions;
}
/**
* @deprecated this will be removed in 2.0
* @param config
* @param signalIdentifier
* @param signalResourcePath
* @param requiredHeaders
*/
export function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath, requiredHeaders) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (config.metadata) {
diag.warn('Metadata cannot be set when using http');
}
return mergeOtlpHttpConfigurationWithDefaults({
url: config.url,
headers: wrapStaticHeadersInFunction(config.headers),
concurrencyLimit: config.concurrencyLimit,
timeoutMillis: config.timeoutMillis,
compression: config.compression,
agentOptions: convertLegacyAgentOptions(config),
}, getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
}
//# sourceMappingURL=convert-legacy-node-http-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GAEvC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mCAAmC,EAAE,MAAM,+BAA+B,CAAC;AAGpF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,SAAS,yBAAyB,CAChC,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,MAAM,CAAC,gBAAgB,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAkC,EAClC,gBAAwB,EACxB,kBAA0B,EAC1B,eAAuC;IAEvC,8DAA8D;IAC9D,IAAK,MAAc,CAAC,QAAQ,EAAE;QAC5B,IAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;KACrD;IAED,OAAO,sCAAsC,CAC3C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,OAAO,CAAC;QACpD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,yBAAyB,CAAC,MAAM,CAAC;KAChD,EACD,mCAAmC,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,EACzE,4BAA4B,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAClE,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 { OTLPExporterNodeConfigBase } from './legacy-node-configuration';\nimport {\n getHttpConfigurationDefaults,\n mergeOtlpHttpConfigurationWithDefaults,\n OtlpHttpConfiguration,\n} from './otlp-http-configuration';\nimport { getHttpConfigurationFromEnvironment } from './otlp-http-env-configuration';\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport { diag } from '@opentelemetry/api';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\n\nfunction convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): http.AgentOptions | https.AgentOptions | undefined {\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;\n}\n\n/**\n * @deprecated this will be removed in 2.0\n * @param config\n * @param signalIdentifier\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function convertLegacyHttpOptions(\n config: OTLPExporterNodeConfigBase,\n signalIdentifier: string,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): OtlpHttpConfiguration {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((config as any).metadata) {\n diag.warn('Metadata cannot be set when using http');\n }\n\n return mergeOtlpHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: wrapStaticHeadersInFunction(config.headers),\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n agentOptions: convertLegacyAgentOptions(config),\n },\n getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath),\n getHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}

View File

@@ -0,0 +1,12 @@
import { ISerializer } from '@opentelemetry/otlp-transformer';
import { IOtlpExportDelegate } from '../otlp-export-delegate';
import { OTLPExporterConfigBase } from './legacy-base-configuration';
/**
* @deprecated
* @param config
* @param serializer
* @param signalResourcePath
* @param requiredHeaders
*/
export declare function createLegacyOtlpBrowserExportDelegate<Internal, Response>(config: OTLPExporterConfigBase, serializer: ISerializer<Internal, Response>, signalResourcePath: string, requiredHeaders: Record<string, string>): IOtlpExportDelegate<Internal>;
//# sourceMappingURL=create-legacy-browser-delegate.d.ts.map

View File

@@ -0,0 +1,20 @@
import { createOtlpSendBeaconExportDelegate, createOtlpXhrExportDelegate, } from '../otlp-browser-http-export-delegate';
import { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';
/**
* @deprecated
* @param config
* @param serializer
* @param signalResourcePath
* @param requiredHeaders
*/
export function createLegacyOtlpBrowserExportDelegate(config, serializer, signalResourcePath, requiredHeaders) {
var useXhr = !!config.headers || typeof navigator.sendBeacon !== 'function';
var options = convertLegacyBrowserHttpOptions(config, signalResourcePath, requiredHeaders);
if (useXhr) {
return createOtlpXhrExportDelegate(options, serializer);
}
else {
return createOtlpSendBeaconExportDelegate(options, serializer);
}
}
//# sourceMappingURL=create-legacy-browser-delegate.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-legacy-browser-delegate.js","sourceRoot":"","sources":["../../../src/configuration/create-legacy-browser-delegate.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,kCAAkC,EAClC,2BAA2B,GAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AAIxF;;;;;;GAMG;AACH,MAAM,UAAU,qCAAqC,CACnD,MAA8B,EAC9B,UAA2C,EAC3C,kBAA0B,EAC1B,eAAuC;IAEvC,IAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;IAE9E,IAAM,OAAO,GAAG,+BAA+B,CAC7C,MAAM,EACN,kBAAkB,EAClB,eAAe,CAChB,CAAC;IAEF,IAAI,MAAM,EAAE;QACV,OAAO,2BAA2B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;KACzD;SAAM;QACL,OAAO,kCAAkC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;KAChE;AACH,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 { ISerializer } from '@opentelemetry/otlp-transformer';\nimport {\n createOtlpSendBeaconExportDelegate,\n createOtlpXhrExportDelegate,\n} from '../otlp-browser-http-export-delegate';\nimport { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';\nimport { IOtlpExportDelegate } from '../otlp-export-delegate';\nimport { OTLPExporterConfigBase } from './legacy-base-configuration';\n\n/**\n * @deprecated\n * @param config\n * @param serializer\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function createLegacyOtlpBrowserExportDelegate<Internal, Response>(\n config: OTLPExporterConfigBase,\n serializer: ISerializer<Internal, Response>,\n signalResourcePath: string,\n requiredHeaders: Record<string, string>\n): IOtlpExportDelegate<Internal> {\n const useXhr = !!config.headers || typeof navigator.sendBeacon !== 'function';\n\n const options = convertLegacyBrowserHttpOptions(\n config,\n signalResourcePath,\n requiredHeaders\n );\n\n if (useXhr) {\n return createOtlpXhrExportDelegate(options, serializer);\n } else {\n return createOtlpSendBeaconExportDelegate(options, serializer);\n }\n}\n"]}

View File

@@ -0,0 +1,9 @@
export interface OTLPExporterConfigBase {
headers?: Record<string, string>;
url?: string;
concurrencyLimit?: number;
/** Maximum time the OTLP exporter will wait for each batch export.
* The default value is 10000ms. */
timeoutMillis?: number;
}
//# sourceMappingURL=legacy-base-configuration.d.ts.map

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=legacy-base-configuration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"legacy-base-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-base-configuration.ts"],"names":[],"mappings":"","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 */\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"]}

View File

@@ -0,0 +1,17 @@
/// <reference types="node" />
import type * as http from 'http';
import type * as https from 'https';
import { OTLPExporterConfigBase } from './legacy-base-configuration';
/**
* Collector Exporter node base config
*/
export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
keepAlive?: boolean;
compression?: CompressionAlgorithm;
httpAgentOptions?: http.AgentOptions | https.AgentOptions;
}
export declare enum CompressionAlgorithm {
NONE = "none",
GZIP = "gzip"
}
//# sourceMappingURL=legacy-node-configuration.d.ts.map

View File

@@ -0,0 +1,21 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export var CompressionAlgorithm;
(function (CompressionAlgorithm) {
CompressionAlgorithm["NONE"] = "none";
CompressionAlgorithm["GZIP"] = "gzip";
})(CompressionAlgorithm || (CompressionAlgorithm = {}));
//# sourceMappingURL=legacy-node-configuration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","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// NOTE: do not change these imports to be actual imports, otherwise they WILL break `@opentelemetry/instrumentation-http`\nimport type * as http from 'http';\nimport type * as https from 'https';\n\nimport { OTLPExporterConfigBase } from './legacy-base-configuration';\n\n/**\n * Collector Exporter node base config\n */\nexport interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {\n keepAlive?: boolean;\n compression?: CompressionAlgorithm;\n httpAgentOptions?: http.AgentOptions | https.AgentOptions;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip',\n}\n"]}

View File

@@ -0,0 +1,17 @@
/// <reference types="node" />
import { OtlpSharedConfiguration } from './shared-configuration';
import type * as http from 'http';
import type * as https from 'https';
export interface OtlpHttpConfiguration extends OtlpSharedConfiguration {
url: string;
headers: () => Record<string, string>;
agentOptions: http.AgentOptions | https.AgentOptions;
}
/**
* @param userProvidedConfiguration Configuration options provided by the user in code.
* @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
* @param defaultConfiguration The defaults as defined by the exporter specification
*/
export declare function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration: Partial<OtlpHttpConfiguration>, fallbackConfiguration: Partial<OtlpHttpConfiguration>, defaultConfiguration: OtlpHttpConfiguration): OtlpHttpConfiguration;
export declare function getHttpConfigurationDefaults(requiredHeaders: Record<string, string>, signalResourcePath: string): OtlpHttpConfiguration;
//# sourceMappingURL=otlp-http-configuration.d.ts.map

View File

@@ -0,0 +1,69 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { getSharedConfigurationDefaults, mergeOtlpSharedConfigurationWithDefaults, } from './shared-configuration';
import { validateAndNormalizeHeaders } from '../util';
function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
var requiredHeaders = __assign({}, defaultHeaders());
var headers = {};
return function () {
// add fallback ones first
if (fallbackHeaders != null) {
Object.assign(headers, fallbackHeaders());
}
// override with user-provided ones
if (userProvidedHeaders != null) {
Object.assign(headers, userProvidedHeaders());
}
// override required ones.
return Object.assign(headers, requiredHeaders);
};
}
function validateUserProvidedUrl(url) {
if (url == null) {
return undefined;
}
try {
new URL(url);
return url;
}
catch (e) {
throw new Error("Configuration: Could not parse user-provided export URL: '" + url + "'");
}
}
/**
* @param userProvidedConfiguration Configuration options provided by the user in code.
* @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
* @param defaultConfiguration The defaults as defined by the exporter specification
*/
export function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
var _a, _b, _c, _d;
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, agentOptions: (_d = (_c = userProvidedConfiguration.agentOptions) !== null && _c !== void 0 ? _c : fallbackConfiguration.agentOptions) !== null && _d !== void 0 ? _d : defaultConfiguration.agentOptions });
}
export function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
return __assign(__assign({}, getSharedConfigurationDefaults()), { headers: function () { return requiredHeaders; }, url: 'http://localhost:4318/' + signalResourcePath, agentOptions: { keepAlive: true } });
}
//# sourceMappingURL=otlp-http-configuration.js.map

View File

@@ -0,0 +1,9 @@
import { OtlpHttpConfiguration } from './otlp-http-configuration';
/**
* Reads and returns configuration from the environment
*
* @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)
* @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)
*/
export declare function getHttpConfigurationFromEnvironment(signalIdentifier: string, signalResourcePath: string): Partial<OtlpHttpConfiguration>;
//# sourceMappingURL=otlp-http-env-configuration.d.ts.map

View File

@@ -0,0 +1,105 @@
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { baggageUtils } from '@opentelemetry/core';
import { diag } from '@opentelemetry/api';
import { getSharedConfigurationFromEnvironment } from './shared-env-configuration';
import { wrapStaticHeadersInFunction } from './shared-configuration';
function getStaticHeadersFromEnv(signalIdentifier) {
var _a, _b;
var signalSpecificRawHeaders = (_a = process.env["OTEL_EXPORTER_OTLP_" + signalIdentifier + "_HEADERS"]) === null || _a === void 0 ? void 0 : _a.trim();
var nonSignalSpecificRawHeaders = (_b = process.env['OTEL_EXPORTER_OTLP_HEADERS']) === null || _b === void 0 ? void 0 : _b.trim();
var signalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders);
var nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
if (Object.keys(signalSpecificHeaders).length === 0 &&
Object.keys(nonSignalSpecificHeaders).length === 0) {
return undefined;
}
// headers are combined instead of overwritten, with the specific headers taking precedence over
// the non-specific ones.
return Object.assign({}, baggageUtils.parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders), baggageUtils.parseKeyPairsIntoRecord(signalSpecificRawHeaders));
}
function appendRootPathToUrlIfNeeded(url) {
try {
var parsedUrl = new URL(url);
// This will automatically append '/' if there's no root path.
return parsedUrl.toString();
}
catch (_a) {
diag.warn("Configuration: Could not parse environment-provided export URL: '" + url + "', falling back to undefined");
return undefined;
}
}
function appendResourcePathToUrl(url, path) {
try {
// just try to parse, if it fails we catch and warn.
new URL(url);
}
catch (_a) {
diag.warn("Configuration: Could not parse environment-provided export URL: '" + url + "', falling back to undefined");
return undefined;
}
if (!url.endsWith('/')) {
url = url + '/';
}
url += path;
try {
// just try to parse, if it fails we catch and warn.
new URL(url);
}
catch (_b) {
diag.warn("Configuration: Provided URL appended with '" + path + "' is not a valid URL, using 'undefined' instead of '" + url + "'");
return undefined;
}
return url;
}
function getNonSpecificUrlFromEnv(signalResourcePath) {
var _a;
var envUrl = (_a = process.env.OTEL_EXPORTER_OTLP_ENDPOINT) === null || _a === void 0 ? void 0 : _a.trim();
if (envUrl == null || envUrl === '') {
return undefined;
}
return appendResourcePathToUrl(envUrl, signalResourcePath);
}
function getSpecificUrlFromEnv(signalIdentifier) {
var _a;
var envUrl = (_a = process.env["OTEL_EXPORTER_OTLP_" + signalIdentifier + "_ENDPOINT"]) === null || _a === void 0 ? void 0 : _a.trim();
if (envUrl == null || envUrl === '') {
return undefined;
}
return appendRootPathToUrlIfNeeded(envUrl);
}
/**
* Reads and returns configuration from the environment
*
* @param signalIdentifier all caps part in environment variables that identifies the signal (e.g.: METRICS, TRACES, LOGS)
* @param signalResourcePath signal resource path to append if necessary (e.g.: v1/metrics, v1/traces, v1/logs)
*/
export function getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
var _a;
return __assign(__assign({}, getSharedConfigurationFromEnvironment(signalIdentifier)), { url: (_a = getSpecificUrlFromEnv(signalIdentifier)) !== null && _a !== void 0 ? _a : getNonSpecificUrlFromEnv(signalResourcePath), headers: wrapStaticHeadersInFunction(getStaticHeadersFromEnv(signalIdentifier)) });
}
//# sourceMappingURL=otlp-http-env-configuration.js.map

View File

@@ -0,0 +1,23 @@
/**
* Configuration shared across all OTLP exporters
*
* Implementation note: anything added here MUST be
* - platform-agnostic
* - signal-agnostic
* - transport-agnostic
*/
export interface OtlpSharedConfiguration {
timeoutMillis: number;
concurrencyLimit: number;
compression: 'gzip' | 'none';
}
export declare function validateTimeoutMillis(timeoutMillis: number): number;
export declare function wrapStaticHeadersInFunction(headers: Record<string, string> | undefined): (() => Record<string, string>) | undefined;
/**
* @param userProvidedConfiguration Configuration options provided by the user in code.
* @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
* @param defaultConfiguration The defaults as defined by the exporter specification
*/
export declare function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration: Partial<OtlpSharedConfiguration>, fallbackConfiguration: Partial<OtlpSharedConfiguration>, defaultConfiguration: OtlpSharedConfiguration): OtlpSharedConfiguration;
export declare function getSharedConfigurationDefaults(): OtlpSharedConfiguration;
//# sourceMappingURL=shared-configuration.d.ts.map

View File

@@ -0,0 +1,50 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function validateTimeoutMillis(timeoutMillis) {
if (!Number.isNaN(timeoutMillis) &&
Number.isFinite(timeoutMillis) &&
timeoutMillis > 0) {
return timeoutMillis;
}
throw new Error("Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '" + timeoutMillis + "')");
}
export function wrapStaticHeadersInFunction(headers) {
if (headers == null) {
return undefined;
}
return function () { return headers; };
}
/**
* @param userProvidedConfiguration Configuration options provided by the user in code.
* @param fallbackConfiguration Fallback to use when the {@link userProvidedConfiguration} does not specify an option.
* @param defaultConfiguration The defaults as defined by the exporter specification
*/
export function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
var _a, _b, _c, _d, _e, _f;
return {
timeoutMillis: validateTimeoutMillis((_b = (_a = userProvidedConfiguration.timeoutMillis) !== null && _a !== void 0 ? _a : fallbackConfiguration.timeoutMillis) !== null && _b !== void 0 ? _b : defaultConfiguration.timeoutMillis),
concurrencyLimit: (_d = (_c = userProvidedConfiguration.concurrencyLimit) !== null && _c !== void 0 ? _c : fallbackConfiguration.concurrencyLimit) !== null && _d !== void 0 ? _d : defaultConfiguration.concurrencyLimit,
compression: (_f = (_e = userProvidedConfiguration.compression) !== null && _e !== void 0 ? _e : fallbackConfiguration.compression) !== null && _f !== void 0 ? _f : defaultConfiguration.compression,
};
}
export function getSharedConfigurationDefaults() {
return {
timeoutMillis: 10000,
concurrencyLimit: 30,
compression: 'none',
};
}
//# sourceMappingURL=shared-configuration.js.map

View File

@@ -0,0 +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,MAAM,UAAU,2BAA2B,CACzC,OAA2C;IAE3C,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,cAAM,OAAA,OAAO,EAAP,CAAO,CAAC;AACvB,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\nexport function wrapStaticHeadersInFunction(\n headers: Record<string, string> | undefined\n): (() => Record<string, string>) | undefined {\n if (headers == null) {\n return undefined;\n }\n\n return () => headers;\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"]}

View File

@@ -0,0 +1,3 @@
import { OtlpSharedConfiguration } from './shared-configuration';
export declare function getSharedConfigurationFromEnvironment(signalIdentifier: string): Partial<OtlpSharedConfiguration>;
//# sourceMappingURL=shared-env-configuration.d.ts.map

View File

@@ -0,0 +1,44 @@
import { diag } from '@opentelemetry/api';
function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
var _a;
var envTimeout = (_a = process.env[timeoutEnvVar]) === null || _a === void 0 ? void 0 : _a.trim();
if (envTimeout != null && envTimeout !== '') {
var definedTimeout = Number(envTimeout);
if (!Number.isNaN(definedTimeout) &&
Number.isFinite(definedTimeout) &&
definedTimeout > 0) {
return definedTimeout;
}
diag.warn("Configuration: " + timeoutEnvVar + " is invalid, expected number greater than 0 (actual: " + envTimeout + ")");
}
return undefined;
}
function getTimeoutFromEnv(signalIdentifier) {
var specificTimeout = parseAndValidateTimeoutFromEnv("OTEL_EXPORTER_OTLP_" + signalIdentifier + "_TIMEOUT");
var nonSpecificTimeout = parseAndValidateTimeoutFromEnv('OTEL_EXPORTER_OTLP_TIMEOUT');
return specificTimeout !== null && specificTimeout !== void 0 ? specificTimeout : nonSpecificTimeout;
}
function parseAndValidateCompressionFromEnv(compressionEnvVar) {
var _a;
var compression = (_a = process.env[compressionEnvVar]) === null || _a === void 0 ? void 0 : _a.trim();
if (compression === '') {
return undefined;
}
if (compression == null || compression === 'none' || compression === 'gzip') {
return compression;
}
diag.warn("Configuration: " + compressionEnvVar + " is invalid, expected 'none' or 'gzip' (actual: '" + compression + "')");
return undefined;
}
function getCompressionFromEnv(signalIdentifier) {
var specificCompression = parseAndValidateCompressionFromEnv("OTEL_EXPORTER_OTLP_" + signalIdentifier + "_COMPRESSION");
var nonSpecificCompression = parseAndValidateCompressionFromEnv('OTEL_EXPORTER_OTLP_COMPRESSION');
return specificCompression !== null && specificCompression !== void 0 ? specificCompression : nonSpecificCompression;
}
export function getSharedConfigurationFromEnvironment(signalIdentifier) {
return {
timeoutMillis: getTimeoutFromEnv(signalIdentifier),
compression: getCompressionFromEnv(signalIdentifier),
};
}
//# sourceMappingURL=shared-env-configuration.js.map

View File

@@ -0,0 +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"]}