Socket
Socket
Sign inDemoInstall

@effect/io

Package Overview
Dependencies
Maintainers
3
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/io - npm Package Compare versions

Comparing version 0.26.2 to 0.27.0

internal_effect_untraced/tracer.d.ts

3

DefaultServices.d.ts

@@ -9,2 +9,3 @@ /**

import type * as Random from "@effect/io/Random";
import type * as Tracer from "@effect/io/Tracer";
/**

@@ -14,3 +15,3 @@ * @since 1.0.0

*/
export type DefaultServices = Clock.Clock | Random.Random | ConfigProvider.ConfigProvider;
export type DefaultServices = Clock.Clock | Random.Random | ConfigProvider.ConfigProvider | Tracer.Tracer;
/**

@@ -17,0 +18,0 @@ * @since 1.0.0

/**
* @since 1.0.0
*/
import type * as Chunk from "@effect/data/Chunk";
import type * as Context from "@effect/data/Context";

@@ -10,2 +9,3 @@ import type * as Differ from "@effect/data/Differ";

import type * as HashSet from "@effect/data/HashSet";
import type * as List from "@effect/data/List";
import type * as Option from "@effect/data/Option";

@@ -23,2 +23,3 @@ import type * as Cause from "@effect/io/Cause";

import type * as Supervisor from "@effect/io/Supervisor";
import type * as Tracer from "@effect/io/Tracer";
/**

@@ -250,3 +251,3 @@ * @since 1.0.0

*/
export declare const currentLogSpan: FiberRef<Chunk.Chunk<LogSpan.LogSpan>>;
export declare const currentLogSpan: FiberRef<List.List<LogSpan.LogSpan>>;
/**

@@ -281,3 +282,13 @@ * @since 1.0.0

*/
export declare const currentTracerSpan: FiberRef<List.List<Tracer.Span>>;
/**
* @since 1.0.0
* @category fiberRefs
*/
export declare const currentTracerSpanAnnotations: FiberRef<HashMap.HashMap<string, string>>;
/**
* @since 1.0.0
* @category fiberRefs
*/
export declare const interruptedCause: FiberRef<Cause.Cause<never>>;
//# sourceMappingURL=FiberRef.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

});
exports.updateSomeAndGet = exports.updateSome = exports.updateAndGet = exports.update = exports.unsafeMakeSupervisor = exports.unsafeMakePatch = exports.unsafeMakeHashSet = exports.unsafeMakeContext = exports.unsafeMake = exports.unhandledErrorLogLevel = exports.set = exports.reset = exports.modifySome = exports.modify = exports.makeWith = exports.makeRuntimeFlags = exports.makeContext = exports.make = exports.interruptedCause = exports.getWith = exports.getAndUpdateSome = exports.getAndUpdate = exports.getAndSet = exports.get = exports.delete = exports.currentTags = exports.currentSupervisor = exports.currentScheduler = exports.currentRuntimeFlags = exports.currentRequestCacheEnabled = exports.currentRequestCache = exports.currentRequestBatchingEnabled = exports.currentParallelism = exports.currentMinimumLogLevel = exports.currentMaxFiberOps = exports.currentLoggers = exports.currentLogSpan = exports.currentLogLevel = exports.currentLogAnnotations = exports.currentContext = exports.FiberRefTypeId = void 0;
exports.updateSomeAndGet = exports.updateSome = exports.updateAndGet = exports.update = exports.unsafeMakeSupervisor = exports.unsafeMakePatch = exports.unsafeMakeHashSet = exports.unsafeMakeContext = exports.unsafeMake = exports.unhandledErrorLogLevel = exports.set = exports.reset = exports.modifySome = exports.modify = exports.makeWith = exports.makeRuntimeFlags = exports.makeContext = exports.make = exports.interruptedCause = exports.getWith = exports.getAndUpdateSome = exports.getAndUpdate = exports.getAndSet = exports.get = exports.delete = exports.currentTracerSpanAnnotations = exports.currentTracerSpan = exports.currentTags = exports.currentSupervisor = exports.currentScheduler = exports.currentRuntimeFlags = exports.currentRequestCacheEnabled = exports.currentRequestCache = exports.currentRequestBatchingEnabled = exports.currentParallelism = exports.currentMinimumLogLevel = exports.currentMaxFiberOps = exports.currentLoggers = exports.currentLogSpan = exports.currentLogLevel = exports.currentLogAnnotations = exports.currentContext = exports.FiberRefTypeId = void 0;
var core = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/core"));

