@ogcio/o11y-sdk-node 0.11.1 → 0.11.2

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.
@@ -20,7 +20,7 @@ export default async function buildGrpcExporters(config) {
20
20
  url: `${config.collectorUrl}`,
21
21
  compression: CompressionAlgorithm.GZIP,
22
22
  metadata: config.grpcMetadata ?? (await defaultMetadata()),
23
- }), getNodeSdkConfig())),
23
+ }), getNodeSdkConfig()), config.batchProcessorsConfig),
24
24
  ..._spansProcessorConfig(config),
25
25
  ],
26
26
  metrics: new metrics.PeriodicExportingMetricReader({
@@ -37,7 +37,7 @@ export default async function buildGrpcExporters(config) {
37
37
  url: `${config.collectorUrl}`,
38
38
  compression: CompressionAlgorithm.GZIP,
39
39
  metadata: config.grpcMetadata ?? (await defaultMetadata()),
40
- }), getNodeSdkConfig())),
40
+ }), getNodeSdkConfig()), config.batchProcessorsConfig),
41
41
  ],
42
42
  };
43
43
  }
@@ -16,7 +16,7 @@ export default function buildHttpExporters(config) {
16
16
  new SpanProcessorMap[config.collectorMode ?? "batch"](new PIIExporterDecorator(new OTLPTraceExporter({
17
17
  url: `${config.collectorUrl}/v1/traces`,
18
18
  compression: CompressionAlgorithm.GZIP,
19
- }), getNodeSdkConfig())),
19
+ }), getNodeSdkConfig()), config.batchProcessorsConfig),
20
20
  ..._spansProcessorConfig(config),
21
21
  ],
22
22
  metrics: new metrics.PeriodicExportingMetricReader({
@@ -31,7 +31,7 @@ export default function buildHttpExporters(config) {
31
31
  new LogRecordProcessorMap[config.collectorMode ?? "batch"](new PIIExporterDecorator(new OTLPLogExporter({
32
32
  url: `${config.collectorUrl}/v1/logs`,
33
33
  compression: CompressionAlgorithm.GZIP,
34
- }), getNodeSdkConfig())),
34
+ }), getNodeSdkConfig()), config.batchProcessorsConfig),
35
35
  ],
36
36
  };
37
37
  }
@@ -3,10 +3,10 @@ import { BasicRedactor } from "../../sdk-core/lib/index.js";
3
3
  import { InstrumentationConfigMap } from "@opentelemetry/auto-instrumentations-node";
4
4
  import { Instrumentation } from "@opentelemetry/instrumentation";
5
5
  import { Sampler, SpanProcessor } from "@opentelemetry/sdk-trace-base";
6
- import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
6
+ import { BufferConfig, LogRecordProcessor } from "@opentelemetry/sdk-logs";
7
7
  import { ContextManager, TextMapPropagator } from "@opentelemetry/api";
8
8
  import { NodeSDK } from "@opentelemetry/sdk-node";
9
- export interface NodeSDKConfig {
9
+ interface BaseNodeSDKConfig {
10
10
  /**
11
11
  * The opentelemetry collector entrypoint GRPC url.
12
12
  * If the collectorUrl is null or undefined, the instrumentation will not be activated.
@@ -28,15 +28,6 @@ export interface NodeSDKConfig {
28
28
  * @default INFO
29
29
  */
30
30
  diagLogLevel?: SDKLogLevel;
31
- /**
32
- * Collector signals processing mode.
33
- * single: makes an http/grpc request for each signal, and it is immediately processed inside grafana
34
- * batch: sends multiple signals within a time window, optimized to reduce http/grpc calls in production
35
- *
36
- * @type string
37
- * @default batch
38
- */
39
- collectorMode?: SDKCollectorMode;
40
31
  /**
41
32
  * Array of not traced urls.
42
33
  *
@@ -169,6 +160,26 @@ export interface NodeSDKConfig {
169
160
  */
170
161
  onSdkStarted?: (sdk: NodeSDK) => void;
171
162
  }
163
+ /**
164
+ * Configuration for batch collector mode (default).
165
+ * Sends multiple signals within a time window, optimized to reduce http/grpc calls in production.
166
+ */
167
+ export interface BatchNodeSDKConfig extends BaseNodeSDKConfig {
168
+ collectorMode?: "batch";
169
+ /**
170
+ * Configuration for the batch processor buffer.
171
+ */
172
+ batchProcessorsConfig?: BufferConfig;
173
+ }
174
+ /**
175
+ * Configuration for single collector mode.
176
+ * Makes an http/grpc request for each signal, immediately processed inside grafana.
177
+ */
178
+ export interface SingleNodeSDKConfig extends BaseNodeSDKConfig {
179
+ collectorMode: "single";
180
+ batchProcessorsConfig?: never;
181
+ }
182
+ export type NodeSDKConfig = BatchNodeSDKConfig | SingleNodeSDKConfig;
172
183
  export interface SamplerCondition {
173
184
  type: "endsWith" | "includes" | "equals";
174
185
  url: string;
@@ -177,3 +188,4 @@ export type SignalAttributeValue = string | number | boolean;
177
188
  export type SDKCollectorMode = "single" | "batch";
178
189
  export type SDKProtocol = "grpc" | "http" | "console";
179
190
  export type SDKLogLevel = "NONE" | "ERROR" | "WARN" | "INFO" | "DEBUG" | "VERBOSE" | "ALL";
191
+ export {};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogcio/o11y-sdk-node",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Opentelemetry standard instrumentation SDK for NodeJS based project",
5
5
  "main": "dist/sdk-node/index.js",
6
6
  "types": "dist/sdk-node/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogcio/o11y-sdk-node",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Opentelemetry standard instrumentation SDK for NodeJS based project",
5
5
  "main": "dist/sdk-node/index.js",
6
6
  "types": "dist/sdk-node/index.d.ts",
@@ -45,10 +45,10 @@
45
45
  "@opentelemetry/sdk-trace-base": "2.7.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@types/node": "25.6.2",
49
- "@vitest/coverage-v8": "4.1.5",
48
+ "@types/node": "25.7.0",
49
+ "@vitest/coverage-v8": "4.1.6",
50
50
  "typescript": "6.0.3",
51
- "vitest": "4.1.5"
51
+ "vitest": "4.1.6"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=20.6.0"