Context.Reference<boolean>Context reference for controlling whether trace timing is enabled globally. When set to false, spans will not contain timing information (trace time will always be set to zero).
When to use
Use to disable or re-enable timing capture for spans in the current context.
Example (Toggling trace timing)
import { Effect, References } from "effect"
const tracingControl = Effect.gen(function*() {
// Check if trace timing is enabled (default is true)
const current = yield* References.TracerTimingEnabled
console.log(current) // true
// Disable trace timing globally
yield* Effect.provideService(
Effect.gen(function*() {
// Spans will not having timing information in this context
const isEnabled = yield* References.TracerTimingEnabled
console.log(isEnabled) // false
}),
References.TracerTimingEnabled,
false
)
// Re-enable trace timing
yield* Effect.provideService(
Effect.gen(function*() {
// Spans will have timing information in this context
const isEnabled = yield* References.TracerTimingEnabled
console.log(isEnabled) // true
}),
References.TracerTimingEnabled,
true
)
})references
Source effect/References.ts:6571 lines
export const const TracerTimingEnabled: Context.Reference<boolean>const TracerTimingEnabled: {
defaultValue: () => Shape;
of: (this: void, self: boolean) => boolean;
context: (self: boolean) => Context.Context<never>;
use: (f: (service: boolean) => Effect<A, E, R>) => Effect<A, E, R>;
useSync: (f: (service: boolean) => A) => Effect<A, never, never>;
Identifier: Identifier;
Service: Shape;
key: string;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Context reference for controlling whether trace timing is enabled globally. When set
to false, spans will not contain timing information (trace time will always
be set to zero).
When to use
Use to disable or re-enable timing capture for spans in the current context.
Example (Toggling trace timing)
import { Effect, References } from "effect"
const tracingControl = Effect.gen(function*() {
// Check if trace timing is enabled (default is true)
const current = yield* References.TracerTimingEnabled
console.log(current) // true
// Disable trace timing globally
yield* Effect.provideService(
Effect.gen(function*() {
// Spans will not having timing information in this context
const isEnabled = yield* References.TracerTimingEnabled
console.log(isEnabled) // false
}),
References.TracerTimingEnabled,
false
)
// Re-enable trace timing
yield* Effect.provideService(
Effect.gen(function*() {
// Spans will have timing information in this context
const isEnabled = yield* References.TracerTimingEnabled
console.log(isEnabled) // true
}),
References.TracerTimingEnabled,
true
)
})
TracerTimingEnabled: import ContextContext.type Context.Reference = /*unresolved*/ anyReference<boolean> = import referencesreferences.const TracerTimingEnabled: Context.Reference<boolean>const TracerTimingEnabled: {
defaultValue: () => Shape;
of: (this: void, self: boolean) => boolean;
context: (self: boolean) => Context.Context<never>;
use: (f: (service: boolean) => Effect<A, E, R>) => Effect<A, E, R>;
useSync: (f: (service: boolean) => A) => Effect<A, never, never>;
Identifier: Identifier;
Service: Shape;
key: string;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TracerTimingEnabled