@opentelemetry/configuration 0.211.0 → 0.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/ConfigFactory.js +1 -12
- package/build/src/ConfigFactory.js.map +1 -1
- package/build/src/EnvironmentConfigFactory.js +37 -86
- package/build/src/EnvironmentConfigFactory.js.map +1 -1
- package/build/src/FileConfigFactory.d.ts +2 -0
- package/build/src/FileConfigFactory.js +166 -113
- package/build/src/FileConfigFactory.js.map +1 -1
- package/build/src/IConfigFactory.js +1 -12
- package/build/src/IConfigFactory.js.map +1 -1
- package/build/src/index.js +1 -12
- package/build/src/index.js.map +1 -1
- package/build/src/models/commonModel.d.ts +77 -39
- package/build/src/models/commonModel.js +29 -13
- package/build/src/models/commonModel.js.map +1 -1
- package/build/src/models/configModel.js +1 -16
- package/build/src/models/configModel.js.map +1 -1
- package/build/src/models/loggerProviderModel.d.ts +26 -16
- package/build/src/models/loggerProviderModel.js +2 -12
- package/build/src/models/loggerProviderModel.js.map +1 -1
- package/build/src/models/meterProviderModel.d.ts +39 -50
- package/build/src/models/meterProviderModel.js +10 -13
- package/build/src/models/meterProviderModel.js.map +1 -1
- package/build/src/models/resourceModel.d.ts +4 -4
- package/build/src/models/resourceModel.js +1 -12
- package/build/src/models/resourceModel.js.map +1 -1
- package/build/src/models/tracerProviderModel.d.ts +72 -79
- package/build/src/models/tracerProviderModel.js +1 -12
- package/build/src/models/tracerProviderModel.js.map +1 -1
- package/build/src/utils.d.ts +3 -0
- package/build/src/utils.js +39 -13
- 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 +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function initializeDefaultTracerProviderConfiguration(): TracerProvider
|
|
1
|
+
import { ExperimentalOtlpFileExporter, OtlpGrpcExporter, OtlpHttpExporter } from './commonModel';
|
|
2
|
+
export declare function initializeDefaultTracerProviderConfiguration(): Required<TracerProvider>;
|
|
3
3
|
export interface TracerProvider {
|
|
4
4
|
/**
|
|
5
5
|
* Configure span processors.
|
|
@@ -15,53 +15,33 @@ export interface TracerProvider {
|
|
|
15
15
|
*/
|
|
16
16
|
sampler?: Sampler;
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
19
|
-
/**
|
|
20
|
-
* Configure a batch span processor.
|
|
21
|
-
*/
|
|
22
|
-
batch?: BatchSpanProcessor;
|
|
23
|
-
/**
|
|
24
|
-
* Configure a simple span processor.
|
|
25
|
-
*/
|
|
26
|
-
simple?: SimpleSpanProcessor;
|
|
27
|
-
}
|
|
28
|
-
export interface SpanLimits {
|
|
29
|
-
/**
|
|
30
|
-
* Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit.
|
|
31
|
-
* Value must be non-negative.
|
|
32
|
-
* If omitted or null, there is no limit.
|
|
33
|
-
*/
|
|
34
|
-
attribute_value_length_limit?: number;
|
|
18
|
+
export interface BatchSpanProcessor {
|
|
35
19
|
/**
|
|
36
|
-
* Configure
|
|
20
|
+
* Configure delay interval (in milliseconds) between two consecutive exports.
|
|
37
21
|
* Value must be non-negative.
|
|
38
|
-
* If omitted or null,
|
|
22
|
+
* If omitted or null, 5000 is used for traces and 1000 for logs.
|
|
39
23
|
*/
|
|
40
|
-
|
|
24
|
+
schedule_delay?: number;
|
|
41
25
|
/**
|
|
42
|
-
* Configure
|
|
43
|
-
* Value must be non-negative.
|
|
44
|
-
* If omitted or null,
|
|
26
|
+
* Configure maximum allowed time (in milliseconds) to export data.
|
|
27
|
+
* Value must be non-negative. A value of 0 indicates no limit (infinity).
|
|
28
|
+
* If omitted or null, 30000 is used.
|
|
45
29
|
*/
|
|
46
|
-
|
|
30
|
+
export_timeout?: number;
|
|
47
31
|
/**
|
|
48
|
-
* Configure
|
|
49
|
-
*
|
|
50
|
-
* If omitted or null, 128 is used.
|
|
32
|
+
* Configure maximum queue size. Value must be positive.
|
|
33
|
+
* If omitted or null, 2048 is used.
|
|
51
34
|
*/
|
|
52
|
-
|
|
35
|
+
max_queue_size?: number;
|
|
53
36
|
/**
|
|
54
|
-
* Configure
|
|
55
|
-
*
|
|
56
|
-
* If omitted or null, 128 is used.
|
|
37
|
+
* Configure maximum batch size. Value must be positive.
|
|
38
|
+
* If omitted or null, 512 is used.
|
|
57
39
|
*/
|
|
58
|
-
|
|
40
|
+
max_export_batch_size?: number;
|
|
59
41
|
/**
|
|
60
|
-
* Configure
|
|
61
|
-
* Value must be non-negative.
|
|
62
|
-
* If omitted or null, 128 is used.
|
|
42
|
+
* Configure exporter.
|
|
63
43
|
*/
|
|
64
|
-
|
|
44
|
+
exporter: SpanExporter;
|
|
65
45
|
}
|
|
66
46
|
export interface Sampler {
|
|
67
47
|
/**
|
|
@@ -76,57 +56,45 @@ export interface Sampler {
|
|
|
76
56
|
* Configure sampler to be always_on.
|
|
77
57
|
*/
|
|
78
58
|
always_on?: object;
|
|
59
|
+
/***
|
|
60
|
+
* Configure sampler to be trace_id_ratio_based.
|
|
61
|
+
*/
|
|
62
|
+
trace_id_ratio_based?: TraceIdRatioBasedSampler;
|
|
79
63
|
}
|
|
80
64
|
export interface ParentBasedSampler {
|
|
81
65
|
/**
|
|
82
66
|
* Configure root sampler.
|
|
83
67
|
* If omitted or null, always_on is used.
|
|
84
68
|
*/
|
|
85
|
-
root
|
|
69
|
+
root?: Sampler;
|
|
86
70
|
/**
|
|
87
71
|
* Configure remote_parent_sampled sampler.
|
|
88
72
|
* If omitted or null, always_on is used.
|
|
89
73
|
*/
|
|
90
|
-
remote_parent_sampled
|
|
74
|
+
remote_parent_sampled?: Sampler;
|
|
91
75
|
/**
|
|
92
76
|
* Configure remote_parent_not_sampled sampler.
|
|
93
77
|
* If omitted or null, always_off is used.
|
|
94
78
|
*/
|
|
95
|
-
remote_parent_not_sampled
|
|
79
|
+
remote_parent_not_sampled?: Sampler;
|
|
96
80
|
/**
|
|
97
81
|
* Configure local_parent_sampled sampler.
|
|
98
82
|
* If omitted or null, always_on is used.
|
|
99
83
|
*/
|
|
100
|
-
local_parent_sampled
|
|
84
|
+
local_parent_sampled?: Sampler;
|
|
101
85
|
/**
|
|
102
86
|
* Configure local_parent_not_sampled sampler.
|
|
103
87
|
* If omitted or null, always_off is used.
|
|
104
88
|
*/
|
|
105
|
-
local_parent_not_sampled
|
|
89
|
+
local_parent_not_sampled?: Sampler;
|
|
106
90
|
}
|
|
107
|
-
export interface
|
|
91
|
+
export interface TraceIdRatioBasedSampler {
|
|
108
92
|
/**
|
|
109
|
-
* Configure
|
|
110
|
-
* Value must be non-negative.
|
|
111
|
-
* If omitted or null, 5000 is used for traces and 1000 for logs.
|
|
93
|
+
* Configure trace_id_ratio.
|
|
112
94
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* Value must be non-negative. A value of 0 indicates no limit (infinity).
|
|
117
|
-
* If omitted or null, 30000 is used.
|
|
118
|
-
*/
|
|
119
|
-
export_timeout?: number;
|
|
120
|
-
/**
|
|
121
|
-
* Configure maximum queue size. Value must be positive.
|
|
122
|
-
* If omitted or null, 2048 is used.
|
|
123
|
-
*/
|
|
124
|
-
max_queue_size?: number;
|
|
125
|
-
/**
|
|
126
|
-
* Configure maximum batch size. Value must be positive.
|
|
127
|
-
* If omitted or null, 512 is used.
|
|
128
|
-
*/
|
|
129
|
-
max_export_batch_size?: number;
|
|
95
|
+
ratio?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface SimpleSpanProcessor {
|
|
130
98
|
/**
|
|
131
99
|
* Configure exporter.
|
|
132
100
|
*/
|
|
@@ -145,33 +113,58 @@ export interface SpanExporter {
|
|
|
145
113
|
* Configure exporter to be OTLP with file transport.
|
|
146
114
|
* This type is in development and subject to breaking changes in minor versions.
|
|
147
115
|
*/
|
|
148
|
-
'otlp_file/development'?:
|
|
116
|
+
'otlp_file/development'?: ExperimentalOtlpFileExporter;
|
|
149
117
|
/**
|
|
150
118
|
* Configure exporter to be console.
|
|
151
119
|
*/
|
|
152
120
|
console?: object;
|
|
121
|
+
}
|
|
122
|
+
export interface SpanLimits {
|
|
153
123
|
/**
|
|
154
|
-
* Configure
|
|
124
|
+
* Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit.
|
|
125
|
+
* Value must be non-negative.
|
|
126
|
+
* If omitted or null, there is no limit.
|
|
155
127
|
*/
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
export interface ZipkinSpanExporter {
|
|
128
|
+
attribute_value_length_limit?: number;
|
|
159
129
|
/**
|
|
160
|
-
* Configure
|
|
161
|
-
*
|
|
130
|
+
* Configure max attribute count. Overrides .attribute_limits.attribute_count_limit.
|
|
131
|
+
* Value must be non-negative.
|
|
132
|
+
* If omitted or null, 128 is used.
|
|
162
133
|
*/
|
|
163
|
-
|
|
134
|
+
attribute_count_limit?: number;
|
|
164
135
|
/**
|
|
165
|
-
* Configure max
|
|
166
|
-
* Value must be non-negative.
|
|
167
|
-
* If omitted or null,
|
|
136
|
+
* Configure max span event count.
|
|
137
|
+
* Value must be non-negative.
|
|
138
|
+
* If omitted or null, 128 is used.
|
|
168
139
|
*/
|
|
169
|
-
|
|
140
|
+
event_count_limit?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Configure max span link count.
|
|
143
|
+
* Value must be non-negative.
|
|
144
|
+
* If omitted or null, 128 is used.
|
|
145
|
+
*/
|
|
146
|
+
link_count_limit?: number;
|
|
147
|
+
/**
|
|
148
|
+
* Configure max attributes per span event.
|
|
149
|
+
* Value must be non-negative.
|
|
150
|
+
* If omitted or null, 128 is used.
|
|
151
|
+
*/
|
|
152
|
+
event_attribute_count_limit?: number;
|
|
153
|
+
/**
|
|
154
|
+
* Configure max attributes per span link.
|
|
155
|
+
* Value must be non-negative.
|
|
156
|
+
* If omitted or null, 128 is used.
|
|
157
|
+
*/
|
|
158
|
+
link_attribute_count_limit?: number;
|
|
170
159
|
}
|
|
171
|
-
export interface
|
|
160
|
+
export interface SpanProcessor {
|
|
172
161
|
/**
|
|
173
|
-
* Configure
|
|
162
|
+
* Configure a batch span processor.
|
|
174
163
|
*/
|
|
175
|
-
|
|
164
|
+
batch?: BatchSpanProcessor;
|
|
165
|
+
/**
|
|
166
|
+
* Configure a simple span processor.
|
|
167
|
+
*/
|
|
168
|
+
simple?: SimpleSpanProcessor;
|
|
176
169
|
}
|
|
177
170
|
//# sourceMappingURL=tracerProviderModel.d.ts.map
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright The OpenTelemetry Authors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
4
|
*/
|
|
16
5
|
'use strict';
|
|
17
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracerProviderModel.js","sourceRoot":"","sources":["../../../src/models/tracerProviderModel.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tracerProviderModel.js","sourceRoot":"","sources":["../../../src/models/tracerProviderModel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,CAAC;;;AAQb,SAAgB,4CAA4C;IAC1D,OAAO;QACL,UAAU,EAAE,EAAE;QACd,MAAM,EAAE;YACN,qBAAqB,EAAE,GAAG;YAC1B,iBAAiB,EAAE,GAAG;YACtB,gBAAgB,EAAE,GAAG;YACrB,2BAA2B,EAAE,GAAG;YAChC,0BAA0B,EAAE,GAAG;SAChC;QACD,OAAO,EAAE;YACP,YAAY,EAAE;gBACZ,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE;gBAC9B,qBAAqB,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE;gBAC/C,yBAAyB,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE;gBACpD,oBAAoB,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE;gBAC9C,wBAAwB,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE;aACpD;SACF;KACF,CAAC;AACJ,CAAC;AApBD,oGAoBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n'use strict';\n\nimport {\n ExperimentalOtlpFileExporter,\n OtlpGrpcExporter,\n OtlpHttpExporter,\n} from './commonModel';\n\nexport function initializeDefaultTracerProviderConfiguration(): Required<TracerProvider> {\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 interface TracerProvider {\n /**\n * Configure span processors.\n */\n processors: SpanProcessor[];\n\n /**\n * Configure span limits. See also attribute_limits.\n */\n limits?: SpanLimits;\n\n /**\n * Configure the sampler.\n * If omitted, parent based sampler with a root of always_on is used.\n */\n sampler?: Sampler;\n}\n\nexport interface BatchSpanProcessor {\n /**\n * Configure delay interval (in milliseconds) between two consecutive exports.\n * Value must be non-negative.\n * If omitted or null, 5000 is used for traces and 1000 for logs.\n */\n schedule_delay?: number;\n\n /**\n * Configure maximum allowed time (in milliseconds) to export data.\n * Value must be non-negative. A value of 0 indicates no limit (infinity).\n * If omitted or null, 30000 is used.\n */\n export_timeout?: number;\n\n /**\n * Configure maximum queue size. Value must be positive.\n * If omitted or null, 2048 is used.\n */\n max_queue_size?: number;\n\n /**\n * Configure maximum batch size. Value must be positive.\n * If omitted or null, 512 is used.\n */\n max_export_batch_size?: number;\n\n /**\n * Configure exporter.\n */\n exporter: SpanExporter;\n}\n\nexport interface Sampler {\n /**\n * Configure sampler to be parent_based.\n */\n parent_based?: ParentBasedSampler;\n\n /**\n * Configure sampler to be always_off.\n */\n always_off?: object;\n\n /**\n * Configure sampler to be always_on.\n */\n always_on?: object;\n\n /***\n * Configure sampler to be trace_id_ratio_based.\n */\n trace_id_ratio_based?: TraceIdRatioBasedSampler;\n}\n\nexport interface ParentBasedSampler {\n /**\n * Configure root sampler.\n * If omitted or null, always_on is used.\n */\n root?: Sampler;\n\n /**\n * Configure remote_parent_sampled sampler.\n * If omitted or null, always_on is used.\n */\n remote_parent_sampled?: Sampler;\n\n /**\n * Configure remote_parent_not_sampled sampler.\n * If omitted or null, always_off is used.\n */\n remote_parent_not_sampled?: Sampler;\n\n /**\n * Configure local_parent_sampled sampler.\n * If omitted or null, always_on is used.\n */\n local_parent_sampled?: Sampler;\n\n /**\n * Configure local_parent_not_sampled sampler.\n * If omitted or null, always_off is used.\n */\n local_parent_not_sampled?: Sampler;\n}\n\nexport interface TraceIdRatioBasedSampler {\n /**\n * Configure trace_id_ratio.\n */\n ratio?: number;\n}\n\nexport interface SimpleSpanProcessor {\n /**\n * Configure exporter.\n */\n exporter: SpanExporter;\n}\n\nexport interface SpanExporter {\n /**\n * Configure exporter to be OTLP with HTTP transport.\n */\n otlp_http?: OtlpHttpExporter;\n\n /**\n * Configure exporter to be OTLP with gRPC transport.\n */\n otlp_grpc?: OtlpGrpcExporter;\n\n /**\n * Configure exporter to be OTLP with file transport.\n * This type is in development and subject to breaking changes in minor versions.\n */\n 'otlp_file/development'?: ExperimentalOtlpFileExporter;\n\n /**\n * Configure exporter to be console.\n */\n console?: object;\n}\n\nexport interface SpanLimits {\n /**\n * Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit.\n * Value must be non-negative.\n * If omitted or null, there is no limit.\n */\n attribute_value_length_limit?: number;\n\n /**\n * Configure max attribute count. Overrides .attribute_limits.attribute_count_limit.\n * Value must be non-negative.\n * If omitted or null, 128 is used.\n */\n attribute_count_limit?: number;\n\n /**\n * Configure max span event count.\n * Value must be non-negative.\n * If omitted or null, 128 is used.\n */\n event_count_limit?: number;\n\n /**\n * Configure max span link count.\n * Value must be non-negative.\n * If omitted or null, 128 is used.\n */\n link_count_limit?: number;\n\n /**\n * Configure max attributes per span event.\n * Value must be non-negative.\n * If omitted or null, 128 is used.\n */\n event_attribute_count_limit?: number;\n\n /**\n * Configure max attributes per span link.\n * Value must be non-negative.\n * If omitted or null, 128 is used.\n */\n link_attribute_count_limit?: number;\n}\n\nexport interface SpanProcessor {\n /**\n * Configure a batch span processor.\n */\n batch?: BatchSpanProcessor;\n\n /**\n * Configure a simple span processor.\n */\n simple?: SimpleSpanProcessor;\n}\n"]}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GrpcTls, HttpTls } from './models/commonModel';
|
|
1
2
|
/**
|
|
2
3
|
* Retrieves a boolean value from a configuration file parameter.
|
|
3
4
|
* - Trims leading and trailing whitespace and ignores casing.
|
|
@@ -63,4 +64,6 @@ export declare function getStringFromConfigFile(value: unknown): string | undefi
|
|
|
63
64
|
*/
|
|
64
65
|
export declare function getStringListFromConfigFile(value: unknown): string[] | undefined;
|
|
65
66
|
export declare function envVariableSubstitution(value: unknown): string | undefined;
|
|
67
|
+
export declare function getGrpcTlsConfig(certificateFile?: string, clientKeyFile?: string, clientCertificateFile?: string, insecure?: boolean): GrpcTls | undefined;
|
|
68
|
+
export declare function getHttpTlsConfig(certificateFile?: string, clientKeyFile?: string, clientCertificateFile?: string): HttpTls | undefined;
|
|
66
69
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/src/utils.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.envVariableSubstitution = exports.getStringListFromConfigFile = exports.getStringFromConfigFile = exports.getNumberListFromConfigFile = exports.getNumberFromConfigFile = exports.getBooleanListFromConfigFile = exports.getBooleanFromConfigFile = void 0;
|
|
3
|
+
exports.getHttpTlsConfig = exports.getGrpcTlsConfig = exports.envVariableSubstitution = exports.getStringListFromConfigFile = exports.getStringFromConfigFile = exports.getNumberListFromConfigFile = exports.getNumberFromConfigFile = exports.getBooleanListFromConfigFile = exports.getBooleanFromConfigFile = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright The OpenTelemetry Authors
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
7
|
*/
|
|
19
8
|
const api_1 = require("@opentelemetry/api");
|
|
20
9
|
const core_1 = require("@opentelemetry/core");
|
|
@@ -171,4 +160,41 @@ function envVariableSubstitution(value) {
|
|
|
171
160
|
return String(value);
|
|
172
161
|
}
|
|
173
162
|
exports.envVariableSubstitution = envVariableSubstitution;
|
|
163
|
+
function getGrpcTlsConfig(certificateFile, clientKeyFile, clientCertificateFile, insecure) {
|
|
164
|
+
if (certificateFile || clientKeyFile || clientCertificateFile) {
|
|
165
|
+
const tls = {};
|
|
166
|
+
if (certificateFile) {
|
|
167
|
+
tls.ca_file = certificateFile;
|
|
168
|
+
}
|
|
169
|
+
if (clientKeyFile) {
|
|
170
|
+
tls.key_file = clientKeyFile;
|
|
171
|
+
}
|
|
172
|
+
if (clientCertificateFile) {
|
|
173
|
+
tls.cert_file = clientCertificateFile;
|
|
174
|
+
}
|
|
175
|
+
if (insecure !== undefined) {
|
|
176
|
+
tls.insecure = insecure;
|
|
177
|
+
}
|
|
178
|
+
return tls;
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
exports.getGrpcTlsConfig = getGrpcTlsConfig;
|
|
183
|
+
function getHttpTlsConfig(certificateFile, clientKeyFile, clientCertificateFile) {
|
|
184
|
+
if (certificateFile || clientKeyFile || clientCertificateFile) {
|
|
185
|
+
const tls = {};
|
|
186
|
+
if (certificateFile) {
|
|
187
|
+
tls.ca_file = certificateFile;
|
|
188
|
+
}
|
|
189
|
+
if (clientKeyFile) {
|
|
190
|
+
tls.key_file = clientKeyFile;
|
|
191
|
+
}
|
|
192
|
+
if (clientCertificateFile) {
|
|
193
|
+
tls.cert_file = clientCertificateFile;
|
|
194
|
+
}
|
|
195
|
+
return tls;
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
exports.getHttpTlsConfig = getHttpTlsConfig;
|
|
174
200
|
//# sourceMappingURL=utils.js.map
|
package/build/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA0C;AAC1C,8CAAuD;AACvD,+BAA+B;AAE/B;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,KAAc;IACrD,MAAM,GAAG,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjE,IA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,CAAC;SAClB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC3B,CAAC;AARD,kEAQC;AAED,SAAgB,uBAAuB,CAAC,KAAc;IACpD,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClE,IAAI,OAAO,EAAE;QACX,IAAI,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3D,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,MAAM,WAAW,GAAG,IAAA,uBAAgB,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC;YAC3D,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;SACvD;QACD,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAjBD,0DAiBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { diag } from '@opentelemetry/api';\nimport { getStringFromEnv } from '@opentelemetry/core';\nimport { inspect } from 'util';\n\n/**\n * Retrieves a boolean value from a configuration file parameter.\n * - Trims leading and trailing whitespace and ignores casing.\n * - Returns `undefined` if the value is empty, unset, or contains only whitespace.\n * - Returns `undefined` and a warning for values that cannot be mapped to a boolean.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {boolean} - The boolean value or `false` if the environment variable is unset empty, unset, or contains only whitespace.\n */\nexport function getBooleanFromConfigFile(value: unknown): boolean | undefined {\n const raw = envVariableSubstitution(value)?.trim().toLowerCase();\n if (raw === 'true') {\n return true;\n } else if (raw === 'false') {\n return false;\n } else if (raw == null || raw === '') {\n return undefined;\n } else {\n diag.warn(`Unknown value ${inspect(raw)}, expected 'true' or 'false'`);\n return undefined;\n }\n}\n\n/**\n * Retrieves a list of booleans from a configuration file parameter.\n * - Uses ',' as the delimiter.\n * - Trims leading and trailing whitespace from each entry.\n * - Excludes empty entries.\n * - Returns `undefined` if the variable is empty or contains only whitespace.\n * - Returns an empty array if all entries are empty or whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {boolean[] | undefined} - The list of strings or `undefined`.\n */\nexport function getBooleanListFromConfigFile(\n value: unknown\n): boolean[] | undefined {\n const list = getStringFromConfigFile(value)?.split(',');\n if (list) {\n const filteredList = [];\n for (let i = 0; i < list.length; i++) {\n const element = getBooleanFromConfigFile(list[i]);\n if (element != null) {\n filteredList.push(element);\n }\n }\n return filteredList;\n }\n return list;\n}\n\n/**\n * Retrieves a number from a configuration file parameter.\n * - Returns `undefined` if the environment variable is empty, unset, or contains only whitespace.\n * - Returns `undefined` and a warning if is not a number.\n * - Returns a number in all other cases.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {number | undefined} - The number value or `undefined`.\n */\nexport function getNumberFromConfigFile(value: unknown): number | undefined {\n const raw = envVariableSubstitution(value)?.trim();\n if (raw == null || raw.trim() === '') {\n return undefined;\n }\n\n const n = Number(raw);\n if (isNaN(n)) {\n diag.warn(`Unknown value ${inspect(raw)}, expected a number`);\n return undefined;\n }\n\n return n;\n}\n\n/**\n * Retrieves a list of numbers from a configuration file parameter.\n * - Uses ',' as the delimiter.\n * - Trims leading and trailing whitespace from each entry.\n * - Excludes empty entries.\n * - Returns `undefined` if the variable is empty or contains only whitespace.\n * - Returns an empty array if all entries are empty or whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {number[] | undefined} - The list of numbers or `undefined`.\n */\nexport function getNumberListFromConfigFile(\n value: unknown\n): number[] | undefined {\n const list = getStringFromConfigFile(value)?.split(',');\n if (list) {\n const filteredList = [];\n for (let i = 0; i < list.length; i++) {\n const element = getNumberFromConfigFile(list[i]);\n if (element || element === 0) {\n filteredList.push(element);\n }\n }\n return filteredList;\n }\n return list;\n}\n\n/**\n * Retrieves a string from a configuration file parameter.\n * - Returns `undefined` if the variable is empty, unset, or contains only whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {string | undefined} - The string value or `undefined`.\n */\nexport function getStringFromConfigFile(value: unknown): string | undefined {\n const raw = envVariableSubstitution(value)?.trim();\n if (value == null || raw === '') {\n return undefined;\n }\n return raw;\n}\n\n/**\n * Retrieves a list of strings from a configuration file parameter.\n * - Uses ',' as the delimiter.\n * - Trims leading and trailing whitespace from each entry.\n * - Excludes empty entries.\n * - Returns `undefined` if the variable is empty or contains only whitespace.\n * - Returns an empty array if all entries are empty or whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {string[] | undefined} - The list of strings or `undefined`.\n */\nexport function getStringListFromConfigFile(\n value: unknown\n): string[] | undefined {\n value = envVariableSubstitution(value);\n return getStringFromConfigFile(value)\n ?.split(',')\n .map(v => v.trim())\n .filter(s => s !== '');\n}\n\nexport function envVariableSubstitution(value: unknown): string | undefined {\n if (value == null) {\n return undefined;\n }\n\n const matches = String(value).match(/\\$\\{[a-zA-Z0-9,=/_:.-]*\\}/g);\n if (matches) {\n let stringValue = String(value);\n for (const match of matches) {\n const v = match.substring(2, match.length - 1).split(':-');\n const defaultValue = v.length === 2 ? v[1] : '';\n const replacement = getStringFromEnv(v[0]) || defaultValue;\n stringValue = stringValue.replace(match, replacement);\n }\n return stringValue;\n }\n return String(value);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,4CAA0C;AAC1C,8CAAuD;AACvD,+BAA+B;AAG/B;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,KAAc;IACrD,MAAM,GAAG,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjE,IAAI,GAAG,KAAK,MAAM,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,GAAG,KAAK,OAAO,EAAE;QAC1B,OAAO,KAAK,CAAC;KACd;SAAM,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,EAAE;QACpC,OAAO,SAAS,CAAC;KAClB;SAAM;QACL,UAAI,CAAC,IAAI,CAAC,iBAAiB,IAAA,cAAO,EAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QACvE,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAZD,4DAYC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,4BAA4B,CAC1C,KAAc;IAEd,MAAM,IAAI,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,IAAI,EAAE;QACR,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,OAAO,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,IAAI,OAAO,IAAI,IAAI,EAAE;gBACnB,YAAY,CAAC,IAA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@opentelemetry/api';\nimport { getStringFromEnv } from '@opentelemetry/core';\nimport { inspect } from 'util';\nimport { GrpcTls, HttpTls } from './models/commonModel';\n\n/**\n * Retrieves a boolean value from a configuration file parameter.\n * - Trims leading and trailing whitespace and ignores casing.\n * - Returns `undefined` if the value is empty, unset, or contains only whitespace.\n * - Returns `undefined` and a warning for values that cannot be mapped to a boolean.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {boolean} - The boolean value or `false` if the environment variable is unset empty, unset, or contains only whitespace.\n */\nexport function getBooleanFromConfigFile(value: unknown): boolean | undefined {\n const raw = envVariableSubstitution(value)?.trim().toLowerCase();\n if (raw === 'true') {\n return true;\n } else if (raw === 'false') {\n return false;\n } else if (raw == null || raw === '') {\n return undefined;\n } else {\n diag.warn(`Unknown value ${inspect(raw)}, expected 'true' or 'false'`);\n return undefined;\n }\n}\n\n/**\n * Retrieves a list of booleans from a configuration file parameter.\n * - Uses ',' as the delimiter.\n * - Trims leading and trailing whitespace from each entry.\n * - Excludes empty entries.\n * - Returns `undefined` if the variable is empty or contains only whitespace.\n * - Returns an empty array if all entries are empty or whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {boolean[] | undefined} - The list of strings or `undefined`.\n */\nexport function getBooleanListFromConfigFile(\n value: unknown\n): boolean[] | undefined {\n const list = getStringFromConfigFile(value)?.split(',');\n if (list) {\n const filteredList = [];\n for (let i = 0; i < list.length; i++) {\n const element = getBooleanFromConfigFile(list[i]);\n if (element != null) {\n filteredList.push(element);\n }\n }\n return filteredList;\n }\n return list;\n}\n\n/**\n * Retrieves a number from a configuration file parameter.\n * - Returns `undefined` if the environment variable is empty, unset, or contains only whitespace.\n * - Returns `undefined` and a warning if is not a number.\n * - Returns a number in all other cases.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {number | undefined} - The number value or `undefined`.\n */\nexport function getNumberFromConfigFile(value: unknown): number | undefined {\n const raw = envVariableSubstitution(value)?.trim();\n if (raw == null || raw.trim() === '') {\n return undefined;\n }\n\n const n = Number(raw);\n if (isNaN(n)) {\n diag.warn(`Unknown value ${inspect(raw)}, expected a number`);\n return undefined;\n }\n\n return n;\n}\n\n/**\n * Retrieves a list of numbers from a configuration file parameter.\n * - Uses ',' as the delimiter.\n * - Trims leading and trailing whitespace from each entry.\n * - Excludes empty entries.\n * - Returns `undefined` if the variable is empty or contains only whitespace.\n * - Returns an empty array if all entries are empty or whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {number[] | undefined} - The list of numbers or `undefined`.\n */\nexport function getNumberListFromConfigFile(\n value: unknown\n): number[] | undefined {\n const list = getStringFromConfigFile(value)?.split(',');\n if (list) {\n const filteredList = [];\n for (let i = 0; i < list.length; i++) {\n const element = getNumberFromConfigFile(list[i]);\n if (element || element === 0) {\n filteredList.push(element);\n }\n }\n return filteredList;\n }\n return list;\n}\n\n/**\n * Retrieves a string from a configuration file parameter.\n * - Returns `undefined` if the variable is empty, unset, or contains only whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {string | undefined} - The string value or `undefined`.\n */\nexport function getStringFromConfigFile(value: unknown): string | undefined {\n const raw = envVariableSubstitution(value)?.trim();\n if (value == null || raw === '') {\n return undefined;\n }\n return raw;\n}\n\n/**\n * Retrieves a list of strings from a configuration file parameter.\n * - Uses ',' as the delimiter.\n * - Trims leading and trailing whitespace from each entry.\n * - Excludes empty entries.\n * - Returns `undefined` if the variable is empty or contains only whitespace.\n * - Returns an empty array if all entries are empty or whitespace.\n *\n * @param {unknown} value - The value from the config file.\n * @returns {string[] | undefined} - The list of strings or `undefined`.\n */\nexport function getStringListFromConfigFile(\n value: unknown\n): string[] | undefined {\n value = envVariableSubstitution(value);\n return getStringFromConfigFile(value)\n ?.split(',')\n .map(v => v.trim())\n .filter(s => s !== '');\n}\n\nexport function envVariableSubstitution(value: unknown): string | undefined {\n if (value == null) {\n return undefined;\n }\n\n const matches = String(value).match(/\\$\\{[a-zA-Z0-9,=/_:.-]*\\}/g);\n if (matches) {\n let stringValue = String(value);\n for (const match of matches) {\n const v = match.substring(2, match.length - 1).split(':-');\n const defaultValue = v.length === 2 ? v[1] : '';\n const replacement = getStringFromEnv(v[0]) || defaultValue;\n stringValue = stringValue.replace(match, replacement);\n }\n return stringValue;\n }\n return String(value);\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 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.213.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.213.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/configuration",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.213.0",
|
|
4
4
|
"description": "OpenTelemetry Configuration",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@opentelemetry/core": "2.
|
|
41
|
+
"@opentelemetry/core": "2.6.0",
|
|
42
42
|
"yaml": "^2.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
},
|
|
58
58
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/configuration",
|
|
59
59
|
"sideEffects": false,
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "541e1b4ad83ad2093459794a18283228fe58d199"
|
|
61
61
|
}
|