@atrim/instrument-node 0.5.1-3a86b84-20260105170223 → 0.5.1-dev.14fdea7.20260108232041

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 CHANGED
@@ -80,6 +80,35 @@ const process = Effect.gen(function* () {
80
80
 
81
81
  Available: `annotateUser`, `annotateBatch`, `annotateDataSize`, `annotateLLM`, `annotateQuery`, `annotateHttpRequest`, `annotateError`, `annotatePriority`, `annotateCache`
82
82
 
83
+ ### Effect Fiber Metadata Extraction
84
+
85
+ To add Effect fiber metadata (fiber ID, status, parent span info) to your spans, you must **explicitly call** the enrichment functions:
86
+
87
+ ```typescript
88
+ import { autoEnrichSpan, withAutoEnrichedSpan } from '@atrim/instrument-node/effect'
89
+
90
+ // Option 1: Call autoEnrichSpan() inside a span
91
+ const operation = Effect.gen(function* () {
92
+ yield* autoEnrichSpan() // Adds fiber metadata to current span
93
+ // ... your logic
94
+ }).pipe(Effect.withSpan('app.operation'))
95
+
96
+ // Option 2: Use the convenience wrapper
97
+ const operation = withAutoEnrichedSpan('app.operation')(
98
+ Effect.gen(function* () {
99
+ // ... your logic (fiber metadata added automatically)
100
+ })
101
+ )
102
+ ```
103
+
104
+ **Extracted metadata:**
105
+ - `effect.fiber.id` - Unique fiber thread name
106
+ - `effect.fiber.status` - Current fiber status
107
+ - `effect.operation.root` / `effect.operation.nested` - Operation hierarchy
108
+ - `effect.parent.span.id`, `effect.parent.span.name`, `effect.parent.trace.id` - Parent span info
109
+
110
+ > **Note:** The `auto_extract_metadata` config option is currently not implemented. Metadata extraction requires explicit calls as shown above. See [#issue] for tracking automatic extraction support.
111
+
83
112
  ## Configuration (Optional)
84
113
 
85
114
  Create `instrumentation.yaml` in your project root:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atrim/instrument-node",
3
- "version": "0.5.1-3a86b84-20260105170223",
3
+ "version": "0.5.1-dev.14fdea7.20260108232041",
4
4
  "description": "OpenTelemetry instrumentation for Node.js with centralized YAML configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,6 +43,11 @@
43
43
  "types": "./target/dist/integrations/effect/index.d.ts",
44
44
  "import": "./target/dist/integrations/effect/index.js",
45
45
  "require": "./target/dist/integrations/effect/index.cjs"
46
+ },
47
+ "./effect/auto": {
48
+ "types": "./target/dist/integrations/effect/auto/index.d.ts",
49
+ "import": "./target/dist/integrations/effect/auto/index.js",
50
+ "require": "./target/dist/integrations/effect/auto/index.cjs"
46
51
  }
47
52
  },
48
53
  "main": "./target/dist/index.js",
@@ -54,7 +59,7 @@
54
59
  "LICENSE"
55
60
  ],
56
61
  "dependencies": {
57
- "@opentelemetry/auto-instrumentations-node": "^0.67.0",
62
+ "@opentelemetry/auto-instrumentations-node": "^0.67.3",
58
63
  "@opentelemetry/exporter-trace-otlp-http": "^0.208.0",
59
64
  "@opentelemetry/instrumentation": "^0.208.0",
60
65
  "@opentelemetry/resources": "^2.2.0",
@@ -66,9 +71,9 @@
66
71
  "zod": "^3.22.0"
67
72
  },
