@atrim/instrument-node 0.5.1-21bb978-20260105202350 → 0.5.1-dev.14fdea7.20260108231120
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 +29 -0
- package/package.json +12 -7
- package/target/dist/index.cjs +94 -9
- package/target/dist/index.cjs.map +1 -1
- package/target/dist/index.js +94 -9
- package/target/dist/index.js.map +1 -1
- package/target/dist/integrations/effect/auto/index.cjs +1181 -0
- package/target/dist/integrations/effect/auto/index.cjs.map +1 -0
- package/target/dist/integrations/effect/auto/index.d.cts +437 -0
- package/target/dist/integrations/effect/auto/index.d.ts +437 -0
- package/target/dist/integrations/effect/auto/index.js +1136 -0
- package/target/dist/integrations/effect/auto/index.js.map +1 -0
- package/target/dist/integrations/effect/index.cjs +94 -63
- package/target/dist/integrations/effect/index.cjs.map +1 -1
- package/target/dist/integrations/effect/index.d.cts +2 -131
- package/target/dist/integrations/effect/index.d.ts +2 -131
- package/target/dist/integrations/effect/index.js +96 -60
- package/target/dist/integrations/effect/index.js.map +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Layer, Effect,
|
|
1
|
+
import { Layer, Effect, FiberSet as FiberSet$1 } from 'effect';
|
|
2
2
|
import * as Tracer from '@effect/opentelemetry/Tracer';
|
|
3
|
-
import { SpanContext } from '@opentelemetry/api';
|
|
4
3
|
import { InstrumentationConfig } from '@atrim/instrument-core';
|
|
5
4
|
import * as effect_Runtime from 'effect/Runtime';
|
|
6
5
|
import * as effect_FiberId from 'effect/FiberId';
|
|
@@ -135,134 +134,6 @@ declare function createEffectInstrumentation(options?: EffectInstrumentationOpti
|
|
|
135
134
|
* ```
|
|
136
135
|
*/
|
|
137
136
|
declare const EffectInstrumentationLive: Layer.Layer<Tracer.OtelTracer, never, never>;
|
|
138
|
-
/**
|
|
139
|
-
* Bridge the current OpenTelemetry span context to Effect's tracer.
|
|
140
|
-
*
|
|
141
|
-
* Use this when running Effect code inside an HTTP handler that was
|
|
142
|
-
* auto-instrumented by OpenTelemetry. This ensures Effect spans become
|
|
143
|
-
* children of the HTTP span rather than starting a new trace.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* // In an Express handler
|
|
148
|
-
* app.get('/api/users', async (req, res) => {
|
|
149
|
-
* const program = fetchUsers().pipe(
|
|
150
|
-
* Effect.withSpan('api.fetchUsers'),
|
|
151
|
-
* withOtelParentSpan, // Bridge to HTTP span
|
|
152
|
-
* Effect.provide(EffectInstrumentationLive)
|
|
153
|
-
* )
|
|
154
|
-
* const result = await Effect.runPromise(program)
|
|
155
|
-
* res.json(result)
|
|
156
|
-
* })
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
|
-
* Without this utility, Effect spans would start a new trace instead of
|
|
160
|
-
* continuing the HTTP request trace, resulting in disconnected spans.
|
|
161
|
-
*
|
|
162
|
-
* @param effect - The Effect to run with the current OTel span as parent
|
|
163
|
-
* @returns The same Effect with OTel parent span context attached
|
|
164
|
-
*/
|
|
165
|
-
declare const withOtelParentSpan: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
166
|
-
/**
|
|
167
|
-
* Create an Effect that gets the current OpenTelemetry span context.
|
|
168
|
-
*
|
|
169
|
-
* This is useful when you need to access the current span context for
|
|
170
|
-
* custom propagation or logging purposes.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```typescript
|
|
174
|
-
* const program = Effect.gen(function* () {
|
|
175
|
-
* const spanContext = yield* getCurrentOtelSpanContext
|
|
176
|
-
* if (spanContext) {
|
|
177
|
-
* console.log('Current trace:', spanContext.traceId)
|
|
178
|
-
* }
|
|
179
|
-
* })
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* @returns Effect that yields the current SpanContext or undefined if none
|
|
183
|
-
*/
|
|
184
|
-
declare const getCurrentOtelSpanContext: Effect.Effect<SpanContext | undefined>;
|
|
185
|
-
/**
|
|
186
|
-
* Create an external span reference from the current OpenTelemetry context.
|
|
187
|
-
*
|
|
188
|
-
* This creates an Effect ExternalSpan that can be used as a parent for
|
|
189
|
-
* Effect spans. Useful when you need more control over span parenting.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```typescript
|
|
193
|
-
* const program = Effect.gen(function* () {
|
|
194
|
-
* const parentSpan = yield* getOtelParentSpan
|
|
195
|
-
* if (parentSpan) {
|
|
196
|
-
* yield* myOperation.pipe(
|
|
197
|
-
* Effect.withSpan('child.operation', { parent: parentSpan })
|
|
198
|
-
* )
|
|
199
|
-
* }
|
|
200
|
-
* })
|
|
201
|
-
* ```
|
|
202
|
-
*
|
|
203
|
-
* @returns Effect that yields an ExternalSpan or undefined if no active span
|
|
204
|
-
*/
|
|
205
|
-
declare const getOtelParentSpan: Effect.Effect<Tracer$1.ExternalSpan | undefined>;
|
|
206
|
-
/**
|
|
207
|
-
* Run an async operation with the current Effect span set as the active OTel span.
|
|
208
|
-
*
|
|
209
|
-
* Use this when calling async code that uses OTel auto-instrumentation
|
|
210
|
-
* (e.g., fetch, database drivers) from within an Effect span. This ensures
|
|
211
|
-
* the auto-instrumented spans become children of the Effect span.
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* const fetchData = Effect.gen(function* () {
|
|
216
|
-
* // This fetch call will have the Effect span as its parent
|
|
217
|
-
* const result = yield* runWithOtelContext(
|
|
218
|
-
* Effect.tryPromise(() => fetch('https://api.example.com/data'))
|
|
219
|
-
* )
|
|
220
|
-
* return result
|
|
221
|
-
* }).pipe(Effect.withSpan('fetch.data'))
|
|
222
|
-
* ```
|
|
223
|
-
*
|
|
224
|
-
* Note: This is most useful when you need OTel auto-instrumentation (HTTP, DB)
|
|
225
|
-
* to see Effect spans as parents. For Effect-only code, this isn't needed.
|
|
226
|
-
*
|
|
227
|
-
* @param effect - The Effect containing async operations with OTel auto-instrumentation
|
|
228
|
-
* @returns The same Effect but with OTel context propagation during execution
|
|
229
|
-
*/
|
|
230
|
-
declare const runWithOtelContext: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
231
|
-
/**
|
|
232
|
-
* Higher-order function to create an Effect that bridges both directions:
|
|
233
|
-
* 1. Captures active OTel span as Effect's parent (OTel → Effect)
|
|
234
|
-
* 2. Sets Effect span as active OTel span during execution (Effect → OTel)
|
|
235
|
-
*
|
|
236
|
-
* This is the recommended way to run Effect code in HTTP handlers when you need
|
|
237
|
-
* full bidirectional tracing with OTel auto-instrumentation.
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* ```typescript
|
|
241
|
-
* // In an Express handler
|
|
242
|
-
* app.get('/api/users', async (req, res) => {
|
|
243
|
-
* const program = Effect.gen(function* () {
|
|
244
|
-
* // Effect spans are children of HTTP request span
|
|
245
|
-
* const users = yield* fetchUsersFromDb()
|
|
246
|
-
*
|
|
247
|
-
* // HTTP client spans (from fetch) are children of Effect span
|
|
248
|
-
* yield* notifyExternalService(users)
|
|
249
|
-
*
|
|
250
|
-
* return users
|
|
251
|
-
* }).pipe(
|
|
252
|
-
* Effect.withSpan('api.getUsers'),
|
|
253
|
-
* withFullOtelBridging, // Bidirectional bridging
|
|
254
|
-
* Effect.provide(EffectInstrumentationLive)
|
|
255
|
-
* )
|
|
256
|
-
*
|
|
257
|
-
* const result = await Effect.runPromise(program)
|
|
258
|
-
* res.json(result)
|
|
259
|
-
* })
|
|
260
|
-
* ```
|
|
261
|
-
*
|
|
262
|
-
* @param effect - The Effect to run with full OTel bridging
|
|
263
|
-
* @returns Effect with bidirectional OTel context bridging
|
|
264
|
-
*/
|
|
265
|
-
declare const withFullOtelBridging: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
266
137
|
|
|
267
138
|
/**
|
|
268
139
|
* Effect-specific span annotation helpers
|
|
@@ -655,4 +526,4 @@ declare const FiberSet: {
|
|
|
655
526
|
}) => Effect.Effect<RuntimeFiber<A, E>, never, R>;
|
|
656
527
|
};
|
|
657
528
|
|
|
658
|
-
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata,
|
|
529
|
+
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata, runIsolated, runWithSpan, withAutoEnrichedSpan };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Layer, Effect,
|
|
1
|
+
import { Layer, Effect, FiberSet as FiberSet$1 } from 'effect';
|
|
2
2
|
import * as Tracer from '@effect/opentelemetry/Tracer';
|
|
3
|
-
import { SpanContext } from '@opentelemetry/api';
|
|
4
3
|
import { InstrumentationConfig } from '@atrim/instrument-core';
|
|
5
4
|
import * as effect_Runtime from 'effect/Runtime';
|
|
6
5
|
import * as effect_FiberId from 'effect/FiberId';
|
|
@@ -135,134 +134,6 @@ declare function createEffectInstrumentation(options?: EffectInstrumentationOpti
|
|
|
135
134
|
* ```
|
|
136
135
|
*/
|
|
137
136
|
declare const EffectInstrumentationLive: Layer.Layer<Tracer.OtelTracer, never, never>;
|
|
138
|
-
/**
|
|
139
|
-
* Bridge the current OpenTelemetry span context to Effect's tracer.
|
|
140
|
-
*
|
|
141
|
-
* Use this when running Effect code inside an HTTP handler that was
|
|
142
|
-
* auto-instrumented by OpenTelemetry. This ensures Effect spans become
|
|
143
|
-
* children of the HTTP span rather than starting a new trace.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* // In an Express handler
|
|
148
|
-
* app.get('/api/users', async (req, res) => {
|
|
149
|
-
* const program = fetchUsers().pipe(
|
|
150
|
-
* Effect.withSpan('api.fetchUsers'),
|
|
151
|
-
* withOtelParentSpan, // Bridge to HTTP span
|
|
152
|
-
* Effect.provide(EffectInstrumentationLive)
|
|
153
|
-
* )
|
|
154
|
-
* const result = await Effect.runPromise(program)
|
|
155
|
-
* res.json(result)
|
|
156
|
-
* })
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
|
-
* Without this utility, Effect spans would start a new trace instead of
|
|
160
|
-
* continuing the HTTP request trace, resulting in disconnected spans.
|
|
161
|
-
*
|
|
162
|
-
* @param effect - The Effect to run with the current OTel span as parent
|
|
163
|
-
* @returns The same Effect with OTel parent span context attached
|
|
164
|
-
*/
|
|
165
|
-
declare const withOtelParentSpan: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
166
|
-
/**
|
|
167
|
-
* Create an Effect that gets the current OpenTelemetry span context.
|
|
168
|
-
*
|
|
169
|
-
* This is useful when you need to access the current span context for
|
|
170
|
-
* custom propagation or logging purposes.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```typescript
|
|
174
|
-
* const program = Effect.gen(function* () {
|
|
175
|
-
* const spanContext = yield* getCurrentOtelSpanContext
|
|
176
|
-
* if (spanContext) {
|
|
177
|
-
* console.log('Current trace:', spanContext.traceId)
|
|
178
|
-
* }
|
|
179
|
-
* })
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* @returns Effect that yields the current SpanContext or undefined if none
|
|
183
|
-
*/
|
|
184
|
-
declare const getCurrentOtelSpanContext: Effect.Effect<SpanContext | undefined>;
|
|
185
|
-
/**
|
|
186
|
-
* Create an external span reference from the current OpenTelemetry context.
|
|
187
|
-
*
|
|
188
|
-
* This creates an Effect ExternalSpan that can be used as a parent for
|
|
189
|
-
* Effect spans. Useful when you need more control over span parenting.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```typescript
|
|
193
|
-
* const program = Effect.gen(function* () {
|
|
194
|
-
* const parentSpan = yield* getOtelParentSpan
|
|
195
|
-
* if (parentSpan) {
|
|
196
|
-
* yield* myOperation.pipe(
|
|
197
|
-
* Effect.withSpan('child.operation', { parent: parentSpan })
|
|
198
|
-
* )
|
|
199
|
-
* }
|
|
200
|
-
* })
|
|
201
|
-
* ```
|
|
202
|
-
*
|
|
203
|
-
* @returns Effect that yields an ExternalSpan or undefined if no active span
|
|
204
|
-
*/
|
|
205
|
-
declare const getOtelParentSpan: Effect.Effect<Tracer$1.ExternalSpan | undefined>;
|
|
206
|
-
/**
|
|
207
|
-
* Run an async operation with the current Effect span set as the active OTel span.
|
|
208
|
-
*
|
|
209
|
-
* Use this when calling async code that uses OTel auto-instrumentation
|
|
210
|
-
* (e.g., fetch, database drivers) from within an Effect span. This ensures
|
|
211
|
-
* the auto-instrumented spans become children of the Effect span.
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* const fetchData = Effect.gen(function* () {
|
|
216
|
-
* // This fetch call will have the Effect span as its parent
|
|
217
|
-
* const result = yield* runWithOtelContext(
|
|
218
|
-
* Effect.tryPromise(() => fetch('https://api.example.com/data'))
|
|
219
|
-
* )
|
|
220
|
-
* return result
|
|
221
|
-
* }).pipe(Effect.withSpan('fetch.data'))
|
|
222
|
-
* ```
|
|
223
|
-
*
|
|
224
|
-
* Note: This is most useful when you need OTel auto-instrumentation (HTTP, DB)
|
|
225
|
-
* to see Effect spans as parents. For Effect-only code, this isn't needed.
|
|
226
|
-
*
|
|
227
|
-
* @param effect - The Effect containing async operations with OTel auto-instrumentation
|
|
228
|
-
* @returns The same Effect but with OTel context propagation during execution
|
|
229
|
-
*/
|
|
230
|
-
declare const runWithOtelContext: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
231
|
-
/**
|
|
232
|
-
* Higher-order function to create an Effect that bridges both directions:
|
|
233
|
-
* 1. Captures active OTel span as Effect's parent (OTel → Effect)
|
|
234
|
-
* 2. Sets Effect span as active OTel span during execution (Effect → OTel)
|
|
235
|
-
*
|
|
236
|
-
* This is the recommended way to run Effect code in HTTP handlers when you need
|
|
237
|
-
* full bidirectional tracing with OTel auto-instrumentation.
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* ```typescript
|
|
241
|
-
* // In an Express handler
|
|
242
|
-
* app.get('/api/users', async (req, res) => {
|
|
243
|
-
* const program = Effect.gen(function* () {
|
|
244
|
-
* // Effect spans are children of HTTP request span
|
|
245
|
-
* const users = yield* fetchUsersFromDb()
|
|
246
|
-
*
|
|
247
|
-
* // HTTP client spans (from fetch) are children of Effect span
|
|
248
|
-
* yield* notifyExternalService(users)
|
|
249
|
-
*
|
|
250
|
-
* return users
|
|
251
|
-
* }).pipe(
|
|
252
|
-
* Effect.withSpan('api.getUsers'),
|
|
253
|
-
* withFullOtelBridging, // Bidirectional bridging
|
|
254
|
-
* Effect.provide(EffectInstrumentationLive)
|
|
255
|
-
* )
|
|
256
|
-
*
|
|
257
|
-
* const result = await Effect.runPromise(program)
|
|
258
|
-
* res.json(result)
|
|
259
|
-
* })
|
|
260
|
-
* ```
|
|
261
|
-
*
|
|
262
|
-
* @param effect - The Effect to run with full OTel bridging
|
|
263
|
-
* @returns Effect with bidirectional OTel context bridging
|
|
264
|
-
*/
|
|
265
|
-
declare const withFullOtelBridging: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
266
137
|
|
|
267
138
|
/**
|
|
268
139
|
* Effect-specific span annotation helpers
|
|
@@ -655,4 +526,4 @@ declare const FiberSet: {
|
|
|
655
526
|
}) => Effect.Effect<RuntimeFiber<A, E>, never, R>;
|
|
656
527
|
};
|
|
657
528
|
|
|
658
|
-
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata,
|
|
529
|
+
export { EffectInstrumentationLive, type EffectMetadata, FiberSet, type IsolationOptions, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata, runIsolated, runWithSpan, withAutoEnrichedSpan };
|
|
@@ -3,7 +3,7 @@ import * as Tracer from '@effect/opentelemetry/Tracer';
|
|
|
3
3
|
import * as Resource from '@effect/opentelemetry/Resource';
|
|
4
4
|
import * as Otlp from '@effect/opentelemetry/Otlp';
|
|
5
5
|
import { FetchHttpClient } from '@effect/platform';
|
|
6
|
-
import { trace, context
|
|
6
|
+
import { TraceFlags, trace, context } from '@opentelemetry/api';
|
|
7
7
|
import { TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_LANGUAGE } from '@opentelemetry/semantic-conventions';
|
|
8
8
|
import { FileSystem } from '@effect/platform/FileSystem';
|
|
9
9
|
import * as HttpClient from '@effect/platform/HttpClient';
|
|
@@ -42,6 +42,69 @@ var AutoIsolationConfigSchema = z.object({
|
|
|
42
42
|
add_metadata: z.boolean().default(true)
|
|
43
43
|
}).default({})
|
|
44
44
|
});
|
|
45
|
+
var SpanNamingRuleSchema = z.object({
|
|
46
|
+
// Match criteria (all specified criteria must match)
|
|
47
|
+
match: z.object({
|
|
48
|
+
// Regex pattern to match file path
|
|
49
|
+
file: z.string().optional(),
|
|
50
|
+
// Regex pattern to match function name
|
|
51
|
+
function: z.string().optional(),
|
|
52
|
+
// Regex pattern to match module name
|
|
53
|
+
module: z.string().optional()
|
|
54
|
+
}),
|
|
55
|
+
// Span name template with variables:
|
|
56
|
+
// {fiber_id} - Fiber ID
|
|
57
|
+
// {function} - Function name
|
|
58
|
+
// {module} - Module name
|
|
59
|
+
// {file} - File path
|
|
60
|
+
// {line} - Line number
|
|
61
|
+
// {operator} - Effect operator (gen, all, forEach, etc.)
|
|
62
|
+
// {match:field:N} - Captured regex group from match
|
|
63
|
+
name: z.string()
|
|
64
|
+
});
|
|
65
|
+
var AutoInstrumentationConfigSchema = z.object({
|
|
66
|
+
// Enable/disable auto-instrumentation
|
|
67
|
+
enabled: z.boolean().default(false),
|
|
68
|
+
// Tracing granularity
|
|
69
|
+
// - 'fiber': Trace at fiber creation (recommended, lower overhead)
|
|
70
|
+
// - 'operator': Trace each Effect operator (higher granularity, more overhead)
|
|
71
|
+
granularity: z.enum(["fiber", "operator"]).default("fiber"),
|
|
72
|
+
// Smart span naming configuration
|
|
73
|
+
span_naming: z.object({
|
|
74
|
+
// Default span name template when no rules match
|
|
75
|
+
default: z.string().default("effect.fiber.{fiber_id}"),
|
|
76
|
+
// Infer span names from source code (requires stack trace parsing)
|
|
77
|
+
// Adds ~50-100μs overhead per fiber
|
|
78
|
+
infer_from_source: z.boolean().default(true),
|
|
79
|
+
// Naming rules (first match wins)
|
|
80
|
+
rules: z.array(SpanNamingRuleSchema).default([])
|
|
81
|
+
}).default({}),
|
|
82
|
+
// Pattern-based filtering
|
|
83
|
+
filter: z.object({
|
|
84
|
+
// Only trace spans matching these patterns (empty = trace all)
|
|
85
|
+
include: z.array(z.string()).default([]),
|
|
86
|
+
// Never trace spans matching these patterns
|
|
87
|
+
exclude: z.array(z.string()).default([])
|
|
88
|
+
}).default({}),
|
|
89
|
+
// Performance controls
|
|
90
|
+
performance: z.object({
|
|
91
|
+
// Sample rate (0.0 - 1.0)
|
|
92
|
+
sampling_rate: z.number().min(0).max(1).default(1),
|
|
93
|
+
// Skip fibers shorter than this duration (e.g., "10ms", "100 millis")
|
|
94
|
+
min_duration: z.string().default("0ms"),
|
|
95
|
+
// Maximum concurrent traced fibers (0 = unlimited)
|
|
96
|
+
max_concurrent: z.number().default(0)
|
|
97
|
+
}).default({}),
|
|
98
|
+
// Automatic metadata extraction
|
|
99
|
+
metadata: z.object({
|
|
100
|
+
// Extract Effect fiber information
|
|
101
|
+
fiber_info: z.boolean().default(true),
|
|
102
|
+
// Extract source location (file:line)
|
|
103
|
+
source_location: z.boolean().default(true),
|
|
104
|
+
// Extract parent fiber information
|
|
105
|
+
parent_fiber: z.boolean().default(true)
|
|
106
|
+
}).default({})
|
|
107
|
+
});
|
|
45
108
|
var HttpFilteringConfigSchema = z.object({
|
|
46
109
|
// Patterns to ignore for outgoing HTTP requests (string patterns only in YAML)
|
|
47
110
|
ignore_outgoing_urls: z.array(z.string()).optional(),
|
|
@@ -63,6 +126,30 @@ var HttpFilteringConfigSchema = z.object({
|
|
|
63
126
|
include_urls: z.array(z.string()).optional()
|
|
64
127
|
}).optional()
|
|
65
128
|
});
|
|
129
|
+
var ExporterConfigSchema = z.object({
|
|
130
|
+
// Exporter type: 'otlp' | 'console' | 'none'
|
|
131
|
+
// - 'otlp': Export to OTLP endpoint (production)
|
|
132
|
+
// - 'console': Log spans to console (development)
|
|
133
|
+
// - 'none': No export (disable tracing)
|
|
134
|
+
type: z.enum(["otlp", "console", "none"]).default("otlp"),
|
|
135
|
+
// OTLP endpoint URL (for type: otlp)
|
|
136
|
+
// Defaults to OTEL_EXPORTER_OTLP_ENDPOINT env var or http://localhost:4318
|
|
137
|
+
endpoint: z.string().optional(),
|
|
138
|
+
// Custom headers to send with OTLP requests (for type: otlp)
|
|
139
|
+
// Useful for authentication (x-api-key, Authorization, etc.)
|
|
140
|
+
headers: z.record(z.string()).optional(),
|
|
141
|
+
// Span processor type
|
|
142
|
+
// - 'batch': Batch spans for export (production, lower overhead)
|
|
143
|
+
// - 'simple': Export immediately (development, no batching delay)
|
|
144
|
+
processor: z.enum(["batch", "simple"]).default("batch"),
|
|
145
|
+
// Batch processor settings (for processor: batch)
|
|
146
|
+
batch: z.object({
|
|
147
|
+
// Max time to wait before exporting (milliseconds)
|
|
148
|
+
scheduled_delay_millis: z.number().default(1e3),
|
|
149
|
+
// Max batch size
|
|
150
|
+
max_export_batch_size: z.number().default(100)
|
|
151
|
+
}).optional()
|
|
152
|
+
});
|
|
66
153
|
var InstrumentationConfigSchema = z.object({
|
|
67
154
|
version: z.string(),
|
|
68
155
|
instrumentation: z.object({
|
|
@@ -76,17 +163,16 @@ var InstrumentationConfigSchema = z.object({
|
|
|
76
163
|
// Enable/disable Effect tracing entirely
|
|
77
164
|
// When false, EffectInstrumentationLive returns Layer.empty
|
|
78
165
|
enabled: z.boolean().default(true),
|
|
79
|
-
// Exporter mode:
|
|
166
|
+
// Exporter mode (legacy - use exporter.type instead):
|
|
80
167
|
// - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
|
|
81
168
|
// - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
|
|
82
169
|
exporter: z.enum(["unified", "standalone"]).default("unified"),
|
|
170
|
+
// Exporter configuration (for auto-instrumentation)
|
|
171
|
+
exporter_config: ExporterConfigSchema.optional(),
|
|
83
172
|
auto_extract_metadata: z.boolean(),
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
// This is essential for proper trace hierarchy when using Effect with HTTP frameworks
|
|
88
|
-
auto_bridge_context: z.boolean().default(true),
|
|
89
|
-
auto_isolation: AutoIsolationConfigSchema.optional()
|
|
173
|
+
auto_isolation: AutoIsolationConfigSchema.optional(),
|
|
174
|
+
// Auto-instrumentation: automatic tracing of all Effect fibers
|
|
175
|
+
auto_instrumentation: AutoInstrumentationConfigSchema.optional()
|
|
90
176
|
}).optional(),
|
|
91
177
|
http: HttpFilteringConfigSchema.optional()
|
|
92
178
|
});
|
|
@@ -110,8 +196,7 @@ var defaultConfig = {
|
|
|
110
196
|
effect: {
|
|
111
197
|
enabled: true,
|
|
112
198
|
exporter: "unified",
|
|
113
|
-
auto_extract_metadata: true
|
|
114
|
-
auto_bridge_context: true
|
|
199
|
+
auto_extract_metadata: true
|
|
115
200
|
}
|
|
116
201
|
};
|
|
117
202
|
function parseAndValidateConfig(content) {
|
|
@@ -594,55 +679,6 @@ var EffectInstrumentationLive = Effect.sync(() => {
|
|
|
594
679
|
)
|
|
595
680
|
);
|
|
596
681
|
}).pipe(Layer.unwrapEffect);
|
|
597
|
-
var withOtelParentSpan = (effect) => {
|
|
598
|
-
const currentSpan = trace.getSpan(context.active());
|
|
599
|
-
if (currentSpan) {
|
|
600
|
-
const spanContext = currentSpan.spanContext();
|
|
601
|
-
return Tracer.withSpanContext(spanContext)(effect);
|
|
602
|
-
}
|
|
603
|
-
return effect;
|
|
604
|
-
};
|
|
605
|
-
var getCurrentOtelSpanContext = Effect.sync(() => {
|
|
606
|
-
const currentSpan = trace.getSpan(context.active());
|
|
607
|
-
return currentSpan?.spanContext();
|
|
608
|
-
});
|
|
609
|
-
var getOtelParentSpan = Effect.sync(
|
|
610
|
-
() => {
|
|
611
|
-
const currentSpan = trace.getSpan(context.active());
|
|
612
|
-
if (!currentSpan) {
|
|
613
|
-
return void 0;
|
|
614
|
-
}
|
|
615
|
-
const spanContext = currentSpan.spanContext();
|
|
616
|
-
return Tracer.makeExternalSpan({
|
|
617
|
-
traceId: spanContext.traceId,
|
|
618
|
-
spanId: spanContext.spanId,
|
|
619
|
-
traceFlags: spanContext.traceFlags,
|
|
620
|
-
traceState: spanContext.traceState?.serialize()
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
);
|
|
624
|
-
var runWithOtelContext = (effect) => {
|
|
625
|
-
return Effect.flatMap(
|
|
626
|
-
Tracer.currentOtelSpan,
|
|
627
|
-
(otelSpan) => Effect.async((resume) => {
|
|
628
|
-
context.with(trace.setSpan(context.active(), otelSpan), () => {
|
|
629
|
-
Effect.runPromiseExit(effect).then((exit) => {
|
|
630
|
-
if (exit._tag === "Success") {
|
|
631
|
-
resume(Effect.succeed(exit.value));
|
|
632
|
-
} else {
|
|
633
|
-
resume(Effect.failCause(exit.cause));
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
});
|
|
637
|
-
})
|
|
638
|
-
).pipe(
|
|
639
|
-
// If no OTel span is available, just run the effect normally
|
|
640
|
-
Effect.catchAll(() => effect)
|
|
641
|
-
);
|
|
642
|
-
};
|
|
643
|
-
var withFullOtelBridging = (effect) => {
|
|
644
|
-
return withOtelParentSpan(effect);
|
|
645
|
-
};
|
|
646
682
|
function annotateUser(userId, email, username) {
|
|
647
683
|
const attributes = {
|
|
648
684
|
"user.id": userId
|
|
@@ -907,6 +943,6 @@ var FiberSet = {
|
|
|
907
943
|
runWithSpan
|
|
908
944
|
};
|
|
909
945
|
|
|
910
|
-
export { EffectInstrumentationLive, FiberSet, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata,
|
|
946
|
+
export { EffectInstrumentationLive, FiberSet, annotateBatch, annotateCache, annotateDataSize, annotateError, annotateHttpRequest, annotateLLM, annotatePriority, annotateQuery, annotateSpawnedTasks, annotateUser, autoEnrichSpan, createEffectInstrumentation, extractEffectMetadata, runIsolated, runWithSpan, withAutoEnrichedSpan };
|
|
911
947
|
//# sourceMappingURL=index.js.map
|
|
912
948
|
//# sourceMappingURL=index.js.map
|