@atrim/instrument-node 0.5.1 → 0.5.2-dev.95aa52a.20251221232442

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atrim/instrument-node",
3
- "version": "0.5.1",
3
+ "version": "0.5.2-dev.95aa52a.20251221232442",
4
4
  "description": "OpenTelemetry instrumentation for Node.js with centralized YAML configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -74,10 +74,10 @@
74
74
  "@opentelemetry/sdk-trace-node": "^2.2.0",
75
75
  "@opentelemetry/sdk-trace-web": "^2.2.0",
76
76
  "@opentelemetry/semantic-conventions": "^1.38.0",
77
- "@types/node": "^20.10.0",
77
+ "@types/node": "^25.0.0",
78
78
  "@vitest/coverage-v8": "^4.0.8",
79
79
  "effect": "^3.19.8",
80
- "testcontainers": "^11.8.1",
80
+ "testcontainers": "^11.10.0",
81
81
  "tsup": "^8.0.1",
82
82
  "tsx": "^4.7.0",
83
83
  "typescript": "^5.7.2",
@@ -107,6 +107,13 @@ var InstrumentationConfigSchema = zod.z.object({
107
107
  ignore_patterns: zod.z.array(PatternConfigSchema)
108
108
  }),
109
109
  effect: zod.z.object({
110
+ // Enable/disable Effect tracing entirely
111
+ // When false, EffectInstrumentationLive returns Layer.empty
112
+ enabled: zod.z.boolean().default(true),
113
+ // Exporter mode:
114
+ // - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
115
+ // - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
116
+ exporter: zod.z.enum(["unified", "standalone"]).default("unified"),
110
117
  auto_extract_metadata: zod.z.boolean(),
111
118
  auto_isolation: AutoIsolationConfigSchema.optional()
112
119
  }).optional(),
@@ -453,8 +460,14 @@ var PatternSpanProcessor = class {
453
460
  constructor(config, wrappedProcessor) {
454
461
  __publicField(this, "matcher");
455
462
  __publicField(this, "wrappedProcessor");
463
+ __publicField(this, "httpIgnorePatterns", []);
456
464
  this.matcher = new PatternMatcher(config);
457
465
  this.wrappedProcessor = wrappedProcessor;
466
+ if (config.http?.ignore_incoming_paths) {
467
+ this.httpIgnorePatterns = config.http.ignore_incoming_paths.map(
468
+ (pattern) => new RegExp(pattern)
469
+ );
470
+ }
458
471
  }
459
472
  /**
460
473
  * Called when a span is started
@@ -472,12 +485,40 @@ var PatternSpanProcessor = class {
472
485
  * Called when a span is ended
473
486
  *
474
487
  * This is where we make the final decision on whether to export the span.
488
+ * We check both span name patterns and HTTP path patterns.
475
489
  */
476
490
  onEnd(span) {
477
491
  const spanName = span.name;
478
- if (this.matcher.shouldInstrument(spanName)) {
479
- this.wrappedProcessor.onEnd(span);
492
+ if (!this.matcher.shouldInstrument(spanName)) {
493
+ return;
494
+ }
495
+ if (this.shouldIgnoreHttpSpan(span)) {
496
+ return;
497
+ }
498
+ this.wrappedProcessor.onEnd(span);
499
+ }
500
+ /**
501
+ * Check if span should be ignored based on HTTP path attributes
502
+ *
503
+ * This checks the span's url.path, http.route, or http.target attributes
504
+ * against the configured http.ignore_incoming_paths patterns.
505
+ *
506
+ * This enables filtering of Effect HTTP spans (and any other HTTP spans)
507
+ * based on path patterns, which is essential for filtering out OTLP
508
+ * endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
509
+ */
510
+ shouldIgnoreHttpSpan(span) {
511
+ if (this.httpIgnorePatterns.length === 0) {
512
+ return false;
513
+ }
514
+ const urlPath = span.attributes["url.path"];
515
+ const httpRoute = span.attributes["http.route"];
516
+ const httpTarget = span.attributes["http.target"];
517
+ const pathToCheck = urlPath || httpRoute || httpTarget;
518
+ if (!pathToCheck) {
519
+ return false;
480
520
  }
521
+ return this.httpIgnorePatterns.some((pattern) => pattern.test(pathToCheck));
481
522
  }
482
523
  /**
483
524
  * Shutdown the processor
@@ -766,6 +807,8 @@ function getDefaultConfig() {
766
807
  ]
767
808
  },
768
809
  effect: {
810
+ enabled: true,
811
+ exporter: "unified",
769
812
  auto_extract_metadata: true
770
813
  }
771
814
  };