@atrim/instrument-node 0.5.2-dev.ac2fbfe.20251221205322 → 0.6.0
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/README.md +92 -330
- package/package.json +17 -16
- package/target/dist/index.cjs +135 -59
- package/target/dist/index.cjs.map +1 -1
- package/target/dist/index.d.cts +28 -13
- package/target/dist/index.d.ts +28 -13
- package/target/dist/index.js +134 -59
- package/target/dist/index.js.map +1 -1
- package/target/dist/integrations/effect/index.cjs +139 -128
- package/target/dist/integrations/effect/index.cjs.map +1 -1
- package/target/dist/integrations/effect/index.d.cts +19 -24
- package/target/dist/integrations/effect/index.d.ts +19 -24
- package/target/dist/integrations/effect/index.js +140 -131
- package/target/dist/integrations/effect/index.js.map +1 -1
package/target/dist/index.d.cts
CHANGED
|
@@ -46,35 +46,33 @@ declare function createOtlpExporter(options?: OtlpExporterOptions): OTLPTraceExp
|
|
|
46
46
|
declare function getOtlpEndpoint(options?: OtlpExporterOptions): string;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* Node.js configuration loader
|
|
49
|
+
* Node.js configuration loader
|
|
50
50
|
*
|
|
51
|
-
* Provides
|
|
51
|
+
* Provides configuration loading using native Node.js APIs (fs, fetch)
|
|
52
|
+
* This module doesn't require Effect Platform, making it work without Effect installed.
|
|
52
53
|
*/
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
declare function _resetConfigLoaderCache(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Load configuration from URI (Promise-based convenience API)
|
|
61
|
-
*
|
|
62
|
-
* Automatically provides Node.js platform layers (FileSystem + HttpClient)
|
|
56
|
+
* Load configuration from URI (file path or URL)
|
|
63
57
|
*
|
|
64
58
|
* @param uri - Configuration URI (file://, http://, https://, or relative path)
|
|
65
|
-
* @param options - Optional loading options (e.g., to disable caching)
|
|
66
59
|
* @returns Promise that resolves to validated configuration
|
|
67
60
|
*/
|
|
68
|
-
declare function loadConfig(uri: string,
|
|
61
|
+
declare function loadConfig(uri: string, _options?: {
|
|
69
62
|
cacheTimeout?: number;
|
|
70
63
|
}): Promise<InstrumentationConfig>;
|
|
71
64
|
/**
|
|
72
|
-
* Load configuration from inline content
|
|
65
|
+
* Load configuration from inline content
|
|
73
66
|
*
|
|
74
67
|
* @param content - YAML string, JSON string, or plain object
|
|
75
68
|
* @returns Promise that resolves to validated configuration
|
|
76
69
|
*/
|
|
77
70
|
declare function loadConfigFromInline(content: string | unknown): Promise<InstrumentationConfig>;
|
|
71
|
+
/**
|
|
72
|
+
* Reset the config loader cache (no-op for native implementation)
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
declare function _resetConfigLoaderCache(): void;
|
|
78
76
|
/**
|
|
79
77
|
* Legacy options interface for backward compatibility
|
|
80
78
|
*/
|
|
@@ -548,6 +546,10 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
548
546
|
* This processor filters spans based on configured patterns before they are exported.
|
|
549
547
|
* It wraps another processor (typically BatchSpanProcessor) and only forwards spans
|
|
550
548
|
* that match the instrumentation patterns.
|
|
549
|
+
*
|
|
550
|
+
* Filtering is applied at two levels:
|
|
551
|
+
* 1. Span name patterns (instrument_patterns / ignore_patterns)
|
|
552
|
+
* 2. HTTP path patterns (http.ignore_incoming_paths) - for HTTP spans
|
|
551
553
|
*/
|
|
552
554
|
|
|
553
555
|
/**
|
|
@@ -570,6 +572,7 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
570
572
|
declare class PatternSpanProcessor implements SpanProcessor {
|
|
571
573
|
private matcher;
|
|
572
574
|
private wrappedProcessor;
|
|
575
|
+
private httpIgnorePatterns;
|
|
573
576
|
constructor(config: InstrumentationConfig, wrappedProcessor: SpanProcessor);
|
|
574
577
|
/**
|
|
575
578
|
* Called when a span is started
|
|
@@ -582,8 +585,20 @@ declare class PatternSpanProcessor implements SpanProcessor {
|
|
|
582
585
|
* Called when a span is ended
|
|
583
586
|
*
|
|
584
587
|
* This is where we make the final decision on whether to export the span.
|
|
588
|
+
* We check both span name patterns and HTTP path patterns.
|
|
585
589
|
*/
|
|
586
590
|
onEnd(span: ReadableSpan): void;
|
|
591
|
+
/**
|
|
592
|
+
* Check if span should be ignored based on HTTP path attributes
|
|
593
|
+
*
|
|
594
|
+
* This checks the span's url.path, http.route, or http.target attributes
|
|
595
|
+
* against the configured http.ignore_incoming_paths patterns.
|
|
596
|
+
*
|
|
597
|
+
* This enables filtering of Effect HTTP spans (and any other HTTP spans)
|
|
598
|
+
* based on path patterns, which is essential for filtering out OTLP
|
|
599
|
+
* endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
|
|
600
|
+
*/
|
|
601
|
+
private shouldIgnoreHttpSpan;
|
|
587
602
|
/**
|
|
588
603
|
* Shutdown the processor
|
|
589
604
|
*/
|
package/target/dist/index.d.ts
CHANGED
|
@@ -46,35 +46,33 @@ declare function createOtlpExporter(options?: OtlpExporterOptions): OTLPTraceExp
|
|
|
46
46
|
declare function getOtlpEndpoint(options?: OtlpExporterOptions): string;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* Node.js configuration loader
|
|
49
|
+
* Node.js configuration loader
|
|
50
50
|
*
|
|
51
|
-
* Provides
|
|
51
|
+
* Provides configuration loading using native Node.js APIs (fs, fetch)
|
|
52
|
+
* This module doesn't require Effect Platform, making it work without Effect installed.
|
|
52
53
|
*/
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
declare function _resetConfigLoaderCache(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Load configuration from URI (Promise-based convenience API)
|
|
61
|
-
*
|
|
62
|
-
* Automatically provides Node.js platform layers (FileSystem + HttpClient)
|
|
56
|
+
* Load configuration from URI (file path or URL)
|
|
63
57
|
*
|
|
64
58
|
* @param uri - Configuration URI (file://, http://, https://, or relative path)
|
|
65
|
-
* @param options - Optional loading options (e.g., to disable caching)
|
|
66
59
|
* @returns Promise that resolves to validated configuration
|
|
67
60
|
*/
|
|
68
|
-
declare function loadConfig(uri: string,
|
|
61
|
+
declare function loadConfig(uri: string, _options?: {
|
|
69
62
|
cacheTimeout?: number;
|
|
70
63
|
}): Promise<InstrumentationConfig>;
|
|
71
64
|
/**
|
|
72
|
-
* Load configuration from inline content
|
|
65
|
+
* Load configuration from inline content
|
|
73
66
|
*
|
|
74
67
|
* @param content - YAML string, JSON string, or plain object
|
|
75
68
|
* @returns Promise that resolves to validated configuration
|
|
76
69
|
*/
|
|
77
70
|
declare function loadConfigFromInline(content: string | unknown): Promise<InstrumentationConfig>;
|
|
71
|
+
/**
|
|
72
|
+
* Reset the config loader cache (no-op for native implementation)
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
declare function _resetConfigLoaderCache(): void;
|
|
78
76
|
/**
|
|
79
77
|
* Legacy options interface for backward compatibility
|
|
80
78
|
*/
|
|
@@ -548,6 +546,10 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
548
546
|
* This processor filters spans based on configured patterns before they are exported.
|
|
549
547
|
* It wraps another processor (typically BatchSpanProcessor) and only forwards spans
|
|
550
548
|
* that match the instrumentation patterns.
|
|
549
|
+
*
|
|
550
|
+
* Filtering is applied at two levels:
|
|
551
|
+
* 1. Span name patterns (instrument_patterns / ignore_patterns)
|
|
552
|
+
* 2. HTTP path patterns (http.ignore_incoming_paths) - for HTTP spans
|
|
551
553
|
*/
|
|
552
554
|
|
|
553
555
|
/**
|
|
@@ -570,6 +572,7 @@ declare function getServiceVersionAsync(): Promise<string | undefined>;
|
|
|
570
572
|
declare class PatternSpanProcessor implements SpanProcessor {
|
|
571
573
|
private matcher;
|
|
572
574
|
private wrappedProcessor;
|
|
575
|
+
private httpIgnorePatterns;
|
|
573
576
|
constructor(config: InstrumentationConfig, wrappedProcessor: SpanProcessor);
|
|
574
577
|
/**
|
|
575
578
|
* Called when a span is started
|
|
@@ -582,8 +585,20 @@ declare class PatternSpanProcessor implements SpanProcessor {
|
|
|
582
585
|
* Called when a span is ended
|
|
583
586
|
*
|
|
584
587
|
* This is where we make the final decision on whether to export the span.
|
|
588
|
+
* We check both span name patterns and HTTP path patterns.
|
|
585
589
|
*/
|
|
586
590
|
onEnd(span: ReadableSpan): void;
|
|
591
|
+
/**
|
|
592
|
+
* Check if span should be ignored based on HTTP path attributes
|
|
593
|
+
*
|
|
594
|
+
* This checks the span's url.path, http.route, or http.target attributes
|
|
595
|
+
* against the configured http.ignore_incoming_paths patterns.
|
|
596
|
+
*
|
|
597
|
+
* This enables filtering of Effect HTTP spans (and any other HTTP spans)
|
|
598
|
+
* based on path patterns, which is essential for filtering out OTLP
|
|
599
|
+
* endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
|
|
600
|
+
*/
|
|
601
|
+
private shouldIgnoreHttpSpan;
|
|
587
602
|
/**
|
|
588
603
|
* Shutdown the processor
|
|
589
604
|
*/
|
package/target/dist/index.js
CHANGED
|
@@ -11,8 +11,7 @@ import { z } from 'zod';
|
|
|
11
11
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
12
12
|
import { readFile } from 'fs/promises';
|
|
13
13
|
import { join } from 'path';
|
|
14
|
-
import {
|
|
15
|
-
import { FetchHttpClient } from '@effect/platform';
|
|
14
|
+
import { createRequire } from 'module';
|
|
16
15
|
|
|
17
16
|
var __defProp = Object.defineProperty;
|
|
18
17
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -84,11 +83,50 @@ var InstrumentationConfigSchema = z.object({
|
|
|
84
83
|
ignore_patterns: z.array(PatternConfigSchema)
|
|
85
84
|
}),
|
|
86
85
|
effect: z.object({
|
|
86
|
+
// Enable/disable Effect tracing entirely
|
|
87
|
+
// When false, EffectInstrumentationLive returns Layer.empty
|
|
88
|
+
enabled: z.boolean().default(true),
|
|
89
|
+
// Exporter mode:
|
|
90
|
+
// - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
|
|
91
|
+
// - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
|
|
92
|
+
exporter: z.enum(["unified", "standalone"]).default("unified"),
|
|
87
93
|
auto_extract_metadata: z.boolean(),
|
|
88
94
|
auto_isolation: AutoIsolationConfigSchema.optional()
|
|
89
95
|
}).optional(),
|
|
90
96
|
http: HttpFilteringConfigSchema.optional()
|
|
91
97
|
});
|
|
98
|
+
var defaultConfig = {
|
|
99
|
+
version: "1.0",
|
|
100
|
+
instrumentation: {
|
|
101
|
+
enabled: true,
|
|
102
|
+
logging: "on",
|
|
103
|
+
description: "Default instrumentation configuration",
|
|
104
|
+
instrument_patterns: [
|
|
105
|
+
{ pattern: "^app\\.", enabled: true, description: "Application operations" },
|
|
106
|
+
{ pattern: "^http\\.server\\.", enabled: true, description: "HTTP server operations" },
|
|
107
|
+
{ pattern: "^http\\.client\\.", enabled: true, description: "HTTP client operations" }
|
|
108
|
+
],
|
|
109
|
+
ignore_patterns: [
|
|
110
|
+
{ pattern: "^test\\.", description: "Test utilities" },
|
|
111
|
+
{ pattern: "^internal\\.", description: "Internal operations" },
|
|
112
|
+
{ pattern: "^health\\.", description: "Health checks" }
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
effect: {
|
|
116
|
+
enabled: true,
|
|
117
|
+
exporter: "unified",
|
|
118
|
+
auto_extract_metadata: true
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
function parseAndValidateConfig(content) {
|
|
122
|
+
let parsed;
|
|
123
|
+
if (typeof content === "string") {
|
|
124
|
+
parsed = parse(content);
|
|
125
|
+
} else {
|
|
126
|
+
parsed = content;
|
|
127
|
+
}
|
|
128
|
+
return InstrumentationConfigSchema.parse(parsed);
|
|
129
|
+
}
|
|
92
130
|
(class extends Data.TaggedError("ConfigError") {
|
|
93
131
|
get message() {
|
|
94
132
|
return this.reason;
|
|
@@ -266,7 +304,7 @@ var makeConfigLoader = Effect.gen(function* () {
|
|
|
266
304
|
})
|
|
267
305
|
});
|
|
268
306
|
});
|
|
269
|
-
|
|
307
|
+
Layer.effect(ConfigLoader, makeConfigLoader);
|
|
270
308
|
var PatternMatcher = class {
|
|
271
309
|
constructor(config) {
|
|
272
310
|
__publicField2(this, "ignorePatterns", []);
|
|
@@ -430,8 +468,14 @@ var PatternSpanProcessor = class {
|
|
|
430
468
|
constructor(config, wrappedProcessor) {
|
|
431
469
|
__publicField(this, "matcher");
|
|
432
470
|
__publicField(this, "wrappedProcessor");
|
|
471
|
+
__publicField(this, "httpIgnorePatterns", []);
|
|
433
472
|
this.matcher = new PatternMatcher(config);
|
|
434
473
|
this.wrappedProcessor = wrappedProcessor;
|
|
474
|
+
if (config.http?.ignore_incoming_paths) {
|
|
475
|
+
this.httpIgnorePatterns = config.http.ignore_incoming_paths.map(
|
|
476
|
+
(pattern) => new RegExp(pattern)
|
|
477
|
+
);
|
|
478
|
+
}
|
|
435
479
|
}
|
|
436
480
|
/**
|
|
437
481
|
* Called when a span is started
|
|
@@ -449,12 +493,40 @@ var PatternSpanProcessor = class {
|
|
|
449
493
|
* Called when a span is ended
|
|
450
494
|
*
|
|
451
495
|
* This is where we make the final decision on whether to export the span.
|
|
496
|
+
* We check both span name patterns and HTTP path patterns.
|
|
452
497
|
*/
|
|
453
498
|
onEnd(span) {
|
|
454
499
|
const spanName = span.name;
|
|
455
|
-
if (this.matcher.shouldInstrument(spanName)) {
|
|
456
|
-
|
|
500
|
+
if (!this.matcher.shouldInstrument(spanName)) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (this.shouldIgnoreHttpSpan(span)) {
|
|
504
|
+
return;
|
|
457
505
|
}
|
|
506
|
+
this.wrappedProcessor.onEnd(span);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Check if span should be ignored based on HTTP path attributes
|
|
510
|
+
*
|
|
511
|
+
* This checks the span's url.path, http.route, or http.target attributes
|
|
512
|
+
* against the configured http.ignore_incoming_paths patterns.
|
|
513
|
+
*
|
|
514
|
+
* This enables filtering of Effect HTTP spans (and any other HTTP spans)
|
|
515
|
+
* based on path patterns, which is essential for filtering out OTLP
|
|
516
|
+
* endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
|
|
517
|
+
*/
|
|
518
|
+
shouldIgnoreHttpSpan(span) {
|
|
519
|
+
if (this.httpIgnorePatterns.length === 0) {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
const urlPath = span.attributes["url.path"];
|
|
523
|
+
const httpRoute = span.attributes["http.route"];
|
|
524
|
+
const httpTarget = span.attributes["http.target"];
|
|
525
|
+
const pathToCheck = urlPath || httpRoute || httpTarget;
|
|
526
|
+
if (!pathToCheck) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
return this.httpIgnorePatterns.some((pattern) => pattern.test(pathToCheck));
|
|
458
530
|
}
|
|
459
531
|
/**
|
|
460
532
|
* Shutdown the processor
|
|
@@ -692,83 +764,55 @@ async function getServiceNameAsync() {
|
|
|
692
764
|
async function getServiceVersionAsync() {
|
|
693
765
|
return Effect.runPromise(getServiceVersion);
|
|
694
766
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
);
|
|
698
|
-
|
|
699
|
-
function getCachedLoader() {
|
|
700
|
-
if (!cachedLoaderPromise) {
|
|
701
|
-
cachedLoaderPromise = Effect.runPromise(
|
|
702
|
-
Effect.gen(function* () {
|
|
703
|
-
return yield* ConfigLoader;
|
|
704
|
-
}).pipe(Effect.provide(NodeConfigLoaderLive))
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
return cachedLoaderPromise;
|
|
767
|
+
async function loadFromFile(filePath) {
|
|
768
|
+
const { readFile: readFile2 } = await import('fs/promises');
|
|
769
|
+
const content = await readFile2(filePath, "utf-8");
|
|
770
|
+
return parseAndValidateConfig(content);
|
|
708
771
|
}
|
|
709
|
-
function
|
|
710
|
-
|
|
772
|
+
async function loadFromUrl(url) {
|
|
773
|
+
const response = await fetch(url);
|
|
774
|
+
if (!response.ok) {
|
|
775
|
+
throw new Error(`Failed to fetch config from ${url}: ${response.statusText}`);
|
|
776
|
+
}
|
|
777
|
+
const content = await response.text();
|
|
778
|
+
return parseAndValidateConfig(content);
|
|
711
779
|
}
|
|
712
|
-
async function loadConfig(uri,
|
|
713
|
-
if (
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
return
|
|
780
|
+
async function loadConfig(uri, _options) {
|
|
781
|
+
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
782
|
+
return loadFromUrl(uri);
|
|
783
|
+
}
|
|
784
|
+
if (uri.startsWith("file://")) {
|
|
785
|
+
const filePath = uri.slice(7);
|
|
786
|
+
return loadFromFile(filePath);
|
|
719
787
|
}
|
|
720
|
-
|
|
721
|
-
return Effect.runPromise(loader.loadFromUri(uri));
|
|
788
|
+
return loadFromFile(uri);
|
|
722
789
|
}
|
|
723
790
|
async function loadConfigFromInline(content) {
|
|
724
|
-
|
|
725
|
-
return Effect.runPromise(loader.loadFromInline(content));
|
|
791
|
+
return parseAndValidateConfig(content);
|
|
726
792
|
}
|
|
727
|
-
function
|
|
728
|
-
return {
|
|
729
|
-
version: "1.0",
|
|
730
|
-
instrumentation: {
|
|
731
|
-
enabled: true,
|
|
732
|
-
logging: "on",
|
|
733
|
-
description: "Default instrumentation configuration",
|
|
734
|
-
instrument_patterns: [
|
|
735
|
-
{ pattern: "^app\\.", enabled: true, description: "Application operations" },
|
|
736
|
-
{ pattern: "^http\\.server\\.", enabled: true, description: "HTTP server operations" },
|
|
737
|
-
{ pattern: "^http\\.client\\.", enabled: true, description: "HTTP client operations" }
|
|
738
|
-
],
|
|
739
|
-
ignore_patterns: [
|
|
740
|
-
{ pattern: "^test\\.", description: "Test utilities" },
|
|
741
|
-
{ pattern: "^internal\\.", description: "Internal operations" },
|
|
742
|
-
{ pattern: "^health\\.", description: "Health checks" }
|
|
743
|
-
]
|
|
744
|
-
},
|
|
745
|
-
effect: {
|
|
746
|
-
auto_extract_metadata: true
|
|
747
|
-
}
|
|
748
|
-
};
|
|
793
|
+
function _resetConfigLoaderCache() {
|
|
749
794
|
}
|
|
750
795
|
async function loadConfigWithOptions(options = {}) {
|
|
751
|
-
const loadOptions = options.cacheTimeout !== void 0 ? { cacheTimeout: options.cacheTimeout } : void 0;
|
|
752
796
|
if (options.config) {
|
|
753
797
|
return loadConfigFromInline(options.config);
|
|
754
798
|
}
|
|
755
799
|
const envConfigPath = process.env.ATRIM_INSTRUMENTATION_CONFIG;
|
|
756
800
|
if (envConfigPath) {
|
|
757
|
-
return loadConfig(envConfigPath
|
|
801
|
+
return loadConfig(envConfigPath);
|
|
758
802
|
}
|
|
759
803
|
if (options.configUrl) {
|
|
760
|
-
return loadConfig(options.configUrl
|
|
804
|
+
return loadConfig(options.configUrl);
|
|
761
805
|
}
|
|
762
806
|
if (options.configPath) {
|
|
763
|
-
return loadConfig(options.configPath
|
|
807
|
+
return loadConfig(options.configPath);
|
|
764
808
|
}
|
|
765
809
|
const { existsSync } = await import('fs');
|
|
766
810
|
const { join: join2 } = await import('path');
|
|
767
811
|
const defaultPath = join2(process.cwd(), "instrumentation.yaml");
|
|
768
812
|
if (existsSync(defaultPath)) {
|
|
769
|
-
return loadConfig(defaultPath
|
|
813
|
+
return loadConfig(defaultPath);
|
|
770
814
|
}
|
|
771
|
-
return
|
|
815
|
+
return defaultConfig;
|
|
772
816
|
}
|
|
773
817
|
|
|
774
818
|
// src/core/sdk-initializer.ts
|
|
@@ -1060,9 +1104,39 @@ function logInitialization(config, serviceName, serviceVersion, options, autoIns
|
|
|
1060
1104
|
logger.log(` - OTLP endpoint: ${endpoint}`);
|
|
1061
1105
|
logger.log("");
|
|
1062
1106
|
}
|
|
1107
|
+
var require2 = createRequire(import.meta.url);
|
|
1108
|
+
function validateOpenTelemetryApi() {
|
|
1109
|
+
try {
|
|
1110
|
+
require2.resolve("@opentelemetry/api");
|
|
1111
|
+
} catch {
|
|
1112
|
+
throw new Error(
|
|
1113
|
+
"@atrim/instrument-node requires @opentelemetry/api as a peer dependency.\n\nInstall it with:\n npm install @opentelemetry/api\n\nOr with your preferred package manager:\n pnpm add @opentelemetry/api\n yarn add @opentelemetry/api\n bun add @opentelemetry/api"
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
function validateEffectDependencies() {
|
|
1118
|
+
const packages = ["effect", "@effect/opentelemetry", "@effect/platform"];
|
|
1119
|
+
for (const pkg of packages) {
|
|
1120
|
+
try {
|
|
1121
|
+
require2.resolve(pkg);
|
|
1122
|
+
} catch {
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
return true;
|
|
1127
|
+
}
|
|
1128
|
+
var validateDependencies = Effect.try({
|
|
1129
|
+
try: () => validateOpenTelemetryApi(),
|
|
1130
|
+
catch: (error) => new InitializationError2({
|
|
1131
|
+
reason: error instanceof Error ? error.message : "Dependency validation failed",
|
|
1132
|
+
cause: error
|
|
1133
|
+
})
|
|
1134
|
+
});
|
|
1135
|
+
Effect.sync(() => validateEffectDependencies());
|
|
1063
1136
|
|
|
1064
1137
|
// src/api.ts
|
|
1065
1138
|
async function initializeInstrumentation(options = {}) {
|
|
1139
|
+
validateOpenTelemetryApi();
|
|
1066
1140
|
const sdk = await initializeSdk(options);
|
|
1067
1141
|
if (sdk) {
|
|
1068
1142
|
const config = await loadConfigWithOptions(options);
|
|
@@ -1079,6 +1153,7 @@ async function initializePatternMatchingOnly(options = {}) {
|
|
|
1079
1153
|
);
|
|
1080
1154
|
}
|
|
1081
1155
|
var initializeInstrumentationEffect = (options = {}) => Effect.gen(function* () {
|
|
1156
|
+
yield* validateDependencies;
|
|
1082
1157
|
const sdk = yield* Effect.tryPromise({
|
|
1083
1158
|
try: () => initializeSdk(options),
|
|
1084
1159
|
catch: (error) => new InitializationError2({
|