@opentelemetry/sdk-node 0.26.0 → 0.29.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
@@ -1,8 +1,6 @@
1
1
  # OpenTelemetry SDK for Node.js
2
2
 
3
3
  [![NPM Published Version][npm-img]][npm-url]
4
- [![dependencies][dependencies-image]][dependencies-url]
5
- [![devDependencies][devdependencies-image]][devdependencies-url]
6
4
  [![Apache License][license-image]][license-image]
7
5
 
8
6
  This package provides the full OpenTelemetry SDK for Node.js including tracing and metrics.
@@ -88,15 +86,15 @@ Detect resources automatically from the environment using the default resource d
88
86
 
89
87
  ### contextManager
90
88
 
91
- Use a custom context manager. Default: [AsyncHooksContextManager](../opentelemetry-context-async-hooks/README.md)
89
+ Use a custom context manager. Default: [AsyncHooksContextManager](../../../packages/opentelemetry-context-async-hooks/README.md)
92
90
 
93
91
  ### textMapPropagator
94
92
 
95
- Use a custom propagator. Default: [CompositePropagator](../opentelemetry-core/src/context/propagation/composite.ts) using [W3C Trace Context](../opentelemetry-core/README.md#httptracecontext-propagator) and [Baggage](../opentelemetry-core/README.md#baggage-propagator)
93
+ Use a custom propagator. Default: [CompositePropagator](../../../packages/opentelemetry-core/src/propagation/composite.ts) using [W3C Trace Context](../../../packages/opentelemetry-core/README.md#w3ctracecontextpropagator-propagator) and [Baggage](../../../packages/opentelemetry-core/README.md#baggage-propagator)
96
94
 
97
95
  ### metricProcessor
98
96
 
99
- Use a custom processor for metrics. Default: [UngroupedProcessor](../opentelemetry-sdk-metrics-base/src/export/Processor.ts#L50)
97
+ Use a custom processor for metrics. Default: UngroupedProcessor
100
98
 
101
99
  ### metricExporter
102
100
 
@@ -124,11 +122,11 @@ Configure a custom sampler. By default all traces will be sampled.
124
122
 
125
123
  ### traceExporter
126
124
 
127
- Configure a trace exporter. If an exporter OR span processor is not configured, the tracing SDK will not be initialized and registered. If an exporter is configured, it will be used with a [BatchSpanProcessor](../opentelemetry-sdk-trace-base/src/platform/node/export/BatchSpanProcessor.ts).
125
+ Configure a trace exporter. If an exporter OR span processor is not configured, the tracing SDK will not be initialized and registered. If an exporter is configured, it will be used with a [BatchSpanProcessor](../../../packages/opentelemetry-sdk-trace-base/src/platform/node/export/BatchSpanProcessor.ts).
128
126
 
129
127
  ### spanLimits
130
128
 
131
- Configure tracing parameters. These are the same trace parameters used to [configure a tracer](../opentelemetry-sdk-trace-base/src/types.ts#L71).
129
+ Configure tracing parameters. These are the same trace parameters used to [configure a tracer](../../../packages/opentelemetry-sdk-trace-base/src/types.ts#L71).
132
130
 
133
131
  ## Useful links
134
132
 
@@ -143,10 +141,6 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
143
141
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
144
142
  [license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
145
143
  [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
146
- [dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-sdk-node
147
- [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-sdk-node
148
- [devdependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-sdk-node&type=dev
149
- [devdependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-sdk-node&type=dev
150
144
  [npm-url]: https://www.npmjs.com/package/@opentelemetry/sdk-node
151
145
  [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fsdk-node.svg
152
146
  [other-tracing-backends]: https://github.com/open-telemetry/opentelemetry-js#trace-exporters
@@ -1,6 +1,6 @@
1
1
  import { TextMapPropagator } from '@opentelemetry/api';
2
2
  import { ContextManager } from '@opentelemetry/api';
3
- import { MeterConfig } from '@opentelemetry/sdk-metrics-base';
3
+ import { MetricReader } from '@opentelemetry/sdk-metrics-base';
4
4
  import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
5
5
  import { Resource, ResourceDetectionConfig } from '@opentelemetry/resources';
6
6
  import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
@@ -9,7 +9,7 @@ import { NodeSDKConfiguration } from './types';
9
9
  export declare class NodeSDK {
10
10
  private _tracerProviderConfig?;
11
11
  private _instrumentations;
12
- private _meterProviderConfig?;
12
+ private _metricReader?;
13
13
  private _resource;
14
14
  private _autoDetectResources;
15
15
  private _tracerProvider?;
@@ -21,7 +21,7 @@ export declare class NodeSDK {
21
21
  /** Set configurations required to register a NodeTracerProvider */
22
22
  configureTracerProvider(tracerConfig: NodeTracerConfig, spanProcessor: SpanProcessor, contextManager?: ContextManager, textMapPropagator?: TextMapPropagator): void;
23
23
  /** Set configurations needed to register a MeterProvider */
24
- configureMeterProvider(config: MeterConfig): void;
24
+ configureMeterProvider(reader: MetricReader): void;
25
25
  /** Detect resource attributes */
26
26
  detectResources(config?: ResourceDetectionConfig): Promise<void>;
27
27
  /** Manually add a resource */
package/build/src/sdk.js CHANGED
@@ -44,18 +44,8 @@ class NodeSDK {
44
44
  const spanProcessor = (_c = configuration.spanProcessor) !== null && _c !== void 0 ? _c : new sdk_trace_base_1.BatchSpanProcessor(configuration.traceExporter);
45
45
  this.configureTracerProvider(tracerProviderConfig, spanProcessor, configuration.contextManager, configuration.textMapPropagator);
46
46
  }
47
- if (configuration.metricExporter) {
48
- const meterConfig = {};
49
- if (configuration.metricProcessor) {
50
- meterConfig.processor = configuration.metricProcessor;
51
- }
52
- if (configuration.metricExporter) {
53
- meterConfig.exporter = configuration.metricExporter;
54
- }
55
- if (typeof configuration.metricInterval === 'number') {
56
- meterConfig.interval = configuration.metricInterval;
57
- }
58
- this.configureMeterProvider(meterConfig);
47
+ if (configuration.metricReader) {
48
+ this.configureMeterProvider(configuration.metricReader);
59
49
  }
60
50
  let instrumentations = [];
61
51
  if (configuration.instrumentations) {
@@ -73,13 +63,13 @@ class NodeSDK {
73
63
  };
74
64
  }
75
65
  /** Set configurations needed to register a MeterProvider */
76
- configureMeterProvider(config) {
77
- this._meterProviderConfig = config;
66
+ configureMeterProvider(reader) {
67
+ this._metricReader = reader;
78
68
  }
79
69
  /** Detect resource attributes */
80
70
  async detectResources(config) {
81
71
  const internalConfig = Object.assign({ detectors: [resource_detector_aws_1.awsEc2Detector, resource_detector_gcp_1.gcpDetector, resources_1.envDetector, resources_1.processDetector] }, config);
82
- this.addResource(await resources_1.detectResources(internalConfig));
72
+ this.addResource(await (0, resources_1.detectResources)(internalConfig));
83
73
  }
84
74
  /** Manually add a resource */
85
75
  addResource(resource) {
@@ -101,12 +91,15 @@ class NodeSDK {
101
91
  propagator: this._tracerProviderConfig.textMapPropagator,
102
92
  });
103
93
  }
104
- if (this._meterProviderConfig) {
105
- const meterProvider = new sdk_metrics_base_1.MeterProvider(Object.assign(Object.assign({}, this._meterProviderConfig), { resource: this._resource }));
94
+ if (this._metricReader) {
95
+ const meterProvider = new sdk_metrics_base_1.MeterProvider({
96
+ resource: this._resource,
97
+ });
98
+ meterProvider.addMetricReader(this._metricReader);
106
99
  this._meterProvider = meterProvider;
107
100
  api_metrics_1.metrics.setGlobalMeterProvider(meterProvider);
108
101
  }
109
- instrumentation_1.registerInstrumentations({
102
+ (0, instrumentation_1.registerInstrumentations)({
110
103
  instrumentations: this._instrumentations,
111
104
  });
112
105
  }
@@ -120,7 +113,8 @@ class NodeSDK {
120
113
  }
121
114
  return (Promise.all(promises)
122
115
  // return void instead of the array from Promise.all
123
- .then(() => { }));
116
+ .then(() => {
117
+ }));
124
118
  }
125
119
  }
126
120
  exports.NodeSDK = NodeSDK;
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,4DAAqD;AAErD,sEAA6E;AAC7E,oEAGwC;AACxC,kEAAqF;AACrF,gFAAsE;AACtE,gFAAmE;AACnE,wDA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C,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;YAC1E,cAAc,CAAC,QAAQ,CAAC;gBACtB,cAAc,EAAE,IAAI,CAAC,qBAAqB,CAAC,cAAc;gBACzD,UAAU,EAAE,IAAI,CAAC,qBAAqB,CAAC,iBAAiB;aACzD,CAAC,CAAC;SACJ;QAED,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC7B,MAAM,aAAa,GAAG,IAAI,gCAAa,iCAClC,IAAI,CAAC,oBAAoB,KAC5B,QAAQ,EAAE,IAAI,CAAC,SAAS,IACxB,CAAC;YAEH,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;YAEpC,qBAAO,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;SAC/C;QAED,0CAAwB,CAAC;YACvB,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;SACzC,CAAC,CAAC;IACL,CAAC;IAEM,QAAQ;QACb,MAAM,QAAQ,GAAuB,EAAE,CAAC;QACxC,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC/C;QAED,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,oDAAoD;aACnD,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAClB,CAAC;IACJ,CAAC;CACF;AA9JD,0BA8JC","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 { TextMapPropagator } from '@opentelemetry/api';\nimport { metrics } from '@opentelemetry/api-metrics';\nimport { ContextManager } from '@opentelemetry/api';\nimport { MeterConfig, MeterProvider } from '@opentelemetry/sdk-metrics-base';\nimport {\n InstrumentationOption,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { awsEc2Detector } from '@opentelemetry/resource-detector-aws';\nimport { gcpDetector } from '@opentelemetry/resource-detector-gcp';\nimport {\n detectResources,\n envDetector,\n processDetector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\nimport { BatchSpanProcessor, SpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { NodeSDKConfiguration } from './types';\n\n/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */\nexport class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessor: SpanProcessor;\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\n private _instrumentations: InstrumentationOption[];\n private _meterProviderConfig?: MeterConfig;\n\n private _resource: Resource;\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider;\n private _meterProvider?: MeterProvider;\n\n /**\n * Create a new NodeJS SDK instance\n */\n public constructor(configuration: Partial<NodeSDKConfiguration> = {}) {\n this._resource = configuration.resource ?? new Resource({});\n\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n\n if (configuration.spanProcessor || configuration.traceExporter) {\n const tracerProviderConfig: NodeTracerConfig = {};\n\n if (configuration.sampler) {\n tracerProviderConfig.sampler = configuration.sampler;\n }\n if (configuration.spanLimits) {\n tracerProviderConfig.spanLimits = configuration.spanLimits;\n }\n\n const spanProcessor =\n configuration.spanProcessor ??\n new BatchSpanProcessor(configuration.traceExporter!);\n\n this.configureTracerProvider(\n tracerProviderConfig,\n spanProcessor,\n configuration.contextManager,\n configuration.textMapPropagator\n );\n }\n\n if (configuration.metricExporter) {\n const meterConfig: MeterConfig = {};\n\n if (configuration.metricProcessor) {\n meterConfig.processor = configuration.metricProcessor;\n }\n if (configuration.metricExporter) {\n meterConfig.exporter = configuration.metricExporter;\n }\n if (typeof configuration.metricInterval === 'number') {\n meterConfig.interval = configuration.metricInterval;\n }\n\n this.configureMeterProvider(meterConfig);\n }\n\n let instrumentations: InstrumentationOption[] = [];\n if (configuration.instrumentations) {\n instrumentations = configuration.instrumentations;\n }\n this._instrumentations = instrumentations;\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: MeterConfig): void {\n this._meterProviderConfig = config;\n }\n\n /** Detect resource attributes */\n public async detectResources(config?: ResourceDetectionConfig): Promise<void> {\n const internalConfig: ResourceDetectionConfig = {\n detectors: [awsEc2Detector, gcpDetector, envDetector, processDetector],\n ...config,\n };\n\n this.addResource(await detectResources(internalConfig));\n }\n\n /** Manually add a resource */\n public addResource(resource: Resource): void {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n * Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API.\n */\n public async start(): Promise<void> {\n if (this._autoDetectResources) {\n await this.detectResources();\n }\n\n if (this._tracerProviderConfig) {\n const tracerProvider = new NodeTracerProvider({\n ...this._tracerProviderConfig.tracerConfig,\n resource: this._resource,\n });\n\n this._tracerProvider = tracerProvider;\n\n tracerProvider.addSpanProcessor(this._tracerProviderConfig.spanProcessor);\n tracerProvider.register({\n contextManager: this._tracerProviderConfig.contextManager,\n propagator: this._tracerProviderConfig.textMapPropagator,\n });\n }\n\n if (this._meterProviderConfig) {\n const meterProvider = new MeterProvider({\n ...this._meterProviderConfig,\n resource: this._resource,\n });\n\n this._meterProvider = meterProvider;\n\n metrics.setGlobalMeterProvider(meterProvider);\n }\n\n registerInstrumentations({\n instrumentations: this._instrumentations,\n });\n }\n\n public shutdown(): Promise<void> {\n const promises: Promise<unknown>[] = [];\n if (this._tracerProvider) {\n promises.push(this._tracerProvider.shutdown());\n }\n if (this._meterProvider) {\n promises.push(this._meterProvider.shutdown());\n }\n\n return (\n Promise.all(promises)\n // return void instead of the array from Promise.all\n .then(() => {})\n );\n }\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,4DAAqD;AAErD,sEAA8E;AAC9E,oEAGwC;AACxC,kEAAqF;AACrF,gFAAsE;AACtE,gFAAmE;AACnE,wDAMkC;AAClC,kEAAkF;AAGlF,uGAAuG;AACvG,MAAa,OAAO;IAiBlB;;OAEG;IACH,YAAmB,gBAA+C,EAAE;;QAClE,IAAI,CAAC,SAAS,GAAG,MAAA,aAAa,CAAC,QAAQ,mCAAI,IAAI,oBAAQ,CAAC,EAAE,CAAC,CAAC;QAE5D,IAAI,CAAC,oBAAoB,GAAG,MAAA,aAAa,CAAC,mBAAmB,mCAAI,IAAI,CAAC;QAEtE,IAAI,aAAa,CAAC,aAAa,IAAI,aAAa,CAAC,aAAa,EAAE;YAC9D,MAAM,oBAAoB,GAAqB,EAAE,CAAC;YAElD,IAAI,aAAa,CAAC,OAAO,EAAE;gBACzB,oBAAoB,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;aACtD;YACD,IAAI,aAAa,CAAC,UAAU,EAAE;gBAC5B,oBAAoB,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;aAC5D;YAED,MAAM,aAAa,GACjB,MAAA,aAAa,CAAC,aAAa,mCA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QAAQ,CAAC;YACnB,oDAAoD;aACnD,IAAI,CAAC,GAAG,EAAE;QACX,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;CACF;AArJD,0BAqJC","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 { TextMapPropagator } from '@opentelemetry/api';\nimport { metrics } from '@opentelemetry/api-metrics';\nimport { ContextManager } from '@opentelemetry/api';\nimport { MeterProvider, MetricReader } from '@opentelemetry/sdk-metrics-base';\nimport {\n InstrumentationOption,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { awsEc2Detector } from '@opentelemetry/resource-detector-aws';\nimport { gcpDetector } from '@opentelemetry/resource-detector-gcp';\nimport {\n detectResources,\n envDetector,\n processDetector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\nimport { BatchSpanProcessor, SpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { NodeSDKConfiguration } from './types';\n\n/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */\nexport class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessor: SpanProcessor;\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\n private _instrumentations: InstrumentationOption[];\n private _metricReader?: MetricReader;\n\n private _resource: Resource;\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider;\n private _meterProvider?: MeterProvider;\n\n /**\n * Create a new NodeJS SDK instance\n */\n public constructor(configuration: Partial<NodeSDKConfiguration> = {}) {\n this._resource = configuration.resource ?? new Resource({});\n\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n\n if (configuration.spanProcessor || configuration.traceExporter) {\n const tracerProviderConfig: NodeTracerConfig = {};\n\n if (configuration.sampler) {\n tracerProviderConfig.sampler = configuration.sampler;\n }\n if (configuration.spanLimits) {\n tracerProviderConfig.spanLimits = configuration.spanLimits;\n }\n\n const spanProcessor =\n configuration.spanProcessor ??\n new BatchSpanProcessor(configuration.traceExporter!);\n\n this.configureTracerProvider(\n tracerProviderConfig,\n spanProcessor,\n configuration.contextManager,\n configuration.textMapPropagator\n );\n }\n\n if (configuration.metricReader) {\n this.configureMeterProvider(configuration.metricReader);\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(reader: MetricReader): void {\n this._metricReader = reader;\n }\n\n /** Detect resource attributes */\n public async detectResources(config?: ResourceDetectionConfig): Promise<void> {\n const internalConfig: ResourceDetectionConfig = {\n detectors: [awsEc2Detector, gcpDetector, envDetector, processDetector],\n ...config,\n };\n\n this.addResource(await detectResources(internalConfig));\n }\n\n /** Manually add a resource */\n public addResource(resource: Resource): void {\n this._resource = this._resource.merge(resource);\n }\n\n /**\n * Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API.\n */\n public async start(): Promise<void> {\n if (this._autoDetectResources) {\n await this.detectResources();\n }\n\n if (this._tracerProviderConfig) {\n const tracerProvider = new NodeTracerProvider({\n ...this._tracerProviderConfig.tracerConfig,\n resource: this._resource,\n });\n\n this._tracerProvider = tracerProvider;\n\n tracerProvider.addSpanProcessor(this._tracerProviderConfig.spanProcessor);\n tracerProvider.register({\n contextManager: this._tracerProviderConfig.contextManager,\n propagator: this._tracerProviderConfig.textMapPropagator,\n });\n }\n\n if (this._metricReader) {\n const meterProvider = new MeterProvider({\n resource: this._resource,\n });\n\n meterProvider.addMetricReader(this._metricReader);\n\n this._meterProvider = meterProvider;\n\n metrics.setGlobalMeterProvider(meterProvider);\n }\n\n registerInstrumentations({\n instrumentations: this._instrumentations,\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}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { SpanAttributes, TextMapPropagator, Sampler } from '@opentelemetry/api';
2
2
  import type { ContextManager } from '@opentelemetry/api';
3
3
  import { InstrumentationOption } from '@opentelemetry/instrumentation';
4
- import { MetricExporter, Processor } from '@opentelemetry/sdk-metrics-base';
4
+ import { MetricReader } from '@opentelemetry/sdk-metrics-base';
5
5
  import { Resource } from '@opentelemetry/resources';
6
6
  import { SpanExporter, SpanProcessor, SpanLimits } from '@opentelemetry/sdk-trace-base';
7
7
  export interface NodeSDKConfiguration {
@@ -9,9 +9,7 @@ export interface NodeSDKConfiguration {
9
9
  contextManager: ContextManager;
10
10
  defaultAttributes: SpanAttributes;
11
11
  textMapPropagator: TextMapPropagator;
12
- metricProcessor: Processor;
13
- metricExporter: MetricExporter;
14
- metricInterval: number;
12
+ metricReader: MetricReader;
15
13
  instrumentations: InstrumentationOption[];
16
14
  resource: Resource;
17
15
  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 { SpanAttributes, TextMapPropagator, Sampler } from '@opentelemetry/api';\nimport type { ContextManager } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { MetricExporter, Processor } from '@opentelemetry/sdk-metrics-base';\nimport { Resource } from '@opentelemetry/resources';\nimport {\n SpanExporter,\n SpanProcessor,\n SpanLimits,\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n defaultAttributes: SpanAttributes;\n textMapPropagator: TextMapPropagator;\n metricProcessor: Processor;\n metricExporter: MetricExporter;\n metricInterval: number;\n instrumentations: InstrumentationOption[];\n resource: Resource;\n sampler: Sampler;\n spanProcessor: SpanProcessor;\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\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 { SpanAttributes, TextMapPropagator, Sampler } from '@opentelemetry/api';\nimport type { ContextManager } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { MetricReader } from '@opentelemetry/sdk-metrics-base';\nimport { Resource } from '@opentelemetry/resources';\nimport {\n SpanExporter,\n SpanProcessor,\n SpanLimits,\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n defaultAttributes: SpanAttributes;\n textMapPropagator: TextMapPropagator;\n metricReader: MetricReader;\n instrumentations: InstrumentationOption[];\n resource: Resource;\n sampler: Sampler;\n spanProcessor: SpanProcessor;\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.26.0";
1
+ export declare const VERSION = "0.29.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.26.0';
20
+ exports.VERSION = '0.29.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.26.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.29.0';\n"]}
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "@opentelemetry/sdk-node",
3
- "version": "0.26.0",
3
+ "version": "0.29.0",
4
4
  "description": "OpenTelemetry SDK for Node.js",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
7
7
  "repository": "open-telemetry/opentelemetry-js",
8
8
  "scripts": {
9
+ "prepublishOnly": "npm run compile",
9
10
  "compile": "tsc --build",
10
11
  "clean": "tsc --build --clean",
11
12
  "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts",
12
- "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
13
+ "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
13
14
  "lint": "eslint . --ext .ts",
14
15
  "lint:fix": "eslint . --ext .ts --fix",
15
16
  "version": "node ../../../scripts/version-update.js",
16
17
  "watch": "tsc --build --watch",
17
- "precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies",
18
- "prewatch": "npm run precompile"
18
+ "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
19
+ "prewatch": "npm run precompile",
20
+ "peer-api-check": "node ../../../scripts/peer-api-check.js"
19
21
  },
20
22
  "keywords": [
21
23
  "opentelemetry",
@@ -29,7 +31,7 @@
29
31
  "author": "OpenTelemetry Authors",
30
32
  "license": "Apache-2.0",
31
33
  "engines": {
32
- "node": ">=8.0.0"
34
+ "node": ">=8.12.0"
33
35
  },
34
36
  "files": [
35
37
  "build/src/**/*.js",
@@ -42,37 +44,37 @@
42
44
  "access": "public"
43
45
  },
44
46
  "dependencies": {
45
- "@opentelemetry/api-metrics": "0.26.0",
46
- "@opentelemetry/core": "1.0.0",
47
- "@opentelemetry/instrumentation": "0.26.0",
48
- "@opentelemetry/resource-detector-aws": "0.24.0",
49
- "@opentelemetry/resource-detector-gcp": "0.24.0",
50
- "@opentelemetry/resources": "1.0.0",
51
- "@opentelemetry/sdk-metrics-base": "0.26.0",
52
- "@opentelemetry/sdk-trace-base": "1.0.0",
53
- "@opentelemetry/sdk-trace-node": "1.0.0"
47
+ "@opentelemetry/api-metrics": "0.29.0",
48
+ "@opentelemetry/core": "1.3.0",
49
+ "@opentelemetry/instrumentation": "0.29.0",
50
+ "@opentelemetry/resource-detector-aws": "~1.0.0",
51
+ "@opentelemetry/resource-detector-gcp": "~0.26.0",
52
+ "@opentelemetry/resources": "1.3.0",
53
+ "@opentelemetry/sdk-metrics-base": "0.29.0",
54
+ "@opentelemetry/sdk-trace-base": "1.3.0",
55
+ "@opentelemetry/sdk-trace-node": "1.3.0"
54
56
  },
55
57
  "peerDependencies": {
56
- "@opentelemetry/api": "^1.0.2"
58
+ "@opentelemetry/api": ">=1.0.0 <1.2.0"
57
59
  },
58
60
  "devDependencies": {
59
- "@opentelemetry/api": "^1.0.2",
60
- "@opentelemetry/context-async-hooks": "1.0.0",
61
+ "@opentelemetry/api": ">=1.0.0 <1.2.0",
62
+ "@opentelemetry/context-async-hooks": "1.3.0",
61
63
  "@types/mocha": "8.2.3",
62
- "@types/node": "14.17.11",
63
- "@types/semver": "7.3.8",
64
- "@types/sinon": "10.0.2",
64
+ "@types/node": "14.17.33",
65
+ "@types/semver": "7.3.9",
66
+ "@types/sinon": "10.0.6",
65
67
  "codecov": "3.8.3",
66
68
  "gcp-metadata": "^4.1.4",
67
69
  "istanbul-instrumenter-loader": "3.0.1",
68
70
  "mocha": "7.2.0",
69
- "nock": "12.0.3",
71
+ "nock": "13.0.11",
70
72
  "nyc": "15.1.0",
71
73
  "semver": "7.3.5",
72
- "sinon": "11.1.2",
74
+ "sinon": "12.0.1",
73
75
  "ts-loader": "8.3.0",
74
- "ts-mocha": "8.0.0",
75
- "typescript": "4.3.5"
76
+ "ts-mocha": "9.0.2",
77
+ "typescript": "4.4.4"
76
78
  },
77
- "gitHead": "0f5a5bc906a2166c30a4344e460b7206c0b20bac"
79
+ "gitHead": "eda0b092db484855ded8b4837ba7fc19a377c5a7"
78
80
  }