@ogcio/o11y-sdk-node 0.1.0-beta.2 → 0.1.0-beta.4

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +96 -10
  3. package/coverage/cobertura-coverage.xml +191 -80
  4. package/coverage/lcov-report/index.html +17 -17
  5. package/coverage/lcov-report/sdk-node/index.html +1 -1
  6. package/coverage/lcov-report/sdk-node/index.ts.html +8 -2
  7. package/coverage/lcov-report/sdk-node/lib/console.ts.html +130 -0
  8. package/coverage/lcov-report/sdk-node/lib/grpc.ts.html +27 -27
  9. package/coverage/lcov-report/sdk-node/lib/http.ts.html +6 -6
  10. package/coverage/lcov-report/sdk-node/lib/index.html +46 -16
  11. package/coverage/lcov-report/sdk-node/lib/index.ts.html +5 -14
  12. package/coverage/lcov-report/sdk-node/lib/instrumentation.node.ts.html +82 -58
  13. package/coverage/lcov-report/sdk-node/lib/metrics.ts.html +295 -0
  14. package/coverage/lcov-report/sdk-node/lib/options.ts.html +4 -7
  15. package/coverage/lcov-report/sdk-node/lib/utils.ts.html +1 -1
  16. package/coverage/lcov.info +196 -90
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +1 -0
  19. package/dist/lib/console.d.ts +3 -0
  20. package/dist/lib/console.js +12 -0
  21. package/dist/lib/grpc.js +4 -4
  22. package/dist/lib/http.js +4 -4
  23. package/dist/lib/index.d.ts +2 -2
  24. package/dist/lib/instrumentation.node.js +10 -1
  25. package/dist/lib/metrics.d.ts +18 -0
  26. package/dist/lib/metrics.js +28 -0
  27. package/dist/lib/options.d.ts +2 -3
  28. package/dist/package.json +50 -0
  29. package/index.ts +2 -0
  30. package/lib/console.ts +15 -0
  31. package/lib/grpc.ts +4 -4
  32. package/lib/http.ts +4 -4
  33. package/lib/index.ts +2 -2
  34. package/lib/instrumentation.node.ts +9 -1
  35. package/lib/metrics.ts +70 -0
  36. package/lib/options.ts +2 -3
  37. package/package.json +22 -22
  38. package/test/metrics.test.ts +142 -0
  39. package/test/node-config.test.ts +35 -9
  40. package/test/validation.test.ts +31 -0
  41. package/test-report.xml +45 -13
  42. package/tsconfig.json +2 -1
@@ -9,38 +9,62 @@ BRF:0
9
9
  BRH:0
10
10
  end_of_record
11
11
  TN:
12
+ SF:lib/console.ts
13
+ FN:5,buildConsoleExporters
14
+ FNF:1
15
+ FNH:1
16
+ FNDA:1,buildConsoleExporters
17
+ DA:1,1
18
+ DA:5,1
19
+ DA:6,1
20
+ DA:7,1
21
+ DA:8,1
22
+ DA:9,1
23
+ DA:10,1
24
+ DA:11,1
25
+ DA:12,1
26
+ DA:13,1
27
+ DA:14,1
28
+ DA:15,1
29
+ LF:12
30
+ LH:12
31
+ BRDA:5,0,0,1
32
+ BRF:1
33
+ BRH:1
34
+ end_of_record
35
+ TN:
12
36
  SF:lib/grpc.ts
13
37
  FN:10,buildGrpcExporters
14
38
  FNF:1
15
39
  FNH:1
16
- FNDA:2,buildGrpcExporters
40
+ FNDA:3,buildGrpcExporters
17
41
  DA:1,1
