@opentelemetry/sdk-node 0.51.0 → 0.52.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 CHANGED
@@ -185,7 +185,7 @@ This is an alternative to programmatically configuring an exporter or span proce
185
185
 
186
186
  | Environment variable | Description |
187
187
  |----------------------|-------------|
188
- | OTEL_TRACES_EXPORTER | List of exporters to be used for tracing, separated by commas. Options include `otlp`, `jaeger`, `zipkin`, and `none`. Default is `otlp`. `none` means no autoconfigured exporter.
188
+ | OTEL_TRACES_EXPORTER | List of exporters to be used for tracing, separated by commas. Options include `otlp`, `jaeger`, `zipkin`, and `none`. Default is `otlp`. `none` means no autoconfigured exporter. |
189
189
 
190
190
  ### OTLP Exporter
191
191
 
package/build/src/sdk.js CHANGED
@@ -33,7 +33,7 @@ class NodeSDK {
33
33
  * Create a new NodeJS SDK instance
34
34
  */
35
35
  constructor(configuration = {}) {
36
- var _a, _b, _c, _d, _e;
36
+ var _a, _b, _c, _d, _e, _f, _g;
37
37
  const env = (0, core_1.getEnv)();
38
38
  const envWithoutDefaults = (0, core_1.getEnvWithoutDefaults)();
39
39
  if (env.OTEL_SDK_DISABLED) {
@@ -104,11 +104,7 @@ class NodeSDK {
104
104
  }
105
105
  this._meterProviderConfig = meterProviderConfig;
106
106
  }
107
- let instrumentations = [];
108
- if (configuration.instrumentations) {
109
- instrumentations = configuration.instrumentations;
110
- }
111
- this._instrumentations = instrumentations;
107
+ this._instrumentations = (_g = (_f = configuration.instrumentations) === null || _f === void 0 ? void 0 : _f.flat()) !== null && _g !== void 0 ? _g : [];
112
108
  }
113
109
  /**
114
110
  * Call this method to construct SDK components and register them with the OpenTelemetry API.
@@ -172,7 +168,7 @@ class NodeSDK {
172
168
  // TODO: This is a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609
173
169
  // If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.
174
170
  // 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)) {
171
+ for (const instrumentation of this._instrumentations) {
176
172
  instrumentation.setMeterProvider(api_1.metrics.getMeterProvider());
177
173
  }
178
174
  }
@@ -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,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;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,gBAAgB,GAAgC,EAAE,CAAC;QACvD,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,IAAI,EAAE;YACpD,gBAAgB,GAAG,IAAA,mCAA2B,GAAE,CAAC;SAClD;aAAM;Y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,2BAAa,CAAC;gBACtC,QAAQ,EAAE,IAAI,CAAC,SAAS;gBACxB,KAAK,EAAE,MAAA,MAAA,IAAI,CAAC,oBAAoB,0CAAE,KAAK,mCAAI,EAAE;gBAC7C,OAAO,EAAE,OAAO;aACjB,CAAC,CAAC;YAEH,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,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/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"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAM4B;AAC5B,sDAA+C;AAC/C,oEAGwC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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,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;AAzOD,0BAyOC","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 Instrumentation,\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 { getResourceDetectorsFromEnv } 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: Instrumentation[];\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 this._instrumentations = configuration.instrumentations?.flat() ?? [];\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 this._instrumentations) {\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,6 +1,6 @@
1
1
  import type { ContextManager } from '@opentelemetry/api';
2
2
  import { TextMapPropagator } from '@opentelemetry/api';
3
- import { InstrumentationOption } from '@opentelemetry/instrumentation';
3
+ import { Instrumentation } from '@opentelemetry/instrumentation';
4
4
  import { Detector, DetectorSync, IResource } from '@opentelemetry/resources';
5
5
  import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
6
6
  import { MetricReader, View } from '@opentelemetry/sdk-metrics';
@@ -12,7 +12,7 @@ export interface NodeSDKConfiguration {
12
12
  logRecordProcessor: LogRecordProcessor;
13
13
  metricReader: MetricReader;
14
14
  views: View[];
15
- instrumentations: InstrumentationOption[];
15
+ instrumentations: (Instrumentation | Instrumentation[])[];
16
16
  resource: IResource;
17
17
  resourceDetectors: Array<Detector | DetectorSync>;
18
18
  sampler: Sampler;
@@ -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 } from '@opentelemetry/api';\nimport { TextMapPropagator } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { Detector, DetectorSync, IResource } from '@opentelemetry/resources';\nimport { LogRecordProcessor } from '@opentelemetry/sdk-logs';\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 textMapPropagator: TextMapPropagator;\n logRecordProcessor: LogRecordProcessor;\n metricReader: MetricReader;\n views: View[];\n instrumentations: InstrumentationOption[];\n resource: IResource;\n resourceDetectors: Array<Detector | DetectorSync>;\n sampler: Sampler;\n serviceName?: string;\n /** @deprecated use spanProcessors instead*/\n spanProcessor?: SpanProcessor;\n spanProcessors?: SpanProcessor[];\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n idGenerator: IdGenerator;\n}\n"]}
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 } from '@opentelemetry/api';\nimport { TextMapPropagator } from '@opentelemetry/api';\nimport { Instrumentation } from '@opentelemetry/instrumentation';\nimport { Detector, DetectorSync, IResource } from '@opentelemetry/resources';\nimport { LogRecordProcessor } from '@opentelemetry/sdk-logs';\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 textMapPropagator: TextMapPropagator;\n logRecordProcessor: LogRecordProcessor;\n metricReader: MetricReader;\n views: View[];\n instrumentations: (Instrumentation | Instrumentation[])[];\n resource: IResource;\n resourceDetectors: Array<Detector | DetectorSync>;\n sampler: Sampler;\n serviceName?: string;\n /** @deprecated use spanProcessors instead*/\n spanProcessor?: SpanProcessor;\n spanProcessors?: SpanProcessor[];\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n idGenerator: IdGenerator;\n}\n"]}
@@ -1,5 +1,3 @@
1
- import { Instrumentation, InstrumentationOption } from '@opentelemetry/instrumentation';
2
1
  import { DetectorSync } from '@opentelemetry/resources';
