@opentelemetry/otlp-exporter-base 0.206.0 → 0.207.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/configuration/convert-legacy-node-http-options.js +1 -0
- package/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esm/configuration/legacy-node-configuration.d.ts +6 -0
- package/build/esm/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-node-http-configuration.d.ts +6 -0
- package/build/esm/configuration/otlp-node-http-configuration.js +8 -1
- package/build/esm/configuration/otlp-node-http-configuration.js.map +1 -1
- package/build/esm/configuration/otlp-node-http-env-configuration.js +35 -0
- package/build/esm/configuration/otlp-node-http-env-configuration.js.map +1 -1
- package/build/esm/transport/http-transport-types.d.ts +1 -0
- package/build/esm/transport/http-transport-types.js.map +1 -1
- package/build/esm/transport/http-transport-utils.js +11 -4
- package/build/esm/transport/http-transport-utils.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/configuration/convert-legacy-node-http-options.js +1 -0
- package/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/esnext/configuration/legacy-node-configuration.d.ts +6 -0
- package/build/esnext/configuration/legacy-node-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-node-http-configuration.d.ts +6 -0
- package/build/esnext/configuration/otlp-node-http-configuration.js +8 -1
- package/build/esnext/configuration/otlp-node-http-configuration.js.map +1 -1
- package/build/esnext/configuration/otlp-node-http-env-configuration.js +35 -0
- package/build/esnext/configuration/otlp-node-http-env-configuration.js.map +1 -1
- package/build/esnext/transport/http-transport-types.d.ts +1 -0
- package/build/esnext/transport/http-transport-types.js.map +1 -1
- package/build/esnext/transport/http-transport-utils.js +11 -4
- package/build/esnext/transport/http-transport-utils.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/configuration/convert-legacy-node-http-options.js +1 -0
- package/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/build/src/configuration/legacy-node-configuration.d.ts +6 -0
- package/build/src/configuration/legacy-node-configuration.js.map +1 -1
- package/build/src/configuration/otlp-node-http-configuration.d.ts +6 -0
- package/build/src/configuration/otlp-node-http-configuration.js +8 -1
- package/build/src/configuration/otlp-node-http-configuration.js.map +1 -1
- package/build/src/configuration/otlp-node-http-env-configuration.js +35 -0
- package/build/src/configuration/otlp-node-http-env-configuration.js.map +1 -1
- package/build/src/transport/http-transport-types.d.ts +1 -0
- package/build/src/transport/http-transport-types.js.map +1 -1
- package/build/src/transport/http-transport-utils.js +11 -4
- package/build/src/transport/http-transport-utils.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 +7 -6
|
@@ -37,6 +37,7 @@ export function convertLegacyHttpOptions(config, signalIdentifier, signalResourc
|
|
|
37
37
|
timeoutMillis: config.timeoutMillis,
|
|
38
38
|
compression: config.compression,
|
|
39
39
|
agentFactory: convertLegacyAgentOptions(config),
|
|
40
|
+
userAgent: config.userAgent,
|
|
40
41
|
}, getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
41
42
|
}
|
|
42
43
|
//# sourceMappingURL=convert-legacy-node-http-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,gCAAgC,EAEhC,0CAA0C,GAE3C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,uCAAuC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,SAAS,yBAAyB,CAChC,MAAkC;IAElC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE;QACjD,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACrC,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE;QAC5B,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;KACrD;IAED,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,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,0CAA0C,CAC/C;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;
|
|
1
|
+
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC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AAe,EAAE,kBAAkB,CAAC,CACtE,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 { diag } from '@opentelemetry/api';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\nimport {\n getNodeHttpConfigurationDefaults,\n HttpAgentFactory,\n mergeOtlpNodeHttpConfigurationWithDefaults,\n OtlpNodeHttpConfiguration,\n} from './otlp-node-http-configuration';\nimport { httpAgentFactoryFromOptions } from '../index-node-http';\nimport { getNodeHttpConfigurationFromEnvironment } from './otlp-node-http-env-configuration';\n\nfunction convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): HttpAgentFactory | undefined {\n if (typeof config.httpAgentOptions === 'function') {\n return config.httpAgentOptions;\n }\n\n let legacy = config.httpAgentOptions;\n if (config.keepAlive != null) {\n legacy = { keepAlive: config.keepAlive, ...legacy };\n }\n\n if (legacy != null) {\n return httpAgentFactoryFromOptions(legacy);\n } else {\n return undefined;\n }\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): OtlpNodeHttpConfiguration {\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 mergeOtlpNodeHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: wrapStaticHeadersInFunction(config.headers),\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n agentFactory: convertLegacyAgentOptions(config),\n userAgent: config.userAgent,\n },\n getNodeHttpConfigurationFromEnvironment(\n signalIdentifier,\n signalResourcePath\n ),\n getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}
|
|
@@ -33,6 +33,12 @@ export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
|
|
|
33
33
|
* }
|
|
34
34
|
*/
|
|
35
35
|
httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;
|
|
36
|
+
/**
|
|
37
|
+
* User agent header string to be prepended to the exporter's default value.
|
|
38
|
+
* Availablie since v1.49.0 of the spec.
|
|
39
|
+
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
|
40
|
+
*/
|
|
41
|
+
userAgent?: string;
|
|
36
42
|
}
|
|
37
43
|
export declare enum CompressionAlgorithm {
|
|
38
44
|
NONE = "none",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA8CH,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 type { OTLPExporterConfigBase } from './legacy-base-configuration';\nimport type { HttpAgentFactory } from './otlp-node-http-configuration';\n\n/**\n * Collector Exporter node base config\n */\nexport interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {\n keepAlive?: boolean;\n compression?: CompressionAlgorithm;\n /**\n * Custom HTTP agent options or a factory function for creating agents.\n *\n * @remarks\n * Prefer using `http.AgentOptions` or `https.AgentOptions` over a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n *\n * @example <caption> Using agent options directly: </caption>\n * httpAgentOptions: {\n * keepAlive: true,\n * maxSockets: 10\n * }\n *\n * @example <caption> Using a factory with dynamic import: </caption>\n * httpAgentOptions: async (protocol) => {\n * const module = protocol === 'http:' ? await import('http') : await import('https');\n * return new module.Agent({ keepAlive: true });\n * }\n */\n httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;\n /**\n * User agent header string to be prepended to the exporter's default value.\n * Availablie since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip',\n}\n"]}
|
|
@@ -16,6 +16,12 @@ export interface OtlpNodeHttpConfiguration extends OtlpHttpConfiguration {
|
|
|
16
16
|
* module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
|
|
17
17
|
*/
|
|
18
18
|
agentFactory: HttpAgentFactory;
|
|
19
|
+
/**
|
|
20
|
+
* User agent header string to be appended to the exporter's value as a prefix.
|
|
21
|
+
* Availablie since v1.49.0 of the spec.
|
|
22
|
+
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
|
23
|
+
*/
|
|
24
|
+
userAgent?: string;
|
|
19
25
|
}
|
|
20
26
|
export declare function httpAgentFactoryFromOptions(options: http.AgentOptions | https.AgentOptions): HttpAgentFactory;
|
|
21
27
|
/**
|
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from './otlp-http-configuration';
|
|
17
17
|
export function httpAgentFactoryFromOptions(options) {
|
|
18
18
|
return async (protocol) => {
|
|
19
|
-
const
|
|
19
|
+
const isInsecure = protocol === 'http:';
|
|
20
|
+
const module = isInsecure ? import('http') : import('https');
|
|
20
21
|
const { Agent } = await module;
|
|
22
|
+
if (isInsecure) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- these props should not be used in agent options
|
|
24
|
+
const { ca, cert, key, ...insecureOptions } = options;
|
|
25
|
+
return new Agent(insecureOptions);
|
|
26
|
+
}
|
|
21
27
|
return new Agent(options);
|
|
22
28
|
};
|
|
23
29
|
}
|
|
@@ -32,6 +38,7 @@ export function mergeOtlpNodeHttpConfigurationWithDefaults(userProvidedConfigura
|
|
|
32
38
|
agentFactory: userProvidedConfiguration.agentFactory ??
|
|
33
39
|
fallbackConfiguration.agentFactory ??
|
|
34
40
|
defaultConfiguration.agentFactory,
|
|
41
|
+
userAgent: userProvidedConfiguration.userAgent,
|
|
35
42
|
};
|
|
36
43
|
}
|
|
37
44
|
export function getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-node-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GAEvC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-node-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GAEvC,MAAM,2BAA2B,CAAC;AA8BnC,MAAM,UAAU,2BAA2B,CACzC,OAA+C;IAE/C,OAAO,KAAK,EAAC,QAAQ,EAAC,EAAE;QACtB,MAAM,UAAU,GAAG,QAAQ,KAAK,OAAO,CAAC;QACxC,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC;QAE/B,IAAI,UAAU,EAAE;YACd,gHAAgH;YAChH,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe,EAAE,GACzC,OAA6B,CAAC;YAChC,OAAO,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;SACnC;QACD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CACxD,yBAA6D,EAC7D,qBAAyD,EACzD,oBAA+C;IAE/C,OAAO;QACL,GAAG,sCAAsC,CACvC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB;QACD,YAAY,EACV,yBAAyB,CAAC,YAAY;YACtC,qBAAqB,CAAC,YAAY;YAClC,oBAAoB,CAAC,YAAY;QACnC,SAAS,EAAE,yBAAyB,CAAC,SAAS;KAC/C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,eAAuC,EACvC,kBAA0B;IAE1B,OAAO;QACL,GAAG,4BAA4B,CAAC,eAAe,EAAE,kBAAkB,CAAC;QACpE,YAAY,EAAE,2BAA2B,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KAC/D,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';\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\nexport type HttpAgentFactory = (\n protocol: string\n) => http.Agent | https.Agent | Promise<http.Agent> | Promise<https.Agent>;\n\nexport interface OtlpNodeHttpConfiguration extends OtlpHttpConfiguration {\n /**\n * Factory function for creating agents.\n *\n * @remarks\n * Prefer using {@link httpAgentFactoryFromOptions} over manually writing a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n */\n agentFactory: HttpAgentFactory;\n /**\n * User agent header string to be appended to the exporter's value as a prefix.\n * Availablie since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport function httpAgentFactoryFromOptions(\n options: http.AgentOptions | https.AgentOptions\n): HttpAgentFactory {\n return async protocol => {\n const isInsecure = protocol === 'http:';\n const module = isInsecure ? import('http') : import('https');\n const { Agent } = await module;\n\n if (isInsecure) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- these props should not be used in agent options\n const { ca, cert, key, ...insecureOptions } =\n options as https.AgentOptions;\n return new Agent(insecureOptions);\n }\n return new Agent(options);\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 mergeOtlpNodeHttpConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpNodeHttpConfiguration>,\n fallbackConfiguration: Partial<OtlpNodeHttpConfiguration>,\n defaultConfiguration: OtlpNodeHttpConfiguration\n): OtlpNodeHttpConfiguration {\n return {\n ...mergeOtlpHttpConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n agentFactory:\n userProvidedConfiguration.agentFactory ??\n fallbackConfiguration.agentFactory ??\n defaultConfiguration.agentFactory,\n userAgent: userProvidedConfiguration.userAgent,\n };\n}\n\nexport function getNodeHttpConfigurationDefaults(\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n): OtlpNodeHttpConfiguration {\n return {\n ...getHttpConfigurationDefaults(requiredHeaders, signalResourcePath),\n agentFactory: httpAgentFactoryFromOptions({ keepAlive: true }),\n };\n}\n"]}
|
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
16
18
|
import { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';
|
|
17
19
|
import { diag } from '@opentelemetry/api';
|
|
18
20
|
import { getSharedConfigurationFromEnvironment } from './shared-env-configuration';
|
|
19
21
|
import { wrapStaticHeadersInFunction } from './shared-configuration';
|
|
22
|
+
import { httpAgentFactoryFromOptions, } from './otlp-node-http-configuration';
|
|
20
23
|
function getStaticHeadersFromEnv(signalIdentifier) {
|
|
21
24
|
const signalSpecificRawHeaders = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`);
|
|
22
25
|
const nonSignalSpecificRawHeaders = getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS');
|
|
@@ -78,6 +81,32 @@ function getSpecificUrlFromEnv(signalIdentifier) {
|
|
|
78
81
|
}
|
|
79
82
|
return appendRootPathToUrlIfNeeded(envUrl);
|
|
80
83
|
}
|
|
84
|
+
function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
|
|
85
|
+
const signalSpecificPath = getStringFromEnv(signalSpecificEnvVar);
|
|
86
|
+
const nonSignalSpecificPath = getStringFromEnv(nonSignalSpecificEnvVar);
|
|
87
|
+
const filePath = signalSpecificPath ?? nonSignalSpecificPath;
|
|
88
|
+
if (filePath != null) {
|
|
89
|
+
try {
|
|
90
|
+
return fs.readFileSync(path.resolve(process.cwd(), filePath));
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
diag.warn(warningMessage);
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function getClientCertificateFromEnv(signalIdentifier) {
|
|
102
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE', 'Failed to read client certificate chain file');
|
|
103
|
+
}
|
|
104
|
+
function getClientKeyFromEnv(signalIdentifier) {
|
|
105
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, 'OTEL_EXPORTER_OTLP_CLIENT_KEY', 'Failed to read client certificate private key file');
|
|
106
|
+
}
|
|
107
|
+
function getRootCertificateFromEnv(signalIdentifier) {
|
|
108
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CERTIFICATE', 'Failed to read root certificate file');
|
|
109
|
+
}
|
|
81
110
|
/**
|
|
82
111
|
* Reads and returns configuration from the environment
|
|
83
112
|
*
|
|
@@ -90,6 +119,12 @@ export function getNodeHttpConfigurationFromEnvironment(signalIdentifier, signal
|
|
|
90
119
|
url: getSpecificUrlFromEnv(signalIdentifier) ??
|
|
91
120
|
getNonSpecificUrlFromEnv(signalResourcePath),
|
|
92
121
|
headers: wrapStaticHeadersInFunction(getStaticHeadersFromEnv(signalIdentifier)),
|
|
122
|
+
agentFactory: httpAgentFactoryFromOptions({
|
|
123
|
+
keepAlive: true,
|
|
124
|
+
ca: getRootCertificateFromEnv(signalIdentifier),
|
|
125
|
+
cert: getClientCertificateFromEnv(signalIdentifier),
|
|
126
|
+
key: getClientKeyFromEnv(signalIdentifier),
|
|
127
|
+
}),
|
|
93
128
|
};
|
|
94
129
|
}
|
|
95
130
|
//# sourceMappingURL=otlp-node-http-env-configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-node-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-env-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-node-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-env-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,MAAM,I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AE,mBAAmB,CAAC,gBAAgB,CAAC;SAC3C,CAAC;KACH,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 * as fs from 'fs';\nimport * as path from 'path';\nimport { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport { diag } from '@opentelemetry/api';\nimport { getSharedConfigurationFromEnvironment } from './shared-env-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\nimport {\n OtlpNodeHttpConfiguration,\n httpAgentFactoryFromOptions,\n} from './otlp-node-http-configuration';\n\nfunction getStaticHeadersFromEnv(\n signalIdentifier: string\n): Record<string, string> | undefined {\n const signalSpecificRawHeaders = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`\n );\n const nonSignalSpecificRawHeaders = getStringFromEnv(\n 'OTEL_EXPORTER_OTLP_HEADERS'\n );\n\n const signalSpecificHeaders = parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = 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 parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders),\n 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 = getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT');\n if (envUrl === undefined) {\n return undefined;\n }\n return appendResourcePathToUrl(envUrl, signalResourcePath);\n}\n\nfunction getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {\n const envUrl = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`\n );\n if (envUrl === undefined) {\n return undefined;\n }\n return appendRootPathToUrlIfNeeded(envUrl);\n}\n\nfunction readFileFromEnv(\n signalSpecificEnvVar: string,\n nonSignalSpecificEnvVar: string,\n warningMessage: string\n): Buffer | undefined {\n const signalSpecificPath = getStringFromEnv(signalSpecificEnvVar);\n const nonSignalSpecificPath = getStringFromEnv(nonSignalSpecificEnvVar);\n const filePath = signalSpecificPath ?? nonSignalSpecificPath;\n\n if (filePath != null) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), filePath));\n } catch {\n diag.warn(warningMessage);\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction getClientCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE',\n 'Failed to read client certificate chain file'\n );\n}\n\nfunction getClientKeyFromEnv(signalIdentifier: string): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`,\n 'OTEL_EXPORTER_OTLP_CLIENT_KEY',\n 'Failed to read client certificate private key file'\n );\n}\n\nfunction getRootCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CERTIFICATE',\n 'Failed to read root certificate file'\n );\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 getNodeHttpConfigurationFromEnvironment(\n signalIdentifier: string,\n signalResourcePath: string\n): Partial<OtlpNodeHttpConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n url:\n getSpecificUrlFromEnv(signalIdentifier) ??\n getNonSpecificUrlFromEnv(signalResourcePath),\n headers: wrapStaticHeadersInFunction(\n getStaticHeadersFromEnv(signalIdentifier)\n ),\n agentFactory: httpAgentFactoryFromOptions({\n keepAlive: true,\n ca: getRootCertificateFromEnv(signalIdentifier),\n cert: getClientCertificateFromEnv(signalIdentifier),\n key: getClientKeyFromEnv(signalIdentifier),\n }),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface HttpRequestParameters {\n url: string;\n headers: () => Record<string, string>;\n compression: 'gzip' | 'none';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface HttpRequestParameters {\n url: string;\n headers: () => Record<string, string>;\n compression: 'gzip' | 'none';\n userAgent?: string;\n}\n"]}
|
|
@@ -2,6 +2,8 @@ import * as zlib from 'zlib';
|
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
import { isExportRetryable, parseRetryAfterToMills, } from '../is-export-retryable';
|
|
4
4
|
import { OTLPExporterError } from '../types';
|
|
5
|
+
import { VERSION } from '../version';
|
|
6
|
+
const DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;
|
|
5
7
|
/**
|
|
6
8
|
* Sends data using http
|
|
7
9
|
* @param request
|
|
@@ -13,15 +15,20 @@ import { OTLPExporterError } from '../types';
|
|
|
13
15
|
*/
|
|
14
16
|
export function sendWithHttp(request, params, agent, data, onDone, timeoutMillis) {
|
|
15
17
|
const parsedUrl = new URL(params.url);
|
|
18
|
+
const headers = { ...params.headers() };
|
|
19
|
+
if (params.userAgent) {
|
|
20
|
+
headers['User-Agent'] = `${params.userAgent} ${DEFAULT_USER_AGENT}`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
headers['User-Agent'] = DEFAULT_USER_AGENT;
|
|
24
|
+
}
|
|
16
25
|
const options = {
|
|
17
26
|
hostname: parsedUrl.hostname,
|
|
18
27
|
port: parsedUrl.port,
|
|
19
28
|
path: parsedUrl.pathname,
|
|
20
29
|
method: 'POST',
|
|
21
|
-
headers
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
agent: agent,
|
|
30
|
+
headers,
|
|
31
|
+
agent,
|
|
25
32
|
};
|
|
26
33
|
const req = request(options, (res) => {
|
|
27
34
|
const responseData = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,kBAAkB,GAAG,iCAAiC,OAAO,EAAE,CAAC;AAEtE;;;;;;;;GAQG;AACH,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U;aACpB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;aACvB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACzB;IAED,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpB,OAAO,QAAQ,CAAC;AAClB,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 type * as http from 'http';\nimport type * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { HttpRequestParameters } from './http-transport-types';\nimport { ExportResponse } from '../export-response';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { OTLPExporterError } from '../types';\nimport { VERSION } from '../version';\n\nconst DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;\n\n/**\n * Sends data using http\n * @param request\n * @param params\n * @param agent\n * @param data\n * @param onDone\n * @param timeoutMillis\n */\nexport function sendWithHttp(\n request: typeof https.request | typeof http.request,\n params: HttpRequestParameters,\n agent: http.Agent | https.Agent,\n data: Uint8Array,\n onDone: (response: ExportResponse) => void,\n timeoutMillis: number\n): void {\n const parsedUrl = new URL(params.url);\n\n const headers = { ...params.headers() };\n if (params.userAgent) {\n headers['User-Agent'] = `${params.userAgent} ${DEFAULT_USER_AGENT}`;\n } else {\n headers['User-Agent'] = DEFAULT_USER_AGENT;\n }\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers,\n agent,\n };\n\n const req = request(options, (res: http.IncomingMessage) => {\n const responseData: Buffer[] = [];\n res.on('data', chunk => responseData.push(chunk));\n\n res.on('end', () => {\n if (res.statusCode && res.statusCode < 299) {\n onDone({\n status: 'success',\n data: Buffer.concat(responseData),\n });\n } else if (res.statusCode && isExportRetryable(res.statusCode)) {\n onDone({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n Buffer.concat(responseData).toString()\n );\n onDone({\n status: 'failure',\n error,\n });\n }\n });\n });\n\n req.setTimeout(timeoutMillis, () => {\n req.destroy();\n onDone({\n status: 'failure',\n error: new Error('Request Timeout'),\n });\n });\n\n req.on('error', (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n\n compressAndSend(req, params.compression, data, (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n}\n\nexport function compressAndSend(\n req: http.ClientRequest,\n compression: 'gzip' | 'none',\n data: Uint8Array,\n onError: (error: Error) => void\n) {\n let dataStream = readableFromUint8Array(data);\n\n if (compression === 'gzip') {\n req.setHeader('Content-Encoding', 'gzip');\n dataStream = dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError);\n }\n\n dataStream.pipe(req).on('error', onError);\n}\n\nfunction readableFromUint8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n"]}
|
package/build/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.207.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
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,SAAS,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,SAAS,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.207.0';\n"]}
|
|
@@ -37,6 +37,7 @@ export function convertLegacyHttpOptions(config, signalIdentifier, signalResourc
|
|
|
37
37
|
timeoutMillis: config.timeoutMillis,
|
|
38
38
|
compression: config.compression,
|
|
39
39
|
agentFactory: convertLegacyAgentOptions(config),
|
|
40
|
+
userAgent: config.userAgent,
|
|
40
41
|
}, getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
41
42
|
}
|
|
42
43
|
//# sourceMappingURL=convert-legacy-node-http-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,gCAAgC,EAEhC,0CAA0C,GAE3C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,uCAAuC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,SAAS,yBAAyB,CAChC,MAAkC;IAElC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE;QACjD,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACrC,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE;QAC5B,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;KACrD;IAED,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,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,0CAA0C,CAC/C;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;
|
|
1
|
+
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,gCAAgC,EAEhC,0CAA0C,GAE3C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,uCAAuC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,SAAS,yBAAyB,CAChC,MAAkC;IAElC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE;QACjD,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACrC,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE;QAC5B,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;KACrD;IAED,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,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,0CAA0C,CAC/C;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;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,EACD,uCAAuC,CACrC,gBAAgB,EAChB,kBAAkB,CACnB,EACD,gCAAgC,CAAC,eAAe,EAAE,kBAAkB,CAAC,CACtE,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 { diag } from '@opentelemetry/api';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\nimport {\n getNodeHttpConfigurationDefaults,\n HttpAgentFactory,\n mergeOtlpNodeHttpConfigurationWithDefaults,\n OtlpNodeHttpConfiguration,\n} from './otlp-node-http-configuration';\nimport { httpAgentFactoryFromOptions } from '../index-node-http';\nimport { getNodeHttpConfigurationFromEnvironment } from './otlp-node-http-env-configuration';\n\nfunction convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): HttpAgentFactory | undefined {\n if (typeof config.httpAgentOptions === 'function') {\n return config.httpAgentOptions;\n }\n\n let legacy = config.httpAgentOptions;\n if (config.keepAlive != null) {\n legacy = { keepAlive: config.keepAlive, ...legacy };\n }\n\n if (legacy != null) {\n return httpAgentFactoryFromOptions(legacy);\n } else {\n return undefined;\n }\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): OtlpNodeHttpConfiguration {\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 mergeOtlpNodeHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: wrapStaticHeadersInFunction(config.headers),\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n agentFactory: convertLegacyAgentOptions(config),\n userAgent: config.userAgent,\n },\n getNodeHttpConfigurationFromEnvironment(\n signalIdentifier,\n signalResourcePath\n ),\n getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}
|
|
@@ -33,6 +33,12 @@ export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
|
|
|
33
33
|
* }
|
|
34
34
|
*/
|
|
35
35
|
httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;
|
|
36
|
+
/**
|
|
37
|
+
* User agent header string to be prepended to the exporter's default value.
|
|
38
|
+
* Availablie since v1.49.0 of the spec.
|
|
39
|
+
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
|
40
|
+
*/
|
|
41
|
+
userAgent?: string;
|
|
36
42
|
}
|
|
37
43
|
export declare enum CompressionAlgorithm {
|
|
38
44
|
NONE = "none",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA8CH,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 type { OTLPExporterConfigBase } from './legacy-base-configuration';\nimport type { HttpAgentFactory } from './otlp-node-http-configuration';\n\n/**\n * Collector Exporter node base config\n */\nexport interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {\n keepAlive?: boolean;\n compression?: CompressionAlgorithm;\n /**\n * Custom HTTP agent options or a factory function for creating agents.\n *\n * @remarks\n * Prefer using `http.AgentOptions` or `https.AgentOptions` over a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n *\n * @example <caption> Using agent options directly: </caption>\n * httpAgentOptions: {\n * keepAlive: true,\n * maxSockets: 10\n * }\n *\n * @example <caption> Using a factory with dynamic import: </caption>\n * httpAgentOptions: async (protocol) => {\n * const module = protocol === 'http:' ? await import('http') : await import('https');\n * return new module.Agent({ keepAlive: true });\n * }\n */\n httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;\n /**\n * User agent header string to be prepended to the exporter's default value.\n * Availablie since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip',\n}\n"]}
|
|
@@ -16,6 +16,12 @@ export interface OtlpNodeHttpConfiguration extends OtlpHttpConfiguration {
|
|
|
16
16
|
* module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
|
|
17
17
|
*/
|
|
18
18
|
agentFactory: HttpAgentFactory;
|
|
19
|
+
/**
|
|
20
|
+
* User agent header string to be appended to the exporter's value as a prefix.
|
|
21
|
+
* Availablie since v1.49.0 of the spec.
|
|
22
|
+
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
|
23
|
+
*/
|
|
24
|
+
userAgent?: string;
|
|
19
25
|
}
|
|
20
26
|
export declare function httpAgentFactoryFromOptions(options: http.AgentOptions | https.AgentOptions): HttpAgentFactory;
|
|
21
27
|
/**
|
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
import { getHttpConfigurationDefaults, mergeOtlpHttpConfigurationWithDefaults, } from './otlp-http-configuration';
|
|
17
17
|
export function httpAgentFactoryFromOptions(options) {
|
|
18
18
|
return async (protocol) => {
|
|
19
|
-
const
|
|
19
|
+
const isInsecure = protocol === 'http:';
|
|
20
|
+
const module = isInsecure ? import('http') : import('https');
|
|
20
21
|
const { Agent } = await module;
|
|
22
|
+
if (isInsecure) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- these props should not be used in agent options
|
|
24
|
+
const { ca, cert, key, ...insecureOptions } = options;
|
|
25
|
+
return new Agent(insecureOptions);
|
|
26
|
+
}
|
|
21
27
|
return new Agent(options);
|
|
22
28
|
};
|
|
23
29
|
}
|
|
@@ -32,6 +38,7 @@ export function mergeOtlpNodeHttpConfigurationWithDefaults(userProvidedConfigura
|
|
|
32
38
|
agentFactory: userProvidedConfiguration.agentFactory ??
|
|
33
39
|
fallbackConfiguration.agentFactory ??
|
|
34
40
|
defaultConfiguration.agentFactory,
|
|
41
|
+
userAgent: userProvidedConfiguration.userAgent,
|
|
35
42
|
};
|
|
36
43
|
}
|
|
37
44
|
export function getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-node-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GAEvC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-node-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GAEvC,MAAM,2BAA2B,CAAC;AA8BnC,MAAM,UAAU,2BAA2B,CACzC,OAA+C;IAE/C,OAAO,KAAK,EAAC,QAAQ,EAAC,EAAE;QACtB,MAAM,UAAU,GAAG,QAAQ,KAAK,OAAO,CAAC;QACxC,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC;QAE/B,IAAI,UAAU,EAAE;YACd,gHAAgH;YAChH,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe,EAAE,GACzC,OAA6B,CAAC;YAChC,OAAO,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;SACnC;QACD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CACxD,yBAA6D,EAC7D,qBAAyD,EACzD,oBAA+C;IAE/C,OAAO;QACL,GAAG,sCAAsC,CACvC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB;QACD,YAAY,EACV,yBAAyB,CAAC,YAAY;YACtC,qBAAqB,CAAC,YAAY;YAClC,oBAAoB,CAAC,YAAY;QACnC,SAAS,EAAE,yBAAyB,CAAC,SAAS;KAC/C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,eAAuC,EACvC,kBAA0B;IAE1B,OAAO;QACL,GAAG,4BAA4B,CAAC,eAAe,EAAE,kBAAkB,CAAC;QACpE,YAAY,EAAE,2BAA2B,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KAC/D,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';\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\nexport type HttpAgentFactory = (\n protocol: string\n) => http.Agent | https.Agent | Promise<http.Agent> | Promise<https.Agent>;\n\nexport interface OtlpNodeHttpConfiguration extends OtlpHttpConfiguration {\n /**\n * Factory function for creating agents.\n *\n * @remarks\n * Prefer using {@link httpAgentFactoryFromOptions} over manually writing a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n */\n agentFactory: HttpAgentFactory;\n /**\n * User agent header string to be appended to the exporter's value as a prefix.\n * Availablie since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport function httpAgentFactoryFromOptions(\n options: http.AgentOptions | https.AgentOptions\n): HttpAgentFactory {\n return async protocol => {\n const isInsecure = protocol === 'http:';\n const module = isInsecure ? import('http') : import('https');\n const { Agent } = await module;\n\n if (isInsecure) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- these props should not be used in agent options\n const { ca, cert, key, ...insecureOptions } =\n options as https.AgentOptions;\n return new Agent(insecureOptions);\n }\n return new Agent(options);\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 mergeOtlpNodeHttpConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpNodeHttpConfiguration>,\n fallbackConfiguration: Partial<OtlpNodeHttpConfiguration>,\n defaultConfiguration: OtlpNodeHttpConfiguration\n): OtlpNodeHttpConfiguration {\n return {\n ...mergeOtlpHttpConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n agentFactory:\n userProvidedConfiguration.agentFactory ??\n fallbackConfiguration.agentFactory ??\n defaultConfiguration.agentFactory,\n userAgent: userProvidedConfiguration.userAgent,\n };\n}\n\nexport function getNodeHttpConfigurationDefaults(\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n): OtlpNodeHttpConfiguration {\n return {\n ...getHttpConfigurationDefaults(requiredHeaders, signalResourcePath),\n agentFactory: httpAgentFactoryFromOptions({ keepAlive: true }),\n };\n}\n"]}
|
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
16
18
|
import { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';
|
|
17
19
|
import { diag } from '@opentelemetry/api';
|
|
18
20
|
import { getSharedConfigurationFromEnvironment } from './shared-env-configuration';
|
|
19
21
|
import { wrapStaticHeadersInFunction } from './shared-configuration';
|
|
22
|
+
import { httpAgentFactoryFromOptions, } from './otlp-node-http-configuration';
|
|
20
23
|
function getStaticHeadersFromEnv(signalIdentifier) {
|
|
21
24
|
const signalSpecificRawHeaders = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`);
|
|
22
25
|
const nonSignalSpecificRawHeaders = getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS');
|
|
@@ -78,6 +81,32 @@ function getSpecificUrlFromEnv(signalIdentifier) {
|
|
|
78
81
|
}
|
|
79
82
|
return appendRootPathToUrlIfNeeded(envUrl);
|
|
80
83
|
}
|
|
84
|
+
function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
|
|
85
|
+
const signalSpecificPath = getStringFromEnv(signalSpecificEnvVar);
|
|
86
|
+
const nonSignalSpecificPath = getStringFromEnv(nonSignalSpecificEnvVar);
|
|
87
|
+
const filePath = signalSpecificPath ?? nonSignalSpecificPath;
|
|
88
|
+
if (filePath != null) {
|
|
89
|
+
try {
|
|
90
|
+
return fs.readFileSync(path.resolve(process.cwd(), filePath));
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
diag.warn(warningMessage);
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function getClientCertificateFromEnv(signalIdentifier) {
|
|
102
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE', 'Failed to read client certificate chain file');
|
|
103
|
+
}
|
|
104
|
+
function getClientKeyFromEnv(signalIdentifier) {
|
|
105
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, 'OTEL_EXPORTER_OTLP_CLIENT_KEY', 'Failed to read client certificate private key file');
|
|
106
|
+
}
|
|
107
|
+
function getRootCertificateFromEnv(signalIdentifier) {
|
|
108
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CERTIFICATE', 'Failed to read root certificate file');
|
|
109
|
+
}
|
|
81
110
|
/**
|
|
82
111
|
* Reads and returns configuration from the environment
|
|
83
112
|
*
|
|
@@ -90,6 +119,12 @@ export function getNodeHttpConfigurationFromEnvironment(signalIdentifier, signal
|
|
|
90
119
|
url: getSpecificUrlFromEnv(signalIdentifier) ??
|
|
91
120
|
getNonSpecificUrlFromEnv(signalResourcePath),
|
|
92
121
|
headers: wrapStaticHeadersInFunction(getStaticHeadersFromEnv(signalIdentifier)),
|
|
122
|
+
agentFactory: httpAgentFactoryFromOptions({
|
|
123
|
+
keepAlive: true,
|
|
124
|
+
ca: getRootCertificateFromEnv(signalIdentifier),
|
|
125
|
+
cert: getClientCertificateFromEnv(signalIdentifier),
|
|
126
|
+
key: getClientKeyFromEnv(signalIdentifier),
|
|
127
|
+
}),
|
|
93
128
|
};
|
|
94
129
|
}
|
|
95
130
|
//# sourceMappingURL=otlp-node-http-env-configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-node-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-env-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"otlp-node-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-env-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAEL,2BAA2B,GAC5B,MAAM,gCAAgC,CAAC;AAExC,SAAS,uBAAuB,CAC9B,gBAAwB;IAExB,MAAM,wBAAwB,GAAG,gBAAgB,CAC/C,sBAAsB,gBAAgB,UAAU,CACjD,CAAC;IACF,MAAM,2BAA2B,GAAG,gBAAgB,CAClD,4BAA4B,CAC7B,CAAC;IAEF,MAAM,qBAAqB,GAAG,uBAAuB,CACnD,wBAAwB,CACzB,CAAC;IACF,MAAM,wBAAwB,GAAG,uBAAuB,CACtD,2BAA2B,CAC5B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C/B,oDAAoD,CACrD,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAChC,gBAAwB;IAExB,OAAO,eAAe,CACpB,sBAAsB,gBAAgB,cAAc,EACpD,gCAAgC,EAChC,sCAAsC,CACvC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uCAAuC,CACrD,gBAAwB,EACxB,kBAA0B;IAE1B,OAAO;QACL,GAAG,qCAAqC,CAAC,gBAAgB,CAAC;QAC1D,GAAG,EACD,qBAAqB,CAAC,gBAAgB,CAAC;YACvC,wBAAwB,CAAC,kBAAkB,CAAC;QAC9C,OAAO,EAAE,2BAA2B,CAClC,uBAAuB,CAAC,gBAAgB,CAAC,CAC1C;QACD,YAAY,EAAE,2BAA2B,CAAC;YACxC,SAAS,EAAE,IAAI;YACf,EAAE,EAAE,yBAAyB,CAAC,gBAAgB,CAAC;YAC/C,IAAI,EAAE,2BAA2B,CAAC,gBAAgB,CAAC;YACnD,GAAG,EAAE,mBAAmB,CAAC,gBAAgB,CAAC;SAC3C,CAAC;KACH,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 * as fs from 'fs';\nimport * as path from 'path';\nimport { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport { diag } from '@opentelemetry/api';\nimport { getSharedConfigurationFromEnvironment } from './shared-env-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\nimport {\n OtlpNodeHttpConfiguration,\n httpAgentFactoryFromOptions,\n} from './otlp-node-http-configuration';\n\nfunction getStaticHeadersFromEnv(\n signalIdentifier: string\n): Record<string, string> | undefined {\n const signalSpecificRawHeaders = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`\n );\n const nonSignalSpecificRawHeaders = getStringFromEnv(\n 'OTEL_EXPORTER_OTLP_HEADERS'\n );\n\n const signalSpecificHeaders = parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = 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 parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders),\n 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 = getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT');\n if (envUrl === undefined) {\n return undefined;\n }\n return appendResourcePathToUrl(envUrl, signalResourcePath);\n}\n\nfunction getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {\n const envUrl = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`\n );\n if (envUrl === undefined) {\n return undefined;\n }\n return appendRootPathToUrlIfNeeded(envUrl);\n}\n\nfunction readFileFromEnv(\n signalSpecificEnvVar: string,\n nonSignalSpecificEnvVar: string,\n warningMessage: string\n): Buffer | undefined {\n const signalSpecificPath = getStringFromEnv(signalSpecificEnvVar);\n const nonSignalSpecificPath = getStringFromEnv(nonSignalSpecificEnvVar);\n const filePath = signalSpecificPath ?? nonSignalSpecificPath;\n\n if (filePath != null) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), filePath));\n } catch {\n diag.warn(warningMessage);\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction getClientCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE',\n 'Failed to read client certificate chain file'\n );\n}\n\nfunction getClientKeyFromEnv(signalIdentifier: string): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`,\n 'OTEL_EXPORTER_OTLP_CLIENT_KEY',\n 'Failed to read client certificate private key file'\n );\n}\n\nfunction getRootCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CERTIFICATE',\n 'Failed to read root certificate file'\n );\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 getNodeHttpConfigurationFromEnvironment(\n signalIdentifier: string,\n signalResourcePath: string\n): Partial<OtlpNodeHttpConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n url:\n getSpecificUrlFromEnv(signalIdentifier) ??\n getNonSpecificUrlFromEnv(signalResourcePath),\n headers: wrapStaticHeadersInFunction(\n getStaticHeadersFromEnv(signalIdentifier)\n ),\n agentFactory: httpAgentFactoryFromOptions({\n keepAlive: true,\n ca: getRootCertificateFromEnv(signalIdentifier),\n cert: getClientCertificateFromEnv(signalIdentifier),\n key: getClientKeyFromEnv(signalIdentifier),\n }),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface HttpRequestParameters {\n url: string;\n headers: () => Record<string, string>;\n compression: 'gzip' | 'none';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface HttpRequestParameters {\n url: string;\n headers: () => Record<string, string>;\n compression: 'gzip' | 'none';\n userAgent?: string;\n}\n"]}
|
|
@@ -2,6 +2,8 @@ import * as zlib from 'zlib';
|
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
import { isExportRetryable, parseRetryAfterToMills, } from '../is-export-retryable';
|
|
4
4
|
import { OTLPExporterError } from '../types';
|
|
5
|
+
import { VERSION } from '../version';
|
|
6
|
+
const DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;
|
|
5
7
|
/**
|
|
6
8
|
* Sends data using http
|
|
7
9
|
* @param request
|
|
@@ -13,15 +15,20 @@ import { OTLPExporterError } from '../types';
|
|
|
13
15
|
*/
|
|
14
16
|
export function sendWithHttp(request, params, agent, data, onDone, timeoutMillis) {
|
|
15
17
|
const parsedUrl = new URL(params.url);
|
|
18
|
+
const headers = { ...params.headers() };
|
|
19
|
+
if (params.userAgent) {
|
|
20
|
+
headers['User-Agent'] = `${params.userAgent} ${DEFAULT_USER_AGENT}`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
headers['User-Agent'] = DEFAULT_USER_AGENT;
|
|
24
|
+
}
|
|
16
25
|
const options = {
|
|
17
26
|
hostname: parsedUrl.hostname,
|
|
18
27
|
port: parsedUrl.port,
|
|
19
28
|
path: parsedUrl.pathname,
|
|
20
29
|
method: 'POST',
|
|
21
|
-
headers
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
agent: agent,
|
|
30
|
+
headers,
|
|
31
|
+
agent,
|
|
25
32
|
};
|
|
26
33
|
const req = request(options, (res) => {
|
|
27
34
|
const responseData = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,IAAI,MAAM,MAAM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GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QAC/B,MAAM,CAAC;YACL,MAAM,EAAE,SAAS;YACjB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,KAAY,EAAE,EAAE;QAC9D,MAAM,CAAC;YACL,MAAM,EAAE,SAAS;YACjB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,GAAuB,EACvB,WAA4B,EAC5B,IAAgB,EAChB,OAA+B;IAE/B,IAAI,UAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE9C,IAAI,WAAW,KAAK,MAAM,EAAE;QAC1B,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC1C,UAAU,GAAG,UAAU;aACpB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;aACvB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACzB;IAED,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpB,OAAO,QAAQ,CAAC;AAClB,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 type * as http from 'http';\nimport type * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { HttpRequestParameters } from './http-transport-types';\nimport { ExportResponse } from '../export-response';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { OTLPExporterError } from '../types';\nimport { VERSION } from '../version';\n\nconst DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;\n\n/**\n * Sends data using http\n * @param request\n * @param params\n * @param agent\n * @param data\n * @param onDone\n * @param timeoutMillis\n */\nexport function sendWithHttp(\n request: typeof https.request | typeof http.request,\n params: HttpRequestParameters,\n agent: http.Agent | https.Agent,\n data: Uint8Array,\n onDone: (response: ExportResponse) => void,\n timeoutMillis: number\n): void {\n const parsedUrl = new URL(params.url);\n\n const headers = { ...params.headers() };\n if (params.userAgent) {\n headers['User-Agent'] = `${params.userAgent} ${DEFAULT_USER_AGENT}`;\n } else {\n headers['User-Agent'] = DEFAULT_USER_AGENT;\n }\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers,\n agent,\n };\n\n const req = request(options, (res: http.IncomingMessage) => {\n const responseData: Buffer[] = [];\n res.on('data', chunk => responseData.push(chunk));\n\n res.on('end', () => {\n if (res.statusCode && res.statusCode < 299) {\n onDone({\n status: 'success',\n data: Buffer.concat(responseData),\n });\n } else if (res.statusCode && isExportRetryable(res.statusCode)) {\n onDone({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n Buffer.concat(responseData).toString()\n );\n onDone({\n status: 'failure',\n error,\n });\n }\n });\n });\n\n req.setTimeout(timeoutMillis, () => {\n req.destroy();\n onDone({\n status: 'failure',\n error: new Error('Request Timeout'),\n });\n });\n\n req.on('error', (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n\n compressAndSend(req, params.compression, data, (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n}\n\nexport function compressAndSend(\n req: http.ClientRequest,\n compression: 'gzip' | 'none',\n data: Uint8Array,\n onError: (error: Error) => void\n) {\n let dataStream = readableFromUint8Array(data);\n\n if (compression === 'gzip') {\n req.setHeader('Content-Encoding', 'gzip');\n dataStream = dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError);\n }\n\n dataStream.pipe(req).on('error', onError);\n}\n\nfunction readableFromUint8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.207.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,SAAS,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,SAAS,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.207.0';\n"]}
|
|
@@ -40,6 +40,7 @@ function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath,
|
|
|
40
40
|
timeoutMillis: config.timeoutMillis,
|
|
41
41
|
compression: config.compression,
|
|
42
42
|
agentFactory: convertLegacyAgentOptions(config),
|
|
43
|
+
userAgent: config.userAgent,
|
|
43
44
|
}, (0, otlp_node_http_env_configuration_1.getNodeHttpConfigurationFromEnvironment)(signalIdentifier, signalResourcePath), (0, otlp_node_http_configuration_1.getNodeHttpConfigurationDefaults)(requiredHeaders, signalResourcePath));
|
|
44
45
|
}
|
|
45
46
|
exports.convertLegacyHttpOptions = convertLegacyHttpOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":";;;AAgBA,4CAA0C;AAC1C,iEAAqE;AACrE,iFAKwC;AACxC,wDAAiE;AACjE,yFAA6F;AAE7F,SAAS,yBAAyB,CAChC,MAAkC;IAElC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE;QACjD,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACrC,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE;QAC5B,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;KACrD;IAED,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,IAAA,6CAA2B,EAAC,MAAM,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,MAAkC,EAClC,gBAAwB,EACxB,kBAA0B,EAC1B,eAAuC;IAEvC,8DAA8D;IAC9D,IAAK,MAAc,CAAC,QAAQ,EAAE;QAC5B,UAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;KACrD;IAED,OAAO,IAAA,yEAA0C,EAC/C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,IAAA,kDAA2B,EAAC,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;
|
|
1
|
+
{"version":3,"file":"convert-legacy-node-http-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-node-http-options.ts"],"names":[],"mappings":";;;AAgBA,4CAA0C;AAC1C,iEAAqE;AACrE,iFAKwC;AACxC,wDAAiE;AACjE,yFAA6F;AAE7F,SAAS,yBAAyB,CAChC,MAAkC;IAElC,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE;QACjD,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACrC,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE;QAC5B,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;KACrD;IAED,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,IAAA,6CAA2B,EAAC,MAAM,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,MAAkC,EAClC,gBAAwB,EACxB,kBAA0B,EAC1B,eAAuC;IAEvC,8DAA8D;IAC9D,IAAK,MAAc,CAAC,QAAQ,EAAE;QAC5B,UAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;KACrD;IAED,OAAO,IAAA,yEAA0C,EAC/C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,IAAA,kDAA2B,EAAC,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;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,EACD,IAAA,0EAAuC,EACrC,gBAAgB,EAChB,kBAAkB,CACnB,EACD,IAAA,+DAAgC,EAAC,eAAe,EAAE,kBAAkB,CAAC,CACtE,CAAC;AACJ,CAAC;AA3BD,4DA2BC","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 { diag } from '@opentelemetry/api';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\nimport {\n getNodeHttpConfigurationDefaults,\n HttpAgentFactory,\n mergeOtlpNodeHttpConfigurationWithDefaults,\n OtlpNodeHttpConfiguration,\n} from './otlp-node-http-configuration';\nimport { httpAgentFactoryFromOptions } from '../index-node-http';\nimport { getNodeHttpConfigurationFromEnvironment } from './otlp-node-http-env-configuration';\n\nfunction convertLegacyAgentOptions(\n config: OTLPExporterNodeConfigBase\n): HttpAgentFactory | undefined {\n if (typeof config.httpAgentOptions === 'function') {\n return config.httpAgentOptions;\n }\n\n let legacy = config.httpAgentOptions;\n if (config.keepAlive != null) {\n legacy = { keepAlive: config.keepAlive, ...legacy };\n }\n\n if (legacy != null) {\n return httpAgentFactoryFromOptions(legacy);\n } else {\n return undefined;\n }\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): OtlpNodeHttpConfiguration {\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 mergeOtlpNodeHttpConfigurationWithDefaults(\n {\n url: config.url,\n headers: wrapStaticHeadersInFunction(config.headers),\n concurrencyLimit: config.concurrencyLimit,\n timeoutMillis: config.timeoutMillis,\n compression: config.compression,\n agentFactory: convertLegacyAgentOptions(config),\n userAgent: config.userAgent,\n },\n getNodeHttpConfigurationFromEnvironment(\n signalIdentifier,\n signalResourcePath\n ),\n getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath)\n );\n}\n"]}
|
|
@@ -33,6 +33,12 @@ export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
|
|
|
33
33
|
* }
|
|
34
34
|
*/
|
|
35
35
|
httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;
|
|
36
|
+
/**
|
|
37
|
+
* User agent header string to be prepended to the exporter's default value.
|
|
38
|
+
* Availablie since v1.49.0 of the spec.
|
|
39
|
+
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
|
40
|
+
*/
|
|
41
|
+
userAgent?: string;
|
|
36
42
|
}
|
|
37
43
|
export declare enum CompressionAlgorithm {
|
|
38
44
|
NONE = "none",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"legacy-node-configuration.js","sourceRoot":"","sources":["../../../src/configuration/legacy-node-configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA8CH,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,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 type { OTLPExporterConfigBase } from './legacy-base-configuration';\nimport type { HttpAgentFactory } from './otlp-node-http-configuration';\n\n/**\n * Collector Exporter node base config\n */\nexport interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {\n keepAlive?: boolean;\n compression?: CompressionAlgorithm;\n /**\n * Custom HTTP agent options or a factory function for creating agents.\n *\n * @remarks\n * Prefer using `http.AgentOptions` or `https.AgentOptions` over a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n *\n * @example <caption> Using agent options directly: </caption>\n * httpAgentOptions: {\n * keepAlive: true,\n * maxSockets: 10\n * }\n *\n * @example <caption> Using a factory with dynamic import: </caption>\n * httpAgentOptions: async (protocol) => {\n * const module = protocol === 'http:' ? await import('http') : await import('https');\n * return new module.Agent({ keepAlive: true });\n * }\n */\n httpAgentOptions?: http.AgentOptions | https.AgentOptions | HttpAgentFactory;\n /**\n * User agent header string to be prepended to the exporter's default value.\n * Availablie since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip',\n}\n"]}
|
|
@@ -16,6 +16,12 @@ export interface OtlpNodeHttpConfiguration extends OtlpHttpConfiguration {
|
|
|
16
16
|
* module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
|
|
17
17
|
*/
|
|
18
18
|
agentFactory: HttpAgentFactory;
|
|
19
|
+
/**
|
|
20
|
+
* User agent header string to be appended to the exporter's value as a prefix.
|
|
21
|
+
* Availablie since v1.49.0 of the spec.
|
|
22
|
+
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
|
23
|
+
*/
|
|
24
|
+
userAgent?: string;
|
|
19
25
|
}
|
|
20
26
|
export declare function httpAgentFactoryFromOptions(options: http.AgentOptions | https.AgentOptions): HttpAgentFactory;
|
|
21
27
|
/**
|
|
@@ -19,8 +19,14 @@ exports.getNodeHttpConfigurationDefaults = exports.mergeOtlpNodeHttpConfiguratio
|
|
|
19
19
|
const otlp_http_configuration_1 = require("./otlp-http-configuration");
|
|
20
20
|
function httpAgentFactoryFromOptions(options) {
|
|
21
21
|
return async (protocol) => {
|
|
22
|
-
const
|
|
22
|
+
const isInsecure = protocol === 'http:';
|
|
23
|
+
const module = isInsecure ? import('http') : import('https');
|
|
23
24
|
const { Agent } = await module;
|
|
25
|
+
if (isInsecure) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- these props should not be used in agent options
|
|
27
|
+
const { ca, cert, key, ...insecureOptions } = options;
|
|
28
|
+
return new Agent(insecureOptions);
|
|
29
|
+
}
|
|
24
30
|
return new Agent(options);
|
|
25
31
|
};
|
|
26
32
|
}
|
|
@@ -36,6 +42,7 @@ function mergeOtlpNodeHttpConfigurationWithDefaults(userProvidedConfiguration, f
|
|
|
36
42
|
agentFactory: userProvidedConfiguration.agentFactory ??
|
|
37
43
|
fallbackConfiguration.agentFactory ??
|
|
38
44
|
defaultConfiguration.agentFactory,
|
|
45
|
+
userAgent: userProvidedConfiguration.userAgent,
|
|
39
46
|
};
|
|
40
47
|
}
|
|
41
48
|
exports.mergeOtlpNodeHttpConfigurationWithDefaults = mergeOtlpNodeHttpConfigurationWithDefaults;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-node-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-configuration.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,uEAImC;
|
|
1
|
+
{"version":3,"file":"otlp-node-http-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-configuration.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,uEAImC;AA8BnC,SAAgB,2BAA2B,CACzC,OAA+C;IAE/C,OAAO,KAAK,EAAC,QAAQ,EAAC,EAAE;QACtB,MAAM,UAAU,GAAG,QAAQ,KAAK,OAAO,CAAC;QACxC,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC;QAE/B,IAAI,UAAU,EAAE;YACd,gHAAgH;YAChH,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe,EAAE,GACzC,OAA6B,CAAC;YAChC,OAAO,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;SACnC;QACD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC;AAhBD,kEAgBC;AAED;;;;GAIG;AACH,SAAgB,0CAA0C,CACxD,yBAA6D,EAC7D,qBAAyD,EACzD,oBAA+C;IAE/C,OAAO;QACL,GAAG,IAAA,gEAAsC,EACvC,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,CACrB;QACD,YAAY,EACV,yBAAyB,CAAC,YAAY;YACtC,qBAAqB,CAAC,YAAY;YAClC,oBAAoB,CAAC,YAAY;QACnC,SAAS,EAAE,yBAAyB,CAAC,SAAS;KAC/C,CAAC;AACJ,CAAC;AAjBD,gGAiBC;AAED,SAAgB,gCAAgC,CAC9C,eAAuC,EACvC,kBAA0B;IAE1B,OAAO;QACL,GAAG,IAAA,sDAA4B,EAAC,eAAe,EAAE,kBAAkB,CAAC;QACpE,YAAY,EAAE,2BAA2B,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AARD,4EAQC","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';\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\nexport type HttpAgentFactory = (\n protocol: string\n) => http.Agent | https.Agent | Promise<http.Agent> | Promise<https.Agent>;\n\nexport interface OtlpNodeHttpConfiguration extends OtlpHttpConfiguration {\n /**\n * Factory function for creating agents.\n *\n * @remarks\n * Prefer using {@link httpAgentFactoryFromOptions} over manually writing a factory function wherever possible.\n * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`\n * statically at the top of the file**.\n * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`\n * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.\n */\n agentFactory: HttpAgentFactory;\n /**\n * User agent header string to be appended to the exporter's value as a prefix.\n * Availablie since v1.49.0 of the spec.\n * Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent\n */\n userAgent?: string;\n}\n\nexport function httpAgentFactoryFromOptions(\n options: http.AgentOptions | https.AgentOptions\n): HttpAgentFactory {\n return async protocol => {\n const isInsecure = protocol === 'http:';\n const module = isInsecure ? import('http') : import('https');\n const { Agent } = await module;\n\n if (isInsecure) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- these props should not be used in agent options\n const { ca, cert, key, ...insecureOptions } =\n options as https.AgentOptions;\n return new Agent(insecureOptions);\n }\n return new Agent(options);\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 mergeOtlpNodeHttpConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpNodeHttpConfiguration>,\n fallbackConfiguration: Partial<OtlpNodeHttpConfiguration>,\n defaultConfiguration: OtlpNodeHttpConfiguration\n): OtlpNodeHttpConfiguration {\n return {\n ...mergeOtlpHttpConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n agentFactory:\n userProvidedConfiguration.agentFactory ??\n fallbackConfiguration.agentFactory ??\n defaultConfiguration.agentFactory,\n userAgent: userProvidedConfiguration.userAgent,\n };\n}\n\nexport function getNodeHttpConfigurationDefaults(\n requiredHeaders: Record<string, string>,\n signalResourcePath: string\n): OtlpNodeHttpConfiguration {\n return {\n ...getHttpConfigurationDefaults(requiredHeaders, signalResourcePath),\n agentFactory: httpAgentFactoryFromOptions({ keepAlive: true }),\n };\n}\n"]}
|
|
@@ -16,10 +16,13 @@ exports.getNodeHttpConfigurationFromEnvironment = void 0;
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
const path = require("path");
|
|
19
21
|
const core_1 = require("@opentelemetry/core");
|
|
20
22
|
const api_1 = require("@opentelemetry/api");
|
|
21
23
|
const shared_env_configuration_1 = require("./shared-env-configuration");
|
|
22
24
|
const shared_configuration_1 = require("./shared-configuration");
|
|
25
|
+
const otlp_node_http_configuration_1 = require("./otlp-node-http-configuration");
|
|
23
26
|
function getStaticHeadersFromEnv(signalIdentifier) {
|
|
24
27
|
const signalSpecificRawHeaders = (0, core_1.getStringFromEnv)(`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`);
|
|
25
28
|
const nonSignalSpecificRawHeaders = (0, core_1.getStringFromEnv)('OTEL_EXPORTER_OTLP_HEADERS');
|
|
@@ -81,6 +84,32 @@ function getSpecificUrlFromEnv(signalIdentifier) {
|
|
|
81
84
|
}
|
|
82
85
|
return appendRootPathToUrlIfNeeded(envUrl);
|
|
83
86
|
}
|
|
87
|
+
function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
|
|
88
|
+
const signalSpecificPath = (0, core_1.getStringFromEnv)(signalSpecificEnvVar);
|
|
89
|
+
const nonSignalSpecificPath = (0, core_1.getStringFromEnv)(nonSignalSpecificEnvVar);
|
|
90
|
+
const filePath = signalSpecificPath ?? nonSignalSpecificPath;
|
|
91
|
+
if (filePath != null) {
|
|
92
|
+
try {
|
|
93
|
+
return fs.readFileSync(path.resolve(process.cwd(), filePath));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
api_1.diag.warn(warningMessage);
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function getClientCertificateFromEnv(signalIdentifier) {
|
|
105
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE', 'Failed to read client certificate chain file');
|
|
106
|
+
}
|
|
107
|
+
function getClientKeyFromEnv(signalIdentifier) {
|
|
108
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, 'OTEL_EXPORTER_OTLP_CLIENT_KEY', 'Failed to read client certificate private key file');
|
|
109
|
+
}
|
|
110
|
+
function getRootCertificateFromEnv(signalIdentifier) {
|
|
111
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CERTIFICATE', 'Failed to read root certificate file');
|
|
112
|
+
}
|
|
84
113
|
/**
|
|
85
114
|
* Reads and returns configuration from the environment
|
|
86
115
|
*
|
|
@@ -93,6 +122,12 @@ function getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourc
|
|
|
93
122
|
url: getSpecificUrlFromEnv(signalIdentifier) ??
|
|
94
123
|
getNonSpecificUrlFromEnv(signalResourcePath),
|
|
95
124
|
headers: (0, shared_configuration_1.wrapStaticHeadersInFunction)(getStaticHeadersFromEnv(signalIdentifier)),
|
|
125
|
+
agentFactory: (0, otlp_node_http_configuration_1.httpAgentFactoryFromOptions)({
|
|
126
|
+
keepAlive: true,
|
|
127
|
+
ca: getRootCertificateFromEnv(signalIdentifier),
|
|
128
|
+
cert: getClientCertificateFromEnv(signalIdentifier),
|
|
129
|
+
key: getClientKeyFromEnv(signalIdentifier),
|
|
130
|
+
}),
|
|
96
131
|
};
|
|
97
132
|
}
|
|
98
133
|
exports.getNodeHttpConfigurationFromEnvironment = getNodeHttpConfigurationFromEnvironment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-node-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-env-configuration.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,8CAAgF;AAChF,4CAA0C;AAC1C,yEAAmF;AACnF,iEAAqE;
|
|
1
|
+
{"version":3,"file":"otlp-node-http-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-node-http-env-configuration.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,yBAAyB;AACzB,6BAA6B;AAC7B,8CAAgF;AAChF,4CAA0C;AAC1C,yEAAmF;AACnF,iEAAqE;AACrE,iFAGwC;AAExC,SAAS,uBAAuB,CAC9B,gBAAwB;IAExB,MAAM,wBAAwB,GAAG,IAAA,uBAAgB,EAC/C,sBAAsB,gBAAgB,UAAU,CACjD,CAAC;IACF,MAAM,2BAA2B,GAAG,IAAA,uBAAgB,EAClD,4BAA4B,CAC7B,CAAC;IAEF,MAAM,qBAAqB,GAAG,IAAA,8BAAuB,EACnD,wBAAwB,CACzB,CAAC;IACF,MAAM,wBAAwB,GAAG,IAAA,8BAAuB,EACtD,2BAA2B,CAC5B,CAAC;IAEF,IACE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,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AAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAChC,gBAAwB;IAExB,OAAO,eAAe,CACpB,sBAAsB,gBAAgB,cAAc,EACpD,gCAAgC,EAChC,sCAAsC,CACvC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uCAAuC,CACrD,gBAAwB,EACxB,kBAA0B;IAE1B,OAAO;QACL,GAAG,IAAA,gEAAqC,EAAC,gBAAgB,CAAC;QAC1D,GAAG,EACD,qBAAqB,CAAC,gBAAgB,CAAC;YACvC,wBAAwB,CAAC,kBAAkB,CAAC;QAC9C,OAAO,EAAE,IAAA,kDAA2B,EAClC,uBAAuB,CAAC,gBAAgB,CAAC,CAC1C;QACD,YAAY,EAAE,IAAA,0DAA2B,EAAC;YACxC,SAAS,EAAE,IAAI;YACf,EAAE,EAAE,yBAAyB,CAAC,gBAAgB,CAAC;YAC/C,IAAI,EAAE,2BAA2B,CAAC,gBAAgB,CAAC;YACnD,GAAG,EAAE,mBAAmB,CAAC,gBAAgB,CAAC;SAC3C,CAAC;KACH,CAAC;AACJ,CAAC;AAnBD,0FAmBC","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 * as fs from 'fs';\nimport * as path from 'path';\nimport { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport { diag } from '@opentelemetry/api';\nimport { getSharedConfigurationFromEnvironment } from './shared-env-configuration';\nimport { wrapStaticHeadersInFunction } from './shared-configuration';\nimport {\n OtlpNodeHttpConfiguration,\n httpAgentFactoryFromOptions,\n} from './otlp-node-http-configuration';\n\nfunction getStaticHeadersFromEnv(\n signalIdentifier: string\n): Record<string, string> | undefined {\n const signalSpecificRawHeaders = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`\n );\n const nonSignalSpecificRawHeaders = getStringFromEnv(\n 'OTEL_EXPORTER_OTLP_HEADERS'\n );\n\n const signalSpecificHeaders = parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = 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 parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders),\n 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 = getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT');\n if (envUrl === undefined) {\n return undefined;\n }\n return appendResourcePathToUrl(envUrl, signalResourcePath);\n}\n\nfunction getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {\n const envUrl = getStringFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`\n );\n if (envUrl === undefined) {\n return undefined;\n }\n return appendRootPathToUrlIfNeeded(envUrl);\n}\n\nfunction readFileFromEnv(\n signalSpecificEnvVar: string,\n nonSignalSpecificEnvVar: string,\n warningMessage: string\n): Buffer | undefined {\n const signalSpecificPath = getStringFromEnv(signalSpecificEnvVar);\n const nonSignalSpecificPath = getStringFromEnv(nonSignalSpecificEnvVar);\n const filePath = signalSpecificPath ?? nonSignalSpecificPath;\n\n if (filePath != null) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), filePath));\n } catch {\n diag.warn(warningMessage);\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction getClientCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE',\n 'Failed to read client certificate chain file'\n );\n}\n\nfunction getClientKeyFromEnv(signalIdentifier: string): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`,\n 'OTEL_EXPORTER_OTLP_CLIENT_KEY',\n 'Failed to read client certificate private key file'\n );\n}\n\nfunction getRootCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CERTIFICATE',\n 'Failed to read root certificate file'\n );\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 getNodeHttpConfigurationFromEnvironment(\n signalIdentifier: string,\n signalResourcePath: string\n): Partial<OtlpNodeHttpConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n url:\n getSpecificUrlFromEnv(signalIdentifier) ??\n getNonSpecificUrlFromEnv(signalResourcePath),\n headers: wrapStaticHeadersInFunction(\n getStaticHeadersFromEnv(signalIdentifier)\n ),\n agentFactory: httpAgentFactoryFromOptions({\n keepAlive: true,\n ca: getRootCertificateFromEnv(signalIdentifier),\n cert: getClientCertificateFromEnv(signalIdentifier),\n key: getClientKeyFromEnv(signalIdentifier),\n }),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface HttpRequestParameters {\n url: string;\n headers: () => Record<string, string>;\n compression: 'gzip' | 'none';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http-transport-types.js","sourceRoot":"","sources":["../../../src/transport/http-transport-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface HttpRequestParameters {\n url: string;\n headers: () => Record<string, string>;\n compression: 'gzip' | 'none';\n userAgent?: string;\n}\n"]}
|
|
@@ -5,6 +5,8 @@ const zlib = require("zlib");
|
|
|
5
5
|
const stream_1 = require("stream");
|
|
6
6
|
const is_export_retryable_1 = require("../is-export-retryable");
|
|
7
7
|
const types_1 = require("../types");
|
|
8
|
+
const version_1 = require("../version");
|
|
9
|
+
const DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${version_1.VERSION}`;
|
|
8
10
|
/**
|
|
9
11
|
* Sends data using http
|
|
10
12
|
* @param request
|
|
@@ -16,15 +18,20 @@ const types_1 = require("../types");
|
|
|
16
18
|
*/
|
|
17
19
|
function sendWithHttp(request, params, agent, data, onDone, timeoutMillis) {
|
|
18
20
|
const parsedUrl = new URL(params.url);
|
|
21
|
+
const headers = { ...params.headers() };
|
|
22
|
+
if (params.userAgent) {
|
|
23
|
+
headers['User-Agent'] = `${params.userAgent} ${DEFAULT_USER_AGENT}`;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
headers['User-Agent'] = DEFAULT_USER_AGENT;
|
|
27
|
+
}
|
|
19
28
|
const options = {
|
|
20
29
|
hostname: parsedUrl.hostname,
|
|
21
30
|
port: parsedUrl.port,
|
|
22
31
|
path: parsedUrl.pathname,
|
|
23
32
|
method: 'POST',
|
|
24
|
-
headers
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
agent: agent,
|
|
33
|
+
headers,
|
|
34
|
+
agent,
|
|
28
35
|
};
|
|
29
36
|
const req = request(options, (res) => {
|
|
30
37
|
const responseData = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport-utils.js","sourceRoot":"","sources":["../../../src/transport/http-transport-utils.ts"],"names":[],"mappings":";;;AAiBA,6BAA6B;AAC7B,mCAAkC;AAGlC,gEAGgC;AACh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L,CAAC;AA5ED,oCA4EC;AAED,SAAgB,eAAe,CAC7B,GAAuB,EACvB,WAA4B,EAC5B,IAAgB,EAChB,OAA+B;IAE/B,IAAI,UAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE9C,IAAI,WAAW,KAAK,MAAM,EAAE;QAC1B,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC1C,UAAU,GAAG,UAAU;aACpB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;aACvB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACzB;IAED,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAjBD,0CAiBC;AAED,SAAS,sBAAsB,CAAC,IAAyB;IACvD,MAAM,QAAQ,GAAG,IAAI,iBAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpB,OAAO,QAAQ,CAAC;AAClB,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 type * as http from 'http';\nimport type * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { HttpRequestParameters } from './http-transport-types';\nimport { ExportResponse } from '../export-response';\nimport {\n isExportRetryable,\n parseRetryAfterToMills,\n} from '../is-export-retryable';\nimport { OTLPExporterError } from '../types';\nimport { VERSION } from '../version';\n\nconst DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;\n\n/**\n * Sends data using http\n * @param request\n * @param params\n * @param agent\n * @param data\n * @param onDone\n * @param timeoutMillis\n */\nexport function sendWithHttp(\n request: typeof https.request | typeof http.request,\n params: HttpRequestParameters,\n agent: http.Agent | https.Agent,\n data: Uint8Array,\n onDone: (response: ExportResponse) => void,\n timeoutMillis: number\n): void {\n const parsedUrl = new URL(params.url);\n\n const headers = { ...params.headers() };\n if (params.userAgent) {\n headers['User-Agent'] = `${params.userAgent} ${DEFAULT_USER_AGENT}`;\n } else {\n headers['User-Agent'] = DEFAULT_USER_AGENT;\n }\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers,\n agent,\n };\n\n const req = request(options, (res: http.IncomingMessage) => {\n const responseData: Buffer[] = [];\n res.on('data', chunk => responseData.push(chunk));\n\n res.on('end', () => {\n if (res.statusCode && res.statusCode < 299) {\n onDone({\n status: 'success',\n data: Buffer.concat(responseData),\n });\n } else if (res.statusCode && isExportRetryable(res.statusCode)) {\n onDone({\n status: 'retryable',\n retryInMillis: parseRetryAfterToMills(res.headers['retry-after']),\n });\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n Buffer.concat(responseData).toString()\n );\n onDone({\n status: 'failure',\n error,\n });\n }\n });\n });\n\n req.setTimeout(timeoutMillis, () => {\n req.destroy();\n onDone({\n status: 'failure',\n error: new Error('Request Timeout'),\n });\n });\n\n req.on('error', (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n\n compressAndSend(req, params.compression, data, (error: Error) => {\n onDone({\n status: 'failure',\n error,\n });\n });\n}\n\nexport function compressAndSend(\n req: http.ClientRequest,\n compression: 'gzip' | 'none',\n data: Uint8Array,\n onError: (error: Error) => void\n) {\n let dataStream = readableFromUint8Array(data);\n\n if (compression === 'gzip') {\n req.setHeader('Content-Encoding', 'gzip');\n dataStream = dataStream\n .on('error', onError)\n .pipe(zlib.createGzip())\n .on('error', onError);\n }\n\n dataStream.pipe(req).on('error', onError);\n}\n\nfunction readableFromUint8Array(buff: string | Uint8Array): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.207.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,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;AAC/C,QAAA,OAAO,GAAG,SAAS,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.207.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/otlp-exporter-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.207.0",
|
|
4
4
|
"description": "OpenTelemetry OTLP Exporter base (for internal use only)",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"module": "build/esm/index.js",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"version": "node ../../../scripts/version-update.js",
|
|
41
41
|
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
42
42
|
"prewatch": "npm run precompile",
|
|
43
|
-
"align-api-deps": "node ../../../scripts/align-api-deps.js"
|
|
43
|
+
"align-api-deps": "node ../../../scripts/align-api-deps.js",
|
|
44
|
+
"maint:regenerate-test-certs": "cd test/certs && ./regenerate.sh"
|
|
44
45
|
},
|
|
45
46
|
"keywords": [
|
|
46
47
|
"opentelemetry",
|
|
@@ -73,8 +74,8 @@
|
|
|
73
74
|
"access": "public"
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
|
-
"@opentelemetry/core": "2.
|
|
77
|
-
"@opentelemetry/otlp-transformer": "0.
|
|
77
|
+
"@opentelemetry/core": "2.2.0",
|
|
78
|
+
"@opentelemetry/otlp-transformer": "0.207.0"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@babel/core": "7.27.1",
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
"karma-mocha": "2.0.1",
|
|
91
92
|
"karma-spec-reporter": "0.0.36",
|
|
92
93
|
"karma-webpack": "5.0.1",
|
|
93
|
-
"mocha": "11.7.
|
|
94
|
+
"mocha": "11.7.4",
|
|
94
95
|
"nyc": "17.1.0",
|
|
95
96
|
"sinon": "18.0.1",
|
|
96
97
|
"ts-loader": "9.5.4",
|
|
@@ -103,5 +104,5 @@
|
|
|
103
104
|
},
|
|
104
105
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-exporter-base",
|
|
105
106
|
"sideEffects": false,
|
|
106
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "fb6476d8243ac8dcaaea74130b9c50c43938275c"
|
|
107
108
|
}
|