18
- DA:10,2
19
- DA:11,2
20
- DA:12,2
21
- DA:13,2
22
- DA:14,2
23
- DA:15,2
24
- DA:16,2
25
- DA:17,2
26
- DA:18,2
27
- DA:19,2
28
- DA:20,2
29
- DA:21,2
30
- DA:22,2
31
- DA:23,2
32
- DA:24,2
33
- DA:25,2
34
- DA:26,2
35
- DA:27,2
36
- DA:28,2
37
- DA:29,2
38
- DA:30,2
39
- DA:31,2
42
+ DA:10,3
43
+ DA:11,3
44
+ DA:12,3
45
+ DA:13,3
46
+ DA:14,3
47
+ DA:15,3
48
+ DA:16,3
49
+ DA:17,3
50
+ DA:18,3
51
+ DA:19,3
52
+ DA:20,3
53
+ DA:21,3
54
+ DA:22,3
55
+ DA:23,3
56
+ DA:24,3
57
+ DA:25,3
58
+ DA:26,3
59
+ DA:27,3
60
+ DA:28,3
61
+ DA:29,3
62
+ DA:30,3
63
+ DA:31,3
40
64
  LF:23
41
65
  LH:23
42
- BRDA:10,0,0,2
43
- BRDA:23,1,0,1
66
+ BRDA:10,0,0,3
67
+ BRDA:23,1,0,2
44
68
  BRF:2
45
69
  BRH:2
46
70
  end_of_record
@@ -97,85 +121,167 @@ BRH:1
97
121
  end_of_record
98
122
  TN:
99
123
  SF:lib/instrumentation.node.ts
100
- FN:11,buildNodeInstrumentation
124
+ FN:13,buildNodeInstrumentation
101
125
  FNF:1
102
126
  FNH:1
103
- FNDA:6,buildNodeInstrumentation
127
+ FNDA:8,buildNodeInstrumentation
104
128
  DA:1,1
105
- DA:11,6
106
- DA:12,6
107
- DA:13,6
108
- DA:14,6
109
- DA:15,1
110
- DA:16,1
129
+ DA:13,8
130
+ DA:14,8
131
+ DA:15,8
132
+ DA:16,8
111
133
  DA:17,1
112
134
  DA:18,1
113
135
  DA:19,1
114
- DA:21,6
115
- DA:22,1
116
- DA:23,1
136
+ DA:20,1
137
+ DA:21,1
138
+ DA:23,8
117
139
  DA:24,1
118
140
  DA:25,1
119
141
  DA:26,1
120
- DA:28,4
121
- DA:29,1
122
- DA:30,1
142
+ DA:27,1
143
+ DA:28,1
144
+ DA:30,8
123
145
  DA:31,1
124
146
  DA:32,1
125
147
  DA:33,1
126
- DA:35,3
127
- DA:37,3
128
- DA:38,1
129
- DA:39,3
130
- DA:40,2
131
- DA:41,2
132
- DA:43,3
148
+ DA:34,1
149
+ DA:35,1
150
+ DA:37,5
151
+ DA:39,8
152
+ DA:40,1
153
+ DA:41,8
154
+ DA:42,1
155
+ DA:43,4
133
156
  DA:44,3
134
157
  DA:45,3
