@opentelemetry/sdk-node 0.32.0 → 0.34.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 +44 -17
- package/build/src/TracerProviderWithEnvExporter.d.ts +16 -0
- package/build/src/TracerProviderWithEnvExporter.js +114 -0
- package/build/src/TracerProviderWithEnvExporter.js.map +1 -0
- package/build/src/sdk.d.ts +4 -6
- package/build/src/sdk.js +20 -15
- package/build/src/sdk.js.map +1 -1
- package/build/src/types.d.ts +2 -1
- package/build/src/types.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +19 -14
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
[![NPM Published Version][npm-img]][npm-url]
|
|
4
4
|
[![Apache License][license-image]][license-image]
|
|
5
5
|
|
|
6
|
+
**Note: This is an experimental package under active development. New releases may include breaking changes.**
|
|
7
|
+
|
|
6
8
|
This package provides the full OpenTelemetry SDK for Node.js including tracing and metrics.
|
|
7
9
|
|
|
8
10
|
## Quick Start
|
|
@@ -18,7 +20,7 @@ $ npm install @opentelemetry/sdk-node
|
|
|
18
20
|
$ # Install exporters and plugins
|
|
19
21
|
$ npm install \
|
|
20
22
|
@opentelemetry/exporter-jaeger \ # add tracing exporters as needed
|
|
21
|
-
@opentelemetry/exporter-prometheus # add metrics exporters as needed
|
|
23
|
+
@opentelemetry/exporter-prometheus \ # add metrics exporters as needed
|
|
22
24
|
@opentelemetry/instrumentation-http # add instrumentations as needed
|
|
23
25
|
|
|
24
26
|
$ # or install all officially supported core and contrib plugins
|
|
@@ -26,7 +28,7 @@ $ npm install @opentelemetry/auto-instrumentations-node
|
|
|
26
28
|
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
> Note: this example is for Node.js. See [examples/
|
|
31
|
+
> Note: this example is for Node.js. See [examples/opentelemetry-web](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/opentelemetry-web) for a browser example.
|
|
30
32
|
|
|
31
33
|
### Initialize the SDK
|
|
32
34
|
|
|
@@ -50,7 +52,7 @@ const sdk = new opentelemetry.NodeSDK({
|
|
|
50
52
|
// Optional - if omitted, the tracing SDK will not be initialized
|
|
51
53
|
traceExporter: jaegerExporter,
|
|
52
54
|
// Optional - If omitted, the metrics SDK will not be initialized
|
|
53
|
-
|
|
55
|
+
metricReader: prometheusExporter,
|
|
54
56
|
// Optional - you can use the metapackage or load each instrumentation individually
|
|
55
57
|
instrumentations: [getNodeAutoInstrumentations()],
|
|
56
58
|
// See the Configuration section below for additional configuration options
|
|
@@ -92,17 +94,17 @@ Use a custom context manager. Default: [AsyncHooksContextManager](../../../packa
|
|
|
92
94
|
|
|
93
95
|
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)
|
|
94
96
|
|
|
95
|
-
###
|
|
96
|
-
|
|
97
|
-
Use a custom processor for metrics. Default: UngroupedProcessor
|
|
98
|
-
|
|
99
|
-
### metricExporter
|
|
97
|
+
### metricReader
|
|
100
98
|
|
|
101
|
-
|
|
99
|
+
Add a [MetricReader](../opentelemetry-sdk-metrics/src/export/MetricReader.ts)
|
|
100
|
+
that will be passed to the `MeterProvider`. If `metricReader` is not configured,
|
|
101
|
+
the metrics SDK will not be initialized and registered.
|
|
102
102
|
|
|
103
|
-
###
|
|
103
|
+
### views
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
A list of views to be passed to the `MeterProvider`.
|
|
106
|
+
Accepts an array of [View](../opentelemetry-sdk-metrics/src/view/View.ts)-instances.
|
|
107
|
+
This parameter can be used to configure explicit bucket sizes of histogram metrics.
|
|
106
108
|
|
|
107
109
|
### instrumentations
|
|
108
110
|
|
|
@@ -114,28 +116,53 @@ or configure each instrumentation individually.
|
|
|
114
116
|
|
|
115
117
|
Configure a resource. Resources may also be detected by using the `autoDetectResources` method of the SDK.
|
|
116
118
|
|
|
119
|
+
### resourceDetectors
|
|
120
|
+
|
|
121
|
+
Configure resource detectors. By default, the resource detectors are [envDetector, processDetector].
|
|
122
|
+
NOTE: In order to enable the detection, the parameter `autoDetectResources` has to be `true`.
|
|
123
|
+
|
|
117
124
|
### sampler
|
|
118
125
|
|
|
119
|
-
Configure a custom sampler. By default all traces will be sampled.
|
|
126
|
+
Configure a custom sampler. By default, all traces will be sampled.
|
|
120
127
|
|
|
121
128
|
### spanProcessor
|
|
122
129
|
|
|
123
130
|
### traceExporter
|
|
124
131
|
|
|
125
|
-
Configure a trace exporter. If an exporter
|
|
132
|
+
Configure a trace exporter. If an exporter is configured, it will be used with a [BatchSpanProcessor](../../../packages/opentelemetry-sdk-trace-base/src/platform/node/export/BatchSpanProcessor.ts). If an exporter OR span processor is not configured programatically, this package will auto setup the default `otlp` exporter with `http/protobuf` protocol with a `BatchSpanProcessor`.
|
|
126
133
|
|
|
127
134
|
### spanLimits
|
|
128
135
|
|
|
129
136
|
Configure tracing parameters. These are the same trace parameters used to [configure a tracer](../../../packages/opentelemetry-sdk-trace-base/src/types.ts#L71).
|
|
130
137
|
|
|
131
|
-
### views
|
|
132
|
-
|
|
133
|
-
Configure views of your instruments and accepts an array of [View](../opentelemetry-sdk-metrics-base/src/view/View.ts)-instances. The parameter can be used to configure the explicit bucket sizes of histogram metrics.
|
|
134
|
-
|
|
135
138
|
### serviceName
|
|
136
139
|
|
|
137
140
|
Configure the [service name](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service).
|
|
138
141
|
|
|
142
|
+
## Configure Trace Exporter from Environment
|
|
143
|
+
|
|
144
|
+
This is an alternative to programmatically configuring an exporter or span processor. This package will auto setup the default `otlp` exporter with `http/protobuf` protocol if `traceExporter` or `spanProcessor` hasn't been passed into the `NodeSDK` constructor.
|
|
145
|
+
|
|
146
|
+
### Exporters
|
|
147
|
+
|
|
148
|
+
| Environment variable | Description |
|
|
149
|
+
|----------------------|-------------|
|
|
150
|
+
| OTEL_TRACES_EXPORTER | List of exporters to be used for tracing, separated by commas. Options include `otlp`, `jaeger`, `zipkin`, and `none`. Default is `otlp`. `none` means no autoconfigured exporter.
|
|
151
|
+
|
|
152
|
+
### OTLP Exporter
|
|
153
|
+
|
|
154
|
+
| Environment variable | Description |
|
|
155
|
+
|----------------------|-------------|
|
|
156
|
+
| OTEL_EXPORTER_OTLP_PROTOCOL | The transport protocol to use on OTLP trace, metric, and log requests. Options include `grpc`, `http/protobuf`, and `http/json`. Default is `http/protobuf`. |
|
|
157
|
+
| OTEL_EXPORTER_OTLP_TRACES_PROTOCOL | The transport protocol to use on OTLP trace requests. Options include `grpc`, `http/protobuf`, and `http/json`. Default is `http/protobuf`. |
|
|
158
|
+
| OTEL_EXPORTER_OTLP_METRICS_PROTOCOL | The transport protocol to use on OTLP metric requests. Options include `grpc`, `http/protobuf`, and `http/json`. Default is `http/protobuf`. |
|
|
159
|
+
|
|
160
|
+
Additionally, you can specify other applicable environment variables that apply to each exporter such as the following:
|
|
161
|
+
|
|
162
|
+
- [OTLP exporter environment configuration](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options)
|
|
163
|
+
- [Zipkin exporter environment configuration](https://github.com/open-telemetry/opentelemetry-specification/blob/6ce62202e5407518e19c56c445c13682ef51a51d/specification/sdk-environment-variables.md#zipkin-exporter)
|
|
164
|
+
- [Jaeger exporter environment configuration](https://github.com/open-telemetry/opentelemetry-specification/blob/6ce62202e5407518e19c56c445c13682ef51a51d/specification/sdk-environment-variables.md#jaeger-exporter)
|
|
165
|
+
|
|
139
166
|
## Useful links
|
|
140
167
|
|
|
141
168
|
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SpanExporter, SDKRegistrationConfig, SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
3
|
+
export declare class TracerProviderWithEnvExporters extends NodeTracerProvider {
|
|
4
|
+
private _configuredExporters;
|
|
5
|
+
private _spanProcessors;
|
|
6
|
+
private _hasSpanProcessors;
|
|
7
|
+
static configureOtlp(): SpanExporter;
|
|
8
|
+
static getOtlpProtocol(): string;
|
|
9
|
+
protected static _registeredExporters: Map<string, () => SpanExporter>;
|
|
10
|
+
constructor(config?: NodeTracerConfig);
|
|
11
|
+
addSpanProcessor(spanProcessor: SpanProcessor): void;
|
|
12
|
+
register(config?: SDKRegistrationConfig): void;
|
|
13
|
+
private configureSpanProcessors;
|
|
14
|
+
private filterBlanksAndNulls;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=TracerProviderWithEnvExporter.d.ts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var _a;
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.TracerProviderWithEnvExporters = void 0;
|
|
20
|
+
const api_1 = require("@opentelemetry/api");
|
|
21
|
+
const core_1 = require("@opentelemetry/core");
|
|
22
|
+
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
23
|
+
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
24
|
+
const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-proto");
|
|
25
|
+
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
26
|
+
const exporter_trace_otlp_grpc_1 = require("@opentelemetry/exporter-trace-otlp-grpc");
|
|
27
|
+
const exporter_zipkin_1 = require("@opentelemetry/exporter-zipkin");
|
|
28
|
+
const exporter_jaeger_1 = require("@opentelemetry/exporter-jaeger");
|
|
29
|
+
class TracerProviderWithEnvExporters extends sdk_trace_node_1.NodeTracerProvider {
|
|
30
|
+
constructor(config = {}) {
|
|
31
|
+
super(config);
|
|
32
|
+
this._configuredExporters = [];
|
|
33
|
+
this._hasSpanProcessors = false;
|
|
34
|
+
let traceExportersList = this.filterBlanksAndNulls(Array.from(new Set((0, core_1.getEnv)().OTEL_TRACES_EXPORTER.split(','))));
|
|
35
|
+
if (traceExportersList.length === 0 || traceExportersList[0] === 'none') {
|
|
36
|
+
api_1.diag.warn('OTEL_TRACES_EXPORTER contains "none" or is empty. SDK will not be initialized.');
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (traceExportersList.length > 1 && traceExportersList.includes('none')) {
|
|
40
|
+
api_1.diag.warn('OTEL_TRACES_EXPORTER contains "none" along with other exporters. Using default otlp exporter.');
|
|
41
|
+
traceExportersList = ['otlp'];
|
|
42
|
+
}
|
|
43
|
+
traceExportersList.forEach(exporterName => {
|
|
44
|
+
const exporter = this._getSpanExporter(exporterName);
|
|
45
|
+
if (exporter) {
|
|
46
|
+
this._configuredExporters.push(exporter);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
api_1.diag.warn(`Unrecognized OTEL_TRACES_EXPORTER value: ${exporterName}.`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (this._configuredExporters.length > 0) {
|
|
53
|
+
this._spanProcessors = this.configureSpanProcessors(this._configuredExporters);
|
|
54
|
+
this._spanProcessors.forEach(processor => {
|
|
55
|
+
this.addSpanProcessor(processor);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
api_1.diag.warn('Unable to set up trace exporter(s) due to invalid exporter and/or protocol values.');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
static configureOtlp() {
|
|
64
|
+
const protocol = this.getOtlpProtocol();
|
|
65
|
+
switch (protocol) {
|
|
66
|
+
case 'grpc':
|
|
67
|
+
return new exporter_trace_otlp_grpc_1.OTLPTraceExporter;
|
|
68
|
+
case 'http/json':
|
|
69
|
+
return new exporter_trace_otlp_http_1.OTLPTraceExporter;
|
|
70
|
+
case 'http/protobuf':
|
|
71
|
+
return new exporter_trace_otlp_proto_1.OTLPTraceExporter;
|
|
72
|
+
default:
|
|
73
|
+
api_1.diag.warn(`Unsupported OTLP traces protocol: ${protocol}. Using http/protobuf.`);
|
|
74
|
+
return new exporter_trace_otlp_proto_1.OTLPTraceExporter;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
static getOtlpProtocol() {
|
|
78
|
+
var _b, _c, _d;
|
|
79
|
+
const parsedEnvValues = (0, core_1.getEnvWithoutDefaults)();
|
|
80
|
+
return (_d = (_c = (_b = parsedEnvValues.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL) !== null && _b !== void 0 ? _b : parsedEnvValues.OTEL_EXPORTER_OTLP_PROTOCOL) !== null && _c !== void 0 ? _c : (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_TRACES_PROTOCOL) !== null && _d !== void 0 ? _d : (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_PROTOCOL;
|
|
81
|
+
}
|
|
82
|
+
addSpanProcessor(spanProcessor) {
|
|
83
|
+
super.addSpanProcessor(spanProcessor);
|
|
84
|
+
this._hasSpanProcessors = true;
|
|
85
|
+
}
|
|
86
|
+
register(config) {
|
|
87
|
+
if (this._hasSpanProcessors) {
|
|
88
|
+
super.register(config);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
configureSpanProcessors(exporters) {
|
|
92
|
+
return exporters.map(exporter => {
|
|
93
|
+
if (exporter instanceof sdk_trace_base_1.ConsoleSpanExporter) {
|
|
94
|
+
return new sdk_trace_base_1.SimpleSpanProcessor(exporter);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return new sdk_trace_base_1.BatchSpanProcessor(exporter);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
filterBlanksAndNulls(list) {
|
|
102
|
+
return list.map(item => item.trim())
|
|
103
|
+
.filter(s => s !== 'null' && s !== '');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.TracerProviderWithEnvExporters = TracerProviderWithEnvExporters;
|
|
107
|
+
_a = TracerProviderWithEnvExporters;
|
|
108
|
+
TracerProviderWithEnvExporters._registeredExporters = new Map([
|
|
109
|
+
['otlp', () => _a.configureOtlp()],
|
|
110
|
+
['zipkin', () => new exporter_zipkin_1.ZipkinExporter],
|
|
111
|
+
['jaeger', () => new exporter_jaeger_1.JaegerExporter],
|
|
112
|
+
['console', () => new sdk_trace_base_1.ConsoleSpanExporter]
|
|
113
|
+
]);
|
|
114
|
+
//# sourceMappingURL=TracerProviderWithEnvExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TracerProviderWithEnvExporter.js","sourceRoot":"","sources":["../../src/TracerProviderWithEnvExporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,4CAA0C;AAC1C,8CAAoE;AACpE,kEAAiK;AACjK,kEAAqF;AACrF,wFAAuG;AACvG,sFAAoG;AACpG,sFAAoG;AACpG,oEAAgE;AAChE,oEAAgE;AAEhE,MAAa,8BAA+B,SAAQ,mCAAkB;IAwCpE,YAAmB,SAA2B,EAAE;QAC9C,KAAK,CAAC,MAAM,CAAC,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AAC;aACzC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,oBAAoB,CAAC,IAAc;QACzC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aACjC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC;;AAhGH,wEAiGC;;AAnE2B,mDAAoB,GAAG,IAAI,GAAG,CAGlD;IACA,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAI,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,gCAAc,CAAC;IACpC,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,gCAAc,CAAC;IACpC,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,oCAAmB,CAAC;CAC3C,CAAE,CAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, getEnvWithoutDefaults } from '@opentelemetry/core';\nimport { ConsoleSpanExporter, SpanExporter, BatchSpanProcessor, SimpleSpanProcessor, SDKRegistrationConfig, SpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';\nimport { OTLPTraceExporter as OTLPHttpTraceExporter} from '@opentelemetry/exporter-trace-otlp-http';\nimport { OTLPTraceExporter as OTLPGrpcTraceExporter} from '@opentelemetry/exporter-trace-otlp-grpc';\nimport { ZipkinExporter } from '@opentelemetry/exporter-zipkin';\nimport { JaegerExporter } from '@opentelemetry/exporter-jaeger';\n\nexport class TracerProviderWithEnvExporters extends NodeTracerProvider {\n private _configuredExporters: SpanExporter[] = [];\n private _spanProcessors: SpanProcessor[] | undefined;\n private _hasSpanProcessors: boolean = false;\n\n static configureOtlp(): SpanExporter {\n const protocol = this.getOtlpProtocol();\n\n switch (protocol) {\n case 'grpc':\n return new OTLPGrpcTraceExporter;\n case 'http/json':\n return new OTLPHttpTraceExporter;\n case 'http/protobuf':\n return new OTLPProtoTraceExporter;\n default:\n diag.warn(`Unsupported OTLP traces protocol: ${protocol}. Using http/protobuf.`);\n return new OTLPProtoTraceExporter;\n }\n }\n\n static getOtlpProtocol(): string {\n const parsedEnvValues = getEnvWithoutDefaults();\n\n return parsedEnvValues.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL ??\n parsedEnvValues.OTEL_EXPORTER_OTLP_PROTOCOL ??\n getEnv().OTEL_EXPORTER_OTLP_TRACES_PROTOCOL ??\n getEnv().OTEL_EXPORTER_OTLP_PROTOCOL;\n }\n\n protected static override _registeredExporters = new Map<\n string,\n () => SpanExporter\n >([\n ['otlp', () => this.configureOtlp()],\n ['zipkin', () => new ZipkinExporter],\n ['jaeger', () => new JaegerExporter],\n ['console', () => new ConsoleSpanExporter]\n ]);\n\n public constructor(config: NodeTracerConfig = {}) {\n super(config);\n let traceExportersList = this.filterBlanksAndNulls(Array.from(new Set(getEnv().OTEL_TRACES_EXPORTER.split(','))));\n\n if (traceExportersList.length === 0 || traceExportersList[0] === 'none') {\n diag.warn('OTEL_TRACES_EXPORTER contains \"none\" or is empty. SDK will not be initialized.');\n } else {\n if (traceExportersList.length > 1 && traceExportersList.includes('none')) {\n diag.warn('OTEL_TRACES_EXPORTER contains \"none\" along with other exporters. Using default otlp exporter.');\n traceExportersList = ['otlp'];\n }\n\n traceExportersList.forEach(exporterName => {\n const exporter = this._getSpanExporter(exporterName);\n if (exporter) {\n this._configuredExporters.push(exporter);\n } else {\n diag.warn(`Unrecognized OTEL_TRACES_EXPORTER value: ${exporterName}.`);\n }\n });\n\n if (this._configuredExporters.length > 0) {\n this._spanProcessors = this.configureSpanProcessors(this._configuredExporters);\n this._spanProcessors.forEach(processor => {\n this.addSpanProcessor(processor);\n });\n } else {\n diag.warn('Unable to set up trace exporter(s) due to invalid exporter and/or protocol values.');\n }\n }\n }\n\n override addSpanProcessor(spanProcessor: SpanProcessor) {\n super.addSpanProcessor(spanProcessor);\n this._hasSpanProcessors = true;\n }\n\n override register(config?: SDKRegistrationConfig) {\n if (this._hasSpanProcessors) {\n super.register(config);\n }\n }\n\n private configureSpanProcessors(exporters: SpanExporter[]): (BatchSpanProcessor | SimpleSpanProcessor)[] {\n return exporters.map(exporter => {\n if (exporter instanceof ConsoleSpanExporter) {\n return new SimpleSpanProcessor(exporter);\n } else {\n return new BatchSpanProcessor(exporter);\n }\n });\n }\n\n private filterBlanksAndNulls(list: string[]): string[] {\n return list.map(item => item.trim())\n .filter(s => s !== 'null' && s !== '');\n }\n}\n"]}
|
package/build/src/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
2
|
-
import { Resource
|
|
2
|
+
import { Resource } from '@opentelemetry/resources';
|
|
3
3
|
import { MetricReader, View } from '@opentelemetry/sdk-metrics';
|
|
4
4
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
5
5
|
import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
|
|
@@ -11,10 +11,7 @@ export declare type MeterProviderConfig = {
|
|
|
11
11
|
*/
|
|
12
12
|
reader?: MetricReader;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* Note: This is only getting used when NodeSDK is responsible for
|
|
17
|
-
* instantiated an instance of MeterProvider
|
|
14
|
+
* List of {@link View}s that should be passed to the MeterProvider
|
|
18
15
|
*/
|
|
19
16
|
views?: View[];
|
|
20
17
|
};
|
|
@@ -23,6 +20,7 @@ export declare class NodeSDK {
|
|
|
23
20
|
private _meterProviderConfig?;
|
|
24
21
|
private _instrumentations;
|
|
25
22
|
private _resource;
|
|
23
|
+
private _resourceDetectors;
|
|
26
24
|
private _autoDetectResources;
|
|
27
25
|
private _tracerProvider?;
|
|
28
26
|
private _meterProvider?;
|
|
@@ -36,7 +34,7 @@ export declare class NodeSDK {
|
|
|
36
34
|
/** Set configurations needed to register a MeterProvider */
|
|
37
35
|
configureMeterProvider(config: MeterProviderConfig): void;
|
|
38
36
|
/** Detect resource attributes */
|
|
39
|
-
detectResources(
|
|
37
|
+
detectResources(): Promise<void>;
|
|
40
38
|
/** Manually add a resource */
|
|
41
39
|
addResource(resource: Resource): void;
|
|
42
40
|
/**
|
package/build/src/sdk.js
CHANGED
|
@@ -16,22 +16,24 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.NodeSDK = void 0;
|
|
19
|
-
const
|
|
19
|
+
const api_1 = require("@opentelemetry/api");
|
|
20
20
|
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
21
21
|
const resources_1 = require("@opentelemetry/resources");
|
|
22
22
|
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
|
|
23
23
|
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
24
24
|
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
25
25
|
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
26
|
+
const TracerProviderWithEnvExporter_1 = require("./TracerProviderWithEnvExporter");
|
|
26
27
|
class NodeSDK {
|
|
27
28
|
/**
|
|
28
29
|
* Create a new NodeJS SDK instance
|
|
29
30
|
*/
|
|
30
31
|
constructor(configuration = {}) {
|
|
31
|
-
var _a, _b, _c;
|
|
32
|
+
var _a, _b, _c, _d;
|
|
32
33
|
this._resource = (_a = configuration.resource) !== null && _a !== void 0 ? _a : new resources_1.Resource({});
|
|
34
|
+
this._resourceDetectors = (_b = configuration.resourceDetectors) !== null && _b !== void 0 ? _b : [resources_1.envDetector, resources_1.processDetector];
|
|
33
35
|
this._serviceName = configuration.serviceName;
|
|
34
|
-
this._autoDetectResources = (
|
|
36
|
+
this._autoDetectResources = (_c = configuration.autoDetectResources) !== null && _c !== void 0 ? _c : true;
|
|
35
37
|
if (configuration.spanProcessor || configuration.traceExporter) {
|
|
36
38
|
const tracerProviderConfig = {};
|
|
37
39
|
if (configuration.sampler) {
|
|
@@ -40,7 +42,7 @@ class NodeSDK {
|
|
|
40
42
|
if (configuration.spanLimits) {
|
|
41
43
|
tracerProviderConfig.spanLimits = configuration.spanLimits;
|
|
42
44
|
}
|
|
43
|
-
const spanProcessor = (
|
|
45
|
+
const spanProcessor = (_d = configuration.spanProcessor) !== null && _d !== void 0 ? _d : new sdk_trace_base_1.BatchSpanProcessor(configuration.traceExporter);
|
|
44
46
|
this.configureTracerProvider(tracerProviderConfig, spanProcessor, configuration.contextManager, configuration.textMapPropagator);
|
|
45
47
|
}
|
|
46
48
|
if (configuration.metricReader || configuration.views) {
|
|
@@ -93,8 +95,10 @@ class NodeSDK {
|
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
/** Detect resource attributes */
|
|
96
|
-
async detectResources(
|
|
97
|
-
const internalConfig =
|
|
98
|
+
async detectResources() {
|
|
99
|
+
const internalConfig = {
|
|
100
|
+
detectors: this._resourceDetectors,
|
|
101
|
+
};
|
|
98
102
|
this.addResource(await (0, resources_1.detectResources)(internalConfig));
|
|
99
103
|
}
|
|
100
104
|
/** Manually add a resource */
|
|
@@ -105,32 +109,33 @@ class NodeSDK {
|
|
|
105
109
|
* Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API.
|
|
106
110
|
*/
|
|
107
111
|
async start() {
|
|
108
|
-
var _a, _b;
|
|
112
|
+
var _a, _b, _c, _d, _e;
|
|
109
113
|
if (this._autoDetectResources) {
|
|
110
114
|
await this.detectResources();
|
|
111
115
|
}
|
|
112
116
|
this._resource = this._serviceName === undefined
|
|
113
117
|
? this._resource
|
|
114
118
|
: this._resource.merge(new resources_1.Resource({ [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: this._serviceName }));
|
|
119
|
+
const Provider = this._tracerProviderConfig ? sdk_trace_node_1.NodeTracerProvider : TracerProviderWithEnvExporter_1.TracerProviderWithEnvExporters;
|
|
120
|
+
const tracerProvider = new Provider(Object.assign(Object.assign({}, (_a = this._tracerProviderConfig) === null || _a === void 0 ? void 0 : _a.tracerConfig), { resource: this._resource }));
|
|
121
|
+
this._tracerProvider = tracerProvider;
|
|
115
122
|
if (this._tracerProviderConfig) {
|
|
116
|
-
const tracerProvider = new sdk_trace_node_1.NodeTracerProvider(Object.assign(Object.assign({}, this._tracerProviderConfig.tracerConfig), { resource: this._resource }));
|
|
117
|
-
this._tracerProvider = tracerProvider;
|
|
118
123
|
tracerProvider.addSpanProcessor(this._tracerProviderConfig.spanProcessor);
|
|
119
|
-
tracerProvider.register({
|
|
120
|
-
contextManager: this._tracerProviderConfig.contextManager,
|
|
121
|
-
propagator: this._tracerProviderConfig.textMapPropagator,
|
|
122
|
-
});
|
|
123
124
|
}
|
|
125
|
+
tracerProvider.register({
|
|
126
|
+
contextManager: (_b = this._tracerProviderConfig) === null || _b === void 0 ? void 0 : _b.contextManager,
|
|
127
|
+
propagator: (_c = this._tracerProviderConfig) === null || _c === void 0 ? void 0 : _c.textMapPropagator,
|
|
128
|
+
});
|
|
124
129
|
if (this._meterProviderConfig) {
|
|
125
130
|
const meterProvider = new sdk_metrics_1.MeterProvider({
|
|
126
131
|
resource: this._resource,
|
|
127
|
-
views: (
|
|
132
|
+
views: (_e = (_d = this._meterProviderConfig) === null || _d === void 0 ? void 0 : _d.views) !== null && _e !== void 0 ? _e : [],
|
|
128
133
|
});
|
|
129
134
|
if (this._meterProviderConfig.reader) {
|
|
130
135
|
meterProvider.addMetricReader(this._meterProviderConfig.reader);
|
|
131
136
|
}
|
|
132
137
|
this._meterProvider = meterProvider;
|
|
133
|
-
|
|
138
|
+
api_1.metrics.setGlobalMeterProvider(meterProvider);
|
|
134
139
|
}
|
|
135
140
|
(0, instrumentation_1.registerInstrumentations)({
|
|
136
141
|
instrumentations: this._instrumentations,
|
package/build/src/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,4DAAqD;AACrD,oEAGwC;AACxC,wDAMkC;AAClC,4DAA+E;AAC/E,kEAGuC;AACvC,kEAAqF;AACrF,8EAAiF;AAkBjF,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,CA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EAAE,CAAC,CAAC;SAC/C;QAED,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,oDAAoD;aACnD,IAAI,CAAC,GAAG,EAAE;QACX,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;CACF;AApMD,0BAoMC","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, View } from '@opentelemetry/sdk-metrics';\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 */\n\nexport type MeterProviderConfig = {\n /**\n * Reference to the MetricReader instance by the NodeSDK\n */\n reader?: MetricReader\n /**\n * Lists the views that should be passed when meterProvider\n *\n * Note: This is only getting used when NodeSDK is responsible for\n * instantiated an instance of MeterProvider\n */\n views?: View[]\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: 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 || 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('MetricReader passed but MetricReader has already been configured.');\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 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._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\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;;;AAEH,4CAAgF;AAChF,oEAGwC;AACxC,wDAOkC;AAClC,4DAA+E;AAC/E,kEAGuC;AACvC,kEAAqF;AACrF,8EAAiF;AAEjF,mFAAiF;AAcjF,MAAa,OAAO;IAmBlB;;OAEG;IACH,YAAmB,gBAA+C,EAAE;;QAClE,IAAI,CAAC,SAAS,GAAG,MAAA,aAAa,CAAC,QAAQ,mCAAI,IAAI,oBAAQ,CAAC,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,kBAAkB,GAAG,MAAA,aAAa,CAAC,iBAAiB,mCAAI,CAAC,uBAAW,EAAE,2BAAe,CAAC,CAAC;QAE5F,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,CA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AI,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;AAvMD,0BAuMC","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, metrics } from '@opentelemetry/api';\nimport {\n InstrumentationOption,\n registerInstrumentations\n} from '@opentelemetry/instrumentation';\nimport {\n Detector,\n detectResources,\n envDetector,\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 { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';\nimport { NodeSDKConfiguration } from './types';\nimport { TracerProviderWithEnvExporters } from './TracerProviderWithEnvExporter';\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};\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: Resource;\n private _resourceDetectors: Detector[];\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider | TracerProviderWithEnvExporters;\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 this._resourceDetectors = configuration.resourceDetectors ?? [envDetector, processDetector];\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 || 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('MetricReader passed but MetricReader has already been configured.');\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 async detectResources(): Promise<void> {\n const internalConfig: ResourceDetectionConfig = {\n detectors: this._resourceDetectors,\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 const Provider =\n this._tracerProviderConfig ? NodeTracerProvider : 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\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"]}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContextManager, SpanAttributes } from '@opentelemetry/api';
|
|
2
2
|
import { TextMapPropagator } from '@opentelemetry/api';
|
|
3
3
|
import { InstrumentationOption } from '@opentelemetry/instrumentation';
|
|
4
|
-
import { Resource } from '@opentelemetry/resources';
|
|
4
|
+
import { Detector, Resource } from '@opentelemetry/resources';
|
|
5
5
|
import { MetricReader, View } from '@opentelemetry/sdk-metrics';
|
|
6
6
|
import { Sampler, SpanExporter, SpanLimits, SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
7
7
|
export interface NodeSDKConfiguration {
|
|
@@ -13,6 +13,7 @@ export interface NodeSDKConfiguration {
|
|
|
13
13
|
views: View[];
|
|
14
14
|
instrumentations: InstrumentationOption[];
|
|
15
15
|
resource: Resource;
|
|
16
|
+
resourceDetectors: Detector[];
|
|
16
17
|
sampler: Sampler;
|
|
17
18
|
serviceName?: string;
|
|
18
19
|
spanProcessor: SpanProcessor;
|
package/build/src/types.js.map
CHANGED
|
@@ -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, SpanAttributes } from '@opentelemetry/api';\nimport { TextMapPropagator } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { Resource } from '@opentelemetry/resources';\nimport { MetricReader, View } from '@opentelemetry/sdk-metrics';\nimport {\n Sampler,\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 views: View[]\n instrumentations: InstrumentationOption[];\n resource: Resource;\n sampler: Sampler;\n serviceName?: string;\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 { TextMapPropagator } from '@opentelemetry/api';\nimport { InstrumentationOption } from '@opentelemetry/instrumentation';\nimport { Detector, Resource } from '@opentelemetry/resources';\nimport { MetricReader, View } from '@opentelemetry/sdk-metrics';\nimport {\n Sampler,\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 views: View[]\n instrumentations: InstrumentationOption[];\n resource: Resource;\n resourceDetectors: Detector[];\n sampler: Sampler;\n serviceName?: string;\n spanProcessor: SpanProcessor;\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.34.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.34.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/sdk-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "OpenTelemetry SDK for Node.js",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -44,22 +44,26 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@opentelemetry/
|
|
48
|
-
"@opentelemetry/
|
|
49
|
-
"@opentelemetry/
|
|
50
|
-
"@opentelemetry/
|
|
51
|
-
"@opentelemetry/
|
|
52
|
-
"@opentelemetry/
|
|
53
|
-
"@opentelemetry/
|
|
47
|
+
"@opentelemetry/core": "1.8.0",
|
|
48
|
+
"@opentelemetry/exporter-jaeger": "1.8.0",
|
|
49
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.34.0",
|
|
50
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.34.0",
|
|
51
|
+
"@opentelemetry/exporter-trace-otlp-proto": "0.34.0",
|
|
52
|
+
"@opentelemetry/exporter-zipkin": "1.8.0",
|
|
53
|
+
"@opentelemetry/instrumentation": "0.34.0",
|
|
54
|
+
"@opentelemetry/resources": "1.8.0",
|
|
55
|
+
"@opentelemetry/sdk-metrics": "1.8.0",
|
|
56
|
+
"@opentelemetry/sdk-trace-base": "1.8.0",
|
|
57
|
+
"@opentelemetry/sdk-trace-node": "1.8.0",
|
|
58
|
+
"@opentelemetry/semantic-conventions": "1.8.0"
|
|
54
59
|
},
|
|
55
60
|
"peerDependencies": {
|
|
56
|
-
"@opentelemetry/api": ">=1.
|
|
61
|
+
"@opentelemetry/api": ">=1.3.0 <1.4.0"
|
|
57
62
|
},
|
|
58
63
|
"devDependencies": {
|
|
59
|
-
"@opentelemetry/api": ">=1.
|
|
60
|
-
"@opentelemetry/context-async-hooks": "1.
|
|
61
|
-
"@
|
|
62
|
-
"@types/mocha": "9.1.1",
|
|
64
|
+
"@opentelemetry/api": ">=1.3.0 <1.4.0",
|
|
65
|
+
"@opentelemetry/context-async-hooks": "1.8.0",
|
|
66
|
+
"@types/mocha": "10.0.0",
|
|
63
67
|
"@types/node": "18.6.5",
|
|
64
68
|
"@types/semver": "7.3.9",
|
|
65
69
|
"@types/sinon": "10.0.13",
|
|
@@ -74,5 +78,6 @@
|
|
|
74
78
|
"typescript": "4.4.4"
|
|
75
79
|
},
|
|
76
80
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-node",
|
|
77
|
-
"
|
|
81
|
+
"sideEffects": false,
|
|
82
|
+
"gitHead": "7972edf6659fb6e0d5928a5cf7a35f26683e168f"
|
|
78
83
|
}
|