@atrim/instrument-node 0.5.1 → 0.5.2-dev.5f953c6.20251221220614
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 +3 -3
- package/target/dist/index.cjs +45 -2
- package/target/dist/index.cjs.map +1 -1
- package/target/dist/index.d.cts +17 -0
- package/target/dist/index.d.ts +17 -0
- package/target/dist/index.js +45 -2
- package/target/dist/index.js.map +1 -1
- package/target/dist/integrations/effect/index.cjs +82 -69
- package/target/dist/integrations/effect/index.cjs.map +1 -1
- package/target/dist/integrations/effect/index.d.cts +16 -22
- package/target/dist/integrations/effect/index.d.ts +16 -22
- package/target/dist/integrations/effect/index.js +82 -71
- package/target/dist/integrations/effect/index.js.map +1 -1
package/target/dist/index.d.cts
CHANGED
|
@@ -548,6 +548,10 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
548
548
|
* This processor filters spans based on configured patterns before they are exported.
|
|
549
549
|
* It wraps another processor (typically BatchSpanProcessor) and only forwards spans
|
|
550
550
|
* that match the instrumentation patterns.
|
|
551
|
+
*
|
|
552
|
+
* Filtering is applied at two levels:
|
|
553
|
+
* 1. Span name patterns (instrument_patterns / ignore_patterns)
|
|
554
|
+
* 2. HTTP path patterns (http.ignore_incoming_paths) - for HTTP spans
|
|
551
555
|
*/
|
|
552
556
|
|
|
553
557
|
/**
|
|
@@ -570,6 +574,7 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
570
574
|
declare class PatternSpanProcessor implements SpanProcessor {
|
|
571
575
|
private matcher;
|
|
572
576
|
private wrappedProcessor;
|
|
577
|
+
private httpIgnorePatterns;
|
|
573
578
|
constructor(config: InstrumentationConfig, wrappedProcessor: SpanProcessor);
|
|
574
579
|
/**
|
|
575
580
|
* Called when a span is started
|
|
@@ -582,8 +587,20 @@ declare class PatternSpanProcessor implements SpanProcessor {
|
|
|
582
587
|
* Called when a span is ended
|
|
583
588
|
*
|
|
584
589
|
* This is where we make the final decision on whether to export the span.
|
|
590
|
+
* We check both span name patterns and HTTP path patterns.
|
|
585
591
|
*/
|
|
586
592
|
onEnd(span: ReadableSpan): void;
|
|
593
|
+
/**
|
|
594
|
+
* Check if span should be ignored based on HTTP path attributes
|
|
595
|
+
*
|
|
596
|
+
* This checks the span's url.path, http.route, or http.target attributes
|
|
597
|
+
* against the configured http.ignore_incoming_paths patterns.
|
|
598
|
+
*
|
|
599
|
+
* This enables filtering of Effect HTTP spans (and any other HTTP spans)
|
|
600
|
+
* based on path patterns, which is essential for filtering out OTLP
|
|
601
|
+
* endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
|
|
602
|
+
*/
|
|
603
|
+
private shouldIgnoreHttpSpan;
|
|
587
604
|
/**
|
|
588
605
|
* Shutdown the processor
|
|
589
606
|
*/
|
package/target/dist/index.d.ts
CHANGED
|
@@ -548,6 +548,10 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
548
548
|
* This processor filters spans based on configured patterns before they are exported.
|
|
549
549
|
* It wraps another processor (typically BatchSpanProcessor) and only forwards spans
|
|
550
550
|
* that match the instrumentation patterns.
|
|
551
|
+
*
|
|
552
|
+
* Filtering is applied at two levels:
|
|
553
|
+
* 1. Span name patterns (instrument_patterns / ignore_patterns)
|
|
554
|
+
* 2. HTTP path patterns (http.ignore_incoming_paths) - for HTTP spans
|
|
551
555
|
*/
|
|
552
556
|
|
|
553
557
|
/**
|
|
@@ -570,6 +574,7 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
570
574
|
declare class PatternSpanProcessor implements SpanProcessor {
|
|
571
575
|
private matcher;
|
|
572
576
|
private wrappedProcessor;
|
|
577
|
+
private httpIgnorePatterns;
|
|
573
578
|
constructor(config: InstrumentationConfig, wrappedProcessor: SpanProcessor);
|
|
574
579
|
/**
|
|
575
580
|
* Called when a span is started
|
|
@@ -582,8 +587,20 @@ declare class PatternSpanProcessor implements SpanProcessor {
|
|
|
582
587
|
* Called when a span is ended
|
|
583
588
|
*
|
|
584
589
|
* This is where we make the final decision on whether to export the span.
|
|
590
|
+
* We check both span name patterns and HTTP path patterns.
|
|
585
591
|
*/
|
|
586
592
|
onEnd(span: ReadableSpan): void;
|
|
593
|
+
/**
|
|
594
|
+
* Check if span should be ignored based on HTTP path attributes
|
|
595
|
+
*
|
|
596
|
+
* This checks the span's url.path, http.route, or http.target attributes
|
|
597
|
+
* against the configured http.ignore_incoming_paths patterns.
|
|
598
|
+
*
|
|
599
|
+
* This enables filtering of Effect HTTP spans (and any other HTTP spans)
|
|
600
|
+
* based on path patterns, which is essential for filtering out OTLP
|
|
601
|
+
* endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
|
|
602
|
+
*/
|
|
603
|
+
private shouldIgnoreHttpSpan;
|
|
587
604
|
/**
|
|
588
605
|
* Shutdown the processor
|
|
589
606
|
*/
|
package/target/dist/index.js
CHANGED
|
@@ -84,6 +84,13 @@ var InstrumentationConfigSchema = z.object({
|
|
|
84
84
|
ignore_patterns: z.array(PatternConfigSchema)
|
|
85
85
|
}),
|
|
86
86
|
effect: z.object({
|
|
87
|
+
// Enable/disable Effect tracing entirely
|
|
88
|
+
// When false, EffectInstrumentationLive returns Layer.empty
|
|
89
|
+
enabled: z.boolean().default(true),
|
|
90
|
+
// Exporter mode:
|
|
91
|
+
// - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
|
|
92
|
+
// - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
|
|
93
|
+
exporter: z.enum(["unified", "standalone"]).default("unified"),
|
|
87
94
|
auto_extract_metadata: z.boolean(),
|
|
88
95
|
auto_isolation: AutoIsolationConfigSchema.optional()
|
|
89
96
|
}).optional(),
|
|
@@ -430,8 +437,14 @@ var PatternSpanProcessor = class {
|
|
|
430
437
|
constructor(config, wrappedProcessor) {
|
|
431
438
|
__publicField(this, "matcher");
|
|
432
439
|
__publicField(this, "wrappedProcessor");
|
|
440
|
+
__publicField(this, "httpIgnorePatterns", []);
|
|
433
441
|
this.matcher = new PatternMatcher(config);
|
|
434
442
|
this.wrappedProcessor = wrappedProcessor;
|
|
443
|
+
if (config.http?.ignore_incoming_paths) {
|
|
444
|
+
this.httpIgnorePatterns = config.http.ignore_incoming_paths.map(
|
|
445
|
+
(pattern) => new RegExp(pattern)
|
|
446
|
+
);
|
|
447
|
+
}
|
|
435
448
|
}
|
|
436
449
|
/**
|
|
437
450
|
* Called when a span is started
|
|
@@ -449,12 +462,40 @@ var PatternSpanProcessor = class {
|
|
|
449
462
|
* Called when a span is ended
|
|
450
463
|
*
|
|
451
464
|
* This is where we make the final decision on whether to export the span.
|
|
465
|
+
* We check both span name patterns and HTTP path patterns.
|
|
452
466
|
*/
|
|
453
467
|
onEnd(span) {
|
|
454
468
|
const spanName = span.name;
|
|
455
|
-
if (this.matcher.shouldInstrument(spanName)) {
|
|
456
|
-
|
|
469
|
+
if (!this.matcher.shouldInstrument(spanName)) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (this.shouldIgnoreHttpSpan(span)) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
this.wrappedProcessor.onEnd(span);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Check if span should be ignored based on HTTP path attributes
|
|
479
|
+
*
|
|
480
|
+
* This checks the span's url.path, http.route, or http.target attributes
|
|
481
|
+
* against the configured http.ignore_incoming_paths patterns.
|
|
482
|
+
*
|
|
483
|
+
* This enables filtering of Effect HTTP spans (and any other HTTP spans)
|
|
484
|
+
* based on path patterns, which is essential for filtering out OTLP
|
|
485
|
+
* endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
|
|
486
|
+
*/
|
|
487
|
+
shouldIgnoreHttpSpan(span) {
|
|
488
|
+
if (this.httpIgnorePatterns.length === 0) {
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
const urlPath = span.attributes["url.path"];
|
|
492
|
+
const httpRoute = span.attributes["http.route"];
|
|
493
|
+
const httpTarget = span.attributes["http.target"];
|
|
494
|
+
const pathToCheck = urlPath || httpRoute || httpTarget;
|
|
495
|
+
if (!pathToCheck) {
|
|
496
|
+
return false;
|
|
457
497
|
}
|
|
498
|
+
return this.httpIgnorePatterns.some((pattern) => pattern.test(pathToCheck));
|
|
458
499
|
}
|
|
459
500
|
/**
|
|
460
501
|
* Shutdown the processor
|
|
@@ -743,6 +784,8 @@ function getDefaultConfig() {
|
|
|
743
784
|
]
|
|
744
785
|
},
|
|
745
786
|
effect: {
|
|
787
|
+
enabled: true,
|
|
788
|
+
exporter: "unified",
|
|
746
789
|
auto_extract_metadata: true
|
|
747
790
|
}
|
|
748
791
|
};
|