135
- DA:46,3
136
- DA:47,3
137
- DA:48,0
138
- DA:49,6
139
- DA:51,6
140
- DA:52,6
141
- DA:53,6
142
- DA:54,6
143
- DA:55,6
144
- DA:56,6
145
- DA:57,6
146
- DA:58,6
147
- DA:59,6
148
- DA:60,6
149
- DA:61,6
150
- DA:62,6
151
- DA:63,6
152
- DA:64,6
153
- DA:66,6
154
- DA:67,6
155
- DA:68,6
156
- DA:69,6
157
- DA:70,0
158
- DA:71,0
159
- DA:72,0
160
- DA:73,0
161
- DA:74,0
162
- DA:75,6
163
- LF:59
164
- LH:53
165
- BRDA:11,0,0,6
166
- BRDA:14,1,0,1
167
- BRDA:19,2,0,5
168
- BRDA:21,3,0,4
169
- BRDA:21,4,0,1
170
- BRDA:28,5,0,1
171
- BRDA:33,6,0,3
172
- BRDA:37,7,0,1
173
- BRDA:39,8,0,2
174
- BRDA:47,9,0,0
175
- BRDA:60,10,0,3
176
- BRDA:69,11,0,0
177
- BRF:12
178
- BRH:10
158
+ DA:47,5
159
+ DA:48,5
160
+ DA:49,5
161
+ DA:50,5
162
+ DA:51,4
163
+ DA:52,1
164
+ DA:53,8
165
+ DA:55,8
166
+ DA:56,8
167
+ DA:57,8
168
+ DA:58,8
169
+ DA:59,8
170
+ DA:60,8
171
+ DA:61,8
172
+ DA:62,8
173
+ DA:63,8
174
+ DA:64,8
175
+ DA:65,8
176
+ DA:66,8
177
+ DA:67,8
178
+ DA:68,8
179
+ DA:69,8
180
+ DA:70,8
181
+ DA:71,8
182
+ DA:72,8
183
+ DA:74,8
184
+ DA:75,8
185
+ DA:76,8
186
+ DA:77,8
187
+ DA:78,1
188
+ DA:79,1
189
+ DA:80,1
190
+ DA:81,1
191
+ DA:82,1
192
+ DA:83,8
193
+ LF:65
194
+ LH:65
195
+ BRDA:13,0,0,8
196
+ BRDA:16,1,0,1
197
+ BRDA:21,2,0,7
198
+ BRDA:23,3,0,1
199
+ BRDA:28,4,0,6
200
+ BRDA:30,5,0,5
201
+ BRDA:30,6,0,1
202
+ BRDA:39,7,0,1
203
+ BRDA:41,8,0,4
204
+ BRDA:41,9,0,1
205
+ BRDA:43,10,0,3
206
+ BRDA:45,11,0,5
207
+ BRDA:50,12,0,4
208
+ BRDA:51,13,0,1
209
+ BRDA:68,14,0,5
210
+ BRDA:77,15,0,1
211
+ BRF:16
212
+ BRH:16
213
+ end_of_record
214
+ TN:
215
+ SF:lib/metrics.ts
216
+ FN:33,gauge
217
+ FN:34,histogram
218
+ FN:35,counter
219
+ FN:36,updowncounter
220
+ FN:37,async-counter
221
+ FN:38,async-updowncounter
222
+ FN:39,async-gauge
223
+ FN:48,getMeter
224
+ FN:59,getMetric
225
+ FNF:9
226
+ FNH:9
227
+ FNDA:1,gauge
228
+ FNDA:1,histogram
229
+ FNDA:1,counter
230
+ FNDA:1,updowncounter
231
+ FNDA:1,async-counter
232
+ FNDA:1,async-updowncounter
233
+ FNDA:2,async-gauge
234
+ FNDA:9,getMeter
235
+ FNDA:9,getMetric
236
+ DA:1,1
237
+ DA:28,1
238
+ DA:32,1
239
+ DA:33,1
240
+ DA:34,1
241
+ DA:35,1
242
+ DA:36,1
243
+ DA:37,1
244
+ DA:38,1
245
+ DA:39,1
246
+ DA:40,1
247
+ DA:48,9
248
+ DA:49,9
249
+ DA:50,9
250
+ DA:51,1
251
+ DA:52,1
252
+ DA:53,9
253
+ DA:54,8
254
+ DA:55,8
255
+ DA:56,9
256
+ DA:57,9
257
+ DA:59,1
258
+ DA:60,9
259
+ DA:61,9
260
+ DA:62,9
261
+ DA:63,9
262
+ DA:65,9
263
+ DA:66,1
264
+ DA:67,1
265
+ DA:69,8
266
+ DA:70,8
267
+ LF:31
268
+ LH:31
269
+ BRDA:33,0,0,1
270
+ BRDA:34,1,0,1
271
+ BRDA:35,2,0,1
272
+ BRDA:36,3,0,1
273
+ BRDA:37,4,0,1
274
+ BRDA:38,5,0,1
275
+ BRDA:39,6,0,2
276
+ BRDA:48,7,0,9
277
+ BRDA:50,8,0,8
278
+ BRDA:50,9,0,1
279
+ BRDA:53,10,0,8
280
+ BRDA:59,11,0,9
281
+ BRDA:65,12,0,1
282
+ BRDA:67,13,0,8
283
+ BRF:14
284
+ BRH:14
179
285
  end_of_record
