@opentelemetry/sdk-node 0.50.0 → 0.51.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/LICENSE +1 -1
- package/README.md +18 -1
- package/build/src/sdk.d.ts +0 -39
- package/build/src/sdk.js +24 -100
- package/build/src/sdk.js.map +1 -1
- package/build/src/utils.d.ts +2 -0
- package/build/src/utils.js +34 -1
- 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 +17 -17
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -115,9 +115,26 @@ Configure a resource. Resources may also be detected by using the `autoDetectRes
|
|
|
115
115
|
|
|
116
116
|
### resourceDetectors
|
|
117
117
|
|
|
118
|
-
Configure resource detectors. By default, the resource detectors are [envDetector, processDetector].
|
|
118
|
+
Configure resource detectors. By default, the resource detectors are [envDetector, processDetector, hostDetector].
|
|
119
119
|
NOTE: In order to enable the detection, the parameter `autoDetectResources` has to be `true`.
|
|
120
120
|
|
|
121
|
+
If `resourceDetectors` was not set, you can also use the environment variable `OTEL_NODE_RESOURCE_DETECTORS` to enable only certain detectors, or completely disable them:
|
|
122
|
+
|
|
123
|
+
- `env`
|
|
124
|
+
- `host`
|
|
125
|
+
- `os`
|
|
126
|
+
- `process`
|
|
127
|
+
- `serviceinstance` (experimental)
|
|
128
|
+
- `all` - enable all resource detectors above
|
|
129
|
+
- **NOTE:** future versions of `@opentelemetry/sdk-node` may include additional detectors that will be covered by this scope.
|
|
130
|
+
- `none` - disable resource detection
|
|
131
|
+
|
|
132
|
+
For example, to enable only the `env`, `host` detectors:
|
|
133
|
+
|
|
134
|
+
```shell
|
|
135
|
+
export OTEL_NODE_RESOURCE_DETECTORS="env,host"
|
|
136
|
+
```
|
|
137
|
+
|
|
121
138
|
### sampler
|
|
122
139
|
|
|
123
140
|
Configure a custom sampler. By default, all traces will be sampled.
|
package/build/src/sdk.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
2
|
-
import { IResource } from '@opentelemetry/resources';
|
|
3
1
|
import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
4
2
|
import { MetricReader, View } from '@opentelemetry/sdk-metrics';
|
|
5
|
-
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
6
|
-
import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
|
|
7
3
|
import { NodeSDKConfiguration } from './types';
|
|
8
4
|
/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */
|
|
9
5
|
export declare type MeterProviderConfig = {
|
|
@@ -40,41 +36,6 @@ export declare class NodeSDK {
|
|
|
40
36
|
* Create a new NodeJS SDK instance
|
|
41
37
|
*/
|
|
42
38
|
constructor(configuration?: Partial<NodeSDKConfiguration>);
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @deprecated Please pass {@code sampler}, {@code generalLimits}, {@code spanLimits}, {@code resource},
|
|
46
|
-
* {@code IdGenerator}, {@code spanProcessor}, {@code contextManager} and {@code textMapPropagator},
|
|
47
|
-
* to the constructor options instead.
|
|
48
|
-
*
|
|
49
|
-
* Set configurations needed to register a TracerProvider
|
|
50
|
-
*/
|
|
51
|
-
configureTracerProvider(tracerConfig: NodeTracerConfig, spanProcessors: SpanProcessor[], contextManager?: ContextManager, textMapPropagator?: TextMapPropagator): void;
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated Please pass {@code logRecordProcessor} to the constructor options instead.
|
|
54
|
-
*
|
|
55
|
-
* Set configurations needed to register a LoggerProvider
|
|
56
|
-
*/
|
|
57
|
-
configureLoggerProvider(config: LoggerProviderConfig): void;
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated Please pass {@code views} and {@code reader} to the constructor options instead.
|
|
60
|
-
*
|
|
61
|
-
* Set configurations needed to register a MeterProvider
|
|
62
|
-
*/
|
|
63
|
-
configureMeterProvider(config: MeterProviderConfig): void;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Resources are detected automatically on {@link NodeSDK.start()}, when the {@code autoDetectResources}
|
|
66
|
-
* constructor option is set to {@code true} or left {@code undefined}.
|
|
67
|
-
*
|
|
68
|
-
* Detect resource attributes
|
|
69
|
-
*/
|
|
70
|
-
detectResources(): void;
|
|
71
|
-
/**
|
|
72
|
-
* @deprecated Please pre-merge resources and pass them to the constructor
|
|
73
|
-
*
|
|
74
|
-
* Manually add a Resource
|
|
75
|
-
* @param resource
|
|
76
|
-
*/
|
|
77
|
-
addResource(resource: IResource): void;
|
|
78
39
|
/**
|
|
79
40
|
* Call this method to construct SDK components and register them with the OpenTelemetry API.
|
|
80
41
|
*/
|
package/build/src/sdk.js
CHANGED
|
@@ -50,11 +50,15 @@ class NodeSDK {
|
|
|
50
50
|
}
|
|
51
51
|
this._configuration = configuration;
|
|
52
52
|
this._resource = (_a = configuration.resource) !== null && _a !== void 0 ? _a : new resources_1.Resource({});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
let defaultDetectors = [];
|
|
54
|
+
if (process.env.OTEL_NODE_RESOURCE_DETECTORS != null) {
|
|
55
|
+
defaultDetectors = (0, utils_1.getResourceDetectorsFromEnv)();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
defaultDetectors = [resources_1.envDetector, resources_1.processDetector, resources_1.hostDetector];
|
|
59
|
+
}
|
|
60
|
+
this._resourceDetectors =
|
|
61
|
+
(_b = configuration.resourceDetectors) !== null && _b !== void 0 ? _b : defaultDetectors;
|
|
58
62
|
this._serviceName = configuration.serviceName;
|
|
59
63
|
this._autoDetectResources = (_c = configuration.autoDetectResources) !== null && _c !== void 0 ? _c : true;
|
|
60
64
|
// If a tracer provider can be created from manual configuration, create it
|
|
@@ -74,15 +78,21 @@ class NodeSDK {
|
|
|
74
78
|
if (configuration.spanProcessor) {
|
|
75
79
|
api_1.diag.warn("The 'spanProcessor' option is deprecated. Please use 'spanProcessors' instead.");
|
|
76
80
|
}
|
|
77
|
-
const spanProcessor = (_d = configuration.spanProcessor) !== null && _d !== void 0 ? _d :
|
|
81
|
+
const spanProcessor = (_d = configuration.spanProcessor) !== null && _d !== void 0 ? _d :
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
83
|
+
new sdk_trace_base_1.BatchSpanProcessor(configuration.traceExporter);
|
|
78
84
|
const spanProcessors = (_e = configuration.spanProcessors) !== null && _e !== void 0 ? _e : [spanProcessor];
|
|
79
|
-
this.
|
|
85
|
+
this._tracerProviderConfig = {
|
|
86
|
+
tracerConfig: tracerProviderConfig,
|
|
87
|
+
spanProcessors,
|
|
88
|
+
contextManager: configuration.contextManager,
|
|
89
|
+
textMapPropagator: configuration.textMapPropagator,
|
|
90
|
+
};
|
|
80
91
|
}
|
|
81
92
|
if (configuration.logRecordProcessor) {
|
|
82
|
-
|
|
93
|
+
this._loggerProviderConfig = {
|
|
83
94
|
logRecordProcessor: configuration.logRecordProcessor,
|
|
84
95
|
};
|
|
85
|
-
this.configureLoggerProvider(loggerProviderConfig);
|
|
86
96
|
}
|
|
87
97
|
if (configuration.metricReader || configuration.views) {
|
|
88
98
|
const meterProviderConfig = {};
|
|
@@ -92,7 +102,7 @@ class NodeSDK {
|
|
|
92
102
|
if (configuration.views) {
|
|
93
103
|
meterProviderConfig.views = configuration.views;
|
|
94
104
|
}
|
|
95
|
-
this.
|
|
105
|
+
this._meterProviderConfig = meterProviderConfig;
|
|
96
106
|
}
|
|
97
107
|
let instrumentations = [];
|
|
98
108
|
if (configuration.instrumentations) {
|
|
@@ -100,95 +110,6 @@ class NodeSDK {
|
|
|
100
110
|
}
|
|
101
111
|
this._instrumentations = instrumentations;
|
|
102
112
|
}
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @deprecated Please pass {@code sampler}, {@code generalLimits}, {@code spanLimits}, {@code resource},
|
|
106
|
-
* {@code IdGenerator}, {@code spanProcessor}, {@code contextManager} and {@code textMapPropagator},
|
|
107
|
-
* to the constructor options instead.
|
|
108
|
-
*
|
|
109
|
-
* Set configurations needed to register a TracerProvider
|
|
110
|
-
*/
|
|
111
|
-
configureTracerProvider(tracerConfig, spanProcessors, contextManager, textMapPropagator) {
|
|
112
|
-
this._tracerProviderConfig = {
|
|
113
|
-
tracerConfig,
|
|
114
|
-
spanProcessors,
|
|
115
|
-
contextManager,
|
|
116
|
-
textMapPropagator,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* @deprecated Please pass {@code logRecordProcessor} to the constructor options instead.
|
|
121
|
-
*
|
|
122
|
-
* Set configurations needed to register a LoggerProvider
|
|
123
|
-
*/
|
|
124
|
-
configureLoggerProvider(config) {
|
|
125
|
-
// nothing is set yet, we can set config and then return
|
|
126
|
-
if (this._loggerProviderConfig == null) {
|
|
127
|
-
this._loggerProviderConfig = config;
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
// make sure we do not override existing logRecordProcessor with other logRecordProcessors.
|
|
131
|
-
if (this._loggerProviderConfig.logRecordProcessor != null &&
|
|
132
|
-
config.logRecordProcessor != null) {
|
|
133
|
-
throw new Error('LogRecordProcessor passed but LogRecordProcessor has already been configured.');
|
|
134
|
-
}
|
|
135
|
-
// set logRecordProcessor, but make sure we do not override existing logRecordProcessors with null/undefined.
|
|
136
|
-
if (config.logRecordProcessor != null) {
|
|
137
|
-
this._loggerProviderConfig.logRecordProcessor = config.logRecordProcessor;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* @deprecated Please pass {@code views} and {@code reader} to the constructor options instead.
|
|
142
|
-
*
|
|
143
|
-
* Set configurations needed to register a MeterProvider
|
|
144
|
-
*/
|
|
145
|
-
configureMeterProvider(config) {
|
|
146
|
-
// nothing is set yet, we can set config and return.
|
|
147
|
-
if (this._meterProviderConfig == null) {
|
|
148
|
-
this._meterProviderConfig = config;
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
// make sure we do not override existing views with other views.
|
|
152
|
-
if (this._meterProviderConfig.views != null && config.views != null) {
|
|
153
|
-
throw new Error('Views passed but Views have already been configured.');
|
|
154
|
-
}
|
|
155
|
-
// set views, but make sure we do not override existing views with null/undefined.
|
|
156
|
-
if (config.views != null) {
|
|
157
|
-
this._meterProviderConfig.views = config.views;
|
|
158
|
-
}
|
|
159
|
-
// make sure we do not override existing reader with another reader.
|
|
160
|
-
if (this._meterProviderConfig.reader != null && config.reader != null) {
|
|
161
|
-
throw new Error('MetricReader passed but MetricReader has already been configured.');
|
|
162
|
-
}
|
|
163
|
-
// set reader, but make sure we do not override existing reader with null/undefined.
|
|
164
|
-
if (config.reader != null) {
|
|
165
|
-
this._meterProviderConfig.reader = config.reader;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* @deprecated Resources are detected automatically on {@link NodeSDK.start()}, when the {@code autoDetectResources}
|
|
170
|
-
* constructor option is set to {@code true} or left {@code undefined}.
|
|
171
|
-
*
|
|
172
|
-
* Detect resource attributes
|
|
173
|
-
*/
|
|
174
|
-
detectResources() {
|
|
175
|
-
if (this._disabled) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
const internalConfig = {
|
|
179
|
-
detectors: this._resourceDetectors,
|
|
180
|
-
};
|
|
181
|
-
this.addResource((0, resources_1.detectResourcesSync)(internalConfig));
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* @deprecated Please pre-merge resources and pass them to the constructor
|
|
185
|
-
*
|
|
186
|
-
* Manually add a Resource
|
|
187
|
-
* @param resource
|
|
188
|
-
*/
|
|
189
|
-
addResource(resource) {
|
|
190
|
-
this._resource = this._resource.merge(resource);
|
|
191
|
-
}
|
|
192
113
|
/**
|
|
193
114
|
* Call this method to construct SDK components and register them with the OpenTelemetry API.
|
|
194
115
|
*/
|
|
@@ -201,7 +122,10 @@ class NodeSDK {
|
|
|
201
122
|
instrumentations: this._instrumentations,
|
|
202
123
|
});
|
|
203
124
|
if (this._autoDetectResources) {
|
|
204
|
-
|
|
125
|
+
const internalConfig = {
|
|
126
|
+
detectors: this._resourceDetectors,
|
|
127
|
+
};
|
|
128
|
+
this._resource = this._resource.merge((0, resources_1.detectResourcesSync)(internalConfig));
|
|
205
129
|
}
|
|
206
130
|
this._resource =
|
|
207
131
|
this._serviceName === undefined
|
package/build/src/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAM4B;AAC5B,sDAA+C;AAC/C,oEAGwC;AACxC,wDAUkC;AAClC,sDAA6E;AAC7E,4DAA+E;AAC/E,kEAGuC;AACvC,kEAGuC;AACvC,8EAA+E;AAE/E,mFAAiF;AACjF,8CAAoE;AACpE,mCAAsD;AAsBtD,MAAa,OAAO;IAwBlB;;OAEG;IACH,YAAmB,gBAA+C,EAAE;;QAClE,MAAM,GAAG,GAAG,IAAA,aAAM,GAAE,CAAC;QACrB,MAAM,kBAAkB,GAAG,IAAA,4BAAqB,GAAE,CAAC;QAEnD,IAAI,GAAG,CAAC,iBAAiB,EAAE;YACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,+CAA+C;YAC/C,kCAAkC;SACnC;QAED,6DAA6D;QAC7D,uDAAuD;QACvD,IAAI,kBAAkB,CAAC,cAAc,EAAE;YACrC,UAAI,CAAC,SAAS,CAAC,IAA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YACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC/C;QAED,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,oDAAoD;aACnD,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAClB,CAAC;IACJ,CAAC;CACF;AAtVD,0BAsVC","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\nimport {\n ContextManager,\n TextMapPropagator,\n metrics,\n diag,\n DiagConsoleLogger,\n} from '@opentelemetry/api';\nimport { logs } from '@opentelemetry/api-logs';\nimport {\n InstrumentationOption,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport {\n Detector,\n DetectorSync,\n detectResourcesSync,\n envDetector,\n hostDetector,\n IResource,\n processDetector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\nimport { LogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';\nimport { MeterProvider, MetricReader, View } from '@opentelemetry/sdk-metrics';\nimport {\n BatchSpanProcessor,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport {\n NodeTracerConfig,\n NodeTracerProvider,\n} from '@opentelemetry/sdk-trace-node';\nimport { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport { NodeSDKConfiguration } from './types';\nimport { TracerProviderWithEnvExporters } from './TracerProviderWithEnvExporter';\nimport { getEnv, getEnvWithoutDefaults } from '@opentelemetry/core';\nimport { parseInstrumentationOptions } from './utils';\n\n/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */\n\nexport type MeterProviderConfig = {\n /**\n * Reference to the MetricReader instance by the NodeSDK\n */\n reader?: MetricReader;\n /**\n * List of {@link View}s that should be passed to the MeterProvider\n */\n views?: View[];\n};\n\nexport type LoggerProviderConfig = {\n /**\n * Reference to the LoggerRecordProcessor instance by the NodeSDK\n */\n logRecordProcessor: LogRecordProcessor;\n};\n\nexport class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessors: SpanProcessor[];\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\n private _loggerProviderConfig?: LoggerProviderConfig;\n private _meterProviderConfig?: MeterProviderConfig;\n private _instrumentations: InstrumentationOption[];\n\n private _resource: IResource;\n private _resourceDetectors: Array<Detector | DetectorSync>;\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider | TracerProviderWithEnvExporters;\n private _loggerProvider?: LoggerProvider;\n private _meterProvider?: MeterProvider;\n private _serviceName?: string;\n private _configuration?: Partial<NodeSDKConfiguration>;\n\n private _disabled?: boolean;\n\n /**\n * Create a new NodeJS SDK instance\n */\n public constructor(configuration: Partial<NodeSDKConfiguration> = {}) {\n const env = getEnv();\n const envWithoutDefaults = getEnvWithoutDefaults();\n\n if (env.OTEL_SDK_DISABLED) {\n this._disabled = true;\n // Functions with possible side-effects are set\n // to no-op via the _disabled flag\n }\n\n // Default is INFO, use environment without defaults to check\n // if the user originally set the environment variable.\n if (envWithoutDefaults.OTEL_LOG_LEVEL) {\n diag.setLogger(new DiagConsoleLogger(), {\n logLevel: envWithoutDefaults.OTEL_LOG_LEVEL,\n });\n }\n\n this._configuration = configuration;\n\n this._resource = configuration.resource ?? new Resource({});\n this._resourceDetectors = configuration.resourceDetectors ?? [\n envDetector,\n processDetector,\n hostDetector,\n ];\n\n this._serviceName = configuration.serviceName;\n\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n\n // If a tracer provider can be created from manual configuration, create it\n if (\n configuration.traceExporter ||\n configuration.spanProcessor ||\n configuration.spanProcessors\n ) {\n const tracerProviderConfig: NodeTracerConfig = {};\n\n if (configuration.sampler) {\n tracerProviderConfig.sampler = configuration.sampler;\n }\n if (configuration.spanLimits) {\n tracerProviderConfig.spanLimits = configuration.spanLimits;\n }\n if (configuration.idGenerator) {\n tracerProviderConfig.idGenerator = configuration.idGenerator;\n }\n\n if (configuration.spanProcessor) {\n diag.warn(\n \"The 'spanProcessor' option is deprecated. Please use 'spanProcessors' instead.\"\n );\n }\n\n const spanProcessor =\n configuration.spanProcessor ??\n new BatchSpanProcessor(configuration.traceExporter!);\n\n const spanProcessors = configuration.spanProcessors ?? [spanProcessor];\n\n this.configureTracerProvider(\n tracerProviderConfig,\n spanProcessors,\n configuration.contextManager,\n configuration.textMapPropagator\n );\n }\n\n if (configuration.logRecordProcessor) {\n const loggerProviderConfig: LoggerProviderConfig = {\n logRecordProcessor: configuration.logRecordProcessor,\n };\n this.configureLoggerProvider(loggerProviderConfig);\n }\n\n if (configuration.metricReader || configuration.views) {\n const meterProviderConfig: MeterProviderConfig = {};\n if (configuration.metricReader) {\n meterProviderConfig.reader = configuration.metricReader;\n }\n\n if (configuration.views) {\n meterProviderConfig.views = configuration.views;\n }\n\n this.configureMeterProvider(meterProviderConfig);\n }\n\n let instrumentations: InstrumentationOption[] = [];\n if (configuration.instrumentations) {\n instrumentations = configuration.instrumentations;\n }\n this._instrumentations = instrumentations;\n }\n\n /**\n *\n * @deprecated Please pass {@code sampler}, {@code generalLimits}, {@code spanLimits}, {@code resource},\n * {@code IdGenerator}, {@code spanProcessor}, {@code contextManager} and {@code textMapPropagator},\n * to the constructor options instead.\n *\n * Set configurations needed to register a TracerProvider\n */\n public configureTracerProvider(\n tracerConfig: NodeTracerConfig,\n spanProcessors: SpanProcessor[],\n contextManager?: ContextManager,\n textMapPropagator?: TextMapPropagator\n ): void {\n this._tracerProviderConfig = {\n tracerConfig,\n spanProcessors,\n contextManager,\n textMapPropagator,\n };\n }\n\n /**\n * @deprecated Please pass {@code logRecordProcessor} to the constructor options instead.\n *\n * Set configurations needed to register a LoggerProvider\n */\n public configureLoggerProvider(config: LoggerProviderConfig): void {\n // nothing is set yet, we can set config and then return\n if (this._loggerProviderConfig == null) {\n this._loggerProviderConfig = config;\n return;\n }\n\n // make sure we do not override existing logRecordProcessor with other logRecordProcessors.\n if (\n this._loggerProviderConfig.logRecordProcessor != null &&\n config.logRecordProcessor != null\n ) {\n throw new Error(\n 'LogRecordProcessor passed but LogRecordProcessor has already been configured.'\n );\n }\n\n // set logRecordProcessor, but make sure we do not override existing logRecordProcessors with null/undefined.\n if (config.logRecordProcessor != null) {\n this._loggerProviderConfig.logRecordProcessor = config.logRecordProcessor;\n }\n }\n\n /**\n * @deprecated Please pass {@code views} and {@code reader} to the constructor options instead.\n *\n * Set configurations needed to register a MeterProvider\n */\n public configureMeterProvider(config: MeterProviderConfig): void {\n // nothing is set yet, we can set config and return.\n if (this._meterProviderConfig == null) {\n this._meterProviderConfig = config;\n return;\n }\n\n // make sure we do not override existing views with other views.\n if (this._meterProviderConfig.views != null && config.views != null) {\n throw new Error('Views passed but Views have already been configured.');\n }\n\n // set views, but make sure we do not override existing views with null/undefined.\n if (config.views != null) {\n this._meterProviderConfig.views = config.views;\n }\n\n // make sure we do not override existing reader with another reader.\n if (this._meterProviderConfig.reader != null && config.reader != null) {\n throw new Error(\n 'MetricReader passed but MetricReader has already been configured.'\n );\n }\n\n // set reader, but make sure we do not override existing reader with null/undefined.\n if (config.reader != null) {\n this._meterProviderConfig.reader = config.reader;\n }\n }\n\n /**\n * @deprecated Resources are detected automatically on {@link NodeSDK.start()}, when the {@code autoDetectResources}\n * constructor option is set to {@code true} or left {@code undefined}.\n *\n * Detect resource attributes\n */\n public detectResources(): void {\n if (this._disabled) {\n return;\n }\n\n const internalConfig: ResourceDetectionConfig = {\n detectors: this._resourceDetectors,\n };\n\n this.addResource(detectResourcesSync(internalConfig));\n }\n\n /**\n * @deprecated Please pre-merge resources and pass them to the constructor\n *\n * Manually add a Resource\n * @param resource\n */\n public addResource(resource: IResource): void {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n * Call this method to construct SDK components and register them with the OpenTelemetry API.\n */\n public start(): void {\n if (this._disabled) {\n return;\n }\n\n registerInstrumentations({\n instrumentations: this._instrumentations,\n });\n\n if (this._autoDetectResources) {\n this.detectResources();\n }\n\n this._resource =\n this._serviceName === undefined\n ? this._resource\n : this._resource.merge(\n new Resource({\n [SEMRESATTRS_SERVICE_NAME]: this._serviceName,\n })\n );\n\n // if there is a tracerProviderConfig (traceExporter/spanProcessor was set manually) or the traceExporter is set manually, use NodeTracerProvider\n const Provider = this._tracerProviderConfig\n ? NodeTracerProvider\n : TracerProviderWithEnvExporters;\n\n // If the Provider is configured with Env Exporters, we need to check if the SDK had any manual configurations and set them here\n const tracerProvider = new Provider({\n ...this._configuration,\n resource: this._resource,\n });\n\n this._tracerProvider = tracerProvider;\n\n if (this._tracerProviderConfig) {\n for (const spanProcessor of this._tracerProviderConfig.spanProcessors) {\n tracerProvider.addSpanProcessor(spanProcessor);\n }\n }\n\n tracerProvider.register({\n contextManager: this._tracerProviderConfig?.contextManager,\n propagator: this._tracerProviderConfig?.textMapPropagator,\n });\n\n if (this._loggerProviderConfig) {\n const loggerProvider = new LoggerProvider({\n resource: this._resource,\n });\n loggerProvider.addLogRecordProcessor(\n this._loggerProviderConfig.logRecordProcessor\n );\n\n this._loggerProvider = loggerProvider;\n\n logs.setGlobalLoggerProvider(loggerProvider);\n }\n\n if (this._meterProviderConfig) {\n const readers: MetricReader[] = [];\n if (this._meterProviderConfig.reader) {\n readers.push(this._meterProviderConfig.reader);\n }\n const meterProvider = new MeterProvider({\n resource: this._resource,\n views: this._meterProviderConfig?.views ?? [],\n readers: readers,\n });\n\n this._meterProvider = meterProvider;\n\n metrics.setGlobalMeterProvider(meterProvider);\n\n // TODO: This is a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609\n // If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.\n // This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.\n for (const instrumentation of parseInstrumentationOptions(\n this._instrumentations\n )) {\n instrumentation.setMeterProvider(metrics.getMeterProvider());\n }\n }\n }\n\n public shutdown(): Promise<void> {\n const promises: Promise<unknown>[] = [];\n if (this._tracerProvider) {\n promises.push(this._tracerProvider.shutdown());\n }\n if (this._loggerProvider) {\n promises.push(this._loggerProvider.shutdown());\n }\n if (this._meterProvider) {\n promises.push(this._meterProvider.shutdown());\n }\n\n return (\n Promise.all(promises)\n // return void instead of the array from Promise.all\n .then(() => {})\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAM4B;AAC5B,sDAA+C;AAC/C,oEAGwC;AACxC,wDAUkC;AAClC,sDAA6E;AAC7E,4DAA+E;AAC/E,kEAGuC;AACvC,kEAGuC;AACvC,8EAA+E;AAE/E,mFAAiF;AACjF,8CAAoE;AACpE,mCAGiB;AAsBjB,MAAa,OAAO;IAwBlB;;OAEG;IACH,YAAmB,gBAA+C,EAAE;;QAClE,MAAM,GAAG,GAAG,IAAA,aAAM,GAAE,CAAC;QACrB,MAAM,kBAAkB,GAAG,IAAA,4BAAqB,GAAE,CAAC;QAEnD,IAAI,GAAG,CAAC,iBAAiB,EAAE;YACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,+CAA+C;YAC/C,kCAAkC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AAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC/C;QAED,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,oDAAoD;aACnD,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAClB,CAAC;IACJ,CAAC;CACF;AA/OD,0BA+OC","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\nimport {\n ContextManager,\n TextMapPropagator,\n metrics,\n diag,\n DiagConsoleLogger,\n} from '@opentelemetry/api';\nimport { logs } from '@opentelemetry/api-logs';\nimport {\n InstrumentationOption,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport {\n Detector,\n DetectorSync,\n detectResourcesSync,\n envDetector,\n hostDetector,\n IResource,\n processDetector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\nimport { LogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';\nimport { MeterProvider, MetricReader, View } from '@opentelemetry/sdk-metrics';\nimport {\n BatchSpanProcessor,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport {\n NodeTracerConfig,\n NodeTracerProvider,\n} from '@opentelemetry/sdk-trace-node';\nimport { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport { NodeSDKConfiguration } from './types';\nimport { TracerProviderWithEnvExporters } from './TracerProviderWithEnvExporter';\nimport { getEnv, getEnvWithoutDefaults } from '@opentelemetry/core';\nimport {\n getResourceDetectorsFromEnv,\n parseInstrumentationOptions,\n} from './utils';\n\n/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */\n\nexport type MeterProviderConfig = {\n /**\n * Reference to the MetricReader instance by the NodeSDK\n */\n reader?: MetricReader;\n /**\n * List of {@link View}s that should be passed to the MeterProvider\n */\n views?: View[];\n};\n\nexport type LoggerProviderConfig = {\n /**\n * Reference to the LoggerRecordProcessor instance by the NodeSDK\n */\n logRecordProcessor: LogRecordProcessor;\n};\n\nexport class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessors: SpanProcessor[];\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\n private _loggerProviderConfig?: LoggerProviderConfig;\n private _meterProviderConfig?: MeterProviderConfig;\n private _instrumentations: InstrumentationOption[];\n\n private _resource: IResource;\n private _resourceDetectors: Array<Detector | DetectorSync>;\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider | TracerProviderWithEnvExporters;\n private _loggerProvider?: LoggerProvider;\n private _meterProvider?: MeterProvider;\n private _serviceName?: string;\n private _configuration?: Partial<NodeSDKConfiguration>;\n\n private _disabled?: boolean;\n\n /**\n * Create a new NodeJS SDK instance\n */\n public constructor(configuration: Partial<NodeSDKConfiguration> = {}) {\n const env = getEnv();\n const envWithoutDefaults = getEnvWithoutDefaults();\n\n if (env.OTEL_SDK_DISABLED) {\n this._disabled = true;\n // Functions with possible side-effects are set\n // to no-op via the _disabled flag\n }\n\n // Default is INFO, use environment without defaults to check\n // if the user originally set the environment variable.\n if (envWithoutDefaults.OTEL_LOG_LEVEL) {\n diag.setLogger(new DiagConsoleLogger(), {\n logLevel: envWithoutDefaults.OTEL_LOG_LEVEL,\n });\n }\n\n this._configuration = configuration;\n\n this._resource = configuration.resource ?? new Resource({});\n let defaultDetectors: (Detector | DetectorSync)[] = [];\n if (process.env.OTEL_NODE_RESOURCE_DETECTORS != null) {\n defaultDetectors = getResourceDetectorsFromEnv();\n } else {\n defaultDetectors = [envDetector, processDetector, hostDetector];\n }\n\n this._resourceDetectors =\n configuration.resourceDetectors ?? defaultDetectors;\n\n this._serviceName = configuration.serviceName;\n\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n\n // If a tracer provider can be created from manual configuration, create it\n if (\n configuration.traceExporter ||\n configuration.spanProcessor ||\n configuration.spanProcessors\n ) {\n const tracerProviderConfig: NodeTracerConfig = {};\n\n if (configuration.sampler) {\n tracerProviderConfig.sampler = configuration.sampler;\n }\n if (configuration.spanLimits) {\n tracerProviderConfig.spanLimits = configuration.spanLimits;\n }\n if (configuration.idGenerator) {\n tracerProviderConfig.idGenerator = configuration.idGenerator;\n }\n\n if (configuration.spanProcessor) {\n diag.warn(\n \"The 'spanProcessor' option is deprecated. Please use 'spanProcessors' instead.\"\n );\n }\n\n const spanProcessor =\n configuration.spanProcessor ??\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n new BatchSpanProcessor(configuration.traceExporter!);\n\n const spanProcessors = configuration.spanProcessors ?? [spanProcessor];\n\n this._tracerProviderConfig = {\n tracerConfig: tracerProviderConfig,\n spanProcessors,\n contextManager: configuration.contextManager,\n textMapPropagator: configuration.textMapPropagator,\n };\n }\n\n if (configuration.logRecordProcessor) {\n this._loggerProviderConfig = {\n logRecordProcessor: configuration.logRecordProcessor,\n };\n }\n\n if (configuration.metricReader || configuration.views) {\n const meterProviderConfig: MeterProviderConfig = {};\n if (configuration.metricReader) {\n meterProviderConfig.reader = configuration.metricReader;\n }\n\n if (configuration.views) {\n meterProviderConfig.views = configuration.views;\n }\n\n this._meterProviderConfig = meterProviderConfig;\n }\n\n let instrumentations: InstrumentationOption[] = [];\n if (configuration.instrumentations) {\n instrumentations = configuration.instrumentations;\n }\n this._instrumentations = instrumentations;\n }\n\n /**\n * Call this method to construct SDK components and register them with the OpenTelemetry API.\n */\n public start(): void {\n if (this._disabled) {\n return;\n }\n\n registerInstrumentations({\n instrumentations: this._instrumentations,\n });\n\n if (this._autoDetectResources) {\n const internalConfig: ResourceDetectionConfig = {\n detectors: this._resourceDetectors,\n };\n\n this._resource = this._resource.merge(\n detectResourcesSync(internalConfig)\n );\n }\n\n this._resource =\n this._serviceName === undefined\n ? this._resource\n : this._resource.merge(\n new Resource({\n [SEMRESATTRS_SERVICE_NAME]: this._serviceName,\n })\n );\n\n // if there is a tracerProviderConfig (traceExporter/spanProcessor was set manually) or the traceExporter is set manually, use NodeTracerProvider\n const Provider = this._tracerProviderConfig\n ? NodeTracerProvider\n : TracerProviderWithEnvExporters;\n\n // If the Provider is configured with Env Exporters, we need to check if the SDK had any manual configurations and set them here\n const tracerProvider = new Provider({\n ...this._configuration,\n resource: this._resource,\n });\n\n this._tracerProvider = tracerProvider;\n\n if (this._tracerProviderConfig) {\n for (const spanProcessor of this._tracerProviderConfig.spanProcessors) {\n tracerProvider.addSpanProcessor(spanProcessor);\n }\n }\n\n tracerProvider.register({\n contextManager: this._tracerProviderConfig?.contextManager,\n propagator: this._tracerProviderConfig?.textMapPropagator,\n });\n\n if (this._loggerProviderConfig) {\n const loggerProvider = new LoggerProvider({\n resource: this._resource,\n });\n loggerProvider.addLogRecordProcessor(\n this._loggerProviderConfig.logRecordProcessor\n );\n\n this._loggerProvider = loggerProvider;\n\n logs.setGlobalLoggerProvider(loggerProvider);\n }\n\n if (this._meterProviderConfig) {\n const readers: MetricReader[] = [];\n if (this._meterProviderConfig.reader) {\n readers.push(this._meterProviderConfig.reader);\n }\n const meterProvider = new MeterProvider({\n resource: this._resource,\n views: this._meterProviderConfig?.views ?? [],\n readers: readers,\n });\n\n this._meterProvider = meterProvider;\n\n metrics.setGlobalMeterProvider(meterProvider);\n\n // TODO: This is a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609\n // If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.\n // This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.\n for (const instrumentation of parseInstrumentationOptions(\n this._instrumentations\n )) {\n instrumentation.setMeterProvider(metrics.getMeterProvider());\n }\n }\n }\n\n public shutdown(): Promise<void> {\n const promises: Promise<unknown>[] = [];\n if (this._tracerProvider) {\n promises.push(this._tracerProvider.shutdown());\n }\n if (this._loggerProvider) {\n promises.push(this._loggerProvider.shutdown());\n }\n if (this._meterProvider) {\n promises.push(this._meterProvider.shutdown());\n }\n\n return (\n Promise.all(promises)\n // return void instead of the array from Promise.all\n .then(() => {})\n );\n }\n}\n"]}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Instrumentation, InstrumentationOption } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { DetectorSync } from '@opentelemetry/resources';
|
|
2
3
|
export declare function parseInstrumentationOptions(options?: InstrumentationOption[]): Instrumentation[];
|
|
4
|
+
export declare function getResourceDetectorsFromEnv(): Array<DetectorSync>;
|
|
3
5
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/src/utils.js
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.parseInstrumentationOptions = void 0;
|
|
18
|
+
exports.getResourceDetectorsFromEnv = exports.parseInstrumentationOptions = void 0;
|
|
19
|
+
const api_1 = require("@opentelemetry/api");
|
|
20
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
19
21
|
// TODO: This part of a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609
|
|
20
22
|
// If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.
|
|
21
23
|
// This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.
|
|
@@ -38,4 +40,35 @@ function parseInstrumentationOptions(options = []) {
|
|
|
38
40
|
return instrumentations;
|
|
39
41
|
}
|
|
40
42
|
exports.parseInstrumentationOptions = parseInstrumentationOptions;
|
|
43
|
+
const RESOURCE_DETECTOR_ENVIRONMENT = 'env';
|
|
44
|
+
const RESOURCE_DETECTOR_HOST = 'host';
|
|
45
|
+
const RESOURCE_DETECTOR_OS = 'os';
|
|
46
|
+
const RESOURCE_DETECTOR_PROCESS = 'process';
|
|
47
|
+
const RESOURCE_DETECTOR_SERVICE_INSTANCE_ID = 'serviceinstance';
|
|
48
|
+
function getResourceDetectorsFromEnv() {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
// When updating this list, make sure to also update the section `resourceDetectors` on README.
|
|
51
|
+
const resourceDetectors = new Map([
|
|
52
|
+
[RESOURCE_DETECTOR_ENVIRONMENT, resources_1.envDetectorSync],
|
|
53
|
+
[RESOURCE_DETECTOR_HOST, resources_1.hostDetectorSync],
|
|
54
|
+
[RESOURCE_DETECTOR_OS, resources_1.osDetectorSync],
|
|
55
|
+
[RESOURCE_DETECTOR_SERVICE_INSTANCE_ID, resources_1.serviceInstanceIdDetectorSync],
|
|
56
|
+
[RESOURCE_DETECTOR_PROCESS, resources_1.processDetectorSync],
|
|
57
|
+
]);
|
|
58
|
+
const resourceDetectorsFromEnv = (_b = (_a = process.env.OTEL_NODE_RESOURCE_DETECTORS) === null || _a === void 0 ? void 0 : _a.split(',')) !== null && _b !== void 0 ? _b : ['all'];
|
|
59
|
+
if (resourceDetectorsFromEnv.includes('all')) {
|
|
60
|
+
return [...resourceDetectors.values()].flat();
|
|
61
|
+
}
|
|
62
|
+
if (resourceDetectorsFromEnv.includes('none')) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return resourceDetectorsFromEnv.flatMap(detector => {
|
|
66
|
+
const resourceDetector = resourceDetectors.get(detector);
|
|
67
|
+
if (!resourceDetector) {
|
|
68
|
+
api_1.diag.error(`Invalid resource detector "${detector}" specified in the environment variable OTEL_NODE_RESOURCE_DETECTORS`);
|
|
69
|
+
}
|
|
70
|
+
return resourceDetector || [];
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.getResourceDetectorsFromEnv = getResourceDetectorsFromEnv;
|
|
41
74
|
//# 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;;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAK1C,wDAOkC;AAElC,wGAAwG;AACxG,4GAA4G;AAC5G,4GAA4G;AAC5G,SAAgB,2BAA2B,CACzC,UAAmC,EAAE;IAErC,IAAI,gBAAgB,GAAsB,EAAE,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC9C,8DAA8D;QAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAQ,CAAC;QACjC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,OAAO,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC;YACpD,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACrD;aAAM,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;YACvC,gBAAgB,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;SACrC;aAAM,IAAK,MAA0B,CAAC,mBAAmB,EAAE;YAC1D,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC/B;KACF;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAlBD,kEAkBC;AAED,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAC5C,MAAM,sBAAsB,GAAG,MAAM,CAAC;AACtC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAC5C,MAAM,qCAAqC,GAAG,iBAAiB,CAAC;AAEhE,SAAgB,2BAA2B;;IACzC,+FAA+F;IAC/F,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAuB;QACtD,CAAC,6BAA6B,EAAE,2BAAe,CAAC;QAChD,CAAC,sBAAsB,EAAE,4BAAgB,CAAC;QAC1C,CAAC,oBAAoB,EAAE,0BAAc,CAAC;QACtC,CAAC,qCAAqC,EAAE,yCAA6B,CAAC;QACtE,CAAC,yBAAyB,EAAE,+BAAmB,CAAC;KACjD,CAAC,CAAC;IAEH,MAAM,wBAAwB,GAC5B,MAAA,MAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,0CAAE,KAAK,CAAC,GAAG,CAAC,mCAAI,CAAC,KAAK,CAAC,CAAC;IAElE,IAAI,wBAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5C,OAAO,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;KAC/C;IAED,IAAI,wBAAwB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC7C,OAAO,EAAE,CAAC;KACX;IAED,OAAO,wBAAwB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACjD,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,EAAE;YACrB,UAAI,CAAC,KAAK,CACR,8BAA8B,QAAQ,sEAAsE,CAC7G,CAAC;SACH;QACD,OAAO,gBAAgB,IAAI,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AA9BD,kEA8BC","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\nimport { diag } from '@opentelemetry/api';\nimport {\n Instrumentation,\n InstrumentationOption,\n} from '@opentelemetry/instrumentation';\nimport {\n DetectorSync,\n envDetectorSync,\n hostDetectorSync,\n osDetectorSync,\n processDetectorSync,\n serviceInstanceIdDetectorSync,\n} from '@opentelemetry/resources';\n\n// TODO: This part of a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609\n// If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.\n// This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.\nexport function parseInstrumentationOptions(\n options: InstrumentationOption[] = []\n): Instrumentation[] {\n let instrumentations: Instrumentation[] = [];\n for (let i = 0, j = options.length; i < j; i++) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const option = options[i] as any;\n if (Array.isArray(option)) {\n const results = parseInstrumentationOptions(option);\n instrumentations = instrumentations.concat(results);\n } else if (typeof option === 'function') {\n instrumentations.push(new option());\n } else if ((option as Instrumentation).instrumentationName) {\n instrumentations.push(option);\n }\n }\n\n return instrumentations;\n}\n\nconst RESOURCE_DETECTOR_ENVIRONMENT = 'env';\nconst RESOURCE_DETECTOR_HOST = 'host';\nconst RESOURCE_DETECTOR_OS = 'os';\nconst RESOURCE_DETECTOR_PROCESS = 'process';\nconst RESOURCE_DETECTOR_SERVICE_INSTANCE_ID = 'serviceinstance';\n\nexport function getResourceDetectorsFromEnv(): Array<DetectorSync> {\n // When updating this list, make sure to also update the section `resourceDetectors` on README.\n const resourceDetectors = new Map<string, DetectorSync>([\n [RESOURCE_DETECTOR_ENVIRONMENT, envDetectorSync],\n [RESOURCE_DETECTOR_HOST, hostDetectorSync],\n [RESOURCE_DETECTOR_OS, osDetectorSync],\n [RESOURCE_DETECTOR_SERVICE_INSTANCE_ID, serviceInstanceIdDetectorSync],\n [RESOURCE_DETECTOR_PROCESS, processDetectorSync],\n ]);\n\n const resourceDetectorsFromEnv =\n process.env.OTEL_NODE_RESOURCE_DETECTORS?.split(',') ?? ['all'];\n\n if (resourceDetectorsFromEnv.includes('all')) {\n return [...resourceDetectors.values()].flat();\n }\n\n if (resourceDetectorsFromEnv.includes('none')) {\n return [];\n }\n\n return resourceDetectorsFromEnv.flatMap(detector => {\n const resourceDetector = resourceDetectors.get(detector);\n if (!resourceDetector) {\n diag.error(\n `Invalid resource detector \"${detector}\" specified in the environment variable OTEL_NODE_RESOURCE_DETECTORS`\n );\n }\n return resourceDetector || [];\n });\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.51.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,QAAQ,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,QAAQ,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.51.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/sdk-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "OpenTelemetry SDK for Node.js",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -44,27 +44,27 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@opentelemetry/api-logs": "0.
|
|
48
|
-
"@opentelemetry/core": "1.
|
|
49
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "0.
|
|
50
|
-
"@opentelemetry/exporter-trace-otlp-http": "0.
|
|
51
|
-
"@opentelemetry/exporter-trace-otlp-proto": "0.
|
|
52
|
-
"@opentelemetry/exporter-zipkin": "1.
|
|
53
|
-
"@opentelemetry/instrumentation": "0.
|
|
54
|
-
"@opentelemetry/resources": "1.
|
|
55
|
-
"@opentelemetry/sdk-logs": "0.
|
|
56
|
-
"@opentelemetry/sdk-metrics": "1.
|
|
57
|
-
"@opentelemetry/sdk-trace-base": "1.
|
|
58
|
-
"@opentelemetry/sdk-trace-node": "1.
|
|
59
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
47
|
+
"@opentelemetry/api-logs": "0.51.0",
|
|
48
|
+
"@opentelemetry/core": "1.24.0",
|
|
49
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.51.0",
|
|
50
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.51.0",
|
|
51
|
+
"@opentelemetry/exporter-trace-otlp-proto": "0.51.0",
|
|
52
|
+
"@opentelemetry/exporter-zipkin": "1.24.0",
|
|
53
|
+
"@opentelemetry/instrumentation": "0.51.0",
|
|
54
|
+
"@opentelemetry/resources": "1.24.0",
|
|
55
|
+
"@opentelemetry/sdk-logs": "0.51.0",
|
|
56
|
+
"@opentelemetry/sdk-metrics": "1.24.0",
|
|
57
|
+
"@opentelemetry/sdk-trace-base": "1.24.0",
|
|
58
|
+
"@opentelemetry/sdk-trace-node": "1.24.0",
|
|
59
|
+
"@opentelemetry/semantic-conventions": "1.24.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@opentelemetry/api": ">=1.3.0 <1.9.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@opentelemetry/api": "1.8.0",
|
|
66
|
-
"@opentelemetry/context-async-hooks": "1.
|
|
67
|
-
"@opentelemetry/exporter-jaeger": "1.
|
|
66
|
+
"@opentelemetry/context-async-hooks": "1.24.0",
|
|
67
|
+
"@opentelemetry/exporter-jaeger": "1.24.0",
|
|
68
68
|
"@types/mocha": "10.0.6",
|
|
69
69
|
"@types/node": "18.6.5",
|
|
70
70
|
"@types/semver": "7.5.6",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
},
|
|
83
83
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-node",
|
|
84
84
|
"sideEffects": false,
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "3ab4f765d8d696327b7d139ae6a45e7bd7edd924"
|
|
86
86
|
}
|