@opentelemetry/otlp-grpc-exporter-base 0.222.0 → 0.300.0-development.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/dist/_virtual/_rolldown/runtime.cjs +44 -0
- package/dist/_virtual/_rolldown/runtime.mjs +37 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.cjs +28 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.cjs.map +1 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.d.cts +12 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.d.cts.map +1 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.d.mts +12 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.d.mts.map +1 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.mjs +27 -0
- package/dist/configuration/convert-legacy-otlp-grpc-options.mjs.map +1 -0
- package/dist/configuration/otlp-grpc-configuration.cjs +50 -0
- package/dist/configuration/otlp-grpc-configuration.cjs.map +1 -0
- package/dist/configuration/otlp-grpc-configuration.d.cts +12 -0
- package/dist/configuration/otlp-grpc-configuration.d.cts.map +1 -0
- package/dist/configuration/otlp-grpc-configuration.d.mts +12 -0
- package/dist/configuration/otlp-grpc-configuration.d.mts.map +1 -0
- package/dist/configuration/otlp-grpc-configuration.mjs +47 -0
- package/dist/configuration/otlp-grpc-configuration.mjs.map +1 -0
- package/dist/configuration/otlp-grpc-env-configuration.cjs +117 -0
- package/dist/configuration/otlp-grpc-env-configuration.cjs.map +1 -0
- package/dist/configuration/otlp-grpc-env-configuration.mjs +114 -0
- package/dist/configuration/otlp-grpc-env-configuration.mjs.map +1 -0
- package/dist/create-service-client-constructor.cjs +50 -0
- package/dist/create-service-client-constructor.cjs.map +1 -0
- package/dist/create-service-client-constructor.mjs +37 -0
- package/dist/create-service-client-constructor.mjs.map +1 -0
- package/dist/grpc-exporter-transport.cjs +110 -0
- package/dist/grpc-exporter-transport.cjs.map +1 -0
- package/dist/grpc-exporter-transport.d.cts +10 -0
- package/dist/grpc-exporter-transport.d.cts.map +1 -0
- package/dist/grpc-exporter-transport.d.mts +10 -0
- package/dist/grpc-exporter-transport.d.mts.map +1 -0
- package/dist/grpc-exporter-transport.mjs +106 -0
- package/dist/grpc-exporter-transport.mjs.map +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +4 -0
- package/dist/otlp-grpc-export-delegate.cjs +39 -0
- package/dist/otlp-grpc-export-delegate.cjs.map +1 -0
- package/dist/otlp-grpc-export-delegate.d.cts +10 -0
- package/dist/otlp-grpc-export-delegate.d.cts.map +1 -0
- package/dist/otlp-grpc-export-delegate.d.mts +10 -0
- package/dist/otlp-grpc-export-delegate.d.mts.map +1 -0
- package/dist/otlp-grpc-export-delegate.mjs +38 -0
- package/dist/otlp-grpc-export-delegate.mjs.map +1 -0
- package/dist/semconv.cjs +19 -0
- package/dist/semconv.cjs.map +1 -0
- package/dist/semconv.mjs +18 -0
- package/dist/semconv.mjs.map +1 -0
- package/dist/types.d.cts +15 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +15 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/version.cjs +7 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.mjs +6 -0
- package/dist/version.mjs.map +1 -0
- package/package.json +25 -16
- package/build/src/configuration/convert-legacy-otlp-grpc-options.d.ts +0 -9
- package/build/src/configuration/convert-legacy-otlp-grpc-options.js +0 -31
- package/build/src/configuration/convert-legacy-otlp-grpc-options.js.map +0 -1
- package/build/src/configuration/otlp-grpc-configuration.d.ts +0 -23
- package/build/src/configuration/otlp-grpc-configuration.js +0 -78
- package/build/src/configuration/otlp-grpc-configuration.js.map +0 -1
- package/build/src/configuration/otlp-grpc-env-configuration.d.ts +0 -3
- package/build/src/configuration/otlp-grpc-env-configuration.js +0 -159
- package/build/src/configuration/otlp-grpc-env-configuration.js.map +0 -1
- package/build/src/create-service-client-constructor.d.ts +0 -10
- package/build/src/create-service-client-constructor.js +0 -39
- package/build/src/create-service-client-constructor.js.map +0 -1
- package/build/src/grpc-exporter-transport.d.ts +0 -42
- package/build/src/grpc-exporter-transport.js +0 -137
- package/build/src/grpc-exporter-transport.js.map +0 -1
- package/build/src/index.d.ts +0 -5
- package/build/src/index.js +0 -17
- package/build/src/index.js.map +0 -1
- package/build/src/otlp-grpc-export-delegate.d.ts +0 -8
- package/build/src/otlp-grpc-export-delegate.js +0 -56
- package/build/src/otlp-grpc-export-delegate.js.map +0 -1
- package/build/src/semconv.d.ts +0 -14
- package/build/src/semconv.js +0 -26
- package/build/src/semconv.js.map +0 -1
- package/build/src/types.d.ts +0 -12
- package/build/src/types.js +0 -7
- package/build/src/types.js.map +0 -1
- package/build/src/version.d.ts +0 -2
- package/build/src/version.js +0 -10
- package/build/src/version.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esmMin = (fn, res, err) => () => {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = fn(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __exportAll = (all, no_symbols) => {
|
|
17
|
+
let target = {};
|
|
18
|
+
for (var name in all) __defProp(target, name, {
|
|
19
|
+
get: all[name],
|
|
20
|
+
enumerable: true
|
|
21
|
+
});
|
|
22
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
23
|
+
return target;
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
27
|
+
key = keys[i];
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
29
|
+
get: ((k) => from[k]).bind(null, key),
|
|
30
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
36
|
+
value: mod,
|
|
37
|
+
enumerable: true
|
|
38
|
+
}) : target, mod));
|
|
39
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.__esmMin = __esmMin;
|
|
42
|
+
exports.__exportAll = __exportAll;
|
|
43
|
+
exports.__toCommonJS = __toCommonJS;
|
|
44
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esmMin = (fn, res, err) => () => {
|
|
8
|
+
if (err) throw err[0];
|
|
9
|
+
try {
|
|
10
|
+
return fn && (res = fn(fn = 0)), res;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw err = [e], e;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var __exportAll = (all, no_symbols) => {
|
|
16
|
+
let target = {};
|
|
17
|
+
for (var name in all) __defProp(target, name, {
|
|
18
|
+
get: all[name],
|
|
19
|
+
enumerable: true
|
|
20
|
+
});
|
|
21
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
26
|
+
key = keys[i];
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
36
|
+
//#endregion
|
|
37
|
+
export { __esmMin, __exportAll, __require, __toCommonJS };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_grpc_exporter_transport = require("../grpc-exporter-transport.cjs");
|
|
3
|
+
const require_otlp_grpc_configuration = require("./otlp-grpc-configuration.cjs");
|
|
4
|
+
const require_otlp_grpc_env_configuration = require("./otlp-grpc-env-configuration.cjs");
|
|
5
|
+
//#region src/configuration/convert-legacy-otlp-grpc-options.ts
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* @param config
|
|
9
|
+
* @param signalIdentifier
|
|
10
|
+
*/
|
|
11
|
+
function convertLegacyOtlpGrpcOptions(config, signalIdentifier) {
|
|
12
|
+
const userProvidedCredentials = config.credentials;
|
|
13
|
+
return require_otlp_grpc_configuration.mergeOtlpGrpcConfigurationWithDefaults({
|
|
14
|
+
url: config.url,
|
|
15
|
+
metadata: () => {
|
|
16
|
+
return config.metadata ?? require_grpc_exporter_transport.createEmptyMetadata();
|
|
17
|
+
},
|
|
18
|
+
compression: config.compression,
|
|
19
|
+
timeoutMillis: config.timeoutMillis,
|
|
20
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
21
|
+
credentials: userProvidedCredentials != null ? () => userProvidedCredentials : void 0,
|
|
22
|
+
userAgent: config.userAgent
|
|
23
|
+
}, require_otlp_grpc_env_configuration.getOtlpGrpcConfigurationFromEnv(signalIdentifier), require_otlp_grpc_configuration.getOtlpGrpcDefaultConfiguration());
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.convertLegacyOtlpGrpcOptions = convertLegacyOtlpGrpcOptions;
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=convert-legacy-otlp-grpc-options.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-legacy-otlp-grpc-options.cjs","names":["mergeOtlpGrpcConfigurationWithDefaults","createEmptyMetadata","getOtlpGrpcConfigurationFromEnv","getOtlpGrpcDefaultConfiguration"],"sources":["../../src/configuration/convert-legacy-otlp-grpc-options.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { OTLPGRPCExporterConfigNode } from '../types';\nimport type { OtlpGrpcConfiguration } from './otlp-grpc-configuration';\nimport {\n getOtlpGrpcDefaultConfiguration,\n mergeOtlpGrpcConfigurationWithDefaults,\n} from './otlp-grpc-configuration';\nimport { createEmptyMetadata } from '../grpc-exporter-transport';\nimport { getOtlpGrpcConfigurationFromEnv } from './otlp-grpc-env-configuration';\n\n/**\n * @deprecated\n * @param config\n * @param signalIdentifier\n */\nexport function convertLegacyOtlpGrpcOptions(\n config: OTLPGRPCExporterConfigNode,\n signalIdentifier: string\n): OtlpGrpcConfiguration {\n // keep credentials locally in case user updates the reference on the config object\n const userProvidedCredentials = config.credentials;\n return mergeOtlpGrpcConfigurationWithDefaults(\n {\n url: config.url,\n metadata: () => {\n // metadata resolution strategy is merge, so we can return empty here, and it will not override the rest of the settings.\n return config.metadata ?? createEmptyMetadata();\n },\n compression: config.compression,\n timeoutMillis: config.timeoutMillis,\n concurrencyLimit: config.concurrencyLimit,\n credentials:\n userProvidedCredentials != null\n ? () => userProvidedCredentials\n : undefined,\n userAgent: config.userAgent,\n },\n getOtlpGrpcConfigurationFromEnv(signalIdentifier),\n getOtlpGrpcDefaultConfiguration()\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAgB,6BACd,QACA,kBACuB;CAEvB,MAAM,0BAA0B,OAAO;CACvC,OAAOA,gCAAAA,uCACL;EACE,KAAK,OAAO;EACZ,gBAAgB;GAEd,OAAO,OAAO,YAAYC,gCAAAA,oBAAoB;EAChD;EACA,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,kBAAkB,OAAO;EACzB,aACE,2BAA2B,aACjB,0BACN,KAAA;EACN,WAAW,OAAO;CACpB,GACAC,oCAAAA,gCAAgC,gBAAgB,GAChDC,gCAAAA,gCAAgC,CAClC;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OTLPGRPCExporterConfigNode } from "../types.cjs";
|
|
2
|
+
import { OtlpGrpcConfiguration } from "./otlp-grpc-configuration.cjs";
|
|
3
|
+
//#region src/configuration/convert-legacy-otlp-grpc-options.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
* @param config
|
|
7
|
+
* @param signalIdentifier
|
|
8
|
+
*/
|
|
9
|
+
declare function convertLegacyOtlpGrpcOptions(config: OTLPGRPCExporterConfigNode, signalIdentifier: string): OtlpGrpcConfiguration;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { convertLegacyOtlpGrpcOptions };
|
|
12
|
+
//# sourceMappingURL=convert-legacy-otlp-grpc-options.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-legacy-otlp-grpc-options.d.cts","names":[],"sources":["../../src/configuration/convert-legacy-otlp-grpc-options.d.ts"],"mappings":";;;;;;;;iBAOwB,6BAA6B,QAAQ,4BAA4B,2BAA2B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OTLPGRPCExporterConfigNode } from "../types.mjs";
|
|
2
|
+
import { OtlpGrpcConfiguration } from "./otlp-grpc-configuration.mjs";
|
|
3
|
+
//#region src/configuration/convert-legacy-otlp-grpc-options.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
* @param config
|
|
7
|
+
* @param signalIdentifier
|
|
8
|
+
*/
|
|
9
|
+
declare function convertLegacyOtlpGrpcOptions(config: OTLPGRPCExporterConfigNode, signalIdentifier: string): OtlpGrpcConfiguration;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { convertLegacyOtlpGrpcOptions };
|
|
12
|
+
//# sourceMappingURL=convert-legacy-otlp-grpc-options.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-legacy-otlp-grpc-options.d.mts","names":[],"sources":["../../src/configuration/convert-legacy-otlp-grpc-options.d.ts"],"mappings":";;;;;;;;iBAOwB,6BAA6B,QAAQ,4BAA4B,2BAA2B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createEmptyMetadata } from "../grpc-exporter-transport.mjs";
|
|
2
|
+
import { getOtlpGrpcDefaultConfiguration, mergeOtlpGrpcConfigurationWithDefaults } from "./otlp-grpc-configuration.mjs";
|
|
3
|
+
import { getOtlpGrpcConfigurationFromEnv } from "./otlp-grpc-env-configuration.mjs";
|
|
4
|
+
//#region src/configuration/convert-legacy-otlp-grpc-options.ts
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated
|
|
7
|
+
* @param config
|
|
8
|
+
* @param signalIdentifier
|
|
9
|
+
*/
|
|
10
|
+
function convertLegacyOtlpGrpcOptions(config, signalIdentifier) {
|
|
11
|
+
const userProvidedCredentials = config.credentials;
|
|
12
|
+
return mergeOtlpGrpcConfigurationWithDefaults({
|
|
13
|
+
url: config.url,
|
|
14
|
+
metadata: () => {
|
|
15
|
+
return config.metadata ?? createEmptyMetadata();
|
|
16
|
+
},
|
|
17
|
+
compression: config.compression,
|
|
18
|
+
timeoutMillis: config.timeoutMillis,
|
|
19
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
20
|
+
credentials: userProvidedCredentials != null ? () => userProvidedCredentials : void 0,
|
|
21
|
+
userAgent: config.userAgent
|
|
22
|
+
}, getOtlpGrpcConfigurationFromEnv(signalIdentifier), getOtlpGrpcDefaultConfiguration());
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { convertLegacyOtlpGrpcOptions };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=convert-legacy-otlp-grpc-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-legacy-otlp-grpc-options.mjs","names":[],"sources":["../../src/configuration/convert-legacy-otlp-grpc-options.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { OTLPGRPCExporterConfigNode } from '../types';\nimport type { OtlpGrpcConfiguration } from './otlp-grpc-configuration';\nimport {\n getOtlpGrpcDefaultConfiguration,\n mergeOtlpGrpcConfigurationWithDefaults,\n} from './otlp-grpc-configuration';\nimport { createEmptyMetadata } from '../grpc-exporter-transport';\nimport { getOtlpGrpcConfigurationFromEnv } from './otlp-grpc-env-configuration';\n\n/**\n * @deprecated\n * @param config\n * @param signalIdentifier\n */\nexport function convertLegacyOtlpGrpcOptions(\n config: OTLPGRPCExporterConfigNode,\n signalIdentifier: string\n): OtlpGrpcConfiguration {\n // keep credentials locally in case user updates the reference on the config object\n const userProvidedCredentials = config.credentials;\n return mergeOtlpGrpcConfigurationWithDefaults(\n {\n url: config.url,\n metadata: () => {\n // metadata resolution strategy is merge, so we can return empty here, and it will not override the rest of the settings.\n return config.metadata ?? createEmptyMetadata();\n },\n compression: config.compression,\n timeoutMillis: config.timeoutMillis,\n concurrencyLimit: config.concurrencyLimit,\n credentials:\n userProvidedCredentials != null\n ? () => userProvidedCredentials\n : undefined,\n userAgent: config.userAgent,\n },\n getOtlpGrpcConfigurationFromEnv(signalIdentifier),\n getOtlpGrpcDefaultConfiguration()\n );\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,6BACd,QACA,kBACuB;CAEvB,MAAM,0BAA0B,OAAO;CACvC,OAAO,uCACL;EACE,KAAK,OAAO;EACZ,gBAAgB;GAEd,OAAO,OAAO,YAAY,oBAAoB;EAChD;EACA,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,kBAAkB,OAAO;EACzB,aACE,2BAA2B,aACjB,0BACN,KAAA;EACN,WAAW,OAAO;CACpB,GACA,gCAAgC,gBAAgB,GAChD,gCAAgC,CAClC;AACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_grpc_exporter_transport = require("../grpc-exporter-transport.cjs");
|
|
3
|
+
let _opentelemetry_otlp_exporter_base = require("@opentelemetry/otlp-exporter-base");
|
|
4
|
+
let url = require("url");
|
|
5
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
6
|
+
//#region src/configuration/otlp-grpc-configuration.ts
|
|
7
|
+
function validateAndNormalizeUrl(url$1) {
|
|
8
|
+
url$1 = url$1.trim();
|
|
9
|
+
if (!url$1.match(/^([\w]{1,8}):\/\//)) url$1 = `https://${url$1}`;
|
|
10
|
+
const target = new url.URL(url$1);
|
|
11
|
+
if (target.protocol === "unix:") return url$1;
|
|
12
|
+
if (target.pathname && target.pathname !== "/") _opentelemetry_api.diag.warn("URL path should not be set when using grpc, the path part of the URL will be ignored.");
|
|
13
|
+
if (target.protocol !== "" && !target.protocol?.match(/^(http)s?:$/)) _opentelemetry_api.diag.warn("URL protocol should be http(s)://. Using http://.");
|
|
14
|
+
return target.host;
|
|
15
|
+
}
|
|
16
|
+
function overrideMetadataEntriesIfNotPresent(metadata, additionalMetadata) {
|
|
17
|
+
for (const [key, value] of Object.entries(additionalMetadata.getMap())) if (metadata.get(key).length < 1) metadata.set(key, value);
|
|
18
|
+
}
|
|
19
|
+
function mergeOtlpGrpcConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
20
|
+
const rawUrl = userProvidedConfiguration.url ?? fallbackConfiguration.url ?? defaultConfiguration.url;
|
|
21
|
+
return {
|
|
22
|
+
...(0, _opentelemetry_otlp_exporter_base.mergeOtlpSharedConfigurationWithDefaults)(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
|
|
23
|
+
metadata: () => {
|
|
24
|
+
const metadata = defaultConfiguration.metadata();
|
|
25
|
+
overrideMetadataEntriesIfNotPresent(metadata, userProvidedConfiguration.metadata?.().clone() ?? require_grpc_exporter_transport.createEmptyMetadata());
|
|
26
|
+
overrideMetadataEntriesIfNotPresent(metadata, fallbackConfiguration.metadata?.() ?? require_grpc_exporter_transport.createEmptyMetadata());
|
|
27
|
+
return metadata;
|
|
28
|
+
},
|
|
29
|
+
url: validateAndNormalizeUrl(rawUrl),
|
|
30
|
+
credentials: userProvidedConfiguration.credentials ?? fallbackConfiguration.credentials?.(rawUrl) ?? defaultConfiguration.credentials(rawUrl),
|
|
31
|
+
userAgent: userProvidedConfiguration.userAgent
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function getOtlpGrpcDefaultConfiguration() {
|
|
35
|
+
return {
|
|
36
|
+
...(0, _opentelemetry_otlp_exporter_base.getSharedConfigurationDefaults)(),
|
|
37
|
+
metadata: () => require_grpc_exporter_transport.createEmptyMetadata(),
|
|
38
|
+
url: "http://localhost:4317",
|
|
39
|
+
credentials: (url$2) => {
|
|
40
|
+
if (url$2.startsWith("http://")) return () => require_grpc_exporter_transport.createInsecureCredentials();
|
|
41
|
+
else return () => require_grpc_exporter_transport.createSslCredentials();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.getOtlpGrpcDefaultConfiguration = getOtlpGrpcDefaultConfiguration;
|
|
47
|
+
exports.mergeOtlpGrpcConfigurationWithDefaults = mergeOtlpGrpcConfigurationWithDefaults;
|
|
48
|
+
exports.validateAndNormalizeUrl = validateAndNormalizeUrl;
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=otlp-grpc-configuration.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-grpc-configuration.cjs","names":["url","URL","mergeOtlpSharedConfigurationWithDefaults","createEmptyMetadata","getSharedConfigurationDefaults","createInsecureCredentials","createSslCredentials"],"sources":["../../src/configuration/otlp-grpc-configuration.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { OtlpSharedConfiguration } from '@opentelemetry/otlp-exporter-base';\nimport {\n getSharedConfigurationDefaults,\n mergeOtlpSharedConfigurationWithDefaults,\n} from '@opentelemetry/otlp-exporter-base';\nimport {\n createEmptyMetadata,\n createInsecureCredentials,\n createSslCredentials,\n} from '../grpc-exporter-transport';\nimport { URL } from 'url';\nimport { diag } from '@opentelemetry/api';\n\n// NOTE: do not change this to be an actual import, doing so will break `@opentelemetry/instrumentation-grpc`\nimport type { ChannelCredentials, Metadata } from '@grpc/grpc-js';\n\nexport interface OtlpGrpcConfiguration extends OtlpSharedConfiguration {\n url: string;\n metadata: () => Metadata;\n credentials: () => ChannelCredentials;\n userAgent?: string;\n}\n\n/**\n * Unresolved configuration where parts of the config may depend on other config options being resolved first.\n */\nexport interface UnresolvedOtlpGrpcConfiguration\n extends OtlpSharedConfiguration {\n url: string;\n metadata: () => Metadata;\n /**\n * Credentials are based on the final resolved URL\n */\n credentials: (url: string) => () => ChannelCredentials;\n}\n\nexport function validateAndNormalizeUrl(url: string): string {\n url = url.trim();\n const hasProtocol = url.match(/^([\\w]{1,8}):\\/\\//);\n if (!hasProtocol) {\n url = `https://${url}`;\n }\n const target = new URL(url);\n if (target.protocol === 'unix:') {\n return url;\n }\n if (target.pathname && target.pathname !== '/') {\n diag.warn(\n 'URL path should not be set when using grpc, the path part of the URL will be ignored.'\n );\n }\n if (target.protocol !== '' && !target.protocol?.match(/^(http)s?:$/)) {\n diag.warn('URL protocol should be http(s)://. Using http://.');\n }\n return target.host;\n}\n\nfunction overrideMetadataEntriesIfNotPresent(\n metadata: Metadata,\n additionalMetadata: Metadata\n): void {\n for (const [key, value] of Object.entries(additionalMetadata.getMap())) {\n // only override with env var data if the key has no values.\n // not using Metadata.merge() as it will keep both values.\n if (metadata.get(key).length < 1) {\n metadata.set(key, value);\n }\n }\n}\n\nexport function mergeOtlpGrpcConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpGrpcConfiguration>,\n fallbackConfiguration: Partial<UnresolvedOtlpGrpcConfiguration>,\n defaultConfiguration: UnresolvedOtlpGrpcConfiguration\n): OtlpGrpcConfiguration {\n const rawUrl =\n userProvidedConfiguration.url ??\n fallbackConfiguration.url ??\n defaultConfiguration.url;\n\n return {\n ...mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n metadata: () => {\n const metadata = defaultConfiguration.metadata();\n overrideMetadataEntriesIfNotPresent(\n metadata,\n // clone to ensure we don't modify what the user gave us in case they hold on to the returned reference\n userProvidedConfiguration.metadata?.().clone() ?? createEmptyMetadata()\n );\n overrideMetadataEntriesIfNotPresent(\n metadata,\n fallbackConfiguration.metadata?.() ?? createEmptyMetadata()\n );\n return metadata;\n },\n url: validateAndNormalizeUrl(rawUrl),\n credentials:\n userProvidedConfiguration.credentials ??\n fallbackConfiguration.credentials?.(rawUrl) ??\n defaultConfiguration.credentials(rawUrl),\n userAgent: userProvidedConfiguration.userAgent,\n };\n}\n\nexport function getOtlpGrpcDefaultConfiguration(): UnresolvedOtlpGrpcConfiguration {\n return {\n ...getSharedConfigurationDefaults(),\n metadata: () => createEmptyMetadata(),\n url: 'http://localhost:4317',\n credentials: (url: string) => {\n if (url.startsWith('http://')) {\n return () => createInsecureCredentials();\n } else {\n return () => createSslCredentials();\n }\n },\n };\n}\n"],"mappings":";;;;;;AAyCA,SAAgB,wBAAwB,OAAqB;CAC3D,QAAMA,MAAI,KAAK;CAEf,IAAI,CADgBA,MAAI,MAAM,mBACf,GACb,QAAM,WAAWA;CAEnB,MAAM,SAAS,IAAIC,IAAAA,IAAID,KAAG;CAC1B,IAAI,OAAO,aAAa,SACtB,OAAOA;CAET,IAAI,OAAO,YAAY,OAAO,aAAa,KACzC,mBAAA,KAAK,KACH,uFACF;CAEF,IAAI,OAAO,aAAa,MAAM,CAAC,OAAO,UAAU,MAAM,aAAa,GACjE,mBAAA,KAAK,KAAK,mDAAmD;CAE/D,OAAO,OAAO;AAChB;AAEA,SAAS,oCACP,UACA,oBACM;CACN,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,mBAAmB,OAAO,CAAC,GAGnE,IAAI,SAAS,IAAI,GAAG,CAAC,CAAC,SAAS,GAC7B,SAAS,IAAI,KAAK,KAAK;AAG7B;AAEA,SAAgB,uCACd,2BACA,uBACA,sBACuB;CACvB,MAAM,SACJ,0BAA0B,OAC1B,sBAAsB,OACtB,qBAAqB;CAEvB,OAAO;EACL,IAAA,GAAGE,kCAAAA,yCAAAA,CACD,2BACA,uBACA,oBACF;EACA,gBAAgB;GACd,MAAM,WAAW,qBAAqB,SAAS;GAC/C,oCACE,UAEA,0BAA0B,WAAW,CAAC,CAAC,MAAM,KAAKC,gCAAAA,oBAAoB,CACxE;GACA,oCACE,UACA,sBAAsB,WAAW,KAAKA,gCAAAA,oBAAoB,CAC5D;GACA,OAAO;EACT;EACA,KAAK,wBAAwB,MAAM;EACnC,aACE,0BAA0B,eAC1B,sBAAsB,cAAc,MAAM,KAC1C,qBAAqB,YAAY,MAAM;EACzC,WAAW,0BAA0B;CACvC;AACF;AAEA,SAAgB,kCAAmE;CACjF,OAAO;EACL,IAAA,GAAGC,kCAAAA,+BAAAA,CAA+B;EAClC,gBAAgBD,gCAAAA,oBAAoB;EACpC,KAAK;EACL,cAAc,UAAgB;GAC5B,IAAIH,MAAI,WAAW,SAAS,GAC1B,aAAaK,gCAAAA,0BAA0B;QAEvC,aAAaC,gCAAAA,qBAAqB;EAEtC;CACF;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChannelCredentials, Metadata } from "@grpc/grpc-js";
|
|
2
|
+
import { OtlpSharedConfiguration } from "@opentelemetry/otlp-exporter-base";
|
|
3
|
+
//#region src/configuration/otlp-grpc-configuration.d.ts
|
|
4
|
+
interface OtlpGrpcConfiguration extends OtlpSharedConfiguration {
|
|
5
|
+
url: string;
|
|
6
|
+
metadata: () => Metadata;
|
|
7
|
+
credentials: () => ChannelCredentials;
|
|
8
|
+
userAgent?: string;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OtlpGrpcConfiguration };
|
|
12
|
+
//# sourceMappingURL=otlp-grpc-configuration.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-grpc-configuration.d.cts","names":[],"sources":["../../src/configuration/otlp-grpc-configuration.d.ts"],"mappings":";;;UAEiB,8BAA8B;EAC3C;EACA,gBAAgB;EAChB,mBAAmB;EACnB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OtlpSharedConfiguration } from "@opentelemetry/otlp-exporter-base";
|
|
2
|
+
import { ChannelCredentials, Metadata } from "@grpc/grpc-js";
|
|
3
|
+
//#region src/configuration/otlp-grpc-configuration.d.ts
|
|
4
|
+
interface OtlpGrpcConfiguration extends OtlpSharedConfiguration {
|
|
5
|
+
url: string;
|
|
6
|
+
metadata: () => Metadata;
|
|
7
|
+
credentials: () => ChannelCredentials;
|
|
8
|
+
userAgent?: string;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OtlpGrpcConfiguration };
|
|
12
|
+
//# sourceMappingURL=otlp-grpc-configuration.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-grpc-configuration.d.mts","names":[],"sources":["../../src/configuration/otlp-grpc-configuration.d.ts"],"mappings":";;;UAEiB,8BAA8B;EAC3C;EACA,gBAAgB;EAChB,mBAAmB;EACnB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createEmptyMetadata, createInsecureCredentials, createSslCredentials } from "../grpc-exporter-transport.mjs";
|
|
2
|
+
import { getSharedConfigurationDefaults, mergeOtlpSharedConfigurationWithDefaults } from "@opentelemetry/otlp-exporter-base";
|
|
3
|
+
import { URL } from "url";
|
|
4
|
+
import { diag } from "@opentelemetry/api";
|
|
5
|
+
//#region src/configuration/otlp-grpc-configuration.ts
|
|
6
|
+
function validateAndNormalizeUrl(url) {
|
|
7
|
+
url = url.trim();
|
|
8
|
+
if (!url.match(/^([\w]{1,8}):\/\//)) url = `https://${url}`;
|
|
9
|
+
const target = new URL(url);
|
|
10
|
+
if (target.protocol === "unix:") return url;
|
|
11
|
+
if (target.pathname && target.pathname !== "/") diag.warn("URL path should not be set when using grpc, the path part of the URL will be ignored.");
|
|
12
|
+
if (target.protocol !== "" && !target.protocol?.match(/^(http)s?:$/)) diag.warn("URL protocol should be http(s)://. Using http://.");
|
|
13
|
+
return target.host;
|
|
14
|
+
}
|
|
15
|
+
function overrideMetadataEntriesIfNotPresent(metadata, additionalMetadata) {
|
|
16
|
+
for (const [key, value] of Object.entries(additionalMetadata.getMap())) if (metadata.get(key).length < 1) metadata.set(key, value);
|
|
17
|
+
}
|
|
18
|
+
function mergeOtlpGrpcConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
19
|
+
const rawUrl = userProvidedConfiguration.url ?? fallbackConfiguration.url ?? defaultConfiguration.url;
|
|
20
|
+
return {
|
|
21
|
+
...mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
|
|
22
|
+
metadata: () => {
|
|
23
|
+
const metadata = defaultConfiguration.metadata();
|
|
24
|
+
overrideMetadataEntriesIfNotPresent(metadata, userProvidedConfiguration.metadata?.().clone() ?? createEmptyMetadata());
|
|
25
|
+
overrideMetadataEntriesIfNotPresent(metadata, fallbackConfiguration.metadata?.() ?? createEmptyMetadata());
|
|
26
|
+
return metadata;
|
|
27
|
+
},
|
|
28
|
+
url: validateAndNormalizeUrl(rawUrl),
|
|
29
|
+
credentials: userProvidedConfiguration.credentials ?? fallbackConfiguration.credentials?.(rawUrl) ?? defaultConfiguration.credentials(rawUrl),
|
|
30
|
+
userAgent: userProvidedConfiguration.userAgent
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function getOtlpGrpcDefaultConfiguration() {
|
|
34
|
+
return {
|
|
35
|
+
...getSharedConfigurationDefaults(),
|
|
36
|
+
metadata: () => createEmptyMetadata(),
|
|
37
|
+
url: "http://localhost:4317",
|
|
38
|
+
credentials: (url) => {
|
|
39
|
+
if (url.startsWith("http://")) return () => createInsecureCredentials();
|
|
40
|
+
else return () => createSslCredentials();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { getOtlpGrpcDefaultConfiguration, mergeOtlpGrpcConfigurationWithDefaults, validateAndNormalizeUrl };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=otlp-grpc-configuration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-grpc-configuration.mjs","names":[],"sources":["../../src/configuration/otlp-grpc-configuration.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { OtlpSharedConfiguration } from '@opentelemetry/otlp-exporter-base';\nimport {\n getSharedConfigurationDefaults,\n mergeOtlpSharedConfigurationWithDefaults,\n} from '@opentelemetry/otlp-exporter-base';\nimport {\n createEmptyMetadata,\n createInsecureCredentials,\n createSslCredentials,\n} from '../grpc-exporter-transport';\nimport { URL } from 'url';\nimport { diag } from '@opentelemetry/api';\n\n// NOTE: do not change this to be an actual import, doing so will break `@opentelemetry/instrumentation-grpc`\nimport type { ChannelCredentials, Metadata } from '@grpc/grpc-js';\n\nexport interface OtlpGrpcConfiguration extends OtlpSharedConfiguration {\n url: string;\n metadata: () => Metadata;\n credentials: () => ChannelCredentials;\n userAgent?: string;\n}\n\n/**\n * Unresolved configuration where parts of the config may depend on other config options being resolved first.\n */\nexport interface UnresolvedOtlpGrpcConfiguration\n extends OtlpSharedConfiguration {\n url: string;\n metadata: () => Metadata;\n /**\n * Credentials are based on the final resolved URL\n */\n credentials: (url: string) => () => ChannelCredentials;\n}\n\nexport function validateAndNormalizeUrl(url: string): string {\n url = url.trim();\n const hasProtocol = url.match(/^([\\w]{1,8}):\\/\\//);\n if (!hasProtocol) {\n url = `https://${url}`;\n }\n const target = new URL(url);\n if (target.protocol === 'unix:') {\n return url;\n }\n if (target.pathname && target.pathname !== '/') {\n diag.warn(\n 'URL path should not be set when using grpc, the path part of the URL will be ignored.'\n );\n }\n if (target.protocol !== '' && !target.protocol?.match(/^(http)s?:$/)) {\n diag.warn('URL protocol should be http(s)://. Using http://.');\n }\n return target.host;\n}\n\nfunction overrideMetadataEntriesIfNotPresent(\n metadata: Metadata,\n additionalMetadata: Metadata\n): void {\n for (const [key, value] of Object.entries(additionalMetadata.getMap())) {\n // only override with env var data if the key has no values.\n // not using Metadata.merge() as it will keep both values.\n if (metadata.get(key).length < 1) {\n metadata.set(key, value);\n }\n }\n}\n\nexport function mergeOtlpGrpcConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpGrpcConfiguration>,\n fallbackConfiguration: Partial<UnresolvedOtlpGrpcConfiguration>,\n defaultConfiguration: UnresolvedOtlpGrpcConfiguration\n): OtlpGrpcConfiguration {\n const rawUrl =\n userProvidedConfiguration.url ??\n fallbackConfiguration.url ??\n defaultConfiguration.url;\n\n return {\n ...mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n metadata: () => {\n const metadata = defaultConfiguration.metadata();\n overrideMetadataEntriesIfNotPresent(\n metadata,\n // clone to ensure we don't modify what the user gave us in case they hold on to the returned reference\n userProvidedConfiguration.metadata?.().clone() ?? createEmptyMetadata()\n );\n overrideMetadataEntriesIfNotPresent(\n metadata,\n fallbackConfiguration.metadata?.() ?? createEmptyMetadata()\n );\n return metadata;\n },\n url: validateAndNormalizeUrl(rawUrl),\n credentials:\n userProvidedConfiguration.credentials ??\n fallbackConfiguration.credentials?.(rawUrl) ??\n defaultConfiguration.credentials(rawUrl),\n userAgent: userProvidedConfiguration.userAgent,\n };\n}\n\nexport function getOtlpGrpcDefaultConfiguration(): UnresolvedOtlpGrpcConfiguration {\n return {\n ...getSharedConfigurationDefaults(),\n metadata: () => createEmptyMetadata(),\n url: 'http://localhost:4317',\n credentials: (url: string) => {\n if (url.startsWith('http://')) {\n return () => createInsecureCredentials();\n } else {\n return () => createSslCredentials();\n }\n },\n };\n}\n"],"mappings":";;;;;AAyCA,SAAgB,wBAAwB,KAAqB;CAC3D,MAAM,IAAI,KAAK;CAEf,IAAI,CADgB,IAAI,MAAM,mBACf,GACb,MAAM,WAAW;CAEnB,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,IAAI,OAAO,aAAa,SACtB,OAAO;CAET,IAAI,OAAO,YAAY,OAAO,aAAa,KACzC,KAAK,KACH,uFACF;CAEF,IAAI,OAAO,aAAa,MAAM,CAAC,OAAO,UAAU,MAAM,aAAa,GACjE,KAAK,KAAK,mDAAmD;CAE/D,OAAO,OAAO;AAChB;AAEA,SAAS,oCACP,UACA,oBACM;CACN,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,mBAAmB,OAAO,CAAC,GAGnE,IAAI,SAAS,IAAI,GAAG,CAAC,CAAC,SAAS,GAC7B,SAAS,IAAI,KAAK,KAAK;AAG7B;AAEA,SAAgB,uCACd,2BACA,uBACA,sBACuB;CACvB,MAAM,SACJ,0BAA0B,OAC1B,sBAAsB,OACtB,qBAAqB;CAEvB,OAAO;EACL,GAAG,yCACD,2BACA,uBACA,oBACF;EACA,gBAAgB;GACd,MAAM,WAAW,qBAAqB,SAAS;GAC/C,oCACE,UAEA,0BAA0B,WAAW,CAAC,CAAC,MAAM,KAAK,oBAAoB,CACxE;GACA,oCACE,UACA,sBAAsB,WAAW,KAAK,oBAAoB,CAC5D;GACA,OAAO;EACT;EACA,KAAK,wBAAwB,MAAM;EACnC,aACE,0BAA0B,eAC1B,sBAAsB,cAAc,MAAM,KAC1C,qBAAqB,YAAY,MAAM;EACzC,WAAW,0BAA0B;CACvC;AACF;AAEA,SAAgB,kCAAmE;CACjF,OAAO;EACL,GAAG,+BAA+B;EAClC,gBAAgB,oBAAoB;EACpC,KAAK;EACL,cAAc,QAAgB;GAC5B,IAAI,IAAI,WAAW,SAAS,GAC1B,aAAa,0BAA0B;QAEvC,aAAa,qBAAqB;EAEtC;CACF;AACF"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_grpc_exporter_transport = require("../grpc-exporter-transport.cjs");
|
|
3
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
4
|
+
let _opentelemetry_core = require("@opentelemetry/core");
|
|
5
|
+
let _opentelemetry_otlp_exporter_base_node_http = require("@opentelemetry/otlp-exporter-base/node-http");
|
|
6
|
+
let fs = require("fs");
|
|
7
|
+
fs = require_runtime.__toESM(fs);
|
|
8
|
+
let path = require("path");
|
|
9
|
+
path = require_runtime.__toESM(path);
|
|
10
|
+
//#region src/configuration/otlp-grpc-env-configuration.ts
|
|
11
|
+
function fallbackIfNullishOrBlank(signalSpecific, nonSignalSpecific) {
|
|
12
|
+
if (signalSpecific != null && signalSpecific !== "") return signalSpecific;
|
|
13
|
+
if (nonSignalSpecific != null && nonSignalSpecific !== "") return nonSignalSpecific;
|
|
14
|
+
}
|
|
15
|
+
function getMetadataFromEnv(signalIdentifier) {
|
|
16
|
+
const signalSpecificRawHeaders = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();
|
|
17
|
+
const nonSignalSpecificRawHeaders = process.env["OTEL_EXPORTER_OTLP_HEADERS"]?.trim();
|
|
18
|
+
const signalSpecificHeaders = (0, _opentelemetry_core.parseKeyPairsIntoRecord)(signalSpecificRawHeaders);
|
|
19
|
+
const nonSignalSpecificHeaders = (0, _opentelemetry_core.parseKeyPairsIntoRecord)(nonSignalSpecificRawHeaders);
|
|
20
|
+
if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) return;
|
|
21
|
+
const mergeHeaders = Object.assign({}, nonSignalSpecificHeaders, signalSpecificHeaders);
|
|
22
|
+
const metadata = require_grpc_exporter_transport.createEmptyMetadata();
|
|
23
|
+
for (const [key, value] of Object.entries(mergeHeaders)) metadata.set(key, value);
|
|
24
|
+
return metadata;
|
|
25
|
+
}
|
|
26
|
+
function getMetadataProviderFromEnv(signalIdentifier) {
|
|
27
|
+
const metadata = getMetadataFromEnv(signalIdentifier);
|
|
28
|
+
if (metadata == null) return;
|
|
29
|
+
return () => metadata;
|
|
30
|
+
}
|
|
31
|
+
function getUrlFromEnv(signalIdentifier) {
|
|
32
|
+
const specificEndpoint = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();
|
|
33
|
+
const nonSpecificEndpoint = process.env["OTEL_EXPORTER_OTLP_ENDPOINT"]?.trim();
|
|
34
|
+
return fallbackIfNullishOrBlank(specificEndpoint, nonSpecificEndpoint);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Determines whether the env var for insecure credentials is set to {@code true}.
|
|
38
|
+
*
|
|
39
|
+
* It will allow the following values as {@code true}
|
|
40
|
+
* - 'true'
|
|
41
|
+
* - 'true '
|
|
42
|
+
* - ' true'
|
|
43
|
+
* - 'TrUE'
|
|
44
|
+
* - 'TRUE'
|
|
45
|
+
*
|
|
46
|
+
* It will not allow:
|
|
47
|
+
* - 'true false'
|
|
48
|
+
* - 'false true'
|
|
49
|
+
* - 'true!'
|
|
50
|
+
* - 'true,true'
|
|
51
|
+
* - '1'
|
|
52
|
+
* - ' '
|
|
53
|
+
*
|
|
54
|
+
* @param signalIdentifier
|
|
55
|
+
*/
|
|
56
|
+
function getInsecureSettingFromEnv(signalIdentifier) {
|
|
57
|
+
const signalSpecificInsecureValue = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_INSECURE`]?.toLowerCase().trim();
|
|
58
|
+
const nonSignalSpecificInsecureValue = process.env["OTEL_EXPORTER_OTLP_INSECURE"]?.toLowerCase().trim();
|
|
59
|
+
return fallbackIfNullishOrBlank(signalSpecificInsecureValue, nonSignalSpecificInsecureValue) === "true";
|
|
60
|
+
}
|
|
61
|
+
function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
|
|
62
|
+
const signalSpecificPath = process.env[signalSpecificEnvVar]?.trim();
|
|
63
|
+
const nonSignalSpecificPath = process.env[nonSignalSpecificEnvVar]?.trim();
|
|
64
|
+
const filePath = fallbackIfNullishOrBlank(signalSpecificPath, nonSignalSpecificPath);
|
|
65
|
+
if (filePath != null) try {
|
|
66
|
+
return fs.readFileSync(path.resolve(process.cwd(), filePath));
|
|
67
|
+
} catch {
|
|
68
|
+
_opentelemetry_api.diag.warn(warningMessage);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
else return;
|
|
72
|
+
}
|
|
73
|
+
function getClientCertificateFromEnv(signalIdentifier) {
|
|
74
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE", "Failed to read client certificate chain file");
|
|
75
|
+
}
|
|
76
|
+
function getClientKeyFromEnv(signalIdentifier) {
|
|
77
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, "OTEL_EXPORTER_OTLP_CLIENT_KEY", "Failed to read client certificate private key file");
|
|
78
|
+
}
|
|
79
|
+
function getRootCertificateFromEnv(signalIdentifier) {
|
|
80
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CERTIFICATE", "Failed to read root certificate file");
|
|
81
|
+
}
|
|
82
|
+
function getCredentialsFromEnvIgnoreInsecure(signalIdentifier) {
|
|
83
|
+
const clientKey = getClientKeyFromEnv(signalIdentifier);
|
|
84
|
+
const clientCertificate = getClientCertificateFromEnv(signalIdentifier);
|
|
85
|
+
const rootCertificate = getRootCertificateFromEnv(signalIdentifier);
|
|
86
|
+
if (rootCertificate != null && !(clientKey != null && clientCertificate != null)) {
|
|
87
|
+
_opentelemetry_api.diag.warn("Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate");
|
|
88
|
+
return require_grpc_exporter_transport.createSslCredentials(getRootCertificateFromEnv(signalIdentifier));
|
|
89
|
+
}
|
|
90
|
+
return require_grpc_exporter_transport.createSslCredentials(rootCertificate, clientKey, clientCertificate);
|
|
91
|
+
}
|
|
92
|
+
function getCredentialsFromEnv(signalIdentifier) {
|
|
93
|
+
if (getInsecureSettingFromEnv(signalIdentifier)) return require_grpc_exporter_transport.createInsecureCredentials();
|
|
94
|
+
return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);
|
|
95
|
+
}
|
|
96
|
+
function getOtlpGrpcConfigurationFromEnv(signalIdentifier) {
|
|
97
|
+
return {
|
|
98
|
+
...(0, _opentelemetry_otlp_exporter_base_node_http.getSharedConfigurationFromEnvironment)(signalIdentifier),
|
|
99
|
+
metadata: getMetadataProviderFromEnv(signalIdentifier),
|
|
100
|
+
url: getUrlFromEnv(signalIdentifier),
|
|
101
|
+
credentials: (finalResolvedUrl) => {
|
|
102
|
+
if (finalResolvedUrl.startsWith("http://")) return () => {
|
|
103
|
+
return require_grpc_exporter_transport.createInsecureCredentials();
|
|
104
|
+
};
|
|
105
|
+
else if (finalResolvedUrl.startsWith("https://")) return () => {
|
|
106
|
+
return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);
|
|
107
|
+
};
|
|
108
|
+
return () => {
|
|
109
|
+
return getCredentialsFromEnv(signalIdentifier);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
exports.getOtlpGrpcConfigurationFromEnv = getOtlpGrpcConfigurationFromEnv;
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=otlp-grpc-env-configuration.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-grpc-env-configuration.cjs","names":["parseKeyPairsIntoRecord","createEmptyMetadata","createSslCredentials","createInsecureCredentials","getSharedConfigurationFromEnvironment"],"sources":["../../src/configuration/otlp-grpc-env-configuration.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { UnresolvedOtlpGrpcConfiguration } from './otlp-grpc-configuration';\nimport type { ChannelCredentials, Metadata } from '@grpc/grpc-js';\nimport { parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport {\n createEmptyMetadata,\n createInsecureCredentials,\n createSslCredentials,\n} from '../grpc-exporter-transport';\nimport { getSharedConfigurationFromEnvironment } from '@opentelemetry/otlp-exporter-base/node-http';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { diag } from '@opentelemetry/api';\n\nfunction fallbackIfNullishOrBlank(\n signalSpecific?: string,\n nonSignalSpecific?: string\n): string | undefined {\n if (signalSpecific != null && signalSpecific !== '') {\n return signalSpecific;\n }\n\n if (nonSignalSpecific != null && nonSignalSpecific !== '') {\n return nonSignalSpecific;\n }\n\n return undefined;\n}\n\nfunction getMetadataFromEnv(signalIdentifier: string): Metadata | undefined {\n const signalSpecificRawHeaders =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();\n const nonSignalSpecificRawHeaders =\n process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();\n\n const signalSpecificHeaders = 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 const mergeHeaders = Object.assign(\n {},\n nonSignalSpecificHeaders,\n signalSpecificHeaders\n );\n\n const metadata = createEmptyMetadata();\n\n // for this to work, metadata MUST be empty - otherwise `Metadata#set()` will merge items.\n for (const [key, value] of Object.entries(mergeHeaders)) {\n metadata.set(key, value);\n }\n\n return metadata;\n}\n\nfunction getMetadataProviderFromEnv(\n signalIdentifier: string\n): (() => Metadata) | undefined {\n const metadata = getMetadataFromEnv(signalIdentifier);\n if (metadata == null) {\n return undefined;\n }\n\n return () => metadata;\n}\n\nfunction getUrlFromEnv(signalIdentifier: string) {\n // This does not change the string beyond trimming on purpose.\n // Normally a user would just use a host and port for gRPC, but the OTLP Exporter specification requires us to\n // use the raw provided endpoint to derive credential settings. Therefore, we only normalize right when\n // we merge user-provided, env-provided and defaults together, and we have determined which credentials to use.\n //\n // Examples:\n // - example.test:4317 -> use secure credentials from environment (or provided via code)\n // - http://example.test:4317 -> use insecure credentials if nothing else is provided\n // - https://example.test:4317 -> use secure credentials from environment (or provided via code)\n\n const specificEndpoint =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();\n const nonSpecificEndpoint =\n process.env['OTEL_EXPORTER_OTLP_ENDPOINT']?.trim();\n\n return fallbackIfNullishOrBlank(specificEndpoint, nonSpecificEndpoint);\n}\n\n/**\n * Determines whether the env var for insecure credentials is set to {@code true}.\n *\n * It will allow the following values as {@code true}\n * - 'true'\n * - 'true '\n * - ' true'\n * - 'TrUE'\n * - 'TRUE'\n *\n * It will not allow:\n * - 'true false'\n * - 'false true'\n * - 'true!'\n * - 'true,true'\n * - '1'\n * - ' '\n *\n * @param signalIdentifier\n */\nfunction getInsecureSettingFromEnv(signalIdentifier: string): boolean {\n const signalSpecificInsecureValue = process.env[\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_INSECURE`\n ]\n ?.toLowerCase()\n .trim();\n const nonSignalSpecificInsecureValue = process.env[\n 'OTEL_EXPORTER_OTLP_INSECURE'\n ]\n ?.toLowerCase()\n .trim();\n\n return (\n fallbackIfNullishOrBlank(\n signalSpecificInsecureValue,\n nonSignalSpecificInsecureValue\n ) === 'true'\n );\n}\n\nfunction readFileFromEnv(\n signalSpecificEnvVar: string,\n nonSignalSpecificEnvVar: string,\n warningMessage: string\n): Buffer | undefined {\n const signalSpecificPath = process.env[signalSpecificEnvVar]?.trim();\n const nonSignalSpecificPath = process.env[nonSignalSpecificEnvVar]?.trim();\n\n const filePath = fallbackIfNullishOrBlank(\n signalSpecificPath,\n nonSignalSpecificPath\n );\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\nfunction getCredentialsFromEnvIgnoreInsecure(\n signalIdentifier: string\n): ChannelCredentials {\n const clientKey = getClientKeyFromEnv(signalIdentifier);\n const clientCertificate = getClientCertificateFromEnv(signalIdentifier);\n const rootCertificate = getRootCertificateFromEnv(signalIdentifier);\n\n // if the chain is not intact, @grpc/grpc-js will throw. This is fine when a user provides it in code, but env var\n // config is not allowed to throw, so we add this safeguard and try to make the best of it here.\n const clientChainIntact = clientKey != null && clientCertificate != null;\n if (rootCertificate != null && !clientChainIntact) {\n diag.warn(\n 'Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate'\n );\n return createSslCredentials(getRootCertificateFromEnv(signalIdentifier));\n }\n\n return createSslCredentials(rootCertificate, clientKey, clientCertificate);\n}\n\nfunction getCredentialsFromEnv(signalIdentifier: string): ChannelCredentials {\n if (getInsecureSettingFromEnv(signalIdentifier)) {\n return createInsecureCredentials();\n }\n\n return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);\n}\n\nexport function getOtlpGrpcConfigurationFromEnv(\n signalIdentifier: string\n): Partial<UnresolvedOtlpGrpcConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n metadata: getMetadataProviderFromEnv(signalIdentifier),\n url: getUrlFromEnv(signalIdentifier),\n credentials: (finalResolvedUrl: string) => {\n // Always assume insecure on http:// and secure on https://, the protocol always takes precedence over the insecure setting.\n // note: the spec does not make any exception for\n // - \"localhost:4317\". If the protocol is omitted, credentials are required unless insecure is set\n // - \"unix://\", as it's neither http:// nor https:// and therefore credentials are required unless insecure is set\n if (finalResolvedUrl.startsWith('http://')) {\n return () => {\n return createInsecureCredentials();\n };\n } else if (finalResolvedUrl.startsWith('https://')) {\n return () => {\n return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);\n };\n }\n\n // defer to env settings in this case\n return () => {\n return getCredentialsFromEnv(signalIdentifier);\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAS,yBACP,gBACA,mBACoB;CACpB,IAAI,kBAAkB,QAAQ,mBAAmB,IAC/C,OAAO;CAGT,IAAI,qBAAqB,QAAQ,sBAAsB,IACrD,OAAO;AAIX;AAEA,SAAS,mBAAmB,kBAAgD;CAC1E,MAAM,2BACJ,QAAQ,IAAI,sBAAsB,iBAAiB,UAAU,EAAE,KAAK;CACtE,MAAM,8BACJ,QAAQ,IAAI,6BAA6B,EAAE,KAAK;CAElD,MAAM,yBAAA,GAAwBA,oBAAAA,wBAAAA,CAC5B,wBACF;CACA,MAAM,4BAAA,GAA2BA,oBAAAA,wBAAAA,CAC/B,2BACF;CAEA,IACE,OAAO,KAAK,qBAAqB,CAAC,CAAC,WAAW,KAC9C,OAAO,KAAK,wBAAwB,CAAC,CAAC,WAAW,GAEjD;CAGF,MAAM,eAAe,OAAO,OAC1B,CAAC,GACD,0BACA,qBACF;CAEA,MAAM,WAAWC,gCAAAA,oBAAoB;CAGrC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,YAAY,GACpD,SAAS,IAAI,KAAK,KAAK;CAGzB,OAAO;AACT;AAEA,SAAS,2BACP,kBAC8B;CAC9B,MAAM,WAAW,mBAAmB,gBAAgB;CACpD,IAAI,YAAY,MACd;CAGF,aAAa;AACf;AAEA,SAAS,cAAc,kBAA0B;CAW/C,MAAM,mBACJ,QAAQ,IAAI,sBAAsB,iBAAiB,WAAW,EAAE,KAAK;CACvE,MAAM,sBACJ,QAAQ,IAAI,8BAA8B,EAAE,KAAK;CAEnD,OAAO,yBAAyB,kBAAkB,mBAAmB;AACvE;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,0BAA0B,kBAAmC;CACpE,MAAM,8BAA8B,QAAQ,IAC1C,sBAAsB,iBAAiB,WACxC,EACG,YAAY,CAAC,CACd,KAAK;CACR,MAAM,iCAAiC,QAAQ,IAC7C,8BACD,EACG,YAAY,CAAC,CACd,KAAK;CAER,OACE,yBACE,6BACA,8BACF,MAAM;AAEV;AAEA,SAAS,gBACP,sBACA,yBACA,gBACoB;CACpB,MAAM,qBAAqB,QAAQ,IAAI,qBAAqB,EAAE,KAAK;CACnE,MAAM,wBAAwB,QAAQ,IAAI,wBAAwB,EAAE,KAAK;CAEzE,MAAM,WAAW,yBACf,oBACA,qBACF;CAEA,IAAI,YAAY,MACd,IAAI;EACF,OAAO,GAAG,aAAa,KAAK,QAAQ,QAAQ,IAAI,GAAG,QAAQ,CAAC;CAC9D,QAAQ;EACN,mBAAA,KAAK,KAAK,cAAc;EACxB;CACF;MAEA;AAEJ;AAEA,SAAS,4BACP,kBACoB;CACpB,OAAO,gBACL,sBAAsB,iBAAiB,sBACvC,yCACA,8CACF;AACF;AAEA,SAAS,oBAAoB,kBAA8C;CACzE,OAAO,gBACL,sBAAsB,iBAAiB,cACvC,iCACA,oDACF;AACF;AAEA,SAAS,0BACP,kBACoB;CACpB,OAAO,gBACL,sBAAsB,iBAAiB,eACvC,kCACA,sCACF;AACF;AAEA,SAAS,oCACP,kBACoB;CACpB,MAAM,YAAY,oBAAoB,gBAAgB;CACtD,MAAM,oBAAoB,4BAA4B,gBAAgB;CACtE,MAAM,kBAAkB,0BAA0B,gBAAgB;CAKlE,IAAI,mBAAmB,QAAQ,EADL,aAAa,QAAQ,qBAAqB,OACjB;EACjD,mBAAA,KAAK,KACH,yIACF;EACA,OAAOC,gCAAAA,qBAAqB,0BAA0B,gBAAgB,CAAC;CACzE;CAEA,OAAOA,gCAAAA,qBAAqB,iBAAiB,WAAW,iBAAiB;AAC3E;AAEA,SAAS,sBAAsB,kBAA8C;CAC3E,IAAI,0BAA0B,gBAAgB,GAC5C,OAAOC,gCAAAA,0BAA0B;CAGnC,OAAO,oCAAoC,gBAAgB;AAC7D;AAEA,SAAgB,gCACd,kBAC0C;CAC1C,OAAO;EACL,IAAA,GAAGC,4CAAAA,sCAAAA,CAAsC,gBAAgB;EACzD,UAAU,2BAA2B,gBAAgB;EACrD,KAAK,cAAc,gBAAgB;EACnC,cAAc,qBAA6B;GAKzC,IAAI,iBAAiB,WAAW,SAAS,GACvC,aAAa;IACX,OAAOD,gCAAAA,0BAA0B;GACnC;QACK,IAAI,iBAAiB,WAAW,UAAU,GAC/C,aAAa;IACX,OAAO,oCAAoC,gBAAgB;GAC7D;GAIF,aAAa;IACX,OAAO,sBAAsB,gBAAgB;GAC/C;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { createEmptyMetadata, createInsecureCredentials, createSslCredentials } from "../grpc-exporter-transport.mjs";
|
|
2
|
+
import { diag } from "@opentelemetry/api";
|
|
3
|
+
import { parseKeyPairsIntoRecord } from "@opentelemetry/core";
|
|
4
|
+
import { getSharedConfigurationFromEnvironment } from "@opentelemetry/otlp-exporter-base/node-http";
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
//#region src/configuration/otlp-grpc-env-configuration.ts
|
|
8
|
+
function fallbackIfNullishOrBlank(signalSpecific, nonSignalSpecific) {
|
|
9
|
+
if (signalSpecific != null && signalSpecific !== "") return signalSpecific;
|
|
10
|
+
if (nonSignalSpecific != null && nonSignalSpecific !== "") return nonSignalSpecific;
|
|
11
|
+
}
|
|
12
|
+
function getMetadataFromEnv(signalIdentifier) {
|
|
13
|
+
const signalSpecificRawHeaders = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();
|
|
14
|
+
const nonSignalSpecificRawHeaders = process.env["OTEL_EXPORTER_OTLP_HEADERS"]?.trim();
|
|
15
|
+
const signalSpecificHeaders = parseKeyPairsIntoRecord(signalSpecificRawHeaders);
|
|
16
|
+
const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
|
|
17
|
+
if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) return;
|
|
18
|
+
const mergeHeaders = Object.assign({}, nonSignalSpecificHeaders, signalSpecificHeaders);
|
|
19
|
+
const metadata = createEmptyMetadata();
|
|
20
|
+
for (const [key, value] of Object.entries(mergeHeaders)) metadata.set(key, value);
|
|
21
|
+
return metadata;
|
|
22
|
+
}
|
|
23
|
+
function getMetadataProviderFromEnv(signalIdentifier) {
|
|
24
|
+
const metadata = getMetadataFromEnv(signalIdentifier);
|
|
25
|
+
if (metadata == null) return;
|
|
26
|
+
return () => metadata;
|
|
27
|
+
}
|
|
28
|
+
function getUrlFromEnv(signalIdentifier) {
|
|
29
|
+
const specificEndpoint = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();
|
|
30
|
+
const nonSpecificEndpoint = process.env["OTEL_EXPORTER_OTLP_ENDPOINT"]?.trim();
|
|
31
|
+
return fallbackIfNullishOrBlank(specificEndpoint, nonSpecificEndpoint);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Determines whether the env var for insecure credentials is set to {@code true}.
|
|
35
|
+
*
|
|
36
|
+
* It will allow the following values as {@code true}
|
|
37
|
+
* - 'true'
|
|
38
|
+
* - 'true '
|
|
39
|
+
* - ' true'
|
|
40
|
+
* - 'TrUE'
|
|
41
|
+
* - 'TRUE'
|
|
42
|
+
*
|
|
43
|
+
* It will not allow:
|
|
44
|
+
* - 'true false'
|
|
45
|
+
* - 'false true'
|
|
46
|
+
* - 'true!'
|
|
47
|
+
* - 'true,true'
|
|
48
|
+
* - '1'
|
|
49
|
+
* - ' '
|
|
50
|
+
*
|
|
51
|
+
* @param signalIdentifier
|
|
52
|
+
*/
|
|
53
|
+
function getInsecureSettingFromEnv(signalIdentifier) {
|
|
54
|
+
const signalSpecificInsecureValue = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_INSECURE`]?.toLowerCase().trim();
|
|
55
|
+
const nonSignalSpecificInsecureValue = process.env["OTEL_EXPORTER_OTLP_INSECURE"]?.toLowerCase().trim();
|
|
56
|
+
return fallbackIfNullishOrBlank(signalSpecificInsecureValue, nonSignalSpecificInsecureValue) === "true";
|
|
57
|
+
}
|
|
58
|
+
function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
|
|
59
|
+
const signalSpecificPath = process.env[signalSpecificEnvVar]?.trim();
|
|
60
|
+
const nonSignalSpecificPath = process.env[nonSignalSpecificEnvVar]?.trim();
|
|
61
|
+
const filePath = fallbackIfNullishOrBlank(signalSpecificPath, nonSignalSpecificPath);
|
|
62
|
+
if (filePath != null) try {
|
|
63
|
+
return fs.readFileSync(path.resolve(process.cwd(), filePath));
|
|
64
|
+
} catch {
|
|
65
|
+
diag.warn(warningMessage);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
else return;
|
|
69
|
+
}
|
|
70
|
+
function getClientCertificateFromEnv(signalIdentifier) {
|
|
71
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE", "Failed to read client certificate chain file");
|
|
72
|
+
}
|
|
73
|
+
function getClientKeyFromEnv(signalIdentifier) {
|
|
74
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, "OTEL_EXPORTER_OTLP_CLIENT_KEY", "Failed to read client certificate private key file");
|
|
75
|
+
}
|
|
76
|
+
function getRootCertificateFromEnv(signalIdentifier) {
|
|
77
|
+
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CERTIFICATE", "Failed to read root certificate file");
|
|
78
|
+
}
|
|
79
|
+
function getCredentialsFromEnvIgnoreInsecure(signalIdentifier) {
|
|
80
|
+
const clientKey = getClientKeyFromEnv(signalIdentifier);
|
|
81
|
+
const clientCertificate = getClientCertificateFromEnv(signalIdentifier);
|
|
82
|
+
const rootCertificate = getRootCertificateFromEnv(signalIdentifier);
|
|
83
|
+
if (rootCertificate != null && !(clientKey != null && clientCertificate != null)) {
|
|
84
|
+
diag.warn("Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate");
|
|
85
|
+
return createSslCredentials(getRootCertificateFromEnv(signalIdentifier));
|
|
86
|
+
}
|
|
87
|
+
return createSslCredentials(rootCertificate, clientKey, clientCertificate);
|
|
88
|
+
}
|
|
89
|
+
function getCredentialsFromEnv(signalIdentifier) {
|
|
90
|
+
if (getInsecureSettingFromEnv(signalIdentifier)) return createInsecureCredentials();
|
|
91
|
+
return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);
|
|
92
|
+
}
|
|
93
|
+
function getOtlpGrpcConfigurationFromEnv(signalIdentifier) {
|
|
94
|
+
return {
|
|
95
|
+
...getSharedConfigurationFromEnvironment(signalIdentifier),
|
|
96
|
+
metadata: getMetadataProviderFromEnv(signalIdentifier),
|
|
97
|
+
url: getUrlFromEnv(signalIdentifier),
|
|
98
|
+
credentials: (finalResolvedUrl) => {
|
|
99
|
+
if (finalResolvedUrl.startsWith("http://")) return () => {
|
|
100
|
+
return createInsecureCredentials();
|
|
101
|
+
};
|
|
102
|
+
else if (finalResolvedUrl.startsWith("https://")) return () => {
|
|
103
|
+
return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);
|
|
104
|
+
};
|
|
105
|
+
return () => {
|
|
106
|
+
return getCredentialsFromEnv(signalIdentifier);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { getOtlpGrpcConfigurationFromEnv };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=otlp-grpc-env-configuration.mjs.map
|