180
286
  TN:
181
287
  SF:lib/options.ts
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ import buildNodeInstrumentation from "./lib/instrumentation.node.js";
4
4
  export type * from "./lib/index.js";
5
5
  export type { NodeSDKConfig, NodeSDK };
6
6
  export { buildNodeInstrumentation as instrumentNode };
7
+ export * from "./lib/metrics.js";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import buildNodeInstrumentation from "./lib/instrumentation.node.js";
2
2
  export { buildNodeInstrumentation as instrumentNode };
3
+ export * from "./lib/metrics.js";
@@ -0,0 +1,3 @@
1
+ import type { NodeSDKConfig } from "./index.js";
2
+ import type { Exporters } from "./options.js";
3
+ export default function buildConsoleExporters(_: NodeSDKConfig): Exporters;
@@ -0,0 +1,12 @@
1
+ import { logs, metrics, tracing } from "@opentelemetry/sdk-node";
2
+ export default function buildConsoleExporters(_) {
3
+ return {
4
+ traces: new tracing.ConsoleSpanExporter(),
5
+ metrics: new metrics.PeriodicExportingMetricReader({
6
+ exporter: new metrics.ConsoleMetricExporter(),
7
+ }),
8
+ logs: [
9
+ new logs.SimpleLogRecordProcessor(new logs.ConsoleLogRecordExporter()),
10
+ ],
11
+ };
12
+ }
package/dist/lib/grpc.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { LogRecordProcessorMap } from "./utils.js";
2
+ import { metrics } from "@opentelemetry/sdk-node";
2
3
  import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
