@atrim/instrument-node 0.7.0 → 0.7.1-dev.14fdea7.20260108224013

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.
@@ -52,6 +52,69 @@ var AutoIsolationConfigSchema = z.object({
52
52
  add_metadata: z.boolean().default(true)
53
53
  }).default({})
54
54
  });
55
+ var SpanNamingRuleSchema = z.object({
56
+ // Match criteria (all specified criteria must match)
57
+ match: z.object({
58
+ // Regex pattern to match file path
59
+ file: z.string().optional(),
60
+ // Regex pattern to match function name
61
+ function: z.string().optional(),
62
+ // Regex pattern to match module name
63
+ module: z.string().optional()
64
+ }),
65
+ // Span name template with variables:
66
+ // {fiber_id} - Fiber ID
67
+ // {function} - Function name
68
+ // {module} - Module name
69
+ // {file} - File path
70
+ // {line} - Line number
71
+ // {operator} - Effect operator (gen, all, forEach, etc.)
72
+ // {match:field:N} - Captured regex group from match
73
+ name: z.string()
74
+ });
75
+ var AutoInstrumentationConfigSchema = z.object({
76
+ // Enable/disable auto-instrumentation
77
+ enabled: z.boolean().default(false),
78
+ // Tracing granularity
79
+ // - 'fiber': Trace at fiber creation (recommended, lower overhead)
80
+ // - 'operator': Trace each Effect operator (higher granularity, more overhead)
81
+ granularity: z.enum(["fiber", "operator"]).default("fiber"),
82
+ // Smart span naming configuration
83
+ span_naming: z.object({
84
+ // Default span name template when no rules match
85
+ default: z.string().default("effect.fiber.{fiber_id}"),
86
+ // Infer span names from source code (requires stack trace parsing)
87
+ // Adds ~50-100μs overhead per fiber
88
+ infer_from_source: z.boolean().default(true),
89
+ // Naming rules (first match wins)
90
+ rules: z.array(SpanNamingRuleSchema).default([])
91
+ }).default({}),
92
+ // Pattern-based filtering
93
+ filter: z.object({
94
+ // Only trace spans matching these patterns (empty = trace all)
95
+ include: z.array(z.string()).default([]),
96
+ // Never trace spans matching these patterns
97
+ exclude: z.array(z.string()).default([])
98
+ }).default({}),
99
+ // Performance controls
100
+ performance: z.object({
101
+ // Sample rate (0.0 - 1.0)
102
+ sampling_rate: z.number().min(0).max(1).default(1),
103
+ // Skip fibers shorter than this duration (e.g., "10ms", "100 millis")
104
+ min_duration: z.string().default("0ms"),
105
+ // Maximum concurrent traced fibers (0 = unlimited)
106
+ max_concurrent: z.number().default(0)
107
+ }).default({}),
108
+ // Automatic metadata extraction
109
+ metadata: z.object({
110
+ // Extract Effect fiber information
111
+ fiber_info: z.boolean().default(true),
112
+ // Extract source location (file:line)
113
+ source_location: z.boolean().default(true),
114
+ // Extract parent fiber information
115
+ parent_fiber: z.boolean().default(true)
116
+ }).default({})
117
+ });
55
118
  var HttpFilteringConfigSchema = z.object({
56
119
  // Patterns to ignore for outgoing HTTP requests (string patterns only in YAML)
57
120
  ignore_outgoing_urls: z.array(z.string()).optional(),
@@ -73,6 +136,30 @@ var HttpFilteringConfigSchema = z.object({
73
136
  include_urls: z.array(z.string()).optional()
74
137
  }).optional()
75
138
  });
139
+ var ExporterConfigSchema = z.object({
140
+ // Exporter type: 'otlp' | 'console' | 'none'
141
+ // - 'otlp': Export to OTLP endpoint (production)
142
+ // - 'console': Log spans to console (development)
143
+ // - 'none': No export (disable tracing)
144
+ type: z.enum(["otlp", "console", "none"]).default("otlp"),
145
+ // OTLP endpoint URL (for type: otlp)
146
+ // Defaults to OTEL_EXPORTER_OTLP_ENDPOINT env var or http://localhost:4318
147
+ endpoint: z.string().optional(),
148
+ // Custom headers to send with OTLP requests (for type: otlp)
149
+ // Useful for authentication (x-api-key, Authorization, etc.)
150
+ headers: z.record(z.string()).optional(),
151
+ // Span processor type
152
+ // - 'batch': Batch spans for export (production, lower overhead)
153
+ // - 'simple': Export immediately (development, no batching delay)
154
+ processor: z.enum(["batch", "simple"]).default("batch"),
155
+ // Batch processor settings (for processor: batch)
156
+ batch: z.object({
157
+ // Max time to wait before exporting (milliseconds)
158
+ scheduled_delay_millis: z.number().default(1e3),
159
+ // Max batch size
160
+ max_export_batch_size: z.number().default(100)
161
+ }).optional()
162
+ });
76
163
  var InstrumentationConfigSchema = z.object({
77
164
  version: z.string(),
78
165
  instrumentation: z.object({
@@ -86,12 +173,16 @@ var InstrumentationConfigSchema = z.object({
86
173
  // Enable/disable Effect tracing entirely
87
174
  // When false, EffectInstrumentationLive returns Layer.empty
88
175
  enabled: z.boolean().default(true),
89
- // Exporter mode:
176
+ // Exporter mode (legacy - use exporter.type instead):
90
177
  // - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
91
178
  // - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
92
179
  exporter: z.enum(["unified", "standalone"]).default("unified"),
180
+ // Exporter configuration (for auto-instrumentation)
181
+ exporter_config: ExporterConfigSchema.optional(),
93
182
  auto_extract_metadata: z.boolean(),
94
- auto_isolation: AutoIsolationConfigSchema.optional()
183
+ auto_isolation: AutoIsolationConfigSchema.optional(),
184
+ // Auto-instrumentation: automatic tracing of all Effect fibers
185
+ auto_instrumentation: AutoInstrumentationConfigSchema.optional()
95
186
  }).optional(),
96
187
  http: HttpFilteringConfigSchema.optional()
97
188
  });