3
- export declare function parseInstrumentationOptions(options?: InstrumentationOption[]): Instrumentation[];
4
2
  export declare function getResourceDetectorsFromEnv(): Array<DetectorSync>;
5
3
  //# sourceMappingURL=utils.d.ts.map
@@ -15,31 +15,9 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getResourceDetectorsFromEnv = exports.parseInstrumentationOptions = void 0;
18
+ exports.getResourceDetectorsFromEnv = void 0;
19
19
  const api_1 = require("@opentelemetry/api");
20
20
  const resources_1 = require("@opentelemetry/resources");
21
- // TODO: This part of a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609
22
- // If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.
23
- // This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.
24
- function parseInstrumentationOptions(options = []) {
25
- let instrumentations = [];
26
- for (let i = 0, j = options.length; i < j; i++) {
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- const option = options[i];
29
- if (Array.isArray(option)) {
30
- const results = parseInstrumentationOptions(option);
31
- instrumentations = instrumentations.concat(results);
32
- }
33
- else if (typeof option === 'function') {
34
- instrumentations.push(new option());
35
- }
36
- else if (option.instrumentationName) {
37
- instrumentations.push(option);
38
- }
39
- }
40
- return instrumentations;
41
- }
42
- exports.parseInstrumentationOptions = parseInstrumentationOptions;
43
21
  const RESOURCE_DETECTOR_ENVIRONMENT = 'env';
44
22
  const RESOURCE_DETECTOR_HOST = 'host';
45
23
  const RESOURCE_DETECTOR_OS = 'os';
