@opentelemetry/sdk-node 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/src/sdk.js +2 -1
- package/build/src/sdk.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/README.md
CHANGED
|
@@ -132,7 +132,7 @@ An array of span processors to register to the tracer provider.
|
|
|
132
132
|
|
|
133
133
|
### traceExporter
|
|
134
134
|
|
|
135
|
-
Configure a trace exporter. If an exporter is configured, it will be used with a [BatchSpanProcessor](../../../packages/opentelemetry-sdk-trace-base/src/platform/node/export/BatchSpanProcessor.ts). If an exporter OR span processor is not configured
|
|
135
|
+
Configure a trace exporter. If an exporter is configured, it will be used with a [BatchSpanProcessor](../../../packages/opentelemetry-sdk-trace-base/src/platform/node/export/BatchSpanProcessor.ts). If an exporter OR span processor is not configured programmatically, this package will auto setup the default `otlp` exporter with `http/protobuf` protocol with a `BatchSpanProcessor`.
|
|
136
136
|
|
|
137
137
|
### spanLimits
|
|
138
138
|
|
package/build/src/sdk.js
CHANGED
|
@@ -53,6 +53,7 @@ class NodeSDK {
|
|
|
53
53
|
this._resourceDetectors = (_b = configuration.resourceDetectors) !== null && _b !== void 0 ? _b : [
|
|
54
54
|
resources_1.envDetector,
|
|
55
55
|
resources_1.processDetector,
|
|
56
|
+
resources_1.hostDetector,
|
|
56
57
|
];
|
|
57
58
|
this._serviceName = configuration.serviceName;
|
|
58
59
|
this._autoDetectResources = (_c = configuration.autoDetectResources) !== null && _c !== void 0 ? _c : true;
|
|
@@ -206,7 +207,7 @@ class NodeSDK {
|
|
|
206
207
|
this._serviceName === undefined
|
|
207
208
|
? this._resource
|
|
208
209
|
: this._resource.merge(new resources_1.Resource({
|
|
209
|
-
[semantic_conventions_1.
|
|
210
|
+
[semantic_conventions_1.SEMRESATTRS_SERVICE_NAME]: this._serviceName,
|
|
210
211
|
}));
|
|
211
212
|
// if there is a tracerProviderConfig (traceExporter/spanProcessor was set manually) or the traceExporter is set manually, use NodeTracerProvider
|
|
212
213
|
const Provider = this._tracerProviderConfig
|
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,wDASkC;AAClC,sDAA6E;AAC7E,4DAA+E;AAC/E,kEAGuC;AACvC,kEAGuC;AACvC,8EAAiF;AAEjF,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,IAAI,uBAAiB,EAAE,EAAE;gBACtC,QAAQ,EAAE,kBAAkB,CAAC,cAAc;aAC5C,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QAEpC,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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YACnB,oDAAoD;aACnD,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAClB,CAAC;IACJ,CAAC;CACF;AArVD,0BAqVC","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 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 { SemanticResourceAttributes } 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 ];\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 [SemanticResourceAttributes.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,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,IAAI,uBAAiB,EAAE,EAAE;gBACtC,QAAQ,EAAE,kBAAkB,CAAC,cAAc;aAC5C,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QAEpC,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;YAC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,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"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.50.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.50.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/sdk-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.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.50.0",
|
|
48
|
+
"@opentelemetry/core": "1.23.0",
|
|
49
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.50.0",
|
|
50
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.50.0",
|
|
51
|
+
"@opentelemetry/exporter-trace-otlp-proto": "0.50.0",
|
|
52
|
+
"@opentelemetry/exporter-zipkin": "1.23.0",
|
|
53
|
+
"@opentelemetry/instrumentation": "0.50.0",
|
|
54
|
+
"@opentelemetry/resources": "1.23.0",
|
|
55
|
+
"@opentelemetry/sdk-logs": "0.50.0",
|
|
56
|
+
"@opentelemetry/sdk-metrics": "1.23.0",
|
|
57
|
+
"@opentelemetry/sdk-trace-base": "1.23.0",
|
|
58
|
+
"@opentelemetry/sdk-trace-node": "1.23.0",
|
|
59
|
+
"@opentelemetry/semantic-conventions": "1.23.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.23.0",
|
|
67
|
+
"@opentelemetry/exporter-jaeger": "1.23.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": "5231aa255047fbc6ee3d6a299f4423ab2f8a5fbc"
|
|
86
86
|
}
|