@@ -253,4 +253,16 @@ var fiberRuntime = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/fiberRuntime"));

exports.currentTags = currentTags;
const currentTracerSpan = core.currentTracerSpan;
/**
* @since 1.0.0
* @category fiberRefs
*/
exports.currentTracerSpan = currentTracerSpan;
const currentTracerSpanAnnotations = core.currentTracerSpanAnnotations;
/**
* @since 1.0.0
* @category fiberRefs
*/
exports.currentTracerSpanAnnotations = currentTracerSpanAnnotations;
const interruptedCause = core.currentInterruptedCause;
exports.interruptedCause = interruptedCause;
//# sourceMappingURL=FiberRef.js.map

@@ -6,3 +6,3 @@ "use strict";

});
exports.withConfigProvider = exports.withClock = exports.sleep = exports.shuffle = exports.randomWith = exports.nextRange = exports.nextIntBetween = exports.nextInt = exports.nextBoolean = exports.next = exports.liveServices = exports.currentTimeMillis = exports.currentServices = exports.configProviderWith = exports.configOrDie = exports.config = exports.clockWith = void 0;
exports.withTracer = exports.withConfigProvider = exports.withClock = exports.tracerWith = exports.sleep = exports.shuffle = exports.randomWith = exports.nextRange = exports.nextIntBetween = exports.nextInt = exports.nextBoolean = exports.next = exports.liveServices = exports.currentTimeMillis = exports.currentServices = exports.configProviderWith = exports.configOrDie = exports.config = exports.clockWith = void 0;
var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Context"));

@@ -14,6 +14,7 @@ var Debug = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Debug"));

var random = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/random"));
var tracer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/tracer"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/** @internal */
const liveServices = /*#__PURE__*/Context.add(configProvider.configProviderTag, configProvider.fromEnv())( /*#__PURE__*/Context.add(random.randomTag, random.make(Math.random() * 4294967296 >>> 0))( /*#__PURE__*/Context.add(clock.clockTag, clock.make())( /*#__PURE__*/Context.empty())));
const liveServices = /*#__PURE__*/Context.add(tracer.tracerTag, tracer.nativeTracer)( /*#__PURE__*/Context.add(configProvider.configProviderTag, configProvider.fromEnv())( /*#__PURE__*/Context.add(random.randomTag, random.make(Math.random() * 4294967296 >>> 0))( /*#__PURE__*/Context.add(clock.clockTag, clock.make())( /*#__PURE__*/Context.empty()))));
/**

@@ -75,3 +76,10 @@ * The `FiberRef` holding the default `Effect` services.

const shuffle = /*#__PURE__*/Debug.methodWithTrace(trace => elements => randomWith(random => random.shuffle(elements)).traced(trace));
// circular with Tracer
/** @internal */
exports.shuffle = shuffle;
const tracerWith = /*#__PURE__*/Debug.methodWithTrace((trace, restore) => f => core.fiberRefGetWith(currentServices, services => restore(f)(Context.get(tracer.tracerTag)(services))).traced(trace));
/** @internal */
exports.tracerWith = tracerWith;
const withTracer = /*#__PURE__*/Debug.dualWithTrace(2, trace => (effect, value) => core.fiberRefLocallyWith(currentServices, Context.add(tracer.tracerTag, value))(effect).traced(trace));
exports.withTracer = withTracer;
//# sourceMappingURL=defaultServices.js.map