@@ -1 +1 @@
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,g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AAC,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"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,wDAOkC;AAElC,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 DetectorSync,\n envDetectorSync,\n hostDetectorSync,\n osDetectorSync,\n processDetectorSync,\n serviceInstanceIdDetectorSync,\n} from '@opentelemetry/resources';\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"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.51.0";
1
+ export declare const VERSION = "0.52.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.51.0';
20
+ exports.VERSION = '0.52.0';
21
21
  //# sourceMappingURL=version.js.map
@@ -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.51.0';\n"]}
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.52.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/sdk-node",
3
- "version": "0.51.0",
3
+ "version": "0.52.0",
4
4
  "description": "OpenTelemetry SDK for Node.js",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -17,7 +17,8 @@
17
17
  "watch": "tsc --build --watch",
18
18
  "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
19
19
  "prewatch": "npm run precompile",
20
- "peer-api-check": "node ../../../scripts/peer-api-check.js"
20
+ "peer-api-check": "node ../../../scripts/peer-api-check.js",
21
+ "align-api-deps": "node ../../../scripts/align-api-deps.js"
21
22
  },
22
23
  "keywords": [
23
24
  "opentelemetry",
@@ -44,31 +45,31 @@
44
45
  "access": "public"
45
46
  },
46
47
  "dependencies": {
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"
48
+ "@opentelemetry/api-logs": "0.52.0",
49
+ "@opentelemetry/core": "1.25.0",
50
+ "@opentelemetry/exporter-trace-otlp-grpc": "0.52.0",
51
+ "@opentelemetry/exporter-trace-otlp-http": "0.52.0",
52
+ "@opentelemetry/exporter-trace-otlp-proto": "0.52.0",
53
+ "@opentelemetry/exporter-zipkin": "1.25.0",
54
+ "@opentelemetry/instrumentation": "0.52.0",
55
+ "@opentelemetry/resources": "1.25.0",
56
+ "@opentelemetry/sdk-logs": "0.52.0",
57
+ "@opentelemetry/sdk-metrics": "1.25.0",
58
+ "@opentelemetry/sdk-trace-base": "1.25.0",
59
+ "@opentelemetry/sdk-trace-node": "1.25.0",
60
+ "@opentelemetry/semantic-conventions": "1.25.0"
60
61
  },
61
62
  "peerDependencies": {
62
- "@opentelemetry/api": ">=1.3.0 <1.9.0"
63
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
63
64
  },
64
65
  "devDependencies": {
65
- "@opentelemetry/api": "1.8.0",
66
- "@opentelemetry/context-async-hooks": "1.24.0",
67
- "@opentelemetry/exporter-jaeger": "1.24.0",
66
+ "@opentelemetry/api": "1.9.0",
67
+ "@opentelemetry/context-async-hooks": "1.25.0",
68
+ "@opentelemetry/exporter-jaeger": "1.25.0",
68
69
  "@types/mocha": "10.0.6",
69
70
  "@types/node": "18.6.5",
70
- "@types/semver": "7.5.6",
71
- "@types/sinon": "10.0.20",
71
+ "@types/semver": "7.5.8",
72
+ "@types/sinon": "17.0.3",
72
73
  "codecov": "3.8.3",
73
74
  "cross-var": "1.1.0",
74
75
  "lerna": "6.6.2",
@@ -76,11 +77,11 @@
76
77
  "nyc": "15.1.0",
77
78
  "semver": "7.5.4",
78
79
  "sinon": "15.1.2",
79
- "ts-loader": "8.4.0",
80
+ "ts-loader": "9.5.1",
80
81
  "ts-mocha": "10.0.0",
81
82
  "typescript": "4.4.4"
82
83
  },
83
84
  "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-node",
84
85
  "sideEffects": false,
85
- "gitHead": "3ab4f765d8d696327b7d139ae6a45e7bd7edd924"
86
+ "gitHead": "c4d3351b6b3f5593c8d7cbfec97b45cea9fe1511"
86
87
  }