68
73
  "devDependencies": {
69
- "@effect/opentelemetry": "^0.59.1",
70
- "@effect/platform": "^0.93.6",
71
- "@effect/platform-node": "^0.103.0",
74
+ "@effect/opentelemetry": "^0.60.0",
75
+ "@effect/platform": "^0.94.1",
76
+ "@effect/platform-node": "^0.104.0",
72
77
  "@opentelemetry/api": "^1.9.0",
73
78
  "@opentelemetry/sdk-logs": "^0.208.0",
74
79
  "@opentelemetry/sdk-metrics": "^2.2.0",
@@ -77,13 +82,13 @@
77
82
  "@opentelemetry/semantic-conventions": "^1.38.0",
78
83
  "@types/node": "^25.0.3",
79
84
  "@vitest/coverage-v8": "^4.0.16",
80
- "effect": "^3.19.8",
85
+ "effect": "^3.19.14",
81
86
  "testcontainers": "^11.11.0",
82
87
  "tsup": "^8.0.1",
83
88
  "tsx": "^4.7.0",
84
89
  "typescript": "^5.7.2",
85
90
  "vitest": "^4.0.16",
86
- "@atrim/instrument-core": "0.5.0"
91
+ "@atrim/instrument-core": "0.6.0"
87
92
  },
88
93
  "peerDependencies": {
89
94
  "@opentelemetry/api": "^1.0.0",
@@ -126,7 +131,7 @@
126
131
  "publish:dev:version": "pnpm version $(node -p \"require('./package.json').version\")-$(git rev-parse --short HEAD)-$(date -u +%Y%m%d%H%M%S) --no-git-tag-version",
127
132
  "publish:dev:save": "node -p \"require('./package.json').version\" > .version",
128
133
  "publish:dev:publish": "pnpm build && pnpm publish --tag dev --access public --no-git-checks",
129
- "publish:dev:reset": "pnpm version 0.5.1 --no-git-tag-version",
134
+ "publish:dev:reset": "pnpm version 0.5.0 --no-git-tag-version",
130
135
  "publish:dev": "pnpm publish:dev:version && pnpm publish:dev:save && pnpm publish:dev:publish && pnpm publish:dev:reset"
131
136
  }
132
137
  }
@@ -76,6 +76,69 @@ var AutoIsolationConfigSchema = zod.z.object({
76
76
  add_metadata: zod.z.boolean().default(true)
77
77
  }).default({})
78
78
  });
79
+ var SpanNamingRuleSchema = zod.z.object({
80
+ // Match criteria (all specified criteria must match)
81
+ match: zod.z.object({
82
+ // Regex pattern to match file path
83
+ file: zod.z.string().optional(),
84
+ // Regex pattern to match function name
85
+ function: zod.z.string().optional(),
86
+ // Regex pattern to match module name
87
+ module: zod.z.string().optional()
88
+ }),
89
+ // Span name template with variables:
90
+ // {fiber_id} - Fiber ID
91
+ // {function} - Function name
92
+ // {module} - Module name
93
+ // {file} - File path
94
+ // {line} - Line number
95
+ // {operator} - Effect operator (gen, all, forEach, etc.)
96
+ // {match:field:N} - Captured regex group from match
97
+ name: zod.z.string()
98
+ });
99
+ var AutoInstrumentationConfigSchema = zod.z.object({
100
+ // Enable/disable auto-instrumentation
101
+ enabled: zod.z.boolean().default(false),
102
+ // Tracing granularity
103
+ // - 'fiber': Trace at fiber creation (recommended, lower overhead)
104
+ // - 'operator': Trace each Effect operator (higher granularity, more overhead)
105
+ granularity: zod.z.enum(["fiber", "operator"]).default("fiber"),
106
+ // Smart span naming configuration
107
+ span_naming: zod.z.object({
108
+ // Default span name template when no rules match
109
+ default: zod.z.string().default("effect.fiber.{fiber_id}"),
110
+ // Infer span names from source code (requires stack trace parsing)
111
+ // Adds ~50-100μs overhead per fiber
112
+ infer_from_source: zod.z.boolean().default(true),
113
+ // Naming rules (first match wins)
114
+ rules: zod.z.array(SpanNamingRuleSchema).default([])
115
+ }).default({}),
116
+ // Pattern-based filtering
117
+ filter: zod.z.object({
118
+ // Only trace spans matching these patterns (empty = trace all)
119
+ include: zod.z.array(zod.z.string()).default([]),
120
+ // Never trace spans matching these patterns
121
+ exclude: zod.z.array(zod.z.string()).default([])
122
+ }).default({}),
123
+ // Performance controls
124
+ performance: zod.z.object({
125
+ // Sample rate (0.0 - 1.0)
126
+ sampling_rate: zod.z.number().min(0).max(1).default(1),
127
+ // Skip fibers shorter than this duration (e.g., "10ms", "100 millis")
128
+ min_duration: zod.z.string().default("0ms"),
129
+ // Maximum concurrent traced fibers (0 = unlimited)
130
+ max_concurrent: zod.z.number().default(0)
131
+ }).default({}),
132
+ // Automatic metadata extraction
133
+ metadata: zod.z.object({
134
+ // Extract Effect fiber information
135
+ fiber_info: zod.z.boolean().default(true),
136
+ // Extract source location (file:line)
137
+ source_location: zod.z.boolean().default(true),
138
+ // Extract parent fiber information
139
+ parent_fiber: zod.z.boolean().default(true)
140
+ }).default({})
141
+ });
79
142
  var HttpFilteringConfigSchema = zod.z.object({
80
143
  // Patterns to ignore for outgoing HTTP requests (string patterns only in YAML)
81
144
  ignore_outgoing_urls: zod.z.array(zod.z.string()).optional(),
@@ -97,6 +160,30 @@ var HttpFilteringConfigSchema = zod.z.object({
97
160
  include_urls: zod.z.array(zod.z.string()).optional()
98
161
  }).optional()
99
162
  });
