@opentelemetry/sdk-node 0.40.0 → 0.41.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.
@@ -1,6 +1,7 @@
1
1
  export * as api from '@opentelemetry/api';
2
2
  export * as contextBase from '@opentelemetry/api';
3
3
  export * as core from '@opentelemetry/core';
4
+ export * as logs from '@opentelemetry/sdk-logs';
4
5
  export * as metrics from '@opentelemetry/sdk-metrics';
5
6
  export * as node from '@opentelemetry/sdk-trace-node';
6
7
  export * as resources from '@opentelemetry/resources';
@@ -25,10 +25,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
25
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.tracing = exports.resources = exports.node = exports.metrics = exports.core = exports.contextBase = exports.api = void 0;
28
+ exports.tracing = exports.resources = exports.node = exports.metrics = exports.logs = exports.core = exports.contextBase = exports.api = void 0;
29
29
  exports.api = require("@opentelemetry/api");
30
30
  exports.contextBase = require("@opentelemetry/api");
31
31
  exports.core = require("@opentelemetry/core");
32
+ exports.logs = require("@opentelemetry/sdk-logs");
32
33
  exports.metrics = require("@opentelemetry/sdk-metrics");
33
34
  exports.node = require("@opentelemetry/sdk-trace-node");
34
35
  exports.resources = require("@opentelemetry/resources");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;AAEH,4CAA0C;AAC1C,oDAAkD;AAClD,8CAA4C;AAC5C,wDAAsD;AACtD,wDAAsD;AACtD,wDAAsD;AACtD,2DAAyD;AACzD,wCAAsB;AACtB,0CAAwB","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\nexport * as api from '@opentelemetry/api';\nexport * as contextBase from '@opentelemetry/api';\nexport * as core from '@opentelemetry/core';\nexport * as metrics from '@opentelemetry/sdk-metrics';\nexport * as node from '@opentelemetry/sdk-trace-node';\nexport * as resources from '@opentelemetry/resources';\nexport * as tracing from '@opentelemetry/sdk-trace-base';\nexport * from './sdk';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;AAEH,4CAA0C;AAC1C,oDAAkD;AAClD,8CAA4C;AAC5C,kDAAgD;AAChD,wDAAsD;AACtD,wDAAsD;AACtD,wDAAsD;AACtD,2DAAyD;AACzD,wCAAsB;AACtB,0CAAwB","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\nexport * as api from '@opentelemetry/api';\nexport * as contextBase from '@opentelemetry/api';\nexport * as core from '@opentelemetry/core';\nexport * as logs from '@opentelemetry/sdk-logs';\nexport * as metrics from '@opentelemetry/sdk-metrics';\nexport * as node from '@opentelemetry/sdk-trace-node';\nexport * as resources from '@opentelemetry/resources';\nexport * as tracing from '@opentelemetry/sdk-trace-base';\nexport * from './sdk';\nexport * from './types';\n"]}
@@ -1,5 +1,6 @@
1
1
  import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
2
2
  import { IResource } from '@opentelemetry/resources';
3
+ import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
3
4
  import { MetricReader, View } from '@opentelemetry/sdk-metrics';
4
5
  import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
5
6
  import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
@@ -15,14 +16,22 @@ export declare type MeterProviderConfig = {
15
16
  */
16
17
  views?: View[];
17
18
  };