@@ -7,5 +7,5 @@ "use strict";

exports.test = void 0;
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk"));
var _Function = /*#__PURE__*/require("@effect/data/Function");
var HashMap = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/HashMap"));
var List = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/List"));
var Cause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Cause"));

@@ -18,4 +18,4 @@ var core = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/core"));

/** @internal */
const test = /*#__PURE__*/(0, _Function.dual)(2, (self, input) => self.log(_fiberId.none, core.logLevelInfo, input, Cause.empty, fiberRefs.unsafeMake(new Map()), Chunk.empty(), HashMap.empty()));
const test = /*#__PURE__*/(0, _Function.dual)(2, (self, input) => self.log(_fiberId.none, core.logLevelInfo, input, Cause.empty, fiberRefs.unsafeMake(new Map()), List.empty(), HashMap.empty()));
exports.test = test;
//# sourceMappingURL=logger-circular.js.map

@@ -7,6 +7,6 @@ "use strict";

exports.zipRight = exports.zipLeft = exports.zip = exports.sync = exports.succeed = exports.stringLogger = exports.simple = exports.none = exports.map = exports.makeLogger = exports.logfmtLogger = exports.filterLogLevel = exports.contramap = exports.LoggerTypeId = void 0;
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk"));
var Debug = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Debug"));
var _Function = /*#__PURE__*/require("@effect/data/Function");
var HashMap = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/HashMap"));
var List = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/List"));
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option"));

