@ogcio/o11y-sdk-node 0.11.1 → 0.11.3

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.
@@ -1,4 +1,5 @@
1
1
  import { _containsEncodedComponents } from "./string-decoding.js";
2
+ import { BasicRedactor } from "../redaction/index.js";
2
3
  const decoder = new TextDecoder();
3
4
  const encoder = new TextEncoder();
4
5
  /**
@@ -1,6 +1,6 @@
1
1
  import buildNodeInstrumentation from "./lib/instrumentation.node.js";
2
2
  export type { Span, SpanStatus } from "@opentelemetry/api";
3
- export { SpanKind, SpanStatusCode, TraceFlags, Exception, } from "@opentelemetry/api";
3
+ export { SpanKind, SpanStatusCode, TraceFlags, type Exception, } from "@opentelemetry/api";
4
4
  export type * from "./lib/index.js";
5
5
  export type { NodeSDK } from "@opentelemetry/sdk-node";
6
6
  export { buildNodeInstrumentation as instrumentNode };
@@ -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
  }
@@ -1,12 +1,12 @@
1
1
  import type { Metadata } from "@grpc/grpc-js";
2
2
  import { BasicRedactor } from "../../sdk-core/lib/index.js";
3
- import { InstrumentationConfigMap } from "@opentelemetry/auto-instrumentations-node";
4
- import { Instrumentation } from "@opentelemetry/instrumentation";
5
- import { Sampler, SpanProcessor } from "@opentelemetry/sdk-trace-base";
6
- import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
7
- import { ContextManager, TextMapPropagator } from "@opentelemetry/api";
3
+ import type { InstrumentationConfigMap } from "@opentelemetry/auto-instrumentations-node";
4
+ import type { Instrumentation } from "@opentelemetry/instrumentation";
5
+ import type { Sampler, SpanProcessor } from "@opentelemetry/sdk-trace-base";
6
+ import type { BufferConfig, LogRecordProcessor } from "@opentelemetry/sdk-logs";
7
+ import type { 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 +1,2 @@
1
- export {};
1
+ import { BasicRedactor } from "../../sdk-core/lib/index.js";
2
+ import { NodeSDK } from "@opentelemetry/sdk-node";
@@ -1,6 +1,7 @@
1
1
  import { EmailRedactorWithMetrics } from "./email.js";
2
2
  import { IpRedactorWithMetrics } from "./ip.js";
3
3
  import { getMetric } from "../../../metrics.js";
4
+ import { BasicRedactor } from "../../../../../sdk-core/index.js";
4
5
  import { PpsnRedactorWithMetrics } from "./ppsn.js";
5
6
  const metricCounter = getMetric("counter", {
6
7
  meterName: "o11y",
@@ -1,4 +1,4 @@
1
- import { NodeSDKConfig } from "../index.js";
1
+ import type { NodeSDKConfig } from "../index.js";
2
2
  import type { NodeOptions as SentryNodeOptions } from "@sentry/node";
3
3
  /**
4
4
  * Options for the withSentry preset function.
@@ -1,5 +1,5 @@
1
- import { Context } from "@opentelemetry/api";
2
- import { LogRecordProcessor, SdkLogRecord } from "@opentelemetry/sdk-logs";
1
+ import type { Context } from "@opentelemetry/api";
2
+ import type { LogRecordProcessor, SdkLogRecord } from "@opentelemetry/sdk-logs";
3
3
  export declare class NextJsLogProcessor implements LogRecordProcessor {
4
4
  onEmit(logRecord: SdkLogRecord, _context?: Context): void;
5
5
  shutdown(): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { Span } from "@opentelemetry/sdk-trace-base";
1
+ import type { Span } from "@opentelemetry/sdk-trace-base";
2
2
  import { OnEndingHookSpanProcessor } from "./on-ending-hook-span-processor.js";
3
3
  export declare class NextJsSpanProcessor extends OnEndingHookSpanProcessor {
4
4
  onEnding(span: Span): void;
@@ -1,5 +1,5 @@
1
- import { Context } from "@opentelemetry/api";
2
- import { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace-base";
1
+ import type { Context } from "@opentelemetry/api";
2
+ import type { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace-base";
3
3
  /**
4
4
  * A SpanProcessor that provides a hook to execute custom logic
5
5
  * just before a span is ended.
@@ -1,3 +1,4 @@
1
+ import { SpanKind, } from "@opentelemetry/api";
1
2
  import { SamplingDecision, } from "@opentelemetry/sdk-trace-base";
2
3
  export class UrlSampler {
3
4
  _samplerCondition;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogcio/o11y-sdk-node",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
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.3",
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"