@atrim/instrument-node 0.4.0 → 0.5.0-3a3dd2c-20251124202015

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
@@ -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.4.0",
3
+ "version": "0.5.0-3a3dd2c-20251124202015",
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,6 +59,9 @@
54
59
  "LICENSE"
55
60
  ],
56
61
  "dependencies": {
62
+ "@effect/opentelemetry": "^0.59.0",
63
+ "@effect/platform": "^0.93.0",
64
+ "@effect/platform-node": "latest",
57
65
  "@opentelemetry/auto-instrumentations-node": "^0.67.0",
58
66
  "@opentelemetry/exporter-trace-otlp-http": "^0.208.0",
59
67
  "@opentelemetry/instrumentation": "^0.208.0",
@@ -64,8 +72,6 @@
64
72
  "zod": "^3.22.0"
65
73
  },
66
74
  "devDependencies": {
67
- "@effect/opentelemetry": "^0.59.0",
68
- "@effect/platform": "^0.93.0",
69
75
  "@opentelemetry/api": "^1.9.0",
70
76
  "@opentelemetry/resources": "^2.2.0",
71
77
  "@opentelemetry/sdk-logs": "^0.208.0",
@@ -81,7 +87,7 @@
81
87
  "tsx": "^4.7.0",
82
88
  "typescript": "^5.7.2",
83
89
  "vitest": "^4.0.8",
84
- "@atrim/instrument-core": "0.4.0"
90
+ "@atrim/instrument-core": "0.5.0"
85
91
  },
86
92
  "peerDependencies": {
87
93
  "@effect/opentelemetry": ">=0.40.0",
@@ -121,10 +127,10 @@
121
127
  "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
122
128
  "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
123
129
  "clean": "rm -rf target",
124
- "publish:dev:version": "npm version $(git describe --tags --abbrev=0 | sed 's/^v//')-$(git rev-parse --short HEAD)-$(date -u +%Y%m%d%H%M%S) --no-git-tag-version",
130
+ "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",
125
131
  "publish:dev:save": "node -p \"require('./package.json').version\" > .version",
126
- "publish:dev:publish": "pnpm build && npm publish --tag dev --access public",
127
- "publish:dev:reset": "npm version 1.0.0 --no-git-tag-version",
132
+ "publish:dev:publish": "pnpm build && pnpm publish --tag dev --access public --no-git-checks",
133
+ "publish:dev:reset": "pnpm version 0.5.0 --no-git-tag-version",
128
134
  "publish:dev": "pnpm publish:dev:version && pnpm publish:dev:save && pnpm publish:dev:publish && pnpm publish:dev:reset"
129
135
  }
130
136
  }