@atrim/instrument-node 0.5.0 → 0.5.1-dev.ac2fbfe.20251221201635
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 +66 -0
- package/package.json +10 -10
- package/target/dist/index.cjs +14 -1
- package/target/dist/index.cjs.map +1 -1
- package/target/dist/index.js +14 -1
- package/target/dist/index.js.map +1 -1
- package/target/dist/integrations/effect/index.cjs +159 -14
- package/target/dist/integrations/effect/index.cjs.map +1 -1
- package/target/dist/integrations/effect/index.d.cts +187 -12
- package/target/dist/integrations/effect/index.d.ts +187 -12
- package/target/dist/integrations/effect/index.js +158 -16
- package/target/dist/integrations/effect/index.js.map +1 -1
package/README.md
CHANGED
|
@@ -161,6 +161,72 @@ const program = Effect.gen(function* () {
|
|
|
161
161
|
await Effect.runPromise(program)
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
+
### Effect-TS Span Annotation Helpers
|
|
165
|
+
|
|
166
|
+
The library provides 9 production-tested annotation helpers for enriching spans with semantic attributes:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { Effect } from 'effect'
|
|
170
|
+
import {
|
|
171
|
+
annotateUser,
|
|
172
|
+
annotateBatch,
|
|
173
|
+
annotateDataSize,
|
|
174
|
+
annotateLLM,
|
|
175
|
+
annotateQuery,
|
|
176
|
+
annotateHttpRequest,
|
|
177
|
+
annotateError,
|
|
178
|
+
annotatePriority,
|
|
179
|
+
annotateCache,
|
|
180
|
+
autoEnrichSpan,
|
|
181
|
+
withAutoEnrichedSpan
|
|
182
|
+
} from '@atrim/instrument-node/effect'
|
|
183
|
+
|
|
184
|
+
// Example: Batch processing with automatic enrichment
|
|
185
|
+
const processBatch = Effect.gen(function* () {
|
|
186
|
+
// Auto-enrich with Effect metadata (fiber ID, status, parent span info)
|
|
187
|
+
yield* autoEnrichSpan()
|
|
188
|
+
|
|
189
|
+
// Add user context
|
|
190
|
+
yield* annotateUser('user-123', 'user@example.com')
|
|
191
|
+
|
|
192
|
+
// Add batch metadata
|
|
193
|
+
yield* annotateBatch(100, 10) // 100 items in batches of 10
|
|
194
|
+
|
|
195
|
+
// Process items
|
|
196
|
+
const results = yield* processItems(items)
|
|
197
|
+
|
|
198
|
+
// Update with results
|
|
199
|
+
yield* annotateBatch(100, 10, results.success, results.failures)
|
|
200
|
+
|
|
201
|
+
return results
|
|
202
|
+
}).pipe(Effect.withSpan('batch.process'))
|
|
203
|
+
|
|
204
|
+
// Or use the convenience wrapper
|
|
205
|
+
const processWithAutoEnrich = withAutoEnrichedSpan('batch.process')(
|
|
206
|
+
Effect.gen(function* () {
|
|
207
|
+
yield* annotateBatch(100, 10)
|
|
208
|
+
return yield* processItems(items)
|
|
209
|
+
})
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Available annotation helpers:**
|
|
214
|
+
- `annotateUser(userId, email?, username?)` - User context
|
|
215
|
+
- `annotateDataSize(bytes, items, compressionRatio?)` - Data size metrics
|
|
216
|
+
- `annotateBatch(totalItems, batchSize, successCount?, failureCount?)` - Batch operations
|
|
217
|
+
- `annotateLLM(model, provider, tokens?)` - LLM operations (GPT, Claude, etc.)
|
|
218
|
+
- `annotateQuery(query, duration?, rowCount?, database?)` - Database queries
|
|
219
|
+
- `annotateHttpRequest(method, url, statusCode?, contentLength?)` - HTTP requests
|
|
220
|
+
- `annotateError(error, recoverable, errorType?)` - Error context
|
|
221
|
+
- `annotatePriority(priority, reason?)` - Operation priority
|
|
222
|
+
- `annotateCache(hit, key, ttl?)` - Cache operations
|
|
223
|
+
|
|
224
|
+
**Auto-enrichment utilities:**
|
|
225
|
+
- `autoEnrichSpan()` - Automatically add Effect metadata (fiber ID, status, parent span info)
|
|
226
|
+
- `withAutoEnrichedSpan(name, options?)` - Wrapper combining `Effect.withSpan()` + auto-enrichment
|
|
227
|
+
|
|
228
|
+
All helpers return `Effect.Effect<void>` and use `Effect.annotateCurrentSpan()` under the hood.
|
|
229
|
+
|
|
164
230
|
### Bun Runtime
|
|
165
231
|
|
|
166
232
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atrim/instrument-node",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1-dev.ac2fbfe.20251221201635",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for Node.js with centralized YAML configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"LICENSE"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@effect/opentelemetry": "^0.59.
|
|
58
|
-
"@effect/platform": "^0.93.
|
|
59
|
-
"@effect/platform-node": "
|
|
57
|
+
"@effect/opentelemetry": "^0.59.1",
|
|
58
|
+
"@effect/platform": "^0.93.6",
|
|
59
|
+
"@effect/platform-node": "^0.103.0",
|
|
60
60
|
"@opentelemetry/auto-instrumentations-node": "^0.67.0",
|
|
61
61
|
"@opentelemetry/exporter-trace-otlp-http": "^0.208.0",
|
|
62
62
|
"@opentelemetry/instrumentation": "^0.208.0",
|
|
63
63
|
"@opentelemetry/sdk-node": "^0.208.0",
|
|
64
64
|
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
65
|
-
"effect": "^3.19.
|
|
65
|
+
"effect": "^3.19.8",
|
|
66
66
|
"yaml": "^2.3.0",
|
|
67
67
|
"zod": "^3.22.0"
|
|
68
68
|
},
|
|
@@ -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": "^
|
|
77
|
+
"@types/node": "^25.0.0",
|
|
78
78
|
"@vitest/coverage-v8": "^4.0.8",
|
|
79
|
-
"effect": "^3.19.
|
|
80
|
-
"testcontainers": "^11.
|
|
79
|
+
"effect": "^3.19.8",
|
|
80
|
+
"testcontainers": "^11.10.0",
|
|
81
81
|
"tsup": "^8.0.1",
|
|
82
82
|
"tsx": "^4.7.0",
|
|
83
83
|
"typescript": "^5.7.2",
|
|
@@ -122,10 +122,10 @@
|
|
|
122
122
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
123
123
|
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
124
124
|
"clean": "rm -rf target",
|
|
125
|
-
"publish:dev:version": "
|
|
125
|
+
"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",
|
|
126
126
|
"publish:dev:save": "node -p \"require('./package.json').version\" > .version",
|
|
127
127
|
"publish:dev:publish": "pnpm build && pnpm publish --tag dev --access public --no-git-checks",
|
|
128
|
-
"publish:dev:reset": "
|
|
128
|
+
"publish:dev:reset": "pnpm version 0.5.0 --no-git-tag-version",
|
|
129
129
|
"publish:dev": "pnpm publish:dev:version && pnpm publish:dev:save && pnpm publish:dev:publish && pnpm publish:dev:reset"
|
|
130
130
|
}
|
|
131
131
|
}
|
package/target/dist/index.cjs
CHANGED
|
@@ -82,7 +82,20 @@ var HttpFilteringConfigSchema = zod.z.object({
|
|
|
82
82
|
// Patterns to ignore for incoming HTTP requests (string patterns only in YAML)
|
|
83
83
|
ignore_incoming_paths: zod.z.array(zod.z.string()).optional(),
|
|
84
84
|
// Require parent span for outgoing requests (prevents root spans for HTTP calls)
|
|
85
|
-
require_parent_for_outgoing_spans: zod.z.boolean().optional()
|
|
85
|
+
require_parent_for_outgoing_spans: zod.z.boolean().optional(),
|
|
86
|
+
// Trace context propagation configuration
|
|
87
|
+
// Controls which cross-origin requests receive W3C Trace Context headers (traceparent, tracestate)
|
|
88
|
+
propagate_trace_context: zod.z.object({
|
|
89
|
+
// Strategy for trace propagation
|
|
90
|
+
// - "all": Propagate to all cross-origin requests (may cause CORS errors)
|
|
91
|
+
// - "none": Never propagate trace headers
|
|
92
|
+
// - "same-origin": Only propagate to same-origin requests (default, safe)
|
|
93
|
+
// - "patterns": Propagate based on include_urls patterns
|
|
94
|
+
strategy: zod.z.enum(["all", "none", "same-origin", "patterns"]).default("same-origin"),
|
|
95
|
+
// URL patterns to include when strategy is "patterns"
|
|
96
|
+
// Supports regex patterns (e.g., "^https://api\\.myapp\\.com")
|
|
97
|
+
include_urls: zod.z.array(zod.z.string()).optional()
|
|
98
|
+
}).optional()
|
|
86
99
|
});
|
|
87
100
|
var InstrumentationConfigSchema = zod.z.object({
|
|
88
101
|
version: zod.z.string(),
|