19
+ export declare type LoggerProviderConfig = {
20
+ /**
21
+ * Reference to the LoggerRecordProcessor instance by the NodeSDK
22
+ */
23
+ logRecordProcessor: LogRecordProcessor;
24
+ };
18
25
  export declare class NodeSDK {
19
26
  private _tracerProviderConfig?;
27
+ private _loggerProviderConfig?;
20
28
  private _meterProviderConfig?;
21
29
  private _instrumentations;
22
30
  private _resource;
23
31
  private _resourceDetectors;
24
32
  private _autoDetectResources;
25
33
  private _tracerProvider?;
34
+ private _loggerProvider?;
26
35
  private _meterProvider?;
27
36
  private _serviceName?;
28
37
  private _disabled?;
@@ -32,6 +41,8 @@ export declare class NodeSDK {
32
41
  constructor(configuration?: Partial<NodeSDKConfiguration>);
33
42
  /** Set configurations required to register a NodeTracerProvider */
34
43
  configureTracerProvider(tracerConfig: NodeTracerConfig, spanProcessor: SpanProcessor, contextManager?: ContextManager, textMapPropagator?: TextMapPropagator): void;
44
+ /**Set configurations needed to register a LoggerProvider */
45
+ configureLoggerProvider(config: LoggerProviderConfig): void;
35
46
  /** Set configurations needed to register a MeterProvider */
36
47
  configureMeterProvider(config: MeterProviderConfig): void;
37
48
  /** Detect resource attributes */
package/build/src/sdk.js CHANGED
@@ -17,8 +17,10 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.NodeSDK = void 0;
19
19
  const api_1 = require("@opentelemetry/api");
20
+ const api_logs_1 = require("@opentelemetry/api-logs");
20
21
  const instrumentation_1 = require("@opentelemetry/instrumentation");
21
22
  const resources_1 = require("@opentelemetry/resources");
23
+ const sdk_logs_1 = require("@opentelemetry/sdk-logs");
22
24
  const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
23
25
  const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
24
26
  const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
@@ -67,6 +69,12 @@ class NodeSDK {
67
69
  const spanProcessor = (_d = configuration.spanProcessor) !== null && _d !== void 0 ? _d : new sdk_trace_base_1.BatchSpanProcessor(configuration.traceExporter);
68
70
  this.configureTracerProvider(tracerProviderConfig, spanProcessor, configuration.contextManager, configuration.textMapPropagator);
69
71
  }
72
+ if (configuration.logRecordProcessor) {
73
+ const loggerProviderConfig = {
74
+ logRecordProcessor: configuration.logRecordProcessor,
75
+ };
76
+ this.configureLoggerProvider(loggerProviderConfig);
77
+ }
70
78
  if (configuration.metricReader || configuration.views) {
71
79
  const meterProviderConfig = {};
72
80
  if (configuration.metricReader) {
@@ -92,6 +100,23 @@ class NodeSDK {
92
100
  textMapPropagator,
93
101
  };
94
102
  }
103
+ /**Set configurations needed to register a LoggerProvider */
104
+ configureLoggerProvider(config) {
105
+ // nothing is set yet, we can set config and then return
106
+ if (this._loggerProviderConfig == null) {
107
+ this._loggerProviderConfig = config;
108
+ return;
109
+ }
110
+ // make sure we do not override existing logRecordProcessor with other logRecordProcessors.
111
+ if (this._loggerProviderConfig.logRecordProcessor != null &&
112
+ config.logRecordProcessor != null) {
113
+ throw new Error('LogRecordProcessor passed but LogRecordProcessor has already been configured.');
114
+ }
115
+ // set logRecordProcessor, but make sure we do not override existing logRecordProcessors with null/undefined.
116
+ if (config.logRecordProcessor != null) {
117
+ this._loggerProviderConfig.logRecordProcessor = config.logRecordProcessor;
118
+ }
119
+ }
95
120
  /** Set configurations needed to register a MeterProvider */
96
121
  configureMeterProvider(config) {
97
122
  // nothing is set yet, we can set config and return.
@@ -162,6 +187,14 @@ class NodeSDK {
162
187
  contextManager: (_b = this._tracerProviderConfig) === null || _b === void 0 ? void 0 : _b.contextManager,
163
188
  propagator: (_c = this._tracerProviderConfig) === null || _c === void 0 ? void 0 : _c.textMapPropagator,
164
189
  });
190
+ if (this._loggerProviderConfig) {
191
+ const loggerProvider = new sdk_logs_1.LoggerProvider({
192
+ resource: this._resource,
193
+ });
194
+ loggerProvider.addLogRecordProcessor(this._loggerProviderConfig.logRecordProcessor);
195
+ this._loggerProvider = loggerProvider;
196
+ api_logs_1.logs.setGlobalLoggerProvider(loggerProvider);
197
+ }
165
198
  if (this._meterProviderConfig) {
166
199
  const meterProvider = new sdk_metrics_1.MeterProvider({
167
200
  resource: this._resource,
@@ -185,6 +218,9 @@ class NodeSDK {
185
218
  if (this._tracerProvider) {
186
219
  promises.push(this._tracerProvider.shutdown());
187
220
  }
221
+ if (this._loggerProvider) {
222
+ promises.push(this._loggerProvider.shutdown());
223
+ }
188
224
  if (this._meterProvider) {
189
225
  promises.push(this._meterProvider.shutdown());
190
226
  }
@@ -1 +1 @@
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,8CAAoE;AACpE,mCAAsD;AAetD,MAAa,OAAO;IAqBlB;;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,CAA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,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;AAtPD,0BAsPC","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, 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 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 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._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"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;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AAC,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;AAvSD,0BAuSC","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 spanProcessor: 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\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._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.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 /** 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 LoggerProvider */\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 /** 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._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 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._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"]}
@@ -2,12 +2,14 @@ import type { ContextManager } from '@opentelemetry/api';
2
2
  import { TextMapPropagator } from '@opentelemetry/api';
3
3
  import { InstrumentationOption } from '@opentelemetry/instrumentation';
4
4
  import { Detector, DetectorSync, IResource } from '@opentelemetry/resources';
5
+ import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
5
6
  import { MetricReader, View } from '@opentelemetry/sdk-metrics';
6
7
  import { Sampler, SpanExporter, SpanLimits, SpanProcessor, IdGenerator } from '@opentelemetry/sdk-trace-base';
7
8
  export interface NodeSDKConfiguration {
8
9
  autoDetectResources: boolean;
9
10
  contextManager: ContextManager;
10
11
  textMapPropagator: TextMapPropagator;
12
+ logRecordProcessor: LogRecordProcessor;
11
13
  metricReader: MetricReader;
12
14
  views: View[];
13
15
  instrumentations: InstrumentationOption[];
@@ -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 { 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 metricReader: MetricReader;\n views: View[];\n instrumentations: InstrumentationOption[];\n resource: IResource;\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"]}
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 spanProcessor: SpanProcessor;\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n idGenerator: IdGenerator;\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.40.0";
1
+ export declare const VERSION = "0.41.1";
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.40.0';
20
+ exports.VERSION = '0.41.1';
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.40.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.41.1';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/sdk-node",
3
- "version": "0.40.0",
3
+ "version": "0.41.1",
4
4
  "description": "OpenTelemetry SDK for Node.js",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "lint:fix": "eslint . --ext .ts --fix",
16
16
  "version": "node ../../../scripts/version-update.js",
17
17
  "watch": "tsc --build --watch",
18
- "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
18
+ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
19
19
  "prewatch": "npm run precompile",
20
20
  "peer-api-check": "node ../../../scripts/peer-api-check.js"
21
21
  },
@@ -44,40 +44,43 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "@opentelemetry/core": "1.14.0",
48
- "@opentelemetry/exporter-jaeger": "1.14.0",
49
- "@opentelemetry/exporter-trace-otlp-grpc": "0.40.0",
50
- "@opentelemetry/exporter-trace-otlp-http": "0.40.0",
51
- "@opentelemetry/exporter-trace-otlp-proto": "0.40.0",
52
- "@opentelemetry/exporter-zipkin": "1.14.0",
53
- "@opentelemetry/instrumentation": "0.40.0",
54
- "@opentelemetry/resources": "1.14.0",
55
- "@opentelemetry/sdk-metrics": "1.14.0",
56
- "@opentelemetry/sdk-trace-base": "1.14.0",
57
- "@opentelemetry/sdk-trace-node": "1.14.0",
58
- "@opentelemetry/semantic-conventions": "1.14.0"
47
+ "@opentelemetry/api-logs": "0.41.1",
48
+ "@opentelemetry/core": "1.15.1",
49
+ "@opentelemetry/exporter-jaeger": "1.15.1",
50
+ "@opentelemetry/exporter-trace-otlp-grpc": "0.41.1",
51
+ "@opentelemetry/exporter-trace-otlp-http": "0.41.1",
52
+ "@opentelemetry/exporter-trace-otlp-proto": "0.41.1",
53
+ "@opentelemetry/exporter-zipkin": "1.15.1",
54
+ "@opentelemetry/instrumentation": "0.41.1",
55
+ "@opentelemetry/resources": "1.15.1",
56
+ "@opentelemetry/sdk-logs": "0.41.1",
57
+ "@opentelemetry/sdk-metrics": "1.15.1",
58
+ "@opentelemetry/sdk-trace-base": "1.15.1",
59
+ "@opentelemetry/sdk-trace-node": "1.15.1",
60
+ "@opentelemetry/semantic-conventions": "1.15.1"
59
61
  },
60
62
  "peerDependencies": {
61
63
  "@opentelemetry/api": ">=1.3.0 <1.5.0"
62
64
  },
63
65
  "devDependencies": {
64
66
  "@opentelemetry/api": "1.4.1",
65
- "@opentelemetry/context-async-hooks": "1.14.0",
66
- "@types/mocha": "10.0.0",
67
+ "@opentelemetry/context-async-hooks": "1.15.1",
68
+ "@types/mocha": "10.0.1",
67
69
  "@types/node": "18.6.5",
68
- "@types/semver": "7.3.9",
69
- "@types/sinon": "10.0.13",
70
+ "@types/semver": "7.5.0",
71
+ "@types/sinon": "10.0.15",
70
72
  "codecov": "3.8.3",
71
- "istanbul-instrumenter-loader": "3.0.1",
72
- "mocha": "10.0.0",
73
+ "cross-var": "1.1.0",
74
+ "lerna": "7.1.3",
75
+ "mocha": "10.2.0",
73
76
  "nyc": "15.1.0",
74
- "semver": "7.3.5",
75
- "sinon": "15.0.0",
77
+ "semver": "7.5.4",
78
+ "sinon": "15.1.2",
76
79
  "ts-loader": "8.4.0",
77
80
  "ts-mocha": "10.0.0",
78
81
  "typescript": "4.4.4"
79
82
  },
80
83
  "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-node",
81
84
  "sideEffects": false,
82
- "gitHead": "edebbcc757535bc88f01340409dbbecc0bb6ccf8"
85
+ "gitHead": "9f71800fdc2a5ee5055684037a12498af71955f2"
83
86
  }