@atrim/instrument-node 0.5.0 → 0.5.1
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 +8 -8
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Layer, FiberSet as FiberSet$1
|
|
1
|
+
import { Layer, Effect, FiberSet as FiberSet$1 } from 'effect';
|
|
2
2
|
import { InstrumentationConfig } from '@atrim/instrument-core';
|
|
3
3
|
import * as effect_Runtime from 'effect/Runtime';
|
|
4
4
|
import * as effect_FiberId from 'effect/FiberId';
|
|
@@ -142,23 +142,111 @@ declare const EffectInstrumentationLive: Layer.Layer<never, never, never>;
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Effect-specific span annotation helpers
|
|
145
|
+
*
|
|
146
|
+
* Provides reusable helper functions for adding common span attributes.
|
|
147
|
+
* These helpers follow OpenTelemetry semantic conventions and platform patterns.
|
|
148
|
+
*
|
|
149
|
+
* Usage:
|
|
150
|
+
* ```typescript
|
|
151
|
+
* Effect.gen(function* () {
|
|
152
|
+
* yield* annotateUser(userId, email)
|
|
153
|
+
* yield* annotateBatch(items.length, 5)
|
|
154
|
+
* const results = yield* storage.writeBatch(items)
|
|
155
|
+
* yield* annotateBatch(items.length, 5, results.success, results.failures)
|
|
156
|
+
* }).pipe(Effect.withSpan('storage.writeBatch'))
|
|
157
|
+
* ```
|
|
145
158
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
declare function
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Annotate span with user context
|
|
162
|
+
*
|
|
163
|
+
* @param userId - User identifier
|
|
164
|
+
* @param email - Optional user email
|
|
165
|
+
* @param username - Optional username
|
|
166
|
+
*/
|
|
167
|
+
declare function annotateUser(userId: string, email?: string, username?: string): Effect.Effect<void, never, never>;
|
|
168
|
+
/**
|
|
169
|
+
* Annotate span with data size metrics
|
|
170
|
+
*
|
|
171
|
+
* @param bytes - Total bytes processed
|
|
172
|
+
* @param items - Number of items
|
|
173
|
+
* @param compressionRatio - Optional compression ratio
|
|
174
|
+
*/
|
|
175
|
+
declare function annotateDataSize(bytes: number, items: number, compressionRatio?: number): Effect.Effect<void, never, never>;
|
|
176
|
+
/**
|
|
177
|
+
* Annotate span with batch operation metadata
|
|
178
|
+
*
|
|
179
|
+
* @param totalItems - Total number of items in batch
|
|
180
|
+
* @param batchSize - Size of each batch
|
|
181
|
+
* @param successCount - Optional number of successful items
|
|
182
|
+
* @param failureCount - Optional number of failed items
|
|
183
|
+
*/
|
|
184
|
+
declare function annotateBatch(totalItems: number, batchSize: number, successCount?: number, failureCount?: number): Effect.Effect<void, never, never>;
|
|
185
|
+
/**
|
|
186
|
+
* Annotate span with LLM operation metadata
|
|
187
|
+
*
|
|
188
|
+
* @param model - Model name (e.g., 'gpt-4', 'claude-3-opus')
|
|
189
|
+
* @param provider - LLM provider (e.g., 'openai', 'anthropic')
|
|
190
|
+
* @param tokens - Optional token usage information
|
|
191
|
+
*/
|
|
192
|
+
declare function annotateLLM(model: string, provider: string, tokens?: {
|
|
193
|
+
prompt?: number;
|
|
194
|
+
completion?: number;
|
|
195
|
+
total?: number;
|
|
196
|
+
}): Effect.Effect<void, never, never>;
|
|
197
|
+
/**
|
|
198
|
+
* Annotate span with database query metadata
|
|
199
|
+
*
|
|
200
|
+
* @param query - SQL query or query description
|
|
201
|
+
* @param duration - Optional query duration in milliseconds
|
|
202
|
+
* @param rowCount - Optional number of rows returned/affected
|
|
203
|
+
* @param database - Optional database name
|
|
204
|
+
*/
|
|
205
|
+
declare function annotateQuery(query: string, duration?: number, rowCount?: number, database?: string): Effect.Effect<void, never, never>;
|
|
206
|
+
/**
|
|
207
|
+
* Annotate span with HTTP request metadata
|
|
208
|
+
*
|
|
209
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
210
|
+
* @param url - Request URL
|
|
211
|
+
* @param statusCode - Optional HTTP status code
|
|
212
|
+
* @param contentLength - Optional response content length
|
|
213
|
+
*/
|
|
214
|
+
declare function annotateHttpRequest(method: string, url: string, statusCode?: number, contentLength?: number): Effect.Effect<void, never, never>;
|
|
215
|
+
/**
|
|
216
|
+
* Annotate span with error context
|
|
217
|
+
*
|
|
218
|
+
* @param error - Error object or message
|
|
219
|
+
* @param recoverable - Whether the error is recoverable
|
|
220
|
+
* @param errorType - Optional error type/category
|
|
221
|
+
*/
|
|
222
|
+
declare function annotateError(error: Error | string, recoverable: boolean, errorType?: string): Effect.Effect<void, never, never>;
|
|
223
|
+
/**
|
|
224
|
+
* Annotate span with operation priority
|
|
225
|
+
*
|
|
226
|
+
* @param priority - Priority level (high, medium, low)
|
|
227
|
+
* @param reason - Optional reason for priority level
|
|
228
|
+
*/
|
|
229
|
+
declare function annotatePriority(priority: 'high' | 'medium' | 'low', reason?: string): Effect.Effect<void, never, never>;
|
|
230
|
+
/**
|
|
231
|
+
* Annotate span with cache operation metadata
|
|
232
|
+
*
|
|
233
|
+
* @param hit - Whether the cache was hit
|
|
234
|
+
* @param key - Cache key
|
|
235
|
+
* @param ttl - Optional time-to-live in seconds
|
|
236
|
+
*/
|
|
237
|
+
declare function annotateCache(hit: boolean, key: string, ttl?: number): Effect.Effect<void, never, never>;
|
|
155
238
|
|
|
156
239
|
/**
|
|
157
240
|
* Effect metadata extraction
|
|
158
241
|
*
|
|
159
242
|
* Automatically extracts metadata from Effect fibers and adds them as span attributes.
|
|
160
243
|
* This provides valuable context about the Effect execution environment.
|
|
244
|
+
*
|
|
245
|
+
* Uses Effect's public APIs:
|
|
246
|
+
* - Fiber.getCurrentFiber() - Get current fiber information
|
|
247
|
+
* - Effect.currentSpan - Detect parent spans and nesting
|
|
161
248
|
*/
|
|
249
|
+
|
|
162
250
|
/**
|
|
163
251
|
* Metadata extracted from Effect fibers
|
|
164
252
|
*/
|
|
@@ -166,8 +254,95 @@ interface EffectMetadata {
|
|
|
166
254
|
'effect.fiber.id'?: string;
|
|
167
255
|
'effect.fiber.status'?: string;
|
|
168
256
|
'effect.operation.root'?: boolean;
|
|
169
|
-
'effect.operation.
|
|
257
|
+
'effect.operation.nested'?: boolean;
|
|
258
|
+
'effect.parent.span.id'?: string;
|
|
259
|
+
'effect.parent.span.name'?: string;
|
|
260
|
+
'effect.parent.trace.id'?: string;
|
|
170
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Extract Effect-native metadata from current execution context
|
|
264
|
+
*
|
|
265
|
+
* Uses Effect's native APIs:
|
|
266
|
+
* - Fiber.getCurrentFiber() - Get current fiber information
|
|
267
|
+
* - Effect.currentSpan - Detect parent spans and nesting
|
|
268
|
+
*
|
|
269
|
+
* @returns Effect that yields extracted metadata
|
|
270
|
+
*/
|
|
271
|
+
declare function extractEffectMetadata(): Effect.Effect<EffectMetadata>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Effect Auto-Enrichment Utilities
|
|
275
|
+
*
|
|
276
|
+
* Provides utilities for automatically extracting and enriching spans with Effect-native metadata.
|
|
277
|
+
*
|
|
278
|
+
* Usage:
|
|
279
|
+
* ```typescript
|
|
280
|
+
* import { autoEnrichSpan, withAutoEnrichedSpan } from '@atrim/instrument-node/effect'
|
|
281
|
+
*
|
|
282
|
+
* // Option 1: Manual enrichment
|
|
283
|
+
* Effect.gen(function* () {
|
|
284
|
+
* yield* autoEnrichSpan() // Auto-add Effect metadata
|
|
285
|
+
* yield* annotateBatch(items.length, 10) // Add custom attributes
|
|
286
|
+
* const result = yield* storage.writeBatch(items)
|
|
287
|
+
* return result
|
|
288
|
+
* }).pipe(Effect.withSpan('storage.writeBatch'))
|
|
289
|
+
*
|
|
290
|
+
* // Option 2: Automatic enrichment wrapper
|
|
291
|
+
* const instrumented = withAutoEnrichedSpan('storage.writeBatch')(
|
|
292
|
+
* Effect.gen(function* () {
|
|
293
|
+
* yield* annotateBatch(items.length, 10)
|
|
294
|
+
* return yield* storage.writeBatch(items)
|
|
295
|
+
* })
|
|
296
|
+
* )
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Auto-enrich the current span with Effect metadata
|
|
302
|
+
*
|
|
303
|
+
* This function should be called within an Effect.withSpan() context.
|
|
304
|
+
* It extracts Effect metadata (fiber ID, status, parent span info)
|
|
305
|
+
* and adds it as span attributes.
|
|
306
|
+
*
|
|
307
|
+
* Best practice: Call this at the start of your instrumented Effect:
|
|
308
|
+
*
|
|
309
|
+
* ```typescript
|
|
310
|
+
* Effect.gen(function* () {
|
|
311
|
+
* yield* autoEnrichSpan() // Auto-add metadata
|
|
312
|
+
* yield* annotateBatch(items.length, 10) // Add custom attributes
|
|
313
|
+
* const result = yield* storage.writeBatch(items)
|
|
314
|
+
* return result
|
|
315
|
+
* }).pipe(Effect.withSpan('storage.writeBatch'))
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* @returns Effect that annotates the current span with Effect metadata
|
|
319
|
+
*/
|
|
320
|
+
declare function autoEnrichSpan(): Effect.Effect<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Create a wrapper that combines Effect.withSpan with automatic enrichment
|
|
323
|
+
*
|
|
324
|
+
* This is a convenience function that wraps an Effect with both:
|
|
325
|
+
* 1. A span (via Effect.withSpan)
|
|
326
|
+
* 2. Automatic metadata extraction (via autoEnrichSpan)
|
|
327
|
+
*
|
|
328
|
+
* Usage:
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const instrumented = withAutoEnrichedSpan('storage.writeBatch')(
|
|
331
|
+
* Effect.gen(function* () {
|
|
332
|
+
* yield* annotateBatch(items.length, 10)
|
|
333
|
+
* return yield* storage.writeBatch(items)
|
|
334
|
+
* })
|
|
335
|
+
* )
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @param spanName - The name of the span
|
|
339
|
+
* @param options - Optional span options
|
|
340
|
+
* @returns Function that wraps an Effect with an auto-enriched span
|
|
341
|
+
*/
|
|
342
|
+
declare function withAutoEnrichedSpan<A, E, R>(spanName: string, options?: {
|
|
343
|
+
readonly attributes?: Record<string, unknown>;
|
|
344
|
+
readonly kind?: 'client' | 'server' | 'producer' | 'consumer' | 'internal';
|
|
345
|
+
}): (self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
171
346
|
|
|
172
347
|
/**
|
|
173
348
|
* Options for span isolation when running effects in FiberSet
|
|
@@ -356,4 +531,4 @@ declare const FiberSet: {
|
|
|
356
531
|
}) => Effect.Effect<RuntimeFiber<A, E>, never, R>;
|
|
357
532
|
};
|
|
358
533
|
|
|
359
|
-
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, createEffectInstrumentation, runIsolated, runWithSpan };
|
|
534
|
+
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata, runIsolated, runWithSpan, withAutoEnrichedSpan };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Layer, FiberSet as FiberSet$1
|
|
1
|
+
import { Layer, Effect, FiberSet as FiberSet$1 } from 'effect';
|
|
2
2
|
import { InstrumentationConfig } from '@atrim/instrument-core';
|
|
3
3
|
import * as effect_Runtime from 'effect/Runtime';
|
|
4
4
|
import * as effect_FiberId from 'effect/FiberId';
|
|
@@ -142,23 +142,111 @@ declare const EffectInstrumentationLive: Layer.Layer<never, never, never>;
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Effect-specific span annotation helpers
|
|
145
|
+
*
|
|
146
|
+
* Provides reusable helper functions for adding common span attributes.
|
|
147
|
+
* These helpers follow OpenTelemetry semantic conventions and platform patterns.
|
|
148
|
+
*
|
|
149
|
+
* Usage:
|
|
150
|
+
* ```typescript
|
|
151
|
+
* Effect.gen(function* () {
|
|
152
|
+
* yield* annotateUser(userId, email)
|
|
153
|
+
* yield* annotateBatch(items.length, 5)
|
|
154
|
+
* const results = yield* storage.writeBatch(items)
|
|
155
|
+
* yield* annotateBatch(items.length, 5, results.success, results.failures)
|
|
156
|
+
* }).pipe(Effect.withSpan('storage.writeBatch'))
|
|
157
|
+
* ```
|
|
145
158
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
declare function
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Annotate span with user context
|
|
162
|
+
*
|
|
163
|
+
* @param userId - User identifier
|
|
164
|
+
* @param email - Optional user email
|
|
165
|
+
* @param username - Optional username
|
|
166
|
+
*/
|
|
167
|
+
declare function annotateUser(userId: string, email?: string, username?: string): Effect.Effect<void, never, never>;
|
|
168
|
+
/**
|
|
169
|
+
* Annotate span with data size metrics
|
|
170
|
+
*
|
|
171
|
+
* @param bytes - Total bytes processed
|
|
172
|
+
* @param items - Number of items
|
|
173
|
+
* @param compressionRatio - Optional compression ratio
|
|
174
|
+
*/
|
|
175
|
+
declare function annotateDataSize(bytes: number, items: number, compressionRatio?: number): Effect.Effect<void, never, never>;
|
|
176
|
+
/**
|
|
177
|
+
* Annotate span with batch operation metadata
|
|
178
|
+
*
|
|
179
|
+
* @param totalItems - Total number of items in batch
|
|
180
|
+
* @param batchSize - Size of each batch
|
|
181
|
+
* @param successCount - Optional number of successful items
|
|
182
|
+
* @param failureCount - Optional number of failed items
|
|
183
|
+
*/
|
|
184
|
+
declare function annotateBatch(totalItems: number, batchSize: number, successCount?: number, failureCount?: number): Effect.Effect<void, never, never>;
|
|
185
|
+
/**
|
|
186
|
+
* Annotate span with LLM operation metadata
|
|
187
|
+
*
|
|
188
|
+
* @param model - Model name (e.g., 'gpt-4', 'claude-3-opus')
|
|
189
|
+
* @param provider - LLM provider (e.g., 'openai', 'anthropic')
|
|
190
|
+
* @param tokens - Optional token usage information
|
|
191
|
+
*/
|
|
192
|
+
declare function annotateLLM(model: string, provider: string, tokens?: {
|
|
193
|
+
prompt?: number;
|
|
194
|
+
completion?: number;
|
|
195
|
+
total?: number;
|
|
196
|
+
}): Effect.Effect<void, never, never>;
|
|
197
|
+
/**
|
|
198
|
+
* Annotate span with database query metadata
|
|
199
|
+
*
|
|
200
|
+
* @param query - SQL query or query description
|
|
201
|
+
* @param duration - Optional query duration in milliseconds
|
|
202
|
+
* @param rowCount - Optional number of rows returned/affected
|
|
203
|
+
* @param database - Optional database name
|
|
204
|
+
*/
|
|
205
|
+
declare function annotateQuery(query: string, duration?: number, rowCount?: number, database?: string): Effect.Effect<void, never, never>;
|
|
206
|
+
/**
|
|
207
|
+
* Annotate span with HTTP request metadata
|
|
208
|
+
*
|
|
209
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
210
|
+
* @param url - Request URL
|
|
211
|
+
* @param statusCode - Optional HTTP status code
|
|
212
|
+
* @param contentLength - Optional response content length
|
|
213
|
+
*/
|
|
214
|
+
declare function annotateHttpRequest(method: string, url: string, statusCode?: number, contentLength?: number): Effect.Effect<void, never, never>;
|
|
215
|
+
/**
|
|
216
|
+
* Annotate span with error context
|
|
217
|
+
*
|
|
218
|
+
* @param error - Error object or message
|
|
219
|
+
* @param recoverable - Whether the error is recoverable
|
|
220
|
+
* @param errorType - Optional error type/category
|
|
221
|
+
*/
|
|
222
|
+
declare function annotateError(error: Error | string, recoverable: boolean, errorType?: string): Effect.Effect<void, never, never>;
|
|
223
|
+
/**
|
|
224
|
+
* Annotate span with operation priority
|
|
225
|
+
*
|
|
226
|
+
* @param priority - Priority level (high, medium, low)
|
|
227
|
+
* @param reason - Optional reason for priority level
|
|
228
|
+
*/
|
|
229
|
+
declare function annotatePriority(priority: 'high' | 'medium' | 'low', reason?: string): Effect.Effect<void, never, never>;
|
|
230
|
+
/**
|
|
231
|
+
* Annotate span with cache operation metadata
|
|
232
|
+
*
|
|
233
|
+
* @param hit - Whether the cache was hit
|
|
234
|
+
* @param key - Cache key
|
|
235
|
+
* @param ttl - Optional time-to-live in seconds
|
|
236
|
+
*/
|
|
237
|
+
declare function annotateCache(hit: boolean, key: string, ttl?: number): Effect.Effect<void, never, never>;
|
|
155
238
|
|
|
156
239
|
/**
|
|
157
240
|
* Effect metadata extraction
|
|
158
241
|
*
|
|
159
242
|
* Automatically extracts metadata from Effect fibers and adds them as span attributes.
|
|
160
243
|
* This provides valuable context about the Effect execution environment.
|
|
244
|
+
*
|
|
245
|
+
* Uses Effect's public APIs:
|
|
246
|
+
* - Fiber.getCurrentFiber() - Get current fiber information
|
|
247
|
+
* - Effect.currentSpan - Detect parent spans and nesting
|
|
161
248
|
*/
|
|
249
|
+
|
|
162
250
|
/**
|
|
163
251
|
* Metadata extracted from Effect fibers
|
|
164
252
|
*/
|
|
@@ -166,8 +254,95 @@ interface EffectMetadata {
|
|
|
166
254
|
'effect.fiber.id'?: string;
|
|
167
255
|
'effect.fiber.status'?: string;
|
|
168
256
|
'effect.operation.root'?: boolean;
|
|
169
|
-
'effect.operation.
|
|
257
|
+
'effect.operation.nested'?: boolean;
|
|
258
|
+
'effect.parent.span.id'?: string;
|
|
259
|
+
'effect.parent.span.name'?: string;
|
|
260
|
+
'effect.parent.trace.id'?: string;
|
|
170
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Extract Effect-native metadata from current execution context
|
|
264
|
+
*
|
|
265
|
+
* Uses Effect's native APIs:
|
|
266
|
+
* - Fiber.getCurrentFiber() - Get current fiber information
|
|
267
|
+
* - Effect.currentSpan - Detect parent spans and nesting
|
|
268
|
+
*
|
|
269
|
+
* @returns Effect that yields extracted metadata
|
|
270
|
+
*/
|
|
271
|
+
declare function extractEffectMetadata(): Effect.Effect<EffectMetadata>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Effect Auto-Enrichment Utilities
|
|
275
|
+
*
|
|
276
|
+
* Provides utilities for automatically extracting and enriching spans with Effect-native metadata.
|
|
277
|
+
*
|
|
278
|
+
* Usage:
|
|
279
|
+
* ```typescript
|
|
280
|
+
* import { autoEnrichSpan, withAutoEnrichedSpan } from '@atrim/instrument-node/effect'
|
|
281
|
+
*
|
|
282
|
+
* // Option 1: Manual enrichment
|
|
283
|
+
* Effect.gen(function* () {
|
|
284
|
+
* yield* autoEnrichSpan() // Auto-add Effect metadata
|
|
285
|
+
* yield* annotateBatch(items.length, 10) // Add custom attributes
|
|
286
|
+
* const result = yield* storage.writeBatch(items)
|
|
287
|
+
* return result
|
|
288
|
+
* }).pipe(Effect.withSpan('storage.writeBatch'))
|
|
289
|
+
*
|
|
290
|
+
* // Option 2: Automatic enrichment wrapper
|
|
291
|
+
* const instrumented = withAutoEnrichedSpan('storage.writeBatch')(
|
|
292
|
+
* Effect.gen(function* () {
|
|
293
|
+
* yield* annotateBatch(items.length, 10)
|
|
294
|
+
* return yield* storage.writeBatch(items)
|
|
295
|
+
* })
|
|
296
|
+
* )
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Auto-enrich the current span with Effect metadata
|
|
302
|
+
*
|
|
303
|
+
* This function should be called within an Effect.withSpan() context.
|
|
304
|
+
* It extracts Effect metadata (fiber ID, status, parent span info)
|
|
305
|
+
* and adds it as span attributes.
|
|
306
|
+
*
|
|
307
|
+
* Best practice: Call this at the start of your instrumented Effect:
|
|
308
|
+
*
|
|
309
|
+
* ```typescript
|
|
310
|
+
* Effect.gen(function* () {
|
|
311
|
+
* yield* autoEnrichSpan() // Auto-add metadata
|
|
312
|
+
* yield* annotateBatch(items.length, 10) // Add custom attributes
|
|
313
|
+
* const result = yield* storage.writeBatch(items)
|
|
314
|
+
* return result
|
|
315
|
+
* }).pipe(Effect.withSpan('storage.writeBatch'))
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* @returns Effect that annotates the current span with Effect metadata
|
|
319
|
+
*/
|
|
320
|
+
declare function autoEnrichSpan(): Effect.Effect<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Create a wrapper that combines Effect.withSpan with automatic enrichment
|
|
323
|
+
*
|
|
324
|
+
* This is a convenience function that wraps an Effect with both:
|
|
325
|
+
* 1. A span (via Effect.withSpan)
|
|
326
|
+
* 2. Automatic metadata extraction (via autoEnrichSpan)
|
|
327
|
+
*
|
|
328
|
+
* Usage:
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const instrumented = withAutoEnrichedSpan('storage.writeBatch')(
|
|
331
|
+
* Effect.gen(function* () {
|
|
332
|
+
* yield* annotateBatch(items.length, 10)
|
|
333
|
+
* return yield* storage.writeBatch(items)
|
|
334
|
+
* })
|
|
335
|
+
* )
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @param spanName - The name of the span
|
|
339
|
+
* @param options - Optional span options
|
|
340
|
+
* @returns Function that wraps an Effect with an auto-enriched span
|
|
341
|
+
*/
|
|
342
|
+
declare function withAutoEnrichedSpan<A, E, R>(spanName: string, options?: {
|
|
343
|
+
readonly attributes?: Record<string, unknown>;
|
|
344
|
+
readonly kind?: 'client' | 'server' | 'producer' | 'consumer' | 'internal';
|
|
345
|
+
}): (self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
171
346
|
|
|
172
347
|
/**
|
|
173
348
|
* Options for span isolation when running effects in FiberSet
|
|
@@ -356,4 +531,4 @@ declare const FiberSet: {
|
|
|
356
531
|
}) => Effect.Effect<RuntimeFiber<A, E>, never, R>;
|
|
357
532
|
};
|
|
358
533
|
|
|
359
|
-
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, createEffectInstrumentation, runIsolated, runWithSpan };
|
|
534
|
+
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata, runIsolated, runWithSpan, withAutoEnrichedSpan };
|