@opentelemetry/sdk-node 0.29.0 → 0.30.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
@@ -128,6 +128,10 @@ Configure a trace exporter. If an exporter OR span processor is not configured,
128
128
 
129
129
  Configure tracing parameters. These are the same trace parameters used to [configure a tracer](../../../packages/opentelemetry-sdk-trace-base/src/types.ts#L71).
130
130
 
131
+ ### serviceName
132
+
133
+ Configure the [service name](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service).
134
+
131
135
  ## Useful links
132
136
 
133
137
  - For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
@@ -1,9 +1,8 @@
1
- import { TextMapPropagator } from '@opentelemetry/api';
2
- import { ContextManager } from '@opentelemetry/api';
3
- import { MetricReader } from '@opentelemetry/sdk-metrics-base';
4
- import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
1
+ import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
5
2
  import { Resource, ResourceDetectionConfig } from '@opentelemetry/resources';
3
+ import { MetricReader } from '@opentelemetry/sdk-metrics-base';
6
4
  import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
5
+ import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
7
6
  import { NodeSDKConfiguration } from './types';
8
7
  /** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */
9
8
  export declare class NodeSDK {
@@ -14,6 +13,7 @@ export declare class NodeSDK {
14
13
  private _autoDetectResources;
15
14
  private _tracerProvider?;
16
15
  private _meterProvider?;
16
+ private _serviceName?;
17
17
  /**
18
18
  * Create a new NodeJS SDK instance
19
19
  */
package/build/src/sdk.js CHANGED
@@ -17,13 +17,12 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.NodeSDK = void 0;
19
19
  const api_metrics_1 = require("@opentelemetry/api-metrics");
20
- const sdk_metrics_base_1 = require("@opentelemetry/sdk-metrics-base");
21
20
  const instrumentation_1 = require("@opentelemetry/instrumentation");
22
- const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
23
- const resource_detector_aws_1 = require("@opentelemetry/resource-detector-aws");
24
- const resource_detector_gcp_1 = require("@opentelemetry/resource-detector-gcp");
25
21
  const resources_1 = require("@opentelemetry/resources");
22
+ const sdk_metrics_base_1 = require("@opentelemetry/sdk-metrics-base");
26
23
  const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
24
+ const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
25
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
27
26
  /** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */
28
27
  class NodeSDK {
29
28
  /**
@@ -32,6 +31,7 @@ class NodeSDK {
32
31
  constructor(configuration = {}) {
33
32
  var _a, _b, _c;
34
33
  this._resource = (_a = configuration.resource) !== null && _a !== void 0 ? _a : new resources_1.Resource({});
34
+ this._serviceName = configuration.serviceName;
35
35
  this._autoDetectResources = (_b = configuration.autoDetectResources) !== null && _b !== void 0 ? _b : true;
36
36
  if (configuration.spanProcessor || configuration.traceExporter) {
37
37
  const tracerProviderConfig = {};
@@ -68,7 +68,7 @@ class NodeSDK {
68
68
  }
69
69
  /** Detect resource attributes */
70
70
  async detectResources(config) {
71
- const internalConfig = Object.assign({ detectors: [resource_detector_aws_1.awsEc2Detector, resource_detector_gcp_1.gcpDetector, resources_1.envDetector, resources_1.processDetector] }, config);
71
+ const internalConfig = Object.assign({ detectors: [resources_1.envDetector, resources_1.processDetector] }, config);
72
72
  this.addResource(await (0, resources_1.detectResources)(internalConfig));
73
73
  }
74
74
  /** Manually add a resource */
@@ -82,6 +82,9 @@ class NodeSDK {
82
82
  if (this._autoDetectResources) {
83
83
  await this.detectResources();
84
84
  }
85
+ this._resource = this._serviceName === undefined
86
+ ? this._resource
87
+ : this._resource.merge(new resources_1.Resource({ [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: this._serviceName }));
85
88
  if (this._tracerProviderConfig) {
86
89
  const tracerProvider = new sdk_trace_node_1.NodeTracerProvider(Object.assign(Object.assign({}, this._tracerProviderConfig.tracerConfig), { resource: this._resource }));
87
90
  this._tracerProvider = tracerProvider;
@@ -1 +1 @@
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,mCAC3B,IAAI,mCAAkB,CAAC,aAAa,CAAC,aAAc,CAAC,CAAC;YAEvD,IAAI,CAAC,uBAAuB,CAC1B,oBAAoB,EACpB,aAAa,EACb,aAAa,CAAC,cAAc,EAC5B,aAAa,CAAC,iBAAiB,CAChC,CAAC;SACH;QAED,IAAI,aAAa,CAAC,YAAY,EAAE;YAC9B,IAAI,CAAC,sBAAsB,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AAe,GAAG,cAAc,CAAC;YAEtC,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,aAAa,EAAE;YACtB,MAAM,aAAa,GAAG,IAAI,gCAAa,CAAC;gBACtC,QAAQ,EAAE,IAAI,CAAC,SAAS;aACzB,CAAC,CAAC;YAEH,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAElD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;YAEpC,qBAAO,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;SAC/C;QAED,IAAA,0CAAwB,EAAC;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;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
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,4DAAqD;AACrD,oEAGwC;AACxC,wDAMkC;AAClC,sEAA8E;AAC9E,kEAGuC;AACvC,kEAAqF;AACrF,8EAAiF;AAGjF,uGAAuG;AACvG,MAAa,OAAO;IAkBlB;;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,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC;QAE9C,IAAI,CAAC,oBAAoB,GAAG,MAAA,aAAa,CAAC,mBAAmB,mCAAI,IAAI,CAAC;QAEtE,IAAI,aAAa,CAAC,aAAa,IAAI,aAAa,CAAC,aAAa,EAAE;YAC9D,MAAM,oBAAoB,GAAqB,EAAE,CAAC;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,mCAC3B,IAAI,mCAAkB,CAAC,aAAa,CAAC,aAAc,CAAC,CAAC;YAEvD,IA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;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;QACX,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;CACF;AAhKD,0BAgKC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ContextManager, TextMapPropagator } from '@opentelemetry/api';\nimport { metrics } from '@opentelemetry/api-metrics';\nimport {\n InstrumentationOption,\n registerInstrumentations\n} from '@opentelemetry/instrumentation';\nimport {\n detectResources,\n envDetector,\n processDetector,\n Resource,\n ResourceDetectionConfig\n} from '@opentelemetry/resources';\nimport { MeterProvider, MetricReader } from '@opentelemetry/sdk-metrics-base';\nimport {\n BatchSpanProcessor,\n SpanProcessor\n} from '@opentelemetry/sdk-trace-base';\nimport { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';\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 private _serviceName?: string;\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._serviceName = configuration.serviceName;\n\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n\n if (configuration.spanProcessor || configuration.traceExporter) {\n const tracerProviderConfig: NodeTracerConfig = {};\n\n if (configuration.sampler) {\n tracerProviderConfig.sampler = configuration.sampler;\n }\n if (configuration.spanLimits) {\n tracerProviderConfig.spanLimits = configuration.spanLimits;\n }\n\n const spanProcessor =\n configuration.spanProcessor ??\n new BatchSpanProcessor(configuration.traceExporter!);\n\n this.configureTracerProvider(\n tracerProviderConfig,\n spanProcessor,\n configuration.contextManager,\n configuration.textMapPropagator\n );\n }\n\n if (configuration.metricReader) {\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(\n config?: ResourceDetectionConfig\n ): Promise<void> {\n const internalConfig: ResourceDetectionConfig = {\n detectors: [ 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 this._resource = this._serviceName === undefined\n ? this._resource\n : this._resource.merge(new Resource(\n {[SemanticResourceAttributes.SERVICE_NAME]: this._serviceName}\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,9 +1,9 @@
1
- import { SpanAttributes, TextMapPropagator, Sampler } from '@opentelemetry/api';
2
- import type { ContextManager } from '@opentelemetry/api';
1
+ import type { ContextManager, SpanAttributes } from '@opentelemetry/api';
2
+ import { Sampler, TextMapPropagator } from '@opentelemetry/api';
3
3
  import { InstrumentationOption } from '@opentelemetry/instrumentation';
4
- import { MetricReader } from '@opentelemetry/sdk-metrics-base';
5
4
  import { Resource } from '@opentelemetry/resources';
6
- import { SpanExporter, SpanProcessor, SpanLimits } from '@opentelemetry/sdk-trace-base';
5
+ import { MetricReader } from '@opentelemetry/sdk-metrics-base';
6
+ import { SpanExporter, SpanLimits, SpanProcessor } from '@opentelemetry/sdk-trace-base';
7
7
  export interface NodeSDKConfiguration {
8
8
  autoDetectResources: boolean;
9
9
  contextManager: ContextManager;
@@ -13,6 +13,7 @@ export interface NodeSDKConfiguration {
13
13
  instrumentations: InstrumentationOption[];
14
14
  resource: Resource;
15
15
  sampler: Sampler;
16
+ serviceName?: string;
16
17
  spanProcessor: SpanProcessor;
17
18
  traceExporter: SpanExporter;
18
19
  spanLimits: SpanLimits;
@@ -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 { 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
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ContextManager, SpanAttributes } from '@opentelemetry/api';\nimport { Sampler, TextMapPropagator } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { Resource } from '@opentelemetry/resources';\nimport { MetricReader } from '@opentelemetry/sdk-metrics-base';\nimport {\n SpanExporter,\n SpanLimits,\n SpanProcessor\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n defaultAttributes: SpanAttributes;\n textMapPropagator: TextMapPropagator;\n metricReader: MetricReader;\n instrumentations: InstrumentationOption[];\n resource: Resource;\n sampler: Sampler;\n serviceName?: string;\n spanProcessor: SpanProcessor;\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.29.0";
1
+ export declare const VERSION = "0.30.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.29.0';
20
+ exports.VERSION = '0.30.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.29.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.30.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/sdk-node",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "OpenTelemetry SDK for Node.js",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "author": "OpenTelemetry Authors",
32
32
  "license": "Apache-2.0",
33
33
  "engines": {
34
- "node": ">=8.12.0"
34
+ "node": ">=14"
35
35
  },
36
36
  "files": [
37
37
  "build/src/**/*.js",
@@ -44,31 +44,28 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
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"
47
+ "@opentelemetry/api-metrics": "0.30.0",
48
+ "@opentelemetry/core": "1.4.0",
49
+ "@opentelemetry/instrumentation": "0.30.0",
50
+ "@opentelemetry/resources": "1.4.0",
51
+ "@opentelemetry/sdk-metrics-base": "0.30.0",
52
+ "@opentelemetry/sdk-trace-base": "1.4.0",
53
+ "@opentelemetry/sdk-trace-node": "1.4.0"
56
54
  },
57
55
  "peerDependencies": {
58
56
  "@opentelemetry/api": ">=1.0.0 <1.2.0"
59
57
  },
60
58
  "devDependencies": {
61
59
  "@opentelemetry/api": ">=1.0.0 <1.2.0",
62
- "@opentelemetry/context-async-hooks": "1.3.0",
60
+ "@opentelemetry/context-async-hooks": "1.4.0",
61
+ "@opentelemetry/semantic-conventions": "1.4.0",
63
62
  "@types/mocha": "8.2.3",
64
63
  "@types/node": "14.17.33",
65
64
  "@types/semver": "7.3.9",
66
65
  "@types/sinon": "10.0.6",
67
66
  "codecov": "3.8.3",
68
- "gcp-metadata": "^4.1.4",
69
67
  "istanbul-instrumenter-loader": "3.0.1",
70
68
  "mocha": "7.2.0",
71
- "nock": "13.0.11",
72
69
  "nyc": "15.1.0",
73
70
  "semver": "7.3.5",
74
71
  "sinon": "12.0.1",
@@ -76,5 +73,5 @@
76
73
  "ts-mocha": "9.0.2",
77
74
  "typescript": "4.4.4"
78
75
  },
79
- "gitHead": "eda0b092db484855ded8b4837ba7fc19a377c5a7"
76
+ "gitHead": "e39ab883b18636238ef0fd741df4ce5ed53e8d04"
80
77
  }