3
- import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
4
- import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
5
- import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-grpc";
6
4
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
5
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-grpc";
6
+ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
7
7
  export default function buildGrpcExporters(config) {
8
8
  return {
9
9
  traces: new OTLPTraceExporter({
10
10
  url: `${config.collectorUrl}`,
11
11
  compression: CompressionAlgorithm.GZIP,
12
12
  }),
13
- metrics: new PeriodicExportingMetricReader({
13
+ metrics: new metrics.PeriodicExportingMetricReader({
14
14
  exporter: new OTLPMetricExporter({
15
15
  url: `${config.collectorUrl}`,
16
16
  compression: CompressionAlgorithm.GZIP,
package/dist/lib/http.js CHANGED
@@ -1,9 +1,9 @@
1
- import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
2
1
  import { LogRecordProcessorMap } from "./utils.js";
2
+ import { metrics } from "@opentelemetry/sdk-node";
3
3
  import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
4
- import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
5
- import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
4
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
6
5
  import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
6
+ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
7
7
  export default function buildHttpExporters(config) {
8
8
  if (config.collectorUrl.endsWith("/")) {
9
9
  config.collectorUrl = config.collectorUrl.slice(0, -1);
@@ -13,7 +13,7 @@ export default function buildHttpExporters(config) {
13
13
  url: `${config.collectorUrl}/v1/traces`,
14
14
  compression: CompressionAlgorithm.GZIP,
15
15
  }),
16
- metrics: new PeriodicExportingMetricReader({
16
+ metrics: new metrics.PeriodicExportingMetricReader({
17
17
  exporter: new OTLPMetricExporter({
18
18
  url: `${config.collectorUrl}/v1/metrics`,
19
19
  compression: CompressionAlgorithm.GZIP,
@@ -34,13 +34,13 @@ export interface NodeSDKConfig extends SDKConfig {
34
34
  */
35
35
  enableFS?: boolean;
36
36
  /**
37
- * http based connection protocol used to send signals.
37
+ * protocol used to send signals.
38
38
  *
39
39
  * @default grpc
40
40
  */
41
41
  protocol?: SDKProtocol;
42
42
  }
43
43
  export type SDKCollectorMode = "single" | "batch";
44
- export type SDKProtocol = "grpc" | "http";
44
+ export type SDKProtocol = "grpc" | "http" | "console";
45
45
  export type SDKLogLevel = "NONE" | "ERROR" | "WARN" | "INFO" | "DEBUG" | "VERBOSE" | "ALL";
46
46
  export {};
@@ -1,10 +1,12 @@
1
- import { NodeSDK } from "@opentelemetry/sdk-node";
1
+ import { NodeSDK, resources } from "@opentelemetry/sdk-node";
2
2
  import isUrl from "is-url";
3
3
  import buildHttpExporters from "./http.js";
4
4
  import buildGrpcExporters from "./grpc.js";
5
+ import buildConsoleExporters from "./console.js";
5
6
  import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
6
7
  import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
7
8
  import { W3CTraceContextPropagator } from "@opentelemetry/core";
9
+ import packageJson from "../package.json" with { type: "json" };
8
10
  export default function buildNodeInstrumentation(config) {
9
11
  if (!config) {
10
12
  console.warn("observability config not set. Skipping NodeJS OpenTelemetry instrumentation.");
@@ -22,6 +24,9 @@ export default function buildNodeInstrumentation(config) {
22
24
  if (config.protocol === "http") {
23
25
  exporter = buildHttpExporters(config);
24
26
  }
27
+ else if (config.protocol === "console") {
28
+ exporter = buildConsoleExporters(config);
29
+ }
25
30
  else {
26
31
  exporter = buildGrpcExporters(config);
27
32
  }
@@ -30,6 +35,10 @@ export default function buildNodeInstrumentation(config) {
30
35
  ? DiagLogLevel[config.diagLogLevel]
31
36
  : DiagLogLevel.INFO);
32
37
  const sdk = new NodeSDK({
38
+ resource: new resources.Resource({
39
+ "o11y.sdk.name": packageJson.name,
40
+ "o11y.sdk.version": packageJson.version,
41
+ }),
33
42
  serviceName: config.serviceName,
34
43
  traceExporter: exporter.traces,
35
44
  metricReader: exporter.metrics,
@@ -0,0 +1,18 @@
1
+ import { Counter, Gauge, Histogram, MetricOptions, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter } from "@opentelemetry/api";
2
+ declare const MetricsMap: {
3
+ gauge: Gauge;
4
+ histogram: Histogram;
5
+ counter: Counter;
6
+ updowncounter: UpDownCounter;
7
+ "async-counter": ObservableCounter;
8
+ "async-updowncounter": ObservableUpDownCounter;
9
+ "async-gauge": ObservableGauge;
10
+ };
11
+ type MetricType = keyof typeof MetricsMap;
12
+ export interface MetricsParams {
13
+ metricName: string;
14
+ attributeName: string;
15
+ options?: MetricOptions;
16
+ }
17
+ export declare function getMetric<T extends MetricType>(type: T, p: MetricsParams): (typeof MetricsMap)[T];
18
+ export {};
@@ -0,0 +1,28 @@
1
+ import { createNoopMeter, metrics, } from "@opentelemetry/api";
2
+ const MetricsFactoryMap = {
3
+ gauge: (meter) => meter.createGauge,
4
+ histogram: (meter) => meter.createHistogram,
5
+ counter: (meter) => meter.createCounter,
6
+ updowncounter: (meter) => meter.createUpDownCounter,
7
+ "async-counter": (meter) => meter.createObservableCounter,
8
+ "async-updowncounter": (meter) => meter.createObservableUpDownCounter,
9
+ "async-gauge": (meter) => meter.createObservableGauge,
10
+ };
11
+ function getMeter({ metricName, attributeName }) {
12
+ let meter;
13
+ if (!metricName || !attributeName) {
14
+ console.error("Invaid metric configuration!");
15
+ meter = createNoopMeter();
16
+ }
17
+ else {
18
+ meter = metrics.getMeter(`custom_metric.${metricName}`);
19
+ }
20
+ return meter;
21
+ }
22
+ export function getMetric(type, p) {
23
+ const meter = getMeter(p);
24
+ if (!MetricsFactoryMap[type]) {
25
+ throw new Error(`Unsupported metric type: ${type}`);
26
+ }
27
+ return MetricsFactoryMap[type](meter).bind(meter)(p.attributeName, p.options);
28
+ }
@@ -1,7 +1,6 @@
1
- import type { MetricReader } from "@opentelemetry/sdk-metrics";
2
- import type { logs, tracing } from "@opentelemetry/sdk-node";
1
+ import type { logs, tracing, metrics } from "@opentelemetry/sdk-node";
3
2
  export type Exporters = {
4
3
  traces: tracing.SpanExporter;
5
- metrics: MetricReader;
4
+ metrics: metrics.MetricReader;
6
5
  logs: logs.LogRecordProcessor[];
7
6
  };
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@ogcio/o11y-sdk-node",
3
+ "version": "0.1.0-beta.4",
4
+ "description": "Opentelemetry standard instrumentation SDK for NodeJS based project",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "rm -rf dist && tsc -p tsconfig.json",
9
+ "test": "vitest",
10
+ "prepublishOnly": "pnpm i && pnpm build && pnpm test"
11
+ },
12
+ "exports": {
13
+ ".": "./dist/index.js",
14
+ "./*": "./dist/*.js"
15
+ },
16
+ "keywords": [
17
+ "observability",
18
+ "o11y",
19
+ "opentelemetry",
20
+ "node",
21
+ "nodejs",
22
+ "ogcio"
23
+ ],
24
+ "author": "team:ogcio/observability",
25
+ "license": "ISC",
26
+ "dependencies": {
27
+ "@opentelemetry/api": "^1.9.0",
28
+ "@opentelemetry/auto-instrumentations-node": "^0.55.3",
29
+ "@opentelemetry/core": "1.30.1",
30
+ "@opentelemetry/exporter-logs-otlp-grpc": "^0.57.1",
31
+ "@opentelemetry/exporter-logs-otlp-http": "^0.57.1",
32
+ "@opentelemetry/exporter-metrics-otlp-grpc": "^0.57.1",
33
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.57.1",
34
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.57.1",
35
+ "@opentelemetry/exporter-trace-otlp-http": "^0.57.1",
36
+ "@opentelemetry/instrumentation": "^0.57.1",
37
+ "@opentelemetry/otlp-exporter-base": "^0.57.1",
38
+ "@opentelemetry/sdk-metrics": "^1.30.1",
39
+ "@opentelemetry/sdk-node": "^0.57.1",
40
+ "is-url": "^1.2.4"
41
+ },
42
+ "devDependencies": {
43
+ "@types/is-url": "^1.2.32",
44
+ "@types/node": "^22.12.0",
45
+ "@vitest/coverage-v8": "^3.0.4",
46
+ "tsx": "^4.19.2",
47
+ "typescript": "^5.7.3",
48
+ "vitest": "^3.0.4"
49
+ }
50
+ }
package/index.ts CHANGED
@@ -5,3 +5,5 @@ import buildNodeInstrumentation from "./lib/instrumentation.node.js";
5
5
  export type * from "./lib/index.js";
6
6
  export type { NodeSDKConfig, NodeSDK };
7
7
  export { buildNodeInstrumentation as instrumentNode };
8
+
9
+ export * from "./lib/metrics.js";
package/lib/console.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { NodeSDKConfig } from "./index.js";
2
+ import type { Exporters } from "./options.js";
3
+ import { logs, metrics, tracing } from "@opentelemetry/sdk-node";
4
+
5
+ export default function buildConsoleExporters(_: NodeSDKConfig): Exporters {
6
+ return {
7
+ traces: new tracing.ConsoleSpanExporter(),
8
+ metrics: new metrics.PeriodicExportingMetricReader({
9
+ exporter: new metrics.ConsoleMetricExporter(),
10
+ }),
11
+ logs: [
12
+ new logs.SimpleLogRecordProcessor(new logs.ConsoleLogRecordExporter()),
13
+ ],
14
+ };
15
+ }
package/lib/grpc.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { NodeSDKConfig } from "./index.js";
2
2
  import type { Exporters } from "./options.js";
3
3
  import { LogRecordProcessorMap } from "./utils.js";
4
+ import { metrics } from "@opentelemetry/sdk-node";
4
5
  import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
5
- import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
6
- import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
7
- import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-grpc";
8
6
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
7
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-grpc";
8
+ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
9
9
 
10
10
  export default function buildGrpcExporters(config: NodeSDKConfig): Exporters {
11
11
  return {
@@ -13,7 +13,7 @@ export default function buildGrpcExporters(config: NodeSDKConfig): Exporters {
13
13
  url: `${config.collectorUrl}`,
14
14
  compression: CompressionAlgorithm.GZIP,
15
15
  }),
16
- metrics: new PeriodicExportingMetricReader({
16
+ metrics: new metrics.PeriodicExportingMetricReader({
17
17
  exporter: new OTLPMetricExporter({
18
18
  url: `${config.collectorUrl}`,
19
19
  compression: CompressionAlgorithm.GZIP,
package/lib/http.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
2
1
  import type { NodeSDKConfig } from "./index.js";
3
2
  import type { Exporters } from "./options.js";
4
3
  import { LogRecordProcessorMap } from "./utils.js";
4
+ import { metrics } from "@opentelemetry/sdk-node";
5
5
  import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
6
- import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
7
- import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
6
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
8
7
  import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
8
+ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
9
9
 
10
10
  export default function buildHttpExporters(config: NodeSDKConfig): Exporters {
11
11
  if (config.collectorUrl.endsWith("/")) {
@@ -17,7 +17,7 @@ export default function buildHttpExporters(config: NodeSDKConfig): Exporters {
17
17
  url: `${config.collectorUrl}/v1/traces`,
18
18
  compression: CompressionAlgorithm.GZIP,
19
19
  }),
20
- metrics: new PeriodicExportingMetricReader({
20
+ metrics: new metrics.PeriodicExportingMetricReader({
21
21
  exporter: new OTLPMetricExporter({
22
22
  url: `${config.collectorUrl}/v1/metrics`,
23
23
  compression: CompressionAlgorithm.GZIP,
package/lib/index.ts CHANGED
@@ -36,7 +36,7 @@ export interface NodeSDKConfig extends SDKConfig {
36
36
  enableFS?: boolean;
37
37
 
38
38
  /**
39
- * http based connection protocol used to send signals.
39
+ * protocol used to send signals.
40
40
  *
41
41
  * @default grpc
42
42
  */
@@ -45,7 +45,7 @@ export interface NodeSDKConfig extends SDKConfig {
45
45
 
46
46
  export type SDKCollectorMode = "single" | "batch";
47
47
 
48
- export type SDKProtocol = "grpc" | "http";
48
+ export type SDKProtocol = "grpc" | "http" | "console";
49
49
 
50
50
  export type SDKLogLevel =
51
51
  | "NONE"