@@ -49,3 +49,3 @@ var Cause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/cause"));

}
if (Chunk.isNonEmpty(spans)) {
if (List.isCons(spans)) {
output = output + " ";

@@ -98,3 +98,3 @@ let first = true;

}
if (Chunk.isNonEmpty(spans)) {
if (List.isCons(spans)) {
output = output + " ";

@@ -101,0 +101,0 @@ let first = true;

/**
* @since 1.0.0
*/
import type * as Chunk from "@effect/data/Chunk";
import type { LazyArg } from "@effect/data/Function";
import type * as HashMap from "@effect/data/HashMap";
import type * as List from "@effect/data/List";
import type * as Option from "@effect/data/Option";

@@ -31,3 +31,3 @@ import type * as Cause from "@effect/io/Cause";

export interface Logger<Message, Output> extends Logger.Variance<Message, Output> {
readonly log: (fiberId: FiberId.FiberId, logLevel: LogLevel.LogLevel, message: Message, cause: Cause.Cause<unknown>, context: FiberRefs.FiberRefs, spans: Chunk.Chunk<LogSpan.LogSpan>, annotations: HashMap.HashMap<string, string>) => Output;
readonly log: (fiberId: FiberId.FiberId, logLevel: LogLevel.LogLevel, message: Message, cause: Cause.Cause<unknown>, context: FiberRefs.FiberRefs, spans: List.List<LogSpan.LogSpan>, annotations: HashMap.HashMap<string, string>) => Output;
}

@@ -53,3 +53,3 @@ /**

*/
export declare const make: <Message, Output>(log: (fiberId: FiberId.FiberId, logLevel: LogLevel.LogLevel, message: Message, cause: Cause.Cause<unknown>, context: FiberRefs.FiberRefs, spans: Chunk.Chunk<LogSpan.LogSpan>, annotations: HashMap.HashMap<string, string>) => Output) => Logger<Message, Output>;
export declare const make: <Message, Output>(log: (fiberId: FiberId.FiberId, logLevel: LogLevel.LogLevel, message: Message, cause: Cause.Cause<unknown>, context: FiberRefs.FiberRefs, spans: List.List<LogSpan.LogSpan>, annotations: HashMap.HashMap<string, string>) => Output) => Logger<Message, Output>;
/**

@@ -56,0 +56,0 @@ * @since 1.0.0

{
"name": "@effect/io",
"version": "0.26.2",
"version": "0.27.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -10,2 +10,3 @@ /**

import type * as Random from "@effect/io/Random"
import type * as Tracer from "@effect/io/Tracer"

@@ -16,3 +17,3 @@ /**

*/
export type DefaultServices = Clock.Clock | Random.Random | ConfigProvider.ConfigProvider
export type DefaultServices = Clock.Clock | Random.Random | ConfigProvider.ConfigProvider | Tracer.Tracer

@@ -19,0 +20,0 @@ /**

/**
* @since 1.0.0
*/
import type * as Chunk from "@effect/data/Chunk"
import type * as Context from "@effect/data/Context"

@@ -10,2 +9,3 @@ import type * as Differ from "@effect/data/Differ"

import type * as HashSet from "@effect/data/HashSet"
import type * as List from "@effect/data/List"
import type * as Option from "@effect/data/Option"

@@ -26,2 +26,3 @@ import type * as Cause from "@effect/io/Cause"

import type * as Supervisor from "@effect/io/Supervisor"
import type * as Tracer from "@effect/io/Tracer"

@@ -330,3 +331,3 @@ /**

*/
export const currentLogSpan: FiberRef<Chunk.Chunk<LogSpan.LogSpan>> = core.currentLogSpan
export const currentLogSpan: FiberRef<List.List<LogSpan.LogSpan>> = core.currentLogSpan

@@ -367,2 +368,14 @@ /**

*/
export const currentTracerSpan: FiberRef<List.List<Tracer.Span>> = core.currentTracerSpan
/**
* @since 1.0.0
* @category fiberRefs
*/
export const currentTracerSpanAnnotations: FiberRef<HashMap.HashMap<string, string>> = core.currentTracerSpanAnnotations
/**
* @since 1.0.0
* @category fiberRefs
*/
export const interruptedCause: FiberRef<Cause.Cause<never>> = core.currentInterruptedCause

@@ -15,3 +15,5 @@ import type * as Chunk from "@effect/data/Chunk"

import * as random from "@effect/io/internal_effect_untraced/random"
import * as tracer from "@effect/io/internal_effect_untraced/tracer"
import type * as Random from "@effect/io/Random"
import type * as Tracer from "@effect/io/Tracer"

@@ -23,3 +25,4 @@ /** @internal */

Context.add(random.randomTag, random.make((Math.random() * 4294967296) >>> 0)),
Context.add(configProvider.configProviderTag, configProvider.fromEnv())
Context.add(configProvider.configProviderTag, configProvider.fromEnv()),
Context.add(tracer.tracerTag, tracer.nativeTracer)
)

@@ -143,1 +146,21 @@

)
// circular with Tracer
/** @internal */
export const tracerWith = Debug.methodWithTrace((trace, restore) =>
<R, E, A>(f: (tracer: Tracer.Tracer) => Effect.Effect<R, E, A>): Effect.Effect<R, E, A> =>
core.fiberRefGetWith(currentServices, (services) => restore(f)(pipe(services, Context.get(tracer.tracerTag))))
.traced(trace)
)
/** @internal */
export const withTracer = Debug.dualWithTrace<
(value: Tracer.Tracer) => <R, E, A>(effect: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A>,
<R, E, A>(effect: Effect.Effect<R, E, A>, value: Tracer.Tracer) => Effect.Effect<R, E, A>
>(2, (trace) =>
(effect, value) =>
core.fiberRefLocallyWith(
currentServices,
Context.add(tracer.tracerTag, value)
)(effect).traced(trace))

@@ -1,4 +0,4 @@

import * as Chunk from "@effect/data/Chunk"
import { dual } from "@effect/data/Function"
import * as HashMap from "@effect/data/HashMap"
import * as List from "@effect/data/List"
import * as Cause from "@effect/io/Cause"

@@ -21,4 +21,4 @@ import * as core from "@effect/io/internal_effect_untraced/core"

fiberRefs.unsafeMake(new Map()),
Chunk.empty(),
List.empty(),
HashMap.empty()
))