163
+ var ExporterConfigSchema = zod.z.object({
164
+ // Exporter type: 'otlp' | 'console' | 'none'
165
+ // - 'otlp': Export to OTLP endpoint (production)
166
+ // - 'console': Log spans to console (development)
167
+ // - 'none': No export (disable tracing)
168
+ type: zod.z.enum(["otlp", "console", "none"]).default("otlp"),
169
+ // OTLP endpoint URL (for type: otlp)
170
+ // Defaults to OTEL_EXPORTER_OTLP_ENDPOINT env var or http://localhost:4318
171
+ endpoint: zod.z.string().optional(),
172
+ // Custom headers to send with OTLP requests (for type: otlp)
173
+ // Useful for authentication (x-api-key, Authorization, etc.)
174
+ headers: zod.z.record(zod.z.string()).optional(),
175
+ // Span processor type
176
+ // - 'batch': Batch spans for export (production, lower overhead)
177
+ // - 'simple': Export immediately (development, no batching delay)
178
+ processor: zod.z.enum(["batch", "simple"]).default("batch"),
179
+ // Batch processor settings (for processor: batch)
180
+ batch: zod.z.object({
181
+ // Max time to wait before exporting (milliseconds)
182
+ scheduled_delay_millis: zod.z.number().default(1e3),
183
+ // Max batch size
184
+ max_export_batch_size: zod.z.number().default(100)
185
+ }).optional()
186
+ });
100
187
  var InstrumentationConfigSchema = zod.z.object({
101
188
  version: zod.z.string(),
102
189
  instrumentation: zod.z.object({
@@ -110,12 +197,16 @@ var InstrumentationConfigSchema = zod.z.object({
110
197
  // Enable/disable Effect tracing entirely
111
198
  // When false, EffectInstrumentationLive returns Layer.empty
112
199
  enabled: zod.z.boolean().default(true),
113
- // Exporter mode:
200
+ // Exporter mode (legacy - use exporter.type instead):
114
201
  // - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
115
202
  // - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
116
203
  exporter: zod.z.enum(["unified", "standalone"]).default("unified"),
204
+ // Exporter configuration (for auto-instrumentation)
205
+ exporter_config: ExporterConfigSchema.optional(),
117
206
  auto_extract_metadata: zod.z.boolean(),
118
- auto_isolation: AutoIsolationConfigSchema.optional()
207
+ auto_isolation: AutoIsolationConfigSchema.optional(),
208
+ // Auto-instrumentation: automatic tracing of all Effect fibers
209
+ auto_instrumentation: AutoInstrumentationConfigSchema.optional()
119
210
  }).optional(),
120
211
  http: HttpFilteringConfigSchema.optional()
121
212
  });