@opentelemetry/configuration 0.221.0 → 0.222.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/README.md +6 -0
- package/build/src/FileConfigFactory.d.ts +6 -1
- package/build/src/FileConfigFactory.js +18 -1
- package/build/src/FileConfigFactory.js.map +1 -1
- package/build/src/index.d.ts +2 -2
- package/build/src/index.js +2 -1
- package/build/src/index.js.map +1 -1
- package/build/src/utils.js +1 -5
- package/build/src/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 +4 -4
package/README.md
CHANGED
|
@@ -139,6 +139,12 @@ When no config file is set, the factory reads from the standard OpenTelemetry SD
|
|
|
139
139
|
|
|
140
140
|
See [`src/EnvironmentConfigFactory.ts`](src/EnvironmentConfigFactory.ts) for the exact parsing logic.
|
|
141
141
|
|
|
142
|
+
## Exported types
|
|
143
|
+
|
|
144
|
+
Types exported from this package that model configuration data use a `ConfigModel` suffix (e.g. `SamplerConfigModel`, `SpanExporterConfigModel`) rather than their schema name (e.g. `Sampler`, `SpanExporter`). This keeps them from colliding with the SDK runtime types of the same name. The root type is `ConfigurationModel`.
|
|
145
|
+
|
|
146
|
+
Internally the package uses the schema names from `src/generated/types.ts`; the renaming happens at export time in `src/index.ts`. Follow this convention when adding new exports.
|
|
147
|
+
|
|
142
148
|
## Development
|
|
143
149
|
|
|
144
150
|
### Generated files
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFactory } from './IConfigFactory';
|
|
2
|
-
import type { AttributeNameValue, ConfigurationModel, TextMapPropagator } from './generated/types';
|
|
2
|
+
import type { AttributeNameValue, ConfigurationModel, NameStringValuePair, TextMapPropagator } from './generated/types';
|
|
3
3
|
export declare class FileConfigFactory implements ConfigFactory {
|
|
4
4
|
private _config;
|
|
5
5
|
constructor();
|
|
@@ -14,6 +14,11 @@ export declare function parseConfigFile(): ConfigurationModel;
|
|
|
14
14
|
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
15
15
|
*/
|
|
16
16
|
export declare function mergeResourceAttributesConfig(attributes?: AttributeNameValue[], attributes_list?: string | null): AttributeNameValue[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Merge headers from `headers` and `headers_list` (comma-separated key=value
|
|
19
|
+
* pairs) into a record. Entries in `headers` take precedence.
|
|
20
|
+
*/
|
|
21
|
+
export declare function mergeHeadersConfig(headers?: NameStringValuePair[], headers_list?: string | null): Record<string, string> | undefined;
|
|
17
22
|
/**
|
|
18
23
|
* Merge propagator.composite_list (comma-separated propagator names) into
|
|
19
24
|
* propagator.composite, with entries already in composite taking precedence.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.mergePropagatorCompositeConfig = exports.mergeResourceAttributesConfig = exports.parseConfigFile = exports.FileConfigFactory = void 0;
|
|
7
|
+
exports.mergePropagatorCompositeConfig = exports.mergeHeadersConfig = exports.mergeResourceAttributesConfig = exports.parseConfigFile = exports.FileConfigFactory = void 0;
|
|
8
8
|
const api_1 = require("@opentelemetry/api");
|
|
9
9
|
const core_1 = require("@opentelemetry/core");
|
|
10
10
|
const fs = require("fs");
|
|
@@ -132,6 +132,23 @@ function mergeResourceAttributesConfig(attributes, attributes_list) {
|
|
|
132
132
|
return mergedAttrs;
|
|
133
133
|
}
|
|
134
134
|
exports.mergeResourceAttributesConfig = mergeResourceAttributesConfig;
|
|
135
|
+
/**
|
|
136
|
+
* Merge headers from `headers` and `headers_list` (comma-separated key=value
|
|
137
|
+
* pairs) into a record. Entries in `headers` take precedence.
|
|
138
|
+
*/
|
|
139
|
+
function mergeHeadersConfig(headers, headers_list) {
|
|
140
|
+
if (!headers && !headers_list) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
const mergedHeaders = (0, core_1.parseKeyPairsIntoRecord)(headers_list ?? undefined);
|
|
144
|
+
headers?.forEach(header => {
|
|
145
|
+
if (header.value !== null) {
|
|
146
|
+
mergedHeaders[header.name] = header.value;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return mergedHeaders;
|
|
150
|
+
}
|
|
151
|
+
exports.mergeHeadersConfig = mergeHeadersConfig;
|
|
135
152
|
/**
|
|
136
153
|
* Merge propagator.composite_list (comma-separated propagator names) into
|
|
137
154
|
* propagator.composite, with entries already in composite taking precedence.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileConfigFactory.js","sourceRoot":"","sources":["../../src/FileConfigFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAA0C;AAC1C,8CAAuD;AACvD,yBAAyB;AACzB,6BAA6B;AAE7B,mCAA4C;AAM5C,oFAAoF;AACpF,2EAA2E;AAC3E,wDAAwD;AAExD,MAAa,iBAAiB;IACpB,OAAO,CAAqB;IAEpC;QACE,IAAI,CAAC,OAAO,GAAG,eAAe,EAAE,CAAC;IACnC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAVD,8CAUC;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,+BAA+B;AAC/B,wFAAwF;AACxF,MAAM,2BAA2B,GAAG,CAAC,CAAC;AACtC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAEtC,SAAS,kBAAkB,CAAC,UAAkB,EAAE,UAAmB;IACjE,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAI,KAAK,CACb,GAAG,UAAU,+BAA+B,UAAU,6CAA6C,CACpG,CAAC;KACH;IAED,6DAA6D;IAC7D,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,C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,OAAO,WAAW,CAAC;AACrB,CAAC;AAvDD,sEAuDC;AAED;;;;;;;;GAQG;AACH,SAAgB,8BAA8B,CAC5C,SAA+B,EAC/B,cAA8B;IAE9B,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAC1C,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1C,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SAC5B;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AApBD,wEAoBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { diag } from '@opentelemetry/api';\nimport { getStringFromEnv } from '@opentelemetry/core';\nimport * as fs from 'fs';\nimport * as yaml from 'yaml';\nimport type { ConfigFactory } from './IConfigFactory';\nimport { substituteEnvVars } from './utils';\nimport type {\n AttributeNameValue,\n ConfigurationModel,\n TextMapPropagator,\n} from './generated/types';\n// Pre-compiled ajv validator — eliminates runtime schema compilation on cold start.\n// Generated by `npm run generate:config`; do not import ajv directly here.\nimport * as validateConfig from './generated/validator';\n\nexport class FileConfigFactory implements ConfigFactory {\n private _config: ConfigurationModel;\n\n constructor() {\n this._config = parseConfigFile();\n }\n\n getConfigModel(): ConfigurationModel {\n return this._config;\n }\n}\n\n// The schema version this SDK targets. Per the configuration versioning spec,\n// an implementation MUST reject a config file whose MAJOR version differs (a\n// breaking-change boundary), accepts any MINOR version within that major, and\n// SHOULD warn when the MINOR version is newer than it targets since unknown\n// settings may be ignored. See\n// https://github.com/open-telemetry/opentelemetry-configuration/blob/main/VERSIONING.md\nconst SUPPORTED_FILE_FORMAT_MAJOR = 1;\nconst SUPPORTED_FILE_FORMAT_MINOR = 1;\n\nfunction validateFileFormat(configFile: string, fileFormat: unknown): void {\n if (typeof fileFormat !== 'string' || fileFormat.length === 0) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected a \"MAJOR.MINOR\" version string.`\n );\n }\n\n // Drop any pre-release / meta tag, e.g. \"1.0-rc.2\" -> \"1.0\".\n const parts = fileFormat.split('-', 1)[0].split('.');\n const major = Number(parts[0]);\n const minor = parts.length > 1 ? Number(parts[1]) : 0;\n if (!Number.isInteger(major) || !Number.isInteger(minor)) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected \"MAJOR.MINOR\" version numbers.`\n );\n }\n\n if (major !== SUPPORTED_FILE_FORMAT_MAJOR) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". This SDK supports schema version ${SUPPORTED_FILE_FORMAT_MAJOR}.x.`\n );\n }\n\n if (minor > SUPPORTED_FILE_FORMAT_MINOR) {\n diag.warn(\n `${configFile}: Configuration file_format \"${fileFormat}\" has a newer minor version than this SDK supports (${SUPPORTED_FILE_FORMAT_MAJOR}.${SUPPORTED_FILE_FORMAT_MINOR}); some settings may be ignored.`\n );\n }\n}\n\nexport function parseConfigFile(): ConfigurationModel {\n const configFile = getStringFromEnv('OTEL_CONFIG_FILE') || '';\n const file = fs.readFileSync(configFile, 'utf8');\n\n const doc = yaml.parseDocument(file, { version: '1.2' });\n substituteEnvVars(doc);\n const processed = doc.toJS() as Record<string, unknown>;\n\n validateFileFormat(configFile, processed?.file_format);\n\n const valid = validateConfig(processed);\n if (!valid) {\n let detail: string;\n if (!validateConfig.errors) {\n detail = 'unknown error';\n } else if (validateConfig.errors.length === 1) {\n const err = validateConfig.errors[0];\n detail = `${err.instancePath} ${err.message}`;\n } else {\n const sep = '\\n ';\n detail =\n sep +\n validateConfig.errors\n .map(e => `${e.instancePath} ${e.message}`)\n .join(sep);\n }\n throw new Error(\n `Invalid OpenTelemetry config file: ${configFile}: ${detail}`\n );\n }\n\n const data = processed as unknown as ConfigurationModel;\n\n // Strip file_format from output — it's a meta-field, not a config value\n delete (data as Record<string, unknown>)['file_format'];\n\n return data;\n}\n\n/**\n * Merge attributes from `resource.attributes` and `resource.attributes_list`\n * (comma-separated key=value pairs) into an `AttributeNameValue[]` array.\n * Entries already in `resource.attributes` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergeResourceAttributesConfig(\n attributes?: AttributeNameValue[],\n attributes_list?: string | null\n): AttributeNameValue[] | undefined {\n if (!attributes_list) {\n return attributes;\n }\n\n const mergedAttrs = attributes ? attributes.slice() : [];\n const existingNames = new Set(mergedAttrs.map(a => a.name));\n\n let discard = false;\n const listAttrs: Record<string, string> = {};\n for (const pair of attributes_list.split(',')) {\n if (pair.trim() === '') continue;\n\n const parts = pair.split('=');\n if (parts.length !== 2) {\n diag.warn(\n `Invalid format for resource.attributes_list entry \"${pair}\": expected key=value with '=' percent-encoded in keys/values. Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n const rawName = parts[0].trim();\n const rawValue = parts[1].trim();\n if (rawName === '') {\n diag.warn(\n `Empty attribute name in resource.attributes_list entry \"${pair}\". Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n try {\n listAttrs[decodeURIComponent(rawName)] = decodeURIComponent(rawValue);\n } catch (e) {\n diag.warn(\n `Failed to percent-decode resource.attributes_list entry \"${pair}\", discarding all entries: ${e}`\n );\n discard = true;\n break;\n }\n }\n\n if (!discard) {\n for (const [name, value] of Object.entries(listAttrs)) {\n if (!existingNames.has(name)) {\n mergedAttrs.push({ name, value, type: 'string' });\n }\n }\n }\n\n return mergedAttrs;\n}\n\n/**\n * Merge propagator.composite_list (comma-separated propagator names) into\n * propagator.composite, with entries already in composite taking precedence.\n * Merge TextMapPropagator configs from `propagator.composite` and `propagator.composite_list`\n * (comma-separated names) into a `TextMapPropagator[]` array.\n * Entries already in `propagator.composite` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergePropagatorCompositeConfig(\n composite?: TextMapPropagator[],\n composite_list?: string | null\n): TextMapPropagator[] | undefined {\n if (!composite_list) {\n return composite;\n }\n\n const mergedComposite = composite ? composite.slice() : [];\n const existingNames = new Set(mergedComposite.map(c => Object.keys(c)[0]));\n\n for (const name of composite_list.split(',')) {\n const trimmed = name.trim();\n if (trimmed && !existingNames.has(trimmed)) {\n mergedComposite.push({ [trimmed]: null });\n existingNames.add(trimmed);\n }\n }\n\n return mergedComposite;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FileConfigFactory.js","sourceRoot":"","sources":["../../src/FileConfigFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAA0C;AAC1C,8CAAgF;AAChF,yBAAyB;AACzB,6BAA6B;AAE7B,mCAA4C;AAO5C,oFAAoF;AACpF,2EAA2E;AAC3E,wDAAwD;AAExD,MAAa,iBAAiB;IACpB,OAAO,CAAqB;IAEpC;QACE,IAAI,CAAC,OAAO,GAAG,eAAe,EAAE,CAAC;IACnC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAVD,8CAUC;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,+BAA+B;AAC/B,wFAAwF;AACxF,MAAM,2BAA2B,GAAG,CAAC,CAAC;AACtC,MAAM,2BAA2B,GAA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M,IAAI,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAC1C,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1C,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SAC5B;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AApBD,wEAoBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { diag } from '@opentelemetry/api';\nimport { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport * as fs from 'fs';\nimport * as yaml from 'yaml';\nimport type { ConfigFactory } from './IConfigFactory';\nimport { substituteEnvVars } from './utils';\nimport type {\n AttributeNameValue,\n ConfigurationModel,\n NameStringValuePair,\n TextMapPropagator,\n} from './generated/types';\n// Pre-compiled ajv validator — eliminates runtime schema compilation on cold start.\n// Generated by `npm run generate:config`; do not import ajv directly here.\nimport * as validateConfig from './generated/validator';\n\nexport class FileConfigFactory implements ConfigFactory {\n private _config: ConfigurationModel;\n\n constructor() {\n this._config = parseConfigFile();\n }\n\n getConfigModel(): ConfigurationModel {\n return this._config;\n }\n}\n\n// The schema version this SDK targets. Per the configuration versioning spec,\n// an implementation MUST reject a config file whose MAJOR version differs (a\n// breaking-change boundary), accepts any MINOR version within that major, and\n// SHOULD warn when the MINOR version is newer than it targets since unknown\n// settings may be ignored. See\n// https://github.com/open-telemetry/opentelemetry-configuration/blob/main/VERSIONING.md\nconst SUPPORTED_FILE_FORMAT_MAJOR = 1;\nconst SUPPORTED_FILE_FORMAT_MINOR = 1;\n\nfunction validateFileFormat(configFile: string, fileFormat: unknown): void {\n if (typeof fileFormat !== 'string' || fileFormat.length === 0) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected a \"MAJOR.MINOR\" version string.`\n );\n }\n\n // Drop any pre-release / meta tag, e.g. \"1.0-rc.2\" -> \"1.0\".\n const parts = fileFormat.split('-', 1)[0].split('.');\n const major = Number(parts[0]);\n const minor = parts.length > 1 ? Number(parts[1]) : 0;\n if (!Number.isInteger(major) || !Number.isInteger(minor)) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected \"MAJOR.MINOR\" version numbers.`\n );\n }\n\n if (major !== SUPPORTED_FILE_FORMAT_MAJOR) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". This SDK supports schema version ${SUPPORTED_FILE_FORMAT_MAJOR}.x.`\n );\n }\n\n if (minor > SUPPORTED_FILE_FORMAT_MINOR) {\n diag.warn(\n `${configFile}: Configuration file_format \"${fileFormat}\" has a newer minor version than this SDK supports (${SUPPORTED_FILE_FORMAT_MAJOR}.${SUPPORTED_FILE_FORMAT_MINOR}); some settings may be ignored.`\n );\n }\n}\n\nexport function parseConfigFile(): ConfigurationModel {\n const configFile = getStringFromEnv('OTEL_CONFIG_FILE') || '';\n const file = fs.readFileSync(configFile, 'utf8');\n\n const doc = yaml.parseDocument(file, { version: '1.2' });\n substituteEnvVars(doc);\n const processed = doc.toJS() as Record<string, unknown>;\n\n validateFileFormat(configFile, processed?.file_format);\n\n const valid = validateConfig(processed);\n if (!valid) {\n let detail: string;\n if (!validateConfig.errors) {\n detail = 'unknown error';\n } else if (validateConfig.errors.length === 1) {\n const err = validateConfig.errors[0];\n detail = `${err.instancePath} ${err.message}`;\n } else {\n const sep = '\\n ';\n detail =\n sep +\n validateConfig.errors\n .map(e => `${e.instancePath} ${e.message}`)\n .join(sep);\n }\n throw new Error(\n `Invalid OpenTelemetry config file: ${configFile}: ${detail}`\n );\n }\n\n const data = processed as unknown as ConfigurationModel;\n\n // Strip file_format from output — it's a meta-field, not a config value\n delete (data as Record<string, unknown>)['file_format'];\n\n return data;\n}\n\n/**\n * Merge attributes from `resource.attributes` and `resource.attributes_list`\n * (comma-separated key=value pairs) into an `AttributeNameValue[]` array.\n * Entries already in `resource.attributes` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergeResourceAttributesConfig(\n attributes?: AttributeNameValue[],\n attributes_list?: string | null\n): AttributeNameValue[] | undefined {\n if (!attributes_list) {\n return attributes;\n }\n\n const mergedAttrs = attributes ? attributes.slice() : [];\n const existingNames = new Set(mergedAttrs.map(a => a.name));\n\n let discard = false;\n const listAttrs: Record<string, string> = {};\n for (const pair of attributes_list.split(',')) {\n if (pair.trim() === '') continue;\n\n const parts = pair.split('=');\n if (parts.length !== 2) {\n diag.warn(\n `Invalid format for resource.attributes_list entry \"${pair}\": expected key=value with '=' percent-encoded in keys/values. Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n const rawName = parts[0].trim();\n const rawValue = parts[1].trim();\n if (rawName === '') {\n diag.warn(\n `Empty attribute name in resource.attributes_list entry \"${pair}\". Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n try {\n listAttrs[decodeURIComponent(rawName)] = decodeURIComponent(rawValue);\n } catch (e) {\n diag.warn(\n `Failed to percent-decode resource.attributes_list entry \"${pair}\", discarding all entries: ${e}`\n );\n discard = true;\n break;\n }\n }\n\n if (!discard) {\n for (const [name, value] of Object.entries(listAttrs)) {\n if (!existingNames.has(name)) {\n mergedAttrs.push({ name, value, type: 'string' });\n }\n }\n }\n\n return mergedAttrs;\n}\n\n/**\n * Merge headers from `headers` and `headers_list` (comma-separated key=value\n * pairs) into a record. Entries in `headers` take precedence.\n */\nexport function mergeHeadersConfig(\n headers?: NameStringValuePair[],\n headers_list?: string | null\n): Record<string, string> | undefined {\n if (!headers && !headers_list) {\n return undefined;\n }\n\n const mergedHeaders = parseKeyPairsIntoRecord(headers_list ?? undefined);\n headers?.forEach(header => {\n if (header.value !== null) {\n mergedHeaders[header.name] = header.value;\n }\n });\n return mergedHeaders;\n}\n\n/**\n * Merge propagator.composite_list (comma-separated propagator names) into\n * propagator.composite, with entries already in composite taking precedence.\n * Merge TextMapPropagator configs from `propagator.composite` and `propagator.composite_list`\n * (comma-separated names) into a `TextMapPropagator[]` array.\n * Entries already in `propagator.composite` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergePropagatorCompositeConfig(\n composite?: TextMapPropagator[],\n composite_list?: string | null\n): TextMapPropagator[] | undefined {\n if (!composite_list) {\n return composite;\n }\n\n const mergedComposite = composite ? composite.slice() : [];\n const existingNames = new Set(mergedComposite.map(c => Object.keys(c)[0]));\n\n for (const name of composite_list.split(',')) {\n const trimmed = name.trim();\n if (trimmed && !existingNames.has(trimmed)) {\n mergedComposite.push({ [trimmed]: null });\n existingNames.add(trimmed);\n }\n }\n\n return mergedComposite;\n}\n"]}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { ConfigFactory } from './IConfigFactory';
|
|
2
|
-
export type { ConfigurationModel, LogRecordExporter as LogRecordExporterConfigModel, PushMetricExporter as PushMetricExporterConfigModel, OtlpHttpMetricExporter as OtlpHttpMetricExporterConfigModel, OtlpGrpcMetricExporter as OtlpGrpcMetricExporterConfigModel, InstrumentType as InstrumentTypeConfigModel, Aggregation as AggregationConfigModel, PeriodicMetricReader as PeriodicMetricReaderConfigModel, Sampler as SamplerConfigModel, SpanExporter as SpanExporterConfigModel, SpanProcessor as SpanProcessorConfigModel, SpanLimits as SpanLimitsConfigModel, MetricProducer as MetricProducerConfigModel, NameStringValuePair as NameStringValuePairConfigModel, HttpTls as HttpTlsConfigModel, GrpcTls as GrpcTlsConfigModel, IdGenerator as IdGeneratorConfigModel, SeverityNumber as SeverityNumberConfigModel, TextMapPropagator as TextMapPropagatorConfigModel, LoggerProvider as LoggerProviderConfigModel, AttributeLimits as AttributeLimitsConfigModel, LogRecordProcessor as LogRecordProcessorConfigModel, BatchLogRecordProcessor as BatchLogRecordProcessorConfigModel, SimpleLogRecordProcessor as SimpleLogRecordProcessorConfigModel, OtlpHttpExporter as OtlpHttpExporterConfigModel, OtlpGrpcExporter as OtlpGrpcExporterConfigModel, LogRecordLimits as LogRecordLimitsConfigModel, } from './generated/types';
|
|
2
|
+
export type { ConfigurationModel, LogRecordExporter as LogRecordExporterConfigModel, PushMetricExporter as PushMetricExporterConfigModel, OtlpHttpMetricExporter as OtlpHttpMetricExporterConfigModel, OtlpGrpcMetricExporter as OtlpGrpcMetricExporterConfigModel, InstrumentType as InstrumentTypeConfigModel, Aggregation as AggregationConfigModel, PeriodicMetricReader as PeriodicMetricReaderConfigModel, Sampler as SamplerConfigModel, SpanExporter as SpanExporterConfigModel, SpanProcessor as SpanProcessorConfigModel, SpanLimits as SpanLimitsConfigModel, MetricProducer as MetricProducerConfigModel, NameStringValuePair as NameStringValuePairConfigModel, HttpTls as HttpTlsConfigModel, GrpcTls as GrpcTlsConfigModel, IdGenerator as IdGeneratorConfigModel, SeverityNumber as SeverityNumberConfigModel, TextMapPropagator as TextMapPropagatorConfigModel, LoggerProvider as LoggerProviderConfigModel, AttributeLimits as AttributeLimitsConfigModel, LogRecordProcessor as LogRecordProcessorConfigModel, BatchLogRecordProcessor as BatchLogRecordProcessorConfigModel, SimpleLogRecordProcessor as SimpleLogRecordProcessorConfigModel, OtlpHttpExporter as OtlpHttpExporterConfigModel, OtlpGrpcExporter as OtlpGrpcExporterConfigModel, LogRecordLimits as LogRecordLimitsConfigModel, Propagator as PropagatorConfigModel, MeterProvider as MeterProviderConfigModel, MetricReader as MetricReaderConfigModel, ExporterTemporalityPreference as ExporterTemporalityPreferenceConfigModel, ExporterDefaultHistogramAggregation as ExporterDefaultHistogramAggregationConfigModel, ConsoleMetricExporter as ConsoleMetricExporterConfigModel, PullMetricReader as PullMetricReaderConfigModel, PullMetricExporter as PullMetricExporterConfigModel, ExperimentalPrometheusMetricExporter as ExperimentalPrometheusMetricExporterConfigModel, View as ViewConfigModel, ExplicitBucketHistogramAggregation as ExplicitBucketHistogramAggregationConfigModel, Base2ExponentialBucketHistogramAggregation as Base2ExponentialBucketHistogramAggregationConfigModel, TracerProvider as TracerProviderConfigModel, BatchSpanProcessor as BatchSpanProcessorConfigModel, SimpleSpanProcessor as SimpleSpanProcessorConfigModel, TraceIdRatioBasedSampler as TraceIdRatioBasedSamplerConfigModel, ParentBasedSampler as ParentBasedSamplerConfigModel, Resource as ResourceConfigModel, } from './generated/types';
|
|
3
3
|
export { createConfigFactory } from './ConfigFactory';
|
|
4
|
-
export { mergeResourceAttributesConfig, mergePropagatorCompositeConfig, } from './FileConfigFactory';
|
|
4
|
+
export { mergeHeadersConfig, mergeResourceAttributesConfig, mergePropagatorCompositeConfig, } from './FileConfigFactory';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.js
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.mergePropagatorCompositeConfig = exports.mergeResourceAttributesConfig = exports.createConfigFactory = void 0;
|
|
7
|
+
exports.mergePropagatorCompositeConfig = exports.mergeResourceAttributesConfig = exports.mergeHeadersConfig = exports.createConfigFactory = void 0;
|
|
8
8
|
var ConfigFactory_1 = require("./ConfigFactory");
|
|
9
9
|
Object.defineProperty(exports, "createConfigFactory", { enumerable: true, get: function () { return ConfigFactory_1.createConfigFactory; } });
|
|
10
10
|
var FileConfigFactory_1 = require("./FileConfigFactory");
|
|
11
|
+
Object.defineProperty(exports, "mergeHeadersConfig", { enumerable: true, get: function () { return FileConfigFactory_1.mergeHeadersConfig; } });
|
|
11
12
|
Object.defineProperty(exports, "mergeResourceAttributesConfig", { enumerable: true, get: function () { return FileConfigFactory_1.mergeResourceAttributesConfig; } });
|
|
12
13
|
Object.defineProperty(exports, "mergePropagatorCompositeConfig", { enumerable: true, get: function () { return FileConfigFactory_1.mergePropagatorCompositeConfig; } });
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyDH,iDAAsD;AAA7C,oHAAA,mBAAmB,OAAA;AAC5B,yDAI6B;AAH3B,uHAAA,kBAAkB,OAAA;AAClB,kIAAA,6BAA6B,OAAA;AAC7B,mIAAA,8BAA8B,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// Naming convention for types exported from this package: configuration\n// types use the `ConfigModel` suffix (e.g. `SamplerConfigModel`) rather than\n// their schema name (e.g. `Sampler`) so that they don't collide with the SDK\n// runtime types of the same name. Internally the package uses the schema\n// names from `./generated/types`; the renaming happens at export time here.\n// Follow this convention when adding new exports.\n\nexport type { ConfigFactory } from './IConfigFactory';\nexport type {\n ConfigurationModel,\n LogRecordExporter as LogRecordExporterConfigModel,\n PushMetricExporter as PushMetricExporterConfigModel,\n OtlpHttpMetricExporter as OtlpHttpMetricExporterConfigModel,\n OtlpGrpcMetricExporter as OtlpGrpcMetricExporterConfigModel,\n InstrumentType as InstrumentTypeConfigModel,\n Aggregation as AggregationConfigModel,\n PeriodicMetricReader as PeriodicMetricReaderConfigModel,\n Sampler as SamplerConfigModel,\n SpanExporter as SpanExporterConfigModel,\n SpanProcessor as SpanProcessorConfigModel,\n SpanLimits as SpanLimitsConfigModel,\n MetricProducer as MetricProducerConfigModel,\n NameStringValuePair as NameStringValuePairConfigModel,\n HttpTls as HttpTlsConfigModel,\n GrpcTls as GrpcTlsConfigModel,\n IdGenerator as IdGeneratorConfigModel,\n SeverityNumber as SeverityNumberConfigModel,\n TextMapPropagator as TextMapPropagatorConfigModel,\n LoggerProvider as LoggerProviderConfigModel,\n AttributeLimits as AttributeLimitsConfigModel,\n LogRecordProcessor as LogRecordProcessorConfigModel,\n BatchLogRecordProcessor as BatchLogRecordProcessorConfigModel,\n SimpleLogRecordProcessor as SimpleLogRecordProcessorConfigModel,\n OtlpHttpExporter as OtlpHttpExporterConfigModel,\n OtlpGrpcExporter as OtlpGrpcExporterConfigModel,\n LogRecordLimits as LogRecordLimitsConfigModel,\n Propagator as PropagatorConfigModel,\n MeterProvider as MeterProviderConfigModel,\n MetricReader as MetricReaderConfigModel,\n ExporterTemporalityPreference as ExporterTemporalityPreferenceConfigModel,\n ExporterDefaultHistogramAggregation as ExporterDefaultHistogramAggregationConfigModel,\n ConsoleMetricExporter as ConsoleMetricExporterConfigModel,\n PullMetricReader as PullMetricReaderConfigModel,\n PullMetricExporter as PullMetricExporterConfigModel,\n ExperimentalPrometheusMetricExporter as ExperimentalPrometheusMetricExporterConfigModel,\n View as ViewConfigModel,\n ExplicitBucketHistogramAggregation as ExplicitBucketHistogramAggregationConfigModel,\n Base2ExponentialBucketHistogramAggregation as Base2ExponentialBucketHistogramAggregationConfigModel,\n TracerProvider as TracerProviderConfigModel,\n BatchSpanProcessor as BatchSpanProcessorConfigModel,\n SimpleSpanProcessor as SimpleSpanProcessorConfigModel,\n TraceIdRatioBasedSampler as TraceIdRatioBasedSamplerConfigModel,\n ParentBasedSampler as ParentBasedSamplerConfigModel,\n Resource as ResourceConfigModel,\n} from './generated/types';\nexport { createConfigFactory } from './ConfigFactory';\nexport {\n mergeHeadersConfig,\n mergeResourceAttributesConfig,\n mergePropagatorCompositeConfig,\n} from './FileConfigFactory';\n"]}
|
package/build/src/utils.js
CHANGED
|
@@ -146,11 +146,7 @@ function initializeDefaultTracerProviderConfiguration() {
|
|
|
146
146
|
},
|
|
147
147
|
sampler: {
|
|
148
148
|
parent_based: {
|
|
149
|
-
root: { always_on:
|
|
150
|
-
remote_parent_sampled: { always_on: undefined },
|
|
151
|
-
remote_parent_not_sampled: { always_off: undefined },
|
|
152
|
-
local_parent_sampled: { always_on: undefined },
|
|
153
|
-
local_parent_not_sampled: { always_off: undefined },
|
|
149
|
+
root: { always_on: null },
|
|
154
150
|
},
|
|
155
151
|
},
|
|
156
152
|
};
|
package/build/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA6B;AAC7B,8CAAuD;AAGvD;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAAC,GAAkB;IAClD,4DAA4D;IAC5D,2CAA2C;IAC3C,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;QACd,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAC3B,IAAI,GAAG,KAAK,KAAK;gBAAE,OAAO,CAAC,oBAAoB;YAC/C,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;gBAAE,OAAO;YAC3C,IAAI,MAAM,GAAqC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvE,IAAI,MAAM,KAAK,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;gBAC5D,8DAA8D;gBAC9D,gDAAgD;gBAChD,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;aACnC;YACD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACtB,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAhBD,8CAgBC;AAED,4EAA4E;AAC5E,uEAAuE;AACvE,mEAAmE;AACnE,8EAA8E;AAC9E,mBAAmB;AACnB,MAAM,mBAAmB,GAAG,4CAA4C,CAAC;AAEzE;;GAEG;AACH,SAAS,WAAW,CAAC,CAAS;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC3B,MAAM,MAAM,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;YACzB,GAAG,CAAC,SAAS,GAAG,qBAAqB,CAAC;SACvC;QACD,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAnBD,4CAmBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport * as yaml from 'yaml';\nimport { getStringFromEnv } from '@opentelemetry/core';\nimport type { ConfigurationModel, GrpcTls, HttpTls } from './generated/types';\n\n/**\n * Handle (Environment) variable substitution per\n * https://opentelemetry.io/docs/specs/otel/configuration/data-model/#environment-variable-substitution\n *\n * This changes the yaml.Document in-place.\n * This must work with a yaml.Document, rather than a raw JS object from\n * `yaml.parse()`, to distinguish between `foo: ${BAR}` and `foo: \"${BAR}\"`.\n *\n * Exported for testing.\n */\nexport function substituteEnvVars(doc: yaml.Document) {\n // Visit each scalar string value in the document. These are\n // the candidates for env var substitution.\n yaml.visit(doc, {\n Scalar: (key, node, _path) => {\n if (key === 'key') return; // skip mapping keys\n if (typeof node.value !== 'string') return;\n let subbed: string | null | number | boolean = envVarSubst(node.value);\n if (subbed !== node.value && node.type === yaml.Scalar.PLAIN) {\n // \"PLAIN\" here is a simple YAML value (e.g. 42 in `foo: 42`).\n // I.e., not quoted (`foo: \"42\"`) or in a block.\n subbed = yamlScalarCoerce(subbed);\n }\n node.value = subbed;\n },\n });\n}\n\n// ENV_SUBSTITUTION_RE *mostly* matches the `ENV-SUBSTITUTION` ABNF from the\n// spec with the exception of the DEFAULT-VALUE: we are using `[^\\n}]*`\n// (copying the OTel Java regex) rather than a regex closer to ABNF\n// `*(VCHAR-WSP-NO-RBRACE)` (which is slightly ambiguous on what whitespace is\n// allowed in WSP).\nconst ENV_SUBSTITUTION_RE = /^([a-zA-Z_][a-zA-Z0-9_]*)(?::-([^\\n}]*))?$/;\n\n/**\n * Do environment variable substitution for the given string value.\n */\nfunction envVarSubst(s: string): string {\n const ESCAPE_RE = /(\\$\\$)/;\n const chunks = s.split(ESCAPE_RE);\n for (let i = 0; i < chunks.length; ++i) {\n if (i % 2 === 1) {\n // Odd chunks are matched escape sequences, i.e. '$$'.\n chunks[i] = '$';\n continue;\n }\n\n // Even chunks are processed for possible substition matches.\n const SUBSTITUTION_REF_RE = /\\$\\{(?:env:)?([^}]+)\\}/g;\n let chunk = '';\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = SUBSTITUTION_REF_RE.exec(chunks[i])) !== null) {\n chunk += chunks[i].slice(lastIndex, match.index);\n const envMatch = ENV_SUBSTITUTION_RE.exec(match[1]);\n if (!envMatch) {\n // E.g.: `key: ${STRING_VALUE:?error}` test case\n throw new Error(\n `parse error: invalid env var substitution: ${match[0]}`\n );\n }\n const envName = envMatch[1];\n const defaultValue = envMatch[2] ?? '';\n chunk += getStringFromEnv(envName) || defaultValue;\n lastIndex = SUBSTITUTION_REF_RE.lastIndex;\n }\n chunk += chunks[i].slice(lastIndex);\n chunks[i] = chunk;\n }\n\n const result = chunks.join('');\n return result;\n}\n\n/**\n * Re-interpret a string value from env var substitution as a possible\n * YAML number, boolean, or null value.\n *\n * If the interpretted value is any other type, we return the original\n * string:\n * - sequences and mappings may not result from env var substitution, per the spec\n * - a re-parsed YAML string normalizes whitespace, which we do not want\n */\nfunction yamlScalarCoerce(value: string): string | null | number | boolean {\n let coerced;\n try {\n coerced = yaml.parse(value, { version: '1.2' });\n } catch {\n return value;\n }\n const type = typeof coerced;\n if (coerced === null || type === 'number' || type === 'boolean') {\n return coerced;\n } else {\n return value;\n }\n}\n\nexport function getGrpcTlsConfig(\n certificateFile?: string,\n clientKeyFile?: string,\n clientCertificateFile?: string,\n insecure?: boolean\n): GrpcTls | undefined {\n if (certificateFile || clientKeyFile || clientCertificateFile) {\n const tls: GrpcTls = {};\n if (certificateFile) {\n tls.ca_file = certificateFile;\n }\n if (clientKeyFile) {\n tls.key_file = clientKeyFile;\n }\n if (clientCertificateFile) {\n tls.cert_file = clientCertificateFile;\n }\n if (insecure !== undefined) {\n tls.insecure = insecure;\n }\n return tls;\n }\n return undefined;\n}\n\nexport function initializeDefaultConfiguration(): ConfigurationModel {\n return {\n disabled: false,\n log_level: 'info',\n resource: {},\n attribute_limits: {\n attribute_count_limit: 128,\n },\n };\n}\n\nexport function initializeDefaultTracerProviderConfiguration(): NonNullable<\n ConfigurationModel['tracer_provider']\n> {\n return {\n processors: [],\n limits: {\n attribute_count_limit: 128,\n event_count_limit: 128,\n link_count_limit: 128,\n event_attribute_count_limit: 128,\n link_attribute_count_limit: 128,\n },\n sampler: {\n parent_based: {\n root: { always_on: undefined },\n remote_parent_sampled: { always_on: undefined },\n remote_parent_not_sampled: { always_off: undefined },\n local_parent_sampled: { always_on: undefined },\n local_parent_not_sampled: { always_off: undefined },\n },\n },\n };\n}\n\nexport function initializeDefaultMeterProviderConfiguration(): NonNullable<\n ConfigurationModel['meter_provider']\n> {\n return {\n readers: [],\n views: [],\n exemplar_filter: 'trace_based',\n };\n}\n\nexport function initializeDefaultLoggerProviderConfiguration(): NonNullable<\n ConfigurationModel['logger_provider']\n> {\n return {\n processors: [],\n limits: { attribute_count_limit: 128 },\n 'logger_configurator/development': {},\n };\n}\n\nexport function getHttpTlsConfig(\n certificateFile?: string,\n clientKeyFile?: string,\n clientCertificateFile?: string\n): HttpTls | undefined {\n if (certificateFile || clientKeyFile || clientCertificateFile) {\n const tls: HttpTls = {};\n if (certificateFile) {\n tls.ca_file = certificateFile;\n }\n if (clientKeyFile) {\n tls.key_file = clientKeyFile;\n }\n if (clientCertificateFile) {\n tls.cert_file = clientCertificateFile;\n }\n return tls;\n }\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA6B;AAC7B,8CAAuD;AAGvD;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAAC,GAAkB;IAClD,4DAA4D;IAC5D,2CAA2C;IAC3C,IAAI,CAAC,KAAK,CAA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ACX,KAAK,EAAE,EAAE;QACT,eAAe,EAAE,aAAa;KAC/B,CAAC;AACJ,CAAC;AARD,kGAQC;AAED,SAAgB,4CAA4C;IAG1D,OAAO;QACL,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,EAAE,qBAAqB,EAAE,GAAG,EAAE;QACtC,iCAAiC,EAAE,EAAE;KACtC,CAAC;AACJ,CAAC;AARD,oGAQC;AAED,SAAgB,gBAAgB,CAC9B,eAAwB,EACxB,aAAsB,EACtB,qBAA8B;IAE9B,IAAI,eAAe,IAAI,aAAa,IAAI,qBAAqB,EAAE;QAC7D,MAAM,GAAG,GAAY,EAAE,CAAC;QACxB,IAAI,eAAe,EAAE;YACnB,GAAG,CAAC,OAAO,GAAG,eAAe,CAAC;SAC/B;QACD,IAAI,aAAa,EAAE;YACjB,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAC;SAC9B;QACD,IAAI,qBAAqB,EAAE;YACzB,GAAG,CAAC,SAAS,GAAG,qBAAqB,CAAC;SACvC;QACD,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAnBD,4CAmBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport * as yaml from 'yaml';\nimport { getStringFromEnv } from '@opentelemetry/core';\nimport type { ConfigurationModel, GrpcTls, HttpTls } from './generated/types';\n\n/**\n * Handle (Environment) variable substitution per\n * https://opentelemetry.io/docs/specs/otel/configuration/data-model/#environment-variable-substitution\n *\n * This changes the yaml.Document in-place.\n * This must work with a yaml.Document, rather than a raw JS object from\n * `yaml.parse()`, to distinguish between `foo: ${BAR}` and `foo: \"${BAR}\"`.\n *\n * Exported for testing.\n */\nexport function substituteEnvVars(doc: yaml.Document) {\n // Visit each scalar string value in the document. These are\n // the candidates for env var substitution.\n yaml.visit(doc, {\n Scalar: (key, node, _path) => {\n if (key === 'key') return; // skip mapping keys\n if (typeof node.value !== 'string') return;\n let subbed: string | null | number | boolean = envVarSubst(node.value);\n if (subbed !== node.value && node.type === yaml.Scalar.PLAIN) {\n // \"PLAIN\" here is a simple YAML value (e.g. 42 in `foo: 42`).\n // I.e., not quoted (`foo: \"42\"`) or in a block.\n subbed = yamlScalarCoerce(subbed);\n }\n node.value = subbed;\n },\n });\n}\n\n// ENV_SUBSTITUTION_RE *mostly* matches the `ENV-SUBSTITUTION` ABNF from the\n// spec with the exception of the DEFAULT-VALUE: we are using `[^\\n}]*`\n// (copying the OTel Java regex) rather than a regex closer to ABNF\n// `*(VCHAR-WSP-NO-RBRACE)` (which is slightly ambiguous on what whitespace is\n// allowed in WSP).\nconst ENV_SUBSTITUTION_RE = /^([a-zA-Z_][a-zA-Z0-9_]*)(?::-([^\\n}]*))?$/;\n\n/**\n * Do environment variable substitution for the given string value.\n */\nfunction envVarSubst(s: string): string {\n const ESCAPE_RE = /(\\$\\$)/;\n const chunks = s.split(ESCAPE_RE);\n for (let i = 0; i < chunks.length; ++i) {\n if (i % 2 === 1) {\n // Odd chunks are matched escape sequences, i.e. '$$'.\n chunks[i] = '$';\n continue;\n }\n\n // Even chunks are processed for possible substition matches.\n const SUBSTITUTION_REF_RE = /\\$\\{(?:env:)?([^}]+)\\}/g;\n let chunk = '';\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = SUBSTITUTION_REF_RE.exec(chunks[i])) !== null) {\n chunk += chunks[i].slice(lastIndex, match.index);\n const envMatch = ENV_SUBSTITUTION_RE.exec(match[1]);\n if (!envMatch) {\n // E.g.: `key: ${STRING_VALUE:?error}` test case\n throw new Error(\n `parse error: invalid env var substitution: ${match[0]}`\n );\n }\n const envName = envMatch[1];\n const defaultValue = envMatch[2] ?? '';\n chunk += getStringFromEnv(envName) || defaultValue;\n lastIndex = SUBSTITUTION_REF_RE.lastIndex;\n }\n chunk += chunks[i].slice(lastIndex);\n chunks[i] = chunk;\n }\n\n const result = chunks.join('');\n return result;\n}\n\n/**\n * Re-interpret a string value from env var substitution as a possible\n * YAML number, boolean, or null value.\n *\n * If the interpretted value is any other type, we return the original\n * string:\n * - sequences and mappings may not result from env var substitution, per the spec\n * - a re-parsed YAML string normalizes whitespace, which we do not want\n */\nfunction yamlScalarCoerce(value: string): string | null | number | boolean {\n let coerced;\n try {\n coerced = yaml.parse(value, { version: '1.2' });\n } catch {\n return value;\n }\n const type = typeof coerced;\n if (coerced === null || type === 'number' || type === 'boolean') {\n return coerced;\n } else {\n return value;\n }\n}\n\nexport function getGrpcTlsConfig(\n certificateFile?: string,\n clientKeyFile?: string,\n clientCertificateFile?: string,\n insecure?: boolean\n): GrpcTls | undefined {\n if (certificateFile || clientKeyFile || clientCertificateFile) {\n const tls: GrpcTls = {};\n if (certificateFile) {\n tls.ca_file = certificateFile;\n }\n if (clientKeyFile) {\n tls.key_file = clientKeyFile;\n }\n if (clientCertificateFile) {\n tls.cert_file = clientCertificateFile;\n }\n if (insecure !== undefined) {\n tls.insecure = insecure;\n }\n return tls;\n }\n return undefined;\n}\n\nexport function initializeDefaultConfiguration(): ConfigurationModel {\n return {\n disabled: false,\n log_level: 'info',\n resource: {},\n attribute_limits: {\n attribute_count_limit: 128,\n },\n };\n}\n\nexport function initializeDefaultTracerProviderConfiguration(): NonNullable<\n ConfigurationModel['tracer_provider']\n> {\n return {\n processors: [],\n limits: {\n attribute_count_limit: 128,\n event_count_limit: 128,\n link_count_limit: 128,\n event_attribute_count_limit: 128,\n link_attribute_count_limit: 128,\n },\n sampler: {\n parent_based: {\n root: { always_on: null },\n },\n },\n };\n}\n\nexport function initializeDefaultMeterProviderConfiguration(): NonNullable<\n ConfigurationModel['meter_provider']\n> {\n return {\n readers: [],\n views: [],\n exemplar_filter: 'trace_based',\n };\n}\n\nexport function initializeDefaultLoggerProviderConfiguration(): NonNullable<\n ConfigurationModel['logger_provider']\n> {\n return {\n processors: [],\n limits: { attribute_count_limit: 128 },\n 'logger_configurator/development': {},\n };\n}\n\nexport function getHttpTlsConfig(\n certificateFile?: string,\n clientKeyFile?: string,\n clientCertificateFile?: string\n): HttpTls | undefined {\n if (certificateFile || clientKeyFile || clientCertificateFile) {\n const tls: HttpTls = {};\n if (certificateFile) {\n tls.ca_file = certificateFile;\n }\n if (clientKeyFile) {\n tls.key_file = clientKeyFile;\n }\n if (clientCertificateFile) {\n tls.cert_file = clientCertificateFile;\n }\n return tls;\n }\n return undefined;\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.222.0-development.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;;;GAGG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,uBAAuB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.222.0-development.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/configuration",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.222.0-development.0",
|
|
4
4
|
"description": "OpenTelemetry Configuration",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@opentelemetry/core": "2.
|
|
42
|
+
"@opentelemetry/core": "2.11.0-development.0",
|
|
43
43
|
"yaml": "^2.8.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/sinon": "17.0.4",
|
|
53
53
|
"ajv": "^8.0.0",
|
|
54
54
|
"json-schema-to-typescript": "^15.0.0",
|
|
55
|
-
"mocha": "11.
|
|
55
|
+
"mocha": "11.8.0",
|
|
56
56
|
"nyc": "17.1.0",
|
|
57
57
|
"sinon": "18.0.1",
|
|
58
58
|
"ts-loader": "9.5.7",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/configuration",
|
|
62
62
|
"sideEffects": false,
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f41805e769ba10fb6dae72a4b7a5a3dc67cca82e"
|
|
64
64
|
}
|