@@ -1,2 +0,1 @@

import * as Chunk from "@effect/data/Chunk"
import * as Debug from "@effect/data/Debug"

@@ -6,2 +5,3 @@ import type { LazyArg } from "@effect/data/Function"

import * as HashMap from "@effect/data/HashMap"
import * as List from "@effect/data/List"
import * as Option from "@effect/data/Option"

@@ -40,3 +40,3 @@ import type * as CauseExt from "@effect/io/Cause"

context: FiberRefs.FiberRefs,
spans: Chunk.Chunk<LogSpan.LogSpan>,
spans: List.List<LogSpan.LogSpan>,
annotations: HashMap.HashMap<string, string>

@@ -73,3 +73,3 @@ ) => Output

if (Chunk.isNonEmpty(spans)) {
if (List.isCons(spans)) {
output = output + " "

@@ -141,3 +141,3 @@

if (Chunk.isNonEmpty(spans)) {
if (List.isCons(spans)) {
output = output + " "

@@ -144,0 +144,0 @@

/**
* @since 1.0.0
*/
import type * as Chunk from "@effect/data/Chunk"
import type { LazyArg } from "@effect/data/Function"
import type * as HashMap from "@effect/data/HashMap"
import type * as List from "@effect/data/List"
import type * as Option from "@effect/data/Option"

@@ -44,3 +44,3 @@ import type * as Cause from "@effect/io/Cause"

context: FiberRefs.FiberRefs,
spans: Chunk.Chunk<LogSpan.LogSpan>,
spans: List.List<LogSpan.LogSpan>,
annotations: HashMap.HashMap<string, string>

@@ -77,3 +77,3 @@ ) => Output

context: FiberRefs.FiberRefs,
spans: Chunk.Chunk<LogSpan.LogSpan>,
spans: List.List<LogSpan.LogSpan>,
annotations: HashMap.HashMap<string, string>

@@ -80,0 +80,0 @@ ) => Output

/**
* @since 1.0.0
*/
import * as Context from "@effect/data/Context"
import { dualWithTrace, methodWithTrace } from "@effect/data/Debug"
import { globalValue } from "@effect/data/Global"
import * as MutableRef from "@effect/data/MutableRef"
import * as Option from "@effect/data/Option"
import * as Clock from "@effect/io/Clock"
import * as Effect from "@effect/io/Effect"
import type * as Context from "@effect/data/Context"
import type * as Option from "@effect/data/Option"
import type * as Effect from "@effect/io/Effect"
import type * as Exit from "@effect/io/Exit"
import * as defaultServices from "@effect/io/internal_effect_untraced/defaultServices"
import * as internal from "@effect/io/internal_effect_untraced/tracer"
import type * as Logger from "@effect/io/Logger"

@@ -16,3 +15,3 @@ /**

*/
export const TracerTypeId = Symbol.for("@effect/io/Tracer")
export const TracerTypeId: unique symbol = internal.TracerTypeId

@@ -34,18 +33,4 @@ /**

* @since 1.0.0
* @category models
*/
export const make = (options: Omit<Tracer, TracerTypeId>): Tracer => ({
[TracerTypeId]: TracerTypeId,
...options
})
/**
* @since 1.0.0
*/
export const Tracer = Context.Tag<Tracer>(
Symbol.for("@effect/io/Tracer")
)
/**
* @since 1.0.0
*/
export type SpanStatus = {

@@ -63,2 +48,3 @@ _tag: "Started"

* @since 1.0.0
* @category models
*/

@@ -69,2 +55,3 @@ export type ParentSpan = Span | ExternalSpan

* @since 1.0.0
* @category models
*/

@@ -80,2 +67,3 @@ export interface ExternalSpan {

* @since 1.0.0
* @category models
*/

@@ -92,145 +80,30 @@ export interface Span {

readonly attribute: (key: string, value: string) => void
readonly event: (name: string, attributes?: Record<string, string>) => void
}
const ids = globalValue("@effect/io/Tracer/SpanId.ids", () => MutableRef.make(0))
/**
* @since 1.0.0
* @category tags
*/
export const Tracer: Context.Tag<Tracer, Tracer> = internal.tracerTag
class NativeSpan implements Span {
readonly _tag = "Span"
readonly spanId: string
readonly traceId: string = "native"
status: SpanStatus
attributes: Map<string, string>
constructor(
readonly name: string,
readonly parent: Option.Option<ParentSpan>,
readonly startTime: number
) {
this.status = {
_tag: "Started",
startTime
}
this.attributes = new Map()
this.spanId = `span${MutableRef.incrementAndGet(ids)}`
}
end = (endTime: number, exit: Exit.Exit<unknown, unknown>): void => {
this.status = {
_tag: "Ended",
endTime,
exit,
startTime: this.status.startTime
}
}
attribute = (key: string, value: string): void => {
this.attributes.set(key, value)
}
}
const nativeTracer: Tracer = make({
span: (name, parent, startTime) => new NativeSpan(name, parent, startTime)
})
/**
* @since 1.0.0
* @category constructors
*/
export const Span = Context.Tag<Span>(
Symbol.for("@effect/io/Span")
)
export const make: (options: Omit<Tracer, typeof TracerTypeId>) => Tracer = internal.make
/**
* @since 1.0.0
* @category constructors
*/
export const useSpan: {
<R, E, A>(name: string, evaluate: (span: Span) => Effect.Effect<R, E, A>): Effect.Effect<R, E, A>
<R, E, A>(name: string, options: {
attributes?: Record<string, string>
parent?: ParentSpan
root?: boolean
}, evaluate: (span: Span) => Effect.Effect<R, E, A>): Effect.Effect<R, E, A>
} = methodWithTrace(() =>
<R, E, A>(
name: string,
...args: [evaluate: (span: Span) => Effect.Effect<R, E, A>] | [
options: any,
evaluate: (span: Span) => Effect.Effect<R, E, A>
]
) => {
const options: {
attributes?: Record<string, string>
parent?: ParentSpan
root?: boolean
} | undefined = args.length === 1 ? undefined : args[0]
const evaluate: (span: Span) => Effect.Effect<R, E, A> = args[args.length - 1]
export const tracerWith: <R, E, A>(f: (tracer: Tracer) => Effect.Effect<R, E, A>) => Effect.Effect<R, E, A> =
defaultServices.tracerWith
return Effect.acquireUseRelease(
Effect.flatMap(
Clock.currentTimeMillis(),
(startTime) =>
Effect.contextWith((context: Context.Context<never>): Span => {
const tracer: Tracer = Option.getOrElse(
Context.getOption(context, Tracer),
() => nativeTracer
)
const parent = Option.orElse(
Option.fromNullable(options?.parent),
() => options?.root === true ? Option.none() : Context.getOption(context, Span)
)
const span = tracer.span(name, parent, startTime)
Object.entries(options?.attributes ?? {}).forEach(([k, v]) => {
span.attribute(k, v)
})
return span
})
),
evaluate,
(span, exit) =>
Effect.flatMap(
Clock.currentTimeMillis(),
(endTime) => Effect.sync(() => span.end(endTime, exit))
)
)
}
)
/**
* A Logger which adds log entries as events to the current span.
*
* @since 1.0.0
* @category loggers
*/
export const withSpan: {
(name: string, options?: {
attributes?: Record<string, string>
parent?: ParentSpan
root?: boolean
}): <R, E, A>(self: Effect.Effect<R, E, A>) => Effect.Effect<Exclude<R, Span>, E, A>
<R, E, A>(self: Effect.Effect<R, E, A>, name: string, options?: {
attributes?: Record<string, string>
parent?: ParentSpan
root?: boolean
}): Effect.Effect<Exclude<R, Span>, E, A>
} = dualWithTrace<
(name: string, options?: {
attributes?: Record<string, string>
parent?: ParentSpan
root?: boolean
}) => <R, E, A>(self: Effect.Effect<R, E, A>) => Effect.Effect<Exclude<R, Span>, E, A>,
<R, E, A>(self: Effect.Effect<R, E, A>, name: string, options?: {
attributes?: Record<string, string>
parent?: ParentSpan
root?: boolean
}) => Effect.Effect<Exclude<R, Span>, E, A>
>(
(args) => typeof args[0] !== "string",
() =>
(self, name, options) =>
useSpan(
name,
options ?? {},
(span) => Effect.provideService(self, Span, span)
)
)
export const logger: Logger.Logger<string, void> = internal.logger
/**
* @since 1.0.0
*/
import * as Context from "@effect/data/Context";
import * as Option from "@effect/data/Option";
import * as Effect from "@effect/io/Effect";
import type * as Context from "@effect/data/Context";
import type * as Option from "@effect/data/Option";
import type * as Effect from "@effect/io/Effect";
import type * as Exit from "@effect/io/Exit";
import type * as Logger from "@effect/io/Logger";
/**

@@ -25,11 +26,4 @@ * @since 1.0.0

* @since 1.0.0
* @category models
*/
export declare const make: (options: Omit<Tracer, TracerTypeId>) => Tracer;
/**
* @since 1.0.0
*/
export declare const Tracer: Context.Tag<Tracer, Tracer>;
/**
* @since 1.0.0
*/
export type SpanStatus = {

@@ -46,2 +40,3 @@ _tag: "Started";

* @since 1.0.0
* @category models
*/

@@ -51,2 +46,3 @@ export type ParentSpan = Span | ExternalSpan;

* @since 1.0.0
* @category models
*/

@@ -61,2 +57,3 @@ export interface ExternalSpan {

* @since 1.0.0
* @category models
*/

@@ -73,33 +70,26 @@ export interface Span {

readonly attribute: (key: string, value: string) => void;
readonly event: (name: string, attributes?: Record<string, string>) => void;
}
/**
* @since 1.0.0
* @category tags
*/
export declare const Span: Context.Tag<Span, Span>;
export declare const Tracer: Context.Tag<Tracer, Tracer>;
/**
* @since 1.0.0
* @category constructors
*/
export declare const useSpan: {
<R, E, A>(name: string, evaluate: (span: Span) => Effect.Effect<R, E, A>): Effect.Effect<R, E, A>;
<R, E, A>(name: string, options: {
attributes?: Record<string, string>;
parent?: ParentSpan;
root?: boolean;
}, evaluate: (span: Span) => Effect.Effect<R, E, A>): Effect.Effect<R, E, A>;
};
export declare const make: (options: Omit<Tracer, typeof TracerTypeId>) => Tracer;
/**
* @since 1.0.0
* @category constructors
*/
export declare const withSpan: {
(name: string, options?: {
attributes?: Record<string, string>;
parent?: ParentSpan;
root?: boolean;
}): <R, E, A>(self: Effect.Effect<R, E, A>) => Effect.Effect<Exclude<R, Span>, E, A>;
<R, E, A>(self: Effect.Effect<R, E, A>, name: string, options?: {
attributes?: Record<string, string>;
parent?: ParentSpan;
root?: boolean;
}): Effect.Effect<Exclude<R, Span>, E, A>;
};
export declare const tracerWith: <R, E, A>(f: (tracer: Tracer) => Effect.Effect<R, E, A>) => Effect.Effect<R, E, A>;
/**
* A Logger which adds log entries as events to the current span.
*
* @since 1.0.0
* @category loggers
*/
export declare const logger: Logger.Logger<string, void>;
//# sourceMappingURL=Tracer.d.ts.map

@@ -6,10 +6,5 @@ "use strict";

});
exports.withSpan = exports.useSpan = exports.make = exports.TracerTypeId = exports.Tracer = exports.Span = void 0;
var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Context"));
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var _Global = /*#__PURE__*/require("@effect/data/Global");
var MutableRef = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/MutableRef"));
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option"));
var Clock = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Clock"));
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
exports.tracerWith = exports.make = exports.logger = exports.TracerTypeId = exports.Tracer = void 0;
var defaultServices = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/defaultServices"));
var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/tracer"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -20,78 +15,30 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

*/
const TracerTypeId = internal.TracerTypeId;
/**
* @since 1.0.0
* @category tags
*/
const TracerTypeId = /*#__PURE__*/Symbol.for("@effect/io/Tracer");
/**
* @since 1.0.0
*/
exports.TracerTypeId = TracerTypeId;
const make = options => ({
[TracerTypeId]: TracerTypeId,
...options
});
const Tracer = internal.tracerTag;
/**
* @since 1.0.0
* @category constructors
*/
exports.make = make;
const Tracer = /*#__PURE__*/Context.Tag( /*#__PURE__*/Symbol.for("@effect/io/Tracer"));
exports.Tracer = Tracer;
const ids = /*#__PURE__*/(0, _Global.globalValue)("@effect/io/Tracer/SpanId.ids", () => MutableRef.make(0));
class NativeSpan {
constructor(name, parent, startTime) {
this.name = name;
this.parent = parent;
this.startTime = startTime;
this._tag = "Span";
this.traceId = "native";
this.end = (endTime, exit) => {
this.status = {
_tag: "Ended",
endTime,
exit,
startTime: this.status.startTime
};
};
this.attribute = (key, value) => {
this.attributes.set(key, value);
};
this.status = {
_tag: "Started",
startTime
};
this.attributes = new Map();
this.spanId = `span${MutableRef.incrementAndGet(ids)}`;
}
}
const nativeTracer = /*#__PURE__*/make({
span: (name, parent, startTime) => new NativeSpan(name, parent, startTime)
});
const make = internal.make;
/**
* @since 1.0.0
* @category constructors
*/
const Span = /*#__PURE__*/Context.Tag( /*#__PURE__*/Symbol.for("@effect/io/Span"));
exports.make = make;
const tracerWith = defaultServices.tracerWith;
/**
* A Logger which adds log entries as events to the current span.
*
* @since 1.0.0
* @category loggers
*/
exports.Span = Span;
const useSpan = /*#__PURE__*/(0, _Debug.methodWithTrace)(() => (name, ...args) => {
const options = args.length === 1 ? undefined : args[0];
const evaluate = args[args.length - 1];
return Effect.acquireUseRelease(Effect.flatMap(Clock.currentTimeMillis(), startTime => Effect.contextWith(context => {
const tracer = Option.getOrElse(Context.getOption(context, Tracer), () => nativeTracer);
const parent = Option.orElse(Option.fromNullable(options?.parent), () => options?.root === true ? Option.none() : Context.getOption(context, Span));
const span = tracer.span(name, parent, startTime);
Object.entries(options?.attributes ?? {}).forEach(([k, v]) => {
span.attribute(k, v);
});
return span;
})), evaluate, (span, exit) => Effect.flatMap(Clock.currentTimeMillis(), endTime => Effect.sync(() => span.end(endTime, exit))));
});
/**
* @since 1.0.0
*/
exports.useSpan = useSpan;
const withSpan = /*#__PURE__*/(0, _Debug.dualWithTrace)(args => typeof args[0] !== "string", () => (self, name, options) => useSpan(name, options ?? {}, span => Effect.provideService(self, Span, span)));
exports.withSpan = withSpan;
exports.tracerWith = tracerWith;
const logger = internal.logger;
exports.logger = logger;
//# sourceMappingURL=Tracer.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc