@opentelemetry/sdk-node 0.35.1 → 0.36.1
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 +15 -1
- package/build/src/sdk.d.ts +4 -4
- package/build/src/sdk.js +21 -5
- package/build/src/sdk.js.map +1 -1
- package/build/src/types.d.ts +4 -3
- package/build/src/types.js.map +1 -1
- package/build/src/utils.d.ts +3 -0
- package/build/src/utils.js +41 -0
- package/build/src/utils.js.map +1 -0
- 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 +16 -16
package/README.md
CHANGED
|
@@ -143,7 +143,21 @@ Configure the [service name](https://github.com/open-telemetry/opentelemetry-spe
|
|
|
143
143
|
|
|
144
144
|
Disable the SDK by setting the `OTEL_SDK_DISABLED` environment variable to `true`.
|
|
145
145
|
|
|
146
|
-
## Configure
|
|
146
|
+
## Configure log level from the environment
|
|
147
|
+
|
|
148
|
+
Set the log level by setting the `OTEL_LOG_LEVEL` environment variable to enums:
|
|
149
|
+
|
|
150
|
+
- `NONE`,
|
|
151
|
+
- `ERROR`,
|
|
152
|
+
- `WARN`,
|
|
153
|
+
- `INFO`,
|
|
154
|
+
- `DEBUG`,
|
|
155
|
+
- `VERBOSE`,
|
|
156
|
+
- `ALL`.
|
|
157
|
+
|
|
158
|
+
The default level is `INFO`.
|
|
159
|
+
|
|
160
|
+
## Configure Trace Exporter from environment
|
|
147
161
|
|
|
148
162
|
This is an alternative to programmatically configuring an exporter or span processor. This package will auto setup the default `otlp` exporter with `http/protobuf` protocol if `traceExporter` or `spanProcessor` hasn't been passed into the `NodeSDK` constructor.
|
|
149
163
|
|
package/build/src/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
2
|
-
import {
|
|
2
|
+
import { IResource } from '@opentelemetry/resources';
|
|
3
3
|
import { MetricReader, View } from '@opentelemetry/sdk-metrics';
|
|
4
4
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
5
5
|
import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
|
|
@@ -35,13 +35,13 @@ export declare class NodeSDK {
|
|
|
35
35
|
/** Set configurations needed to register a MeterProvider */
|
|
36
36
|
configureMeterProvider(config: MeterProviderConfig): void;
|
|
37
37
|
/** Detect resource attributes */
|
|
38
|
-
detectResources():
|
|
38
|
+
detectResources(): void;
|
|
39
39
|
/** Manually add a resource */
|
|
40
|
-
addResource(resource:
|
|
40
|
+
addResource(resource: IResource): void;
|
|
41
41
|
/**
|
|
42
42
|
* Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API.
|
|
43
43
|
*/
|
|
44
|
-
start():
|
|
44
|
+
start(): void;
|
|
45
45
|
shutdown(): Promise<void>;
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=sdk.d.ts.map
|
package/build/src/sdk.js
CHANGED
|
@@ -25,17 +25,24 @@ const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
|
25
25
|
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
26
26
|
const TracerProviderWithEnvExporter_1 = require("./TracerProviderWithEnvExporter");
|
|
27
27
|
const core_1 = require("@opentelemetry/core");
|
|
28
|
+
const utils_1 = require("./utils");
|
|
28
29
|
class NodeSDK {
|
|
29
30
|
/**
|
|
30
31
|
* Create a new NodeJS SDK instance
|
|
31
32
|
*/
|
|
32
33
|
constructor(configuration = {}) {
|
|
33
34
|
var _a, _b, _c, _d;
|
|
34
|
-
|
|
35
|
+
const env = (0, core_1.getEnv)();
|
|
36
|
+
if (env.OTEL_SDK_DISABLED) {
|
|
35
37
|
this._disabled = true;
|
|
36
38
|
// Functions with possible side-effects are set
|
|
37
39
|
// to no-op via the _disabled flag
|
|
38
40
|
}
|
|
41
|
+
if (env.OTEL_LOG_LEVEL) {
|
|
42
|
+
api_1.diag.setLogger(new api_1.DiagConsoleLogger(), {
|
|
43
|
+
logLevel: env.OTEL_LOG_LEVEL,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
39
46
|
this._resource = (_a = configuration.resource) !== null && _a !== void 0 ? _a : new resources_1.Resource({});
|
|
40
47
|
this._resourceDetectors = (_b = configuration.resourceDetectors) !== null && _b !== void 0 ? _b : [
|
|
41
48
|
resources_1.envDetector,
|
|
@@ -51,6 +58,9 @@ class NodeSDK {
|
|
|
51
58
|
if (configuration.spanLimits) {
|
|
52
59
|
tracerProviderConfig.spanLimits = configuration.spanLimits;
|
|
53
60
|
}
|
|
61
|
+
if (configuration.idGenerator) {
|
|
62
|
+
tracerProviderConfig.idGenerator = configuration.idGenerator;
|
|
63
|
+
}
|
|
54
64
|
const spanProcessor = (_d = configuration.spanProcessor) !== null && _d !== void 0 ? _d : new sdk_trace_base_1.BatchSpanProcessor(configuration.traceExporter);
|
|
55
65
|
this.configureTracerProvider(tracerProviderConfig, spanProcessor, configuration.contextManager, configuration.textMapPropagator);
|
|
56
66
|
}
|
|
@@ -104,14 +114,14 @@ class NodeSDK {
|
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
/** Detect resource attributes */
|
|
107
|
-
|
|
117
|
+
detectResources() {
|
|
108
118
|
if (this._disabled) {
|
|
109
119
|
return;
|
|
110
120
|
}
|
|
111
121
|
const internalConfig = {
|
|
112
122
|
detectors: this._resourceDetectors,
|
|
113
123
|
};
|
|
114
|
-
this.addResource(
|
|
124
|
+
this.addResource((0, resources_1.detectResourcesSync)(internalConfig));
|
|
115
125
|
}
|
|
116
126
|
/** Manually add a resource */
|
|
117
127
|
addResource(resource) {
|
|
@@ -120,7 +130,7 @@ class NodeSDK {
|
|
|
120
130
|
/**
|
|
121
131
|
* Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API.
|
|
122
132
|
*/
|
|
123
|
-
|
|
133
|
+
start() {
|
|
124
134
|
var _a, _b, _c, _d, _e;
|
|
125
135
|
if (this._disabled) {
|
|
126
136
|
return;
|
|
@@ -129,7 +139,7 @@ class NodeSDK {
|
|
|
129
139
|
instrumentations: this._instrumentations,
|
|
130
140
|
});
|
|
131
141
|
if (this._autoDetectResources) {
|
|
132
|
-
|
|
142
|
+
this.detectResources();
|
|
133
143
|
}
|
|
134
144
|
this._resource =
|
|
135
145
|
this._serviceName === undefined
|
|
@@ -159,6 +169,12 @@ class NodeSDK {
|
|
|
159
169
|
}
|
|
160
170
|
this._meterProvider = meterProvider;
|
|
161
171
|
api_1.metrics.setGlobalMeterProvider(meterProvider);
|
|
172
|
+
// TODO: This is a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609
|
|
173
|
+
// If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.
|
|
174
|
+
// This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.
|
|
175
|
+
for (const instrumentation of (0, utils_1.parseInstrumentationOptions)(this._instrumentations)) {
|
|
176
|
+
instrumentation.setMeterProvider(api_1.metrics.getMeterProvider());
|
|
177
|
+
}
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
180
|
shutdown() {
|
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,4CAAgF;AAChF,oEAGwC;AACxC,wDAOkC;AAClC,4DAA+E;AAC/E,kEAGuC;AACvC,kEAGuC;AACvC,8EAAiF;AAEjF,mFAAiF;AACjF,8CAA6C;AAc7C,MAAa,OAAO;IAqBlB;;OAEG;IACH,YAAmB,gBAA+C,EAAE;;QAClE,IAAI,IAAA,aAAM,GAAE,CAAC,iBAAiB,EAAE;YAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,+CAA+C;YAC/C,kCAAkC;SACnC;QAED,IAAI,CAAC,SAAS,GAAG,MAAA,aAAa,CAAC,QAAQ,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C;YACtB,cAAc,EAAE,MAAA,IAAI,CAAC,qBAAqB,0CAAE,cAAc;YAC1D,UAAU,EAAE,MAAA,IAAI,CAAC,qBAAqB,0CAAE,iBAAiB;SAC1D,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC7B,MAAM,aAAa,GAAG,IAAI,2BAAa,CAAC;gBACtC,QAAQ,EAAE,IAAI,CAAC,SAAS;gBACxB,KAAK,EAAE,MAAA,MAAA,IAAI,CAAC,oBAAoB,0CAAE,KAAK,mCAAI,EAAE;aAC9C,CAAC,CAAC;YAEH,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE;gBACpC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;aACjE;YAED,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;YAEpC,aAAO,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;SAC/C;IACH,CAAC;IAEM,QAAQ;QACb,MAAM,QAAQ,GAAuB,EAAE,CAAC;QACxC,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;AA/ND,0BA+NC","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 { ContextManager, TextMapPropagator, metrics } from '@opentelemetry/api';\nimport {\n InstrumentationOption,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport {\n Detector,\n detectResources,\n envDetector,\n processDetector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\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 { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';\nimport { NodeSDKConfiguration } from './types';\nimport { TracerProviderWithEnvExporters } from './TracerProviderWithEnvExporter';\nimport { getEnv } from '@opentelemetry/core';\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};\nexport class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessor: SpanProcessor;\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\n private _meterProviderConfig?: MeterProviderConfig;\n private _instrumentations: InstrumentationOption[];\n\n private _resource: Resource;\n private _resourceDetectors: Detector[];\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider | TracerProviderWithEnvExporters;\n private _meterProvider?: MeterProvider;\n private _serviceName?: string;\n\n private _disabled?: boolean;\n\n /**\n * Create a new NodeJS SDK instance\n */\n public constructor(configuration: Partial<NodeSDKConfiguration> = {}) {\n if (getEnv().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 this._resource = configuration.resource ?? new Resource({});\n this._resourceDetectors = configuration.resourceDetectors ?? [\n envDetector,\n processDetector,\n ];\n\n this._serviceName = configuration.serviceName;\n\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n\n if (configuration.spanProcessor || configuration.traceExporter) {\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\n const spanProcessor =\n configuration.spanProcessor ??\n new BatchSpanProcessor(configuration.traceExporter!);\n\n this.configureTracerProvider(\n tracerProviderConfig,\n spanProcessor,\n configuration.contextManager,\n configuration.textMapPropagator\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.configureMeterProvider(meterProviderConfig);\n }\n\n let instrumentations: InstrumentationOption[] = [];\n if (configuration.instrumentations) {\n instrumentations = configuration.instrumentations;\n }\n this._instrumentations = instrumentations;\n }\n\n /** Set configurations required to register a NodeTracerProvider */\n public configureTracerProvider(\n tracerConfig: NodeTracerConfig,\n spanProcessor: SpanProcessor,\n contextManager?: ContextManager,\n textMapPropagator?: TextMapPropagator\n ): void {\n this._tracerProviderConfig = {\n tracerConfig,\n spanProcessor,\n contextManager,\n textMapPropagator,\n };\n }\n\n /** Set configurations needed to register a MeterProvider */\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 /** Detect resource attributes */\n public async detectResources(): Promise<void> {\n if (this._disabled) {\n return;\n }\n\n const internalConfig: ResourceDetectionConfig = {\n detectors: this._resourceDetectors,\n };\n\n this.addResource(await detectResources(internalConfig));\n }\n\n /** Manually add a resource */\n public addResource(resource: Resource): void {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n * Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API.\n */\n public async start(): Promise<void> {\n if (this._disabled) {\n return;\n }\n\n registerInstrumentations({\n instrumentations: this._instrumentations,\n });\n\n if (this._autoDetectResources) {\n await this.detectResources();\n }\n\n this._resource =\n this._serviceName === undefined\n ? this._resource\n : this._resource.merge(\n new Resource({\n [SemanticResourceAttributes.SERVICE_NAME]: this._serviceName,\n })\n );\n\n const Provider = this._tracerProviderConfig\n ? NodeTracerProvider\n : TracerProviderWithEnvExporters;\n\n const tracerProvider = new Provider({\n ...this._tracerProviderConfig?.tracerConfig,\n resource: this._resource,\n });\n\n this._tracerProvider = tracerProvider;\n\n if (this._tracerProviderConfig) {\n tracerProvider.addSpanProcessor(this._tracerProviderConfig.spanProcessor);\n }\n\n tracerProvider.register({\n contextManager: this._tracerProviderConfig?.contextManager,\n propagator: this._tracerProviderConfig?.textMapPropagator,\n });\n\n if (this._meterProviderConfig) {\n const meterProvider = new MeterProvider({\n resource: this._resource,\n views: this._meterProviderConfig?.views ?? [],\n });\n\n if (this._meterProviderConfig.reader) {\n meterProvider.addMetricReader(this._meterProviderConfig.reader);\n }\n\n this._meterProvider = meterProvider;\n\n metrics.setGlobalMeterProvider(meterProvider);\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._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,oEAGwC;AACxC,wDASkC;AAClC,4DAA+E;AAC/E,kEAGuC;AACvC,kEAGuC;AACvC,8EAAiF;AAEjF,mFAAiF;AACjF,8CAA6C;AAC7C,mCAAsD;AAetD,MAAa,OAAO;IAqBlB;;OAEG;IACH,YAAmB,gBAA+C,EAAE;;QAClE,MAAM,GAAG,GAAG,IAAA,aAAM,GAAE,CAAC;QACrB,IAAI,GAAG,CAAC,iBAAiB,EAAE;YACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,+CAA+C;YAC/C,kCAAkC;SACnC;QACD,IAAI,GAAG,CAAC,cAAc,EAAE;YACtB,UAAI,CAAC,SAAS,CAAC,IAAI,uBAAiB,EAAE,EAAE;gBACtC,QAAQ,EAAE,GAAG,CAAC,cAAc;aAC7B,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,SAAS,GAAG,MAAA,aAAa,CAAC,QAAQ,mCAAI,IAAI,oBAAQ,CAAC,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,kBAAkB,GAAG,MAAA,aAAa,CAAC,iBAAiB,mCAAI;YAC3D,uBAAW;YACX,2BAAe;SAChB,CAAC;QAEF,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC;QAE9C,IAAI,CAAC,oBAAoB,GAAG,MAAA,aAAa,CAAC,mBAAmB,mCAAI,IAAI,CAAC;QAEtE,IAAI,aAAa,CAAC,aAAa,IAAI,aAAa,CAAC,aAAa,EAAE;YAC9D,MAAM,oBAAoB,GAAqB,EAAE,CAAC;YA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CAAI,EAAE;aAC9C,CAAC,CAAC;YAEH,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE;gBACpC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;aACjE;YAED,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;YAEpC,aAAO,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;YAE9C,mGAAmG;YACnG,4GAA4G;YAC5G,4GAA4G;YAC5G,KAAK,MAAM,eAAe,IAAI,IAAA,mCAA2B,EACvD,IAAI,CAAC,iBAAiB,CACvB,EAAE;gBACD,eAAe,CAAC,gBAAgB,CAAC,aAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;aAC9D;SACF;IACH,CAAC;IAEM,QAAQ;QACb,MAAM,QAAQ,GAAuB,EAAE,CAAC;QACxC,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;AAjPD,0BAiPC","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 {\n InstrumentationOption,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport {\n Detector,\n DetectorSync,\n detectResourcesSync,\n envDetector,\n IResource,\n processDetector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\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 { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';\nimport { NodeSDKConfiguration } from './types';\nimport { TracerProviderWithEnvExporters } from './TracerProviderWithEnvExporter';\nimport { getEnv } 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 class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessor: SpanProcessor;\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\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 _meterProvider?: MeterProvider;\n private _serviceName?: string;\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 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 if (env.OTEL_LOG_LEVEL) {\n diag.setLogger(new DiagConsoleLogger(), {\n logLevel: env.OTEL_LOG_LEVEL,\n });\n }\n\n this._resource = configuration.resource ?? new Resource({});\n this._resourceDetectors = configuration.resourceDetectors ?? [\n envDetector,\n processDetector,\n ];\n\n this._serviceName = configuration.serviceName;\n\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n\n if (configuration.spanProcessor || configuration.traceExporter) {\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 const spanProcessor =\n configuration.spanProcessor ??\n new BatchSpanProcessor(configuration.traceExporter!);\n\n this.configureTracerProvider(\n tracerProviderConfig,\n spanProcessor,\n configuration.contextManager,\n configuration.textMapPropagator\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.configureMeterProvider(meterProviderConfig);\n }\n\n let instrumentations: InstrumentationOption[] = [];\n if (configuration.instrumentations) {\n instrumentations = configuration.instrumentations;\n }\n this._instrumentations = instrumentations;\n }\n\n /** Set configurations required to register a NodeTracerProvider */\n public configureTracerProvider(\n tracerConfig: NodeTracerConfig,\n spanProcessor: SpanProcessor,\n contextManager?: ContextManager,\n textMapPropagator?: TextMapPropagator\n ): void {\n this._tracerProviderConfig = {\n tracerConfig,\n spanProcessor,\n contextManager,\n textMapPropagator,\n };\n }\n\n /** Set configurations needed to register a MeterProvider */\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 /** Detect resource attributes */\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 /** Manually add a resource */\n public addResource(resource: IResource): void {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n * Once the SDK has been configured, 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 [SemanticResourceAttributes.SERVICE_NAME]: this._serviceName,\n })\n );\n\n const Provider = this._tracerProviderConfig\n ? NodeTracerProvider\n : TracerProviderWithEnvExporters;\n\n const tracerProvider = new Provider({\n ...this._tracerProviderConfig?.tracerConfig,\n resource: this._resource,\n });\n\n this._tracerProvider = tracerProvider;\n\n if (this._tracerProviderConfig) {\n tracerProvider.addSpanProcessor(this._tracerProviderConfig.spanProcessor);\n }\n\n tracerProvider.register({\n contextManager: this._tracerProviderConfig?.contextManager,\n propagator: this._tracerProviderConfig?.textMapPropagator,\n });\n\n if (this._meterProviderConfig) {\n const meterProvider = new MeterProvider({\n resource: this._resource,\n views: this._meterProviderConfig?.views ?? [],\n });\n\n if (this._meterProviderConfig.reader) {\n meterProvider.addMetricReader(this._meterProviderConfig.reader);\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._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/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ContextManager, SpanAttributes } from '@opentelemetry/api';
|
|
2
2
|
import { TextMapPropagator } from '@opentelemetry/api';
|
|
3
3
|
import { InstrumentationOption } from '@opentelemetry/instrumentation';
|
|
4
|
-
import { Detector, Resource } from '@opentelemetry/resources';
|
|
4
|
+
import { Detector, DetectorSync, Resource } from '@opentelemetry/resources';
|
|
5
5
|
import { MetricReader, View } from '@opentelemetry/sdk-metrics';
|
|
6
|
-
import { Sampler, SpanExporter, SpanLimits, SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
6
|
+
import { Sampler, SpanExporter, SpanLimits, SpanProcessor, IdGenerator } from '@opentelemetry/sdk-trace-base';
|
|
7
7
|
export interface NodeSDKConfiguration {
|
|
8
8
|
autoDetectResources: boolean;
|
|
9
9
|
contextManager: ContextManager;
|
|
@@ -13,11 +13,12 @@ export interface NodeSDKConfiguration {
|
|
|
13
13
|
views: View[];
|
|
14
14
|
instrumentations: InstrumentationOption[];
|
|
15
15
|
resource: Resource;
|
|
16
|
-
resourceDetectors: Detector
|
|
16
|
+
resourceDetectors: Array<Detector | DetectorSync>;
|
|
17
17
|
sampler: Sampler;
|
|
18
18
|
serviceName?: string;
|
|
19
19
|
spanProcessor: SpanProcessor;
|
|
20
20
|
traceExporter: SpanExporter;
|
|
21
21
|
spanLimits: SpanLimits;
|
|
22
|
+
idGenerator: IdGenerator;
|
|
22
23
|
}
|
|
23
24
|
//# sourceMappingURL=types.d.ts.map
|
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ContextManager, SpanAttributes } from '@opentelemetry/api';\nimport { TextMapPropagator } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { Detector, Resource } from '@opentelemetry/resources';\nimport { MetricReader, View } from '@opentelemetry/sdk-metrics';\nimport {\n Sampler,\n SpanExporter,\n SpanLimits,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n defaultAttributes: SpanAttributes;\n textMapPropagator: TextMapPropagator;\n metricReader: MetricReader;\n views: View[];\n instrumentations: InstrumentationOption[];\n resource: Resource;\n resourceDetectors: Detector
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ContextManager, SpanAttributes } from '@opentelemetry/api';\nimport { TextMapPropagator } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { Detector, DetectorSync, Resource } from '@opentelemetry/resources';\nimport { MetricReader, View } from '@opentelemetry/sdk-metrics';\nimport {\n Sampler,\n SpanExporter,\n SpanLimits,\n SpanProcessor,\n IdGenerator,\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n defaultAttributes: SpanAttributes;\n textMapPropagator: TextMapPropagator;\n metricReader: MetricReader;\n views: View[];\n instrumentations: InstrumentationOption[];\n resource: Resource;\n resourceDetectors: Array<Detector | DetectorSync>;\n sampler: Sampler;\n serviceName?: string;\n spanProcessor: SpanProcessor;\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n idGenerator: IdGenerator;\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.parseInstrumentationOptions = void 0;
|
|
19
|
+
// TODO: This part of a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609
|
|
20
|
+
// If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.
|
|
21
|
+
// This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.
|
|
22
|
+
function parseInstrumentationOptions(options = []) {
|
|
23
|
+
let instrumentations = [];
|
|
24
|
+
for (let i = 0, j = options.length; i < j; i++) {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
const option = options[i];
|
|
27
|
+
if (Array.isArray(option)) {
|
|
28
|
+
const results = parseInstrumentationOptions(option);
|
|
29
|
+
instrumentations = instrumentations.concat(results);
|
|
30
|
+
}
|
|
31
|
+
else if (typeof option === 'function') {
|
|
32
|
+
instrumentations.push(new option());
|
|
33
|
+
}
|
|
34
|
+
else if (option.instrumentationName) {
|
|
35
|
+
instrumentations.push(option);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return instrumentations;
|
|
39
|
+
}
|
|
40
|
+
exports.parseInstrumentationOptions = parseInstrumentationOptions;
|
|
41
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAOH,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","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 Instrumentation,\n InstrumentationOption,\n} from '@opentelemetry/instrumentation';\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"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.36.1";
|
|
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.36.1';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/sdk-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "OpenTelemetry SDK for Node.js",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -44,25 +44,25 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@opentelemetry/core": "1.
|
|
48
|
-
"@opentelemetry/exporter-jaeger": "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-metrics": "1.
|
|
56
|
-
"@opentelemetry/sdk-trace-base": "1.
|
|
57
|
-
"@opentelemetry/sdk-trace-node": "1.
|
|
58
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
47
|
+
"@opentelemetry/core": "1.10.1",
|
|
48
|
+
"@opentelemetry/exporter-jaeger": "1.10.1",
|
|
49
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.36.1",
|
|
50
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.36.1",
|
|
51
|
+
"@opentelemetry/exporter-trace-otlp-proto": "0.36.1",
|
|
52
|
+
"@opentelemetry/exporter-zipkin": "1.10.1",
|
|
53
|
+
"@opentelemetry/instrumentation": "0.36.1",
|
|
54
|
+
"@opentelemetry/resources": "1.10.1",
|
|
55
|
+
"@opentelemetry/sdk-metrics": "1.10.1",
|
|
56
|
+
"@opentelemetry/sdk-trace-base": "1.10.1",
|
|
57
|
+
"@opentelemetry/sdk-trace-node": "1.10.1",
|
|
58
|
+
"@opentelemetry/semantic-conventions": "1.10.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@opentelemetry/api": ">=1.3.0 <1.5.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@opentelemetry/api": "
|
|
65
|
-
"@opentelemetry/context-async-hooks": "1.
|
|
64
|
+
"@opentelemetry/api": "1.4.1",
|
|
65
|
+
"@opentelemetry/context-async-hooks": "1.10.1",
|
|
66
66
|
"@types/mocha": "10.0.0",
|
|
67
67
|
"@types/node": "18.6.5",
|
|
68
68
|
"@types/semver": "7.3.9",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
},
|
|
80
80
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-node",
|
|
81
81
|
"sideEffects": false,
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "486df99906958de9b8b666839785b00160a6a229"
|
|
83
83
|
}
|