@clayroach/effect 3.19.14-source-capture.8 → 3.19.14-source-trace.2
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/SourceLocation/package.json +6 -0
- package/dist/cjs/Effect.js +2 -28
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/FiberRef.js +12 -1
- package/dist/cjs/FiberRef.js.map +1 -1
- package/dist/cjs/Layer.js +2 -24
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/RuntimeFlags.js +1 -29
- package/dist/cjs/RuntimeFlags.js.map +1 -1
- package/dist/cjs/SourceLocation.js +60 -0
- package/dist/cjs/SourceLocation.js.map +1 -0
- package/dist/cjs/Tracer.js +1 -15
- package/dist/cjs/Tracer.js.map +1 -1
- package/dist/cjs/Utils.js +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/clock.js +1 -1
- package/dist/cjs/internal/clock.js.map +1 -1
- package/dist/cjs/internal/core.js +17 -50
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +18 -30
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +16 -65
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/layer/circular.js +1 -5
- package/dist/cjs/internal/layer/circular.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -3
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/logger.js +25 -2
- package/dist/cjs/internal/logger.js.map +1 -1
- package/dist/cjs/internal/runtimeFlags.js +2 -11
- package/dist/cjs/internal/runtimeFlags.js.map +1 -1
- package/dist/cjs/internal/tracer.js +1 -114
- package/dist/cjs/internal/tracer.js.map +1 -1
- package/dist/dts/Config.d.ts +2 -2
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +8 -29
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/FiberRef.d.ts +12 -0
- package/dist/dts/FiberRef.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +0 -22
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/RuntimeFlags.d.ts +0 -28
- package/dist/dts/RuntimeFlags.d.ts.map +1 -1
- package/dist/dts/SourceLocation.d.ts +88 -0
- package/dist/dts/SourceLocation.d.ts.map +1 -0
- package/dist/dts/Tracer.d.ts +0 -15
- package/dist/dts/Tracer.d.ts.map +1 -1
- package/dist/dts/index.d.ts +6 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/layer.d.ts.map +1 -1
- package/dist/dts/internal/runtimeFlags.d.ts.map +1 -1
- package/dist/esm/Effect.js +0 -26
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/FiberRef.js +11 -0
- package/dist/esm/FiberRef.js.map +1 -1
- package/dist/esm/Layer.js +0 -22
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/RuntimeFlags.js +0 -28
- package/dist/esm/RuntimeFlags.js.map +1 -1
- package/dist/esm/SourceLocation.js +51 -0
- package/dist/esm/SourceLocation.js.map +1 -0
- package/dist/esm/Tracer.js +0 -14
- package/dist/esm/Tracer.js.map +1 -1
- package/dist/esm/Utils.js +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/clock.js +1 -1
- package/dist/esm/internal/clock.js.map +1 -1
- package/dist/esm/internal/core.js +12 -45
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +18 -30
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +13 -60
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/layer/circular.js +0 -4
- package/dist/esm/internal/layer/circular.js.map +1 -1
- package/dist/esm/internal/layer.js +0 -2
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/logger.js +25 -2
- package/dist/esm/internal/logger.js.map +1 -1
- package/dist/esm/internal/runtimeFlags.js +1 -9
- package/dist/esm/internal/runtimeFlags.js.map +1 -1
- package/dist/esm/internal/tracer.js +0 -111
- package/dist/esm/internal/tracer.js.map +1 -1
- package/package.json +12 -1
- package/src/Arbitrary.ts +1101 -0
- package/src/Array.ts +3589 -0
- package/src/BigDecimal.ts +1349 -0
- package/src/BigInt.ts +643 -0
- package/src/Boolean.ts +287 -0
- package/src/Brand.ts +360 -0
- package/src/Cache.ts +281 -0
- package/src/Cause.ts +1555 -0
- package/src/Channel.ts +2355 -0
- package/src/ChildExecutorDecision.ts +146 -0
- package/src/Chunk.ts +1495 -0
- package/src/Clock.ts +111 -0
- package/src/Config.ts +542 -0
- package/src/ConfigError.ts +270 -0
- package/src/ConfigProvider.ts +333 -0
- package/src/ConfigProviderPathPatch.ts +100 -0
- package/src/Console.ts +226 -0
- package/src/Context.ts +585 -0
- package/src/Cron.ts +706 -0
- package/src/Data.ts +596 -0
- package/src/DateTime.ts +1686 -0
- package/src/DefaultServices.ts +34 -0
- package/src/Deferred.ts +301 -0
- package/src/Differ.ts +450 -0
- package/src/Duration.ts +1000 -0
- package/src/Effect.ts +14817 -0
- package/src/Effectable.ts +107 -0
- package/src/Either.ts +1040 -0
- package/src/Encoding.ts +195 -0
- package/src/Equal.ts +98 -0
- package/src/Equivalence.ts +235 -0
- package/src/ExecutionPlan.ts +308 -0
- package/src/ExecutionStrategy.ts +119 -0
- package/src/Exit.ts +467 -0
- package/src/FastCheck.ts +9 -0
- package/src/Fiber.ts +744 -0
- package/src/FiberHandle.ts +540 -0
- package/src/FiberId.ts +195 -0
- package/src/FiberMap.ts +656 -0
- package/src/FiberRef.ts +444 -0
- package/src/FiberRefs.ts +204 -0
- package/src/FiberRefsPatch.ts +105 -0
- package/src/FiberSet.ts +491 -0
- package/src/FiberStatus.ts +108 -0
- package/src/Function.ts +1222 -0
- package/src/GlobalValue.ts +53 -0
- package/src/Graph.ts +3732 -0
- package/src/GroupBy.ts +103 -0
- package/src/HKT.ts +45 -0
- package/src/Hash.ts +195 -0
- package/src/HashMap.ts +519 -0
- package/src/HashRing.ts +317 -0
- package/src/HashSet.ts +2346 -0
- package/src/Inspectable.ts +287 -0
- package/src/Iterable.ts +1119 -0
- package/src/JSONSchema.ts +1044 -0
- package/src/KeyedPool.ts +167 -0
- package/src/Layer.ts +1228 -0
- package/src/LayerMap.ts +436 -0
- package/src/List.ts +977 -0
- package/src/LogLevel.ts +285 -0
- package/src/LogSpan.ts +25 -0
- package/src/Logger.ts +702 -0
- package/src/Mailbox.ts +268 -0
- package/src/ManagedRuntime.ts +180 -0
- package/src/Match.ts +1477 -0
- package/src/MergeDecision.ts +95 -0
- package/src/MergeState.ts +172 -0
- package/src/MergeStrategy.ts +107 -0
- package/src/Metric.ts +780 -0
- package/src/MetricBoundaries.ts +69 -0
- package/src/MetricHook.ts +151 -0
- package/src/MetricKey.ts +224 -0
- package/src/MetricKeyType.ts +262 -0
- package/src/MetricLabel.ts +47 -0
- package/src/MetricPair.ts +71 -0
- package/src/MetricPolling.ts +148 -0
- package/src/MetricRegistry.ts +48 -0
- package/src/MetricState.ts +257 -0
- package/src/Micro.ts +4405 -0
- package/src/ModuleVersion.ts +18 -0
- package/src/MutableHashMap.ts +411 -0
- package/src/MutableHashSet.ts +706 -0
- package/src/MutableList.ts +297 -0
- package/src/MutableQueue.ts +227 -0
- package/src/MutableRef.ts +202 -0
- package/src/NonEmptyIterable.ts +32 -0
- package/src/Number.ts +1071 -0
- package/src/Option.ts +2170 -0
- package/src/Order.ts +373 -0
- package/src/Ordering.ts +111 -0
- package/src/ParseResult.ts +2031 -0
- package/src/PartitionedSemaphore.ts +200 -0
- package/src/Pipeable.ts +566 -0
- package/src/Pool.ts +204 -0
- package/src/Predicate.ts +1405 -0
- package/src/Pretty.ts +205 -0
- package/src/PrimaryKey.ts +23 -0
- package/src/PubSub.ts +182 -0
- package/src/Queue.ts +644 -0
- package/src/Random.ts +204 -0
- package/src/RateLimiter.ts +138 -0
- package/src/RcMap.ts +141 -0
- package/src/RcRef.ts +122 -0
- package/src/Readable.ts +93 -0
- package/src/Record.ts +1274 -0
- package/src/RedBlackTree.ts +421 -0
- package/src/Redacted.ts +144 -0
- package/src/Ref.ts +180 -0
- package/src/RegExp.ts +38 -0
- package/src/Reloadable.ts +127 -0
- package/src/Request.ts +347 -0
- package/src/RequestBlock.ts +118 -0
- package/src/RequestResolver.ts +366 -0
- package/src/Resource.ts +119 -0
- package/src/Runtime.ts +383 -0
- package/src/RuntimeFlags.ts +336 -0
- package/src/RuntimeFlagsPatch.ts +183 -0
- package/src/STM.ts +2045 -0
- package/src/Schedule.ts +2219 -0
- package/src/ScheduleDecision.ts +62 -0
- package/src/ScheduleInterval.ts +151 -0
- package/src/ScheduleIntervals.ts +122 -0
- package/src/Scheduler.ts +353 -0
- package/src/Schema.ts +10914 -0
- package/src/SchemaAST.ts +3043 -0
- package/src/Scope.ts +204 -0
- package/src/ScopedCache.ts +151 -0
- package/src/ScopedRef.ts +117 -0
- package/src/Secret.ts +88 -0
- package/src/SingleProducerAsyncInput.ts +67 -0
- package/src/Sink.ts +1461 -0
- package/src/SortedMap.ts +287 -0
- package/src/SortedSet.ts +390 -0
- package/src/SourceLocation.ts +108 -0
- package/src/Stream.ts +6468 -0
- package/src/StreamEmit.ts +136 -0
- package/src/StreamHaltStrategy.ts +123 -0
- package/src/Streamable.ts +45 -0
- package/src/String.ts +778 -0
- package/src/Struct.ts +243 -0
- package/src/Subscribable.ts +100 -0
- package/src/SubscriptionRef.ts +298 -0
- package/src/Supervisor.ts +240 -0
- package/src/Symbol.ts +29 -0
- package/src/SynchronizedRef.ts +270 -0
- package/src/TArray.ts +495 -0
- package/src/TDeferred.ts +100 -0
- package/src/TMap.ts +515 -0
- package/src/TPriorityQueue.ts +223 -0
- package/src/TPubSub.ts +200 -0
- package/src/TQueue.ts +432 -0
- package/src/TRandom.ts +129 -0
- package/src/TReentrantLock.ts +224 -0
- package/src/TRef.ts +178 -0
- package/src/TSemaphore.ts +129 -0
- package/src/TSet.ts +365 -0
- package/src/TSubscriptionRef.ts +192 -0
- package/src/Take.ts +258 -0
- package/src/TestAnnotation.ts +158 -0
- package/src/TestAnnotationMap.ts +119 -0
- package/src/TestAnnotations.ts +117 -0
- package/src/TestClock.ts +556 -0
- package/src/TestConfig.ts +47 -0
- package/src/TestContext.ts +36 -0
- package/src/TestLive.ts +53 -0
- package/src/TestServices.ts +390 -0
- package/src/TestSized.ts +55 -0
- package/src/Tracer.ts +182 -0
- package/src/Trie.ts +840 -0
- package/src/Tuple.ts +305 -0
- package/src/Types.ts +353 -0
- package/src/Unify.ts +113 -0
- package/src/UpstreamPullRequest.ts +117 -0
- package/src/UpstreamPullStrategy.ts +121 -0
- package/src/Utils.ts +809 -0
- package/src/index.ts +1568 -0
- package/src/internal/array.ts +8 -0
- package/src/internal/blockedRequests.ts +520 -0
- package/src/internal/cache.ts +733 -0
- package/src/internal/cause.ts +1050 -0
- package/src/internal/channel/channelExecutor.ts +1200 -0
- package/src/internal/channel/channelState.ts +134 -0
- package/src/internal/channel/childExecutorDecision.ts +96 -0
- package/src/internal/channel/continuation.ts +200 -0
- package/src/internal/channel/mergeDecision.ts +113 -0
- package/src/internal/channel/mergeState.ts +120 -0
- package/src/internal/channel/mergeStrategy.ts +72 -0
- package/src/internal/channel/singleProducerAsyncInput.ts +259 -0
- package/src/internal/channel/subexecutor.ts +229 -0
- package/src/internal/channel/upstreamPullRequest.ts +84 -0
- package/src/internal/channel/upstreamPullStrategy.ts +87 -0
- package/src/internal/channel.ts +2603 -0
- package/src/internal/clock.ts +95 -0
- package/src/internal/completedRequestMap.ts +9 -0
- package/src/internal/concurrency.ts +54 -0
- package/src/internal/config.ts +716 -0
- package/src/internal/configError.ts +304 -0
- package/src/internal/configProvider/pathPatch.ts +97 -0
- package/src/internal/configProvider.ts +799 -0
- package/src/internal/console.ts +153 -0
- package/src/internal/context.ts +337 -0
- package/src/internal/core-effect.ts +2293 -0
- package/src/internal/core-stream.ts +998 -0
- package/src/internal/core.ts +3189 -0
- package/src/internal/data.ts +36 -0
- package/src/internal/dataSource.ts +327 -0
- package/src/internal/dateTime.ts +1277 -0
- package/src/internal/defaultServices/console.ts +100 -0
- package/src/internal/defaultServices.ts +163 -0
- package/src/internal/deferred.ts +46 -0
- package/src/internal/differ/chunkPatch.ts +211 -0
- package/src/internal/differ/contextPatch.ts +232 -0
- package/src/internal/differ/hashMapPatch.ts +220 -0
- package/src/internal/differ/hashSetPatch.ts +176 -0
- package/src/internal/differ/orPatch.ts +311 -0
- package/src/internal/differ/readonlyArrayPatch.ts +210 -0
- package/src/internal/differ.ts +200 -0
- package/src/internal/doNotation.ts +80 -0
- package/src/internal/effect/circular.ts +895 -0
- package/src/internal/effectable.ts +131 -0
- package/src/internal/either.ts +110 -0
- package/src/internal/encoding/base64.ts +286 -0
- package/src/internal/encoding/base64Url.ts +29 -0
- package/src/internal/encoding/common.ts +51 -0
- package/src/internal/encoding/hex.ts +315 -0
- package/src/internal/errors.ts +7 -0
- package/src/internal/executionPlan.ts +114 -0
- package/src/internal/executionStrategy.ts +74 -0
- package/src/internal/fiber.ts +388 -0
- package/src/internal/fiberId.ts +267 -0
- package/src/internal/fiberMessage.ts +82 -0
- package/src/internal/fiberRefs/patch.ts +144 -0
- package/src/internal/fiberRefs.ts +297 -0
- package/src/internal/fiberRuntime.ts +3842 -0
- package/src/internal/fiberScope.ts +71 -0
- package/src/internal/fiberStatus.ts +119 -0
- package/src/internal/groupBy.ts +530 -0
- package/src/internal/hashMap/array.ts +49 -0
- package/src/internal/hashMap/bitwise.ts +32 -0
- package/src/internal/hashMap/config.ts +14 -0
- package/src/internal/hashMap/keySet.ts +8 -0
- package/src/internal/hashMap/node.ts +391 -0
- package/src/internal/hashMap.ts +586 -0
- package/src/internal/hashSet.ts +323 -0
- package/src/internal/keyedPool.ts +244 -0
- package/src/internal/layer/circular.ts +214 -0
- package/src/internal/layer.ts +1483 -0
- package/src/internal/logSpan.ts +20 -0
- package/src/internal/logger-circular.ts +24 -0
- package/src/internal/logger.ts +522 -0
- package/src/internal/mailbox.ts +561 -0
- package/src/internal/managedRuntime/circular.ts +6 -0
- package/src/internal/managedRuntime.ts +134 -0
- package/src/internal/matcher.ts +652 -0
- package/src/internal/metric/boundaries.ts +75 -0
- package/src/internal/metric/hook.ts +483 -0
- package/src/internal/metric/key.ts +167 -0
- package/src/internal/metric/keyType.ts +238 -0
- package/src/internal/metric/label.ts +41 -0
- package/src/internal/metric/pair.ts +48 -0
- package/src/internal/metric/polling.ts +149 -0
- package/src/internal/metric/registry.ts +187 -0
- package/src/internal/metric/state.ts +290 -0
- package/src/internal/metric.ts +577 -0
- package/src/internal/opCodes/cause.ts +35 -0
- package/src/internal/opCodes/channel.ts +83 -0
- package/src/internal/opCodes/channelChildExecutorDecision.ts +17 -0
- package/src/internal/opCodes/channelMergeDecision.ts +11 -0
- package/src/internal/opCodes/channelMergeState.ts +17 -0
- package/src/internal/opCodes/channelMergeStrategy.ts +11 -0
- package/src/internal/opCodes/channelState.ts +23 -0
- package/src/internal/opCodes/channelUpstreamPullRequest.ts +11 -0
- package/src/internal/opCodes/channelUpstreamPullStrategy.ts +11 -0
- package/src/internal/opCodes/config.ts +65 -0
- package/src/internal/opCodes/configError.ts +35 -0
- package/src/internal/opCodes/continuation.ts +11 -0
- package/src/internal/opCodes/deferred.ts +11 -0
- package/src/internal/opCodes/effect.ts +89 -0
- package/src/internal/opCodes/layer.ts +59 -0
- package/src/internal/opCodes/streamHaltStrategy.ts +23 -0
- package/src/internal/option.ts +80 -0
- package/src/internal/pool.ts +432 -0
- package/src/internal/pubsub.ts +1762 -0
- package/src/internal/query.ts +204 -0
- package/src/internal/queue.ts +766 -0
- package/src/internal/random.ts +161 -0
- package/src/internal/rateLimiter.ts +93 -0
- package/src/internal/rcMap.ts +285 -0
- package/src/internal/rcRef.ts +192 -0
- package/src/internal/redBlackTree/iterator.ts +200 -0
- package/src/internal/redBlackTree/node.ts +68 -0
- package/src/internal/redBlackTree.ts +1245 -0
- package/src/internal/redacted.ts +73 -0
- package/src/internal/ref.ts +171 -0
- package/src/internal/reloadable.ts +140 -0
- package/src/internal/request.ts +177 -0
- package/src/internal/resource.ts +76 -0
- package/src/internal/ringBuffer.ts +68 -0
- package/src/internal/runtime.ts +558 -0
- package/src/internal/runtimeFlags.ts +178 -0
- package/src/internal/runtimeFlagsPatch.ts +103 -0
- package/src/internal/schedule/decision.ts +47 -0
- package/src/internal/schedule/interval.ts +101 -0
- package/src/internal/schedule/intervals.ts +180 -0
- package/src/internal/schedule.ts +2199 -0
- package/src/internal/schema/errors.ts +191 -0
- package/src/internal/schema/schemaId.ts +106 -0
- package/src/internal/schema/util.ts +50 -0
- package/src/internal/scopedCache.ts +644 -0
- package/src/internal/scopedRef.ts +118 -0
- package/src/internal/secret.ts +89 -0
- package/src/internal/singleShotGen.ts +35 -0
- package/src/internal/sink.ts +2120 -0
- package/src/internal/stack.ts +10 -0
- package/src/internal/stm/core.ts +817 -0
- package/src/internal/stm/entry.ts +59 -0
- package/src/internal/stm/journal.ts +123 -0
- package/src/internal/stm/opCodes/stm.ts +71 -0
- package/src/internal/stm/opCodes/stmState.ts +17 -0
- package/src/internal/stm/opCodes/strategy.ts +17 -0
- package/src/internal/stm/opCodes/tExit.ts +29 -0
- package/src/internal/stm/opCodes/tryCommit.ts +11 -0
- package/src/internal/stm/stm.ts +1453 -0
- package/src/internal/stm/stmState.ts +136 -0
- package/src/internal/stm/tArray.ts +550 -0
- package/src/internal/stm/tDeferred.ts +81 -0
- package/src/internal/stm/tExit.ts +190 -0
- package/src/internal/stm/tMap.ts +824 -0
- package/src/internal/stm/tPriorityQueue.ts +267 -0
- package/src/internal/stm/tPubSub.ts +551 -0
- package/src/internal/stm/tQueue.ts +393 -0
- package/src/internal/stm/tRandom.ts +140 -0
- package/src/internal/stm/tReentrantLock.ts +352 -0
- package/src/internal/stm/tRef.ts +195 -0
- package/src/internal/stm/tSemaphore.ts +113 -0
- package/src/internal/stm/tSet.ts +259 -0
- package/src/internal/stm/tSubscriptionRef.ts +286 -0
- package/src/internal/stm/tryCommit.ts +34 -0
- package/src/internal/stm/txnId.ts +14 -0
- package/src/internal/stm/versioned.ts +4 -0
- package/src/internal/stream/debounceState.ts +57 -0
- package/src/internal/stream/emit.ts +123 -0
- package/src/internal/stream/haltStrategy.ts +94 -0
- package/src/internal/stream/handoff.ts +187 -0
- package/src/internal/stream/handoffSignal.ts +59 -0
- package/src/internal/stream/pull.ts +34 -0
- package/src/internal/stream/sinkEndReason.ts +30 -0
- package/src/internal/stream/zipAllState.ts +88 -0
- package/src/internal/stream/zipChunksState.ts +56 -0
- package/src/internal/stream.ts +8801 -0
- package/src/internal/string-utils.ts +107 -0
- package/src/internal/subscriptionRef.ts +138 -0
- package/src/internal/supervisor/patch.ts +190 -0
- package/src/internal/supervisor.ts +303 -0
- package/src/internal/synchronizedRef.ts +114 -0
- package/src/internal/take.ts +199 -0
- package/src/internal/testing/sleep.ts +27 -0
- package/src/internal/testing/suspendedWarningData.ts +85 -0
- package/src/internal/testing/warningData.ts +94 -0
- package/src/internal/tracer.ts +150 -0
- package/src/internal/trie.ts +722 -0
- package/src/internal/version.ts +7 -0
package/src/Metric.ts
ADDED
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 2.0.0
|
|
3
|
+
*/
|
|
4
|
+
import type * as Duration from "./Duration.js"
|
|
5
|
+
import type * as Effect from "./Effect.js"
|
|
6
|
+
import type { LazyArg } from "./Function.js"
|
|
7
|
+
import * as fiberRuntime from "./internal/fiberRuntime.js"
|
|
8
|
+
import * as internal from "./internal/metric.js"
|
|
9
|
+
import type * as MetricBoundaries from "./MetricBoundaries.js"
|
|
10
|
+
import type * as MetricKey from "./MetricKey.js"
|
|
11
|
+
import type * as MetricKeyType from "./MetricKeyType.js"
|
|
12
|
+
import type * as MetricLabel from "./MetricLabel.js"
|
|
13
|
+
import type * as MetricPair from "./MetricPair.js"
|
|
14
|
+
import type * as MetricRegistry from "./MetricRegistry.js"
|
|
15
|
+
import type * as MetricState from "./MetricState.js"
|
|
16
|
+
import type { Pipeable } from "./Pipeable.js"
|
|
17
|
+
import type * as Types from "./Types.js"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @since 2.0.0
|
|
21
|
+
* @category symbols
|
|
22
|
+
*/
|
|
23
|
+
export const MetricTypeId: unique symbol = internal.MetricTypeId
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @since 2.0.0
|
|
27
|
+
* @category symbols
|
|
28
|
+
*/
|
|
29
|
+
export type MetricTypeId = typeof MetricTypeId
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A `Metric<Type, In, Out>` represents a concurrent metric which accepts
|
|
33
|
+
* updates of type `In` and are aggregated to a stateful value of type `Out`.
|
|
34
|
+
*
|
|
35
|
+
* For example, a counter metric would have type `Metric<number, number>`,
|
|
36
|
+
* representing the fact that the metric can be updated with numbers (the amount
|
|
37
|
+
* to increment or decrement the counter by), and the state of the counter is a
|
|
38
|
+
* number.
|
|
39
|
+
*
|
|
40
|
+
* There are five primitive metric types supported by Effect:
|
|
41
|
+
*
|
|
42
|
+
* - Counters
|
|
43
|
+
* - Frequencies
|
|
44
|
+
* - Gauges
|
|
45
|
+
* - Histograms
|
|
46
|
+
* - Summaries
|
|
47
|
+
*
|
|
48
|
+
* @since 2.0.0
|
|
49
|
+
* @category models
|
|
50
|
+
*/
|
|
51
|
+
export interface Metric<in out Type, in In, out Out> extends Metric.Variance<Type, In, Out>, Pipeable {
|
|
52
|
+
/**
|
|
53
|
+
* The type of the underlying primitive metric. For example, this could be
|
|
54
|
+
* `MetricKeyType.Counter` or `MetricKeyType.Gauge`.
|
|
55
|
+
*/
|
|
56
|
+
readonly keyType: Type
|
|
57
|
+
unsafeUpdate(input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>): void
|
|
58
|
+
unsafeValue(extraTags: ReadonlyArray<MetricLabel.MetricLabel>): Out
|
|
59
|
+
unsafeModify(input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>): void
|
|
60
|
+
register(): this
|
|
61
|
+
<A extends In, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @since 2.0.0
|
|
66
|
+
* @category models
|
|
67
|
+
*/
|
|
68
|
+
export interface MetricApply {
|
|
69
|
+
<Type, In, Out>(
|
|
70
|
+
keyType: Type,
|
|
71
|
+
unsafeUpdate: (input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>) => void,
|
|
72
|
+
unsafeValue: (extraTags: ReadonlyArray<MetricLabel.MetricLabel>) => Out,
|
|
73
|
+
unsafeModify: (input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>) => void
|
|
74
|
+
): Metric<Type, In, Out>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @since 2.0.0
|
|
79
|
+
*/
|
|
80
|
+
export declare namespace Metric {
|
|
81
|
+
/**
|
|
82
|
+
* @since 2.0.0
|
|
83
|
+
* @category models
|
|
84
|
+
*/
|
|
85
|
+
export interface Counter<In extends number | bigint>
|
|
86
|
+
extends Metric<MetricKeyType.MetricKeyType.Counter<In>, In, MetricState.MetricState.Counter<In>>
|
|
87
|
+
{}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @since 2.0.0
|
|
91
|
+
* @category models
|
|
92
|
+
*/
|
|
93
|
+
export interface Gauge<In extends number | bigint>
|
|
94
|
+
extends Metric<MetricKeyType.MetricKeyType.Gauge<In>, In, MetricState.MetricState.Gauge<In>>
|
|
95
|
+
{}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @since 2.0.0
|
|
99
|
+
* @category models
|
|
100
|
+
*/
|
|
101
|
+
export interface Frequency<In>
|
|
102
|
+
extends Metric<MetricKeyType.MetricKeyType.Frequency, In, MetricState.MetricState.Frequency>
|
|
103
|
+
{}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @since 2.0.0
|
|
107
|
+
* @category models
|
|
108
|
+
*/
|
|
109
|
+
export interface Histogram<In>
|
|
110
|
+
extends Metric<MetricKeyType.MetricKeyType.Histogram, In, MetricState.MetricState.Histogram>
|
|
111
|
+
{}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @since 2.0.0
|
|
115
|
+
* @category models
|
|
116
|
+
*/
|
|
117
|
+
export interface Summary<In>
|
|
118
|
+
extends Metric<MetricKeyType.MetricKeyType.Summary, In, MetricState.MetricState.Summary>
|
|
119
|
+
{}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @since 2.0.0
|
|
123
|
+
* @category models
|
|
124
|
+
*/
|
|
125
|
+
export interface Variance<in out Type, in In, out Out> {
|
|
126
|
+
readonly [MetricTypeId]: {
|
|
127
|
+
readonly _Type: Types.Invariant<Type>
|
|
128
|
+
readonly _In: Types.Contravariant<In>
|
|
129
|
+
readonly _Out: Types.Covariant<Out>
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @since 2.0.0
|
|
136
|
+
* @category globals
|
|
137
|
+
*/
|
|
138
|
+
export const globalMetricRegistry: MetricRegistry.MetricRegistry = internal.globalMetricRegistry
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @since 2.0.0
|
|
142
|
+
* @category constructors
|
|
143
|
+
*/
|
|
144
|
+
export const make: MetricApply = internal.make
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Returns a new metric that is powered by this one, but which accepts updates
|
|
148
|
+
* of the specified new type, which must be transformable to the input type of
|
|
149
|
+
* this metric.
|
|
150
|
+
*
|
|
151
|
+
* @since 2.0.0
|
|
152
|
+
* @category mapping
|
|
153
|
+
*/
|
|
154
|
+
export const mapInput: {
|
|
155
|
+
<In, In2>(f: (input: In2) => In): <Type, Out>(self: Metric<Type, In, Out>) => Metric<Type, In2, Out>
|
|
156
|
+
<Type, In, Out, In2>(self: Metric<Type, In, Out>, f: (input: In2) => In): Metric<Type, In2, Out>
|
|
157
|
+
} = internal.mapInput
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Represents a Counter metric that tracks cumulative numerical values over time.
|
|
161
|
+
* Counters can be incremented and decremented and provide a running total of changes.
|
|
162
|
+
*
|
|
163
|
+
* **Options**
|
|
164
|
+
*
|
|
165
|
+
* - description - A description of the counter.
|
|
166
|
+
* - bigint - Indicates if the counter uses 'bigint' data type.
|
|
167
|
+
* - incremental - Set to 'true' for a counter that only increases. With this configuration, Effect ensures that non-incremental updates have no impact on the counter, making it exclusively suitable for counting upwards.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* import { Metric } from "effect"
|
|
172
|
+
*
|
|
173
|
+
* const numberCounter = Metric.counter("count", {
|
|
174
|
+
* description: "A number counter"
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* const bigintCounter = Metric.counter("count", {
|
|
178
|
+
* description: "A bigint counter",
|
|
179
|
+
* bigint: true
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @since 2.0.0
|
|
184
|
+
* @category constructors
|
|
185
|
+
*/
|
|
186
|
+
export const counter: {
|
|
187
|
+
(
|
|
188
|
+
name: string,
|
|
189
|
+
options?: {
|
|
190
|
+
readonly description?: string | undefined
|
|
191
|
+
readonly bigint?: false | undefined
|
|
192
|
+
readonly incremental?: boolean | undefined
|
|
193
|
+
}
|
|
194
|
+
): Metric.Counter<number>
|
|
195
|
+
(
|
|
196
|
+
name: string,
|
|
197
|
+
options: {
|
|
198
|
+
readonly description?: string | undefined
|
|
199
|
+
readonly bigint: true
|
|
200
|
+
readonly incremental?: boolean | undefined
|
|
201
|
+
}
|
|
202
|
+
): Metric.Counter<bigint>
|
|
203
|
+
} = internal.counter
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Creates a Frequency metric to count occurrences of events.
|
|
207
|
+
* Frequency metrics are used to count the number of times specific events or incidents occur.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* import { Metric } from "effect"
|
|
212
|
+
*
|
|
213
|
+
* const errorFrequency = Metric.frequency("error_frequency", {
|
|
214
|
+
* description: "Counts the occurrences of errors."
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @since 2.0.0
|
|
219
|
+
* @category constructors
|
|
220
|
+
*/
|
|
221
|
+
export const frequency: (
|
|
222
|
+
name: string,
|
|
223
|
+
options?:
|
|
224
|
+
| { readonly description?: string | undefined; readonly preregisteredWords?: ReadonlyArray<string> | undefined }
|
|
225
|
+
| undefined
|
|
226
|
+
) => Metric.Frequency<string> = internal.frequency
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Returns a new metric that is powered by this one, but which accepts updates
|
|
230
|
+
* of any type, and translates them to updates with the specified constant
|
|
231
|
+
* update value.
|
|
232
|
+
*
|
|
233
|
+
* @since 2.0.0
|
|
234
|
+
* @category constructors
|
|
235
|
+
*/
|
|
236
|
+
export const withConstantInput: {
|
|
237
|
+
<In>(input: In): <Type, Out>(self: Metric<Type, In, Out>) => Metric<Type, unknown, Out>
|
|
238
|
+
<Type, In, Out>(self: Metric<Type, In, Out>, input: In): Metric<Type, unknown, Out>
|
|
239
|
+
} = internal.withConstantInput
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @since 2.0.0
|
|
243
|
+
* @category constructors
|
|
244
|
+
*/
|
|
245
|
+
export const fromMetricKey: <Type extends MetricKeyType.MetricKeyType<any, any>>(
|
|
246
|
+
key: MetricKey.MetricKey<Type>
|
|
247
|
+
) => Metric<Type, MetricKeyType.MetricKeyType.InType<Type>, MetricKeyType.MetricKeyType.OutType<Type>> =
|
|
248
|
+
internal.fromMetricKey
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Represents a Gauge metric that tracks and reports a single numerical value at a specific moment.
|
|
252
|
+
* Gauges are suitable for metrics that represent instantaneous values, such as memory usage or CPU load.
|
|
253
|
+
*
|
|
254
|
+
* **Options**
|
|
255
|
+
*
|
|
256
|
+
* - description - A description of the gauge metric.
|
|
257
|
+
* - bigint - Indicates if the counter uses 'bigint' data type.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* import { Metric } from "effect"
|
|
262
|
+
*
|
|
263
|
+
* const numberGauge = Metric.gauge("memory_usage", {
|
|
264
|
+
* description: "A gauge for memory usage"
|
|
265
|
+
* });
|
|
266
|
+
*
|
|
267
|
+
* const bigintGauge = Metric.gauge("cpu_load", {
|
|
268
|
+
* description: "A gauge for CPU load",
|
|
269
|
+
* bigint: true
|
|
270
|
+
* });
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* @since 2.0.0
|
|
274
|
+
* @category constructors
|
|
275
|
+
*/
|
|
276
|
+
export const gauge: {
|
|
277
|
+
(name: string, options?: {
|
|
278
|
+
readonly description?: string | undefined
|
|
279
|
+
readonly bigint?: false | undefined
|
|
280
|
+
}): Metric.Gauge<number>
|
|
281
|
+
(name: string, options: {
|
|
282
|
+
readonly description?: string | undefined
|
|
283
|
+
readonly bigint: true
|
|
284
|
+
}): Metric.Gauge<bigint>
|
|
285
|
+
} = internal.gauge
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Represents a Histogram metric that records observations in specified value boundaries.
|
|
289
|
+
* Histogram metrics are useful for measuring the distribution of values within a range.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* import { Metric, MetricBoundaries } from "effect"
|
|
294
|
+
*
|
|
295
|
+
* const latencyHistogram = Metric.histogram("latency_histogram",
|
|
296
|
+
* MetricBoundaries.linear({ start: 0, width: 10, count: 11 }),
|
|
297
|
+
* "Measures the distribution of request latency."
|
|
298
|
+
* );
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* @since 2.0.0
|
|
302
|
+
* @category constructors
|
|
303
|
+
*/
|
|
304
|
+
export const histogram: (
|
|
305
|
+
name: string,
|
|
306
|
+
boundaries: MetricBoundaries.MetricBoundaries,
|
|
307
|
+
description?: string
|
|
308
|
+
) => Metric<MetricKeyType.MetricKeyType.Histogram, number, MetricState.MetricState.Histogram> = internal.histogram
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @since 2.0.0
|
|
312
|
+
* @category combinators
|
|
313
|
+
*/
|
|
314
|
+
export const increment: (
|
|
315
|
+
self: Metric.Counter<number> | Metric.Counter<bigint> | Metric.Gauge<number> | Metric.Gauge<bigint>
|
|
316
|
+
) => Effect.Effect<void> = internal.increment
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @since 2.0.0
|
|
320
|
+
* @category combinators
|
|
321
|
+
*/
|
|
322
|
+
export const incrementBy: {
|
|
323
|
+
(amount: number): (self: Metric.Counter<number> | Metric.Counter<number>) => Effect.Effect<void>
|
|
324
|
+
(amount: bigint): (self: Metric.Counter<bigint> | Metric.Gauge<bigint>) => Effect.Effect<void>
|
|
325
|
+
(self: Metric.Counter<number> | Metric.Gauge<number>, amount: number): Effect.Effect<void>
|
|
326
|
+
(self: Metric.Counter<bigint> | Metric.Gauge<bigint>, amount: bigint): Effect.Effect<void>
|
|
327
|
+
} = internal.incrementBy
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Returns a new metric that is powered by this one, but which outputs a new
|
|
331
|
+
* state type, determined by transforming the state type of this metric by the
|
|
332
|
+
* specified function.
|
|
333
|
+
*
|
|
334
|
+
* @since 2.0.0
|
|
335
|
+
* @category mapping
|
|
336
|
+
*/
|
|
337
|
+
export const map: {
|
|
338
|
+
<Out, Out2>(f: (out: Out) => Out2): <Type, In>(self: Metric<Type, In, Out>) => Metric<Type, In, Out2>
|
|
339
|
+
<Type, In, Out, Out2>(self: Metric<Type, In, Out>, f: (out: Out) => Out2): Metric<Type, In, Out2>
|
|
340
|
+
} = internal.map
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @since 2.0.0
|
|
344
|
+
* @category mapping
|
|
345
|
+
*/
|
|
346
|
+
export const mapType: {
|
|
347
|
+
<Type, Type2>(f: (type: Type) => Type2): <In, Out>(self: Metric<Type, In, Out>) => Metric<Type2, In, Out>
|
|
348
|
+
<Type, In, Out, Type2>(self: Metric<Type, In, Out>, f: (type: Type) => Type2): Metric<Type2, In, Out>
|
|
349
|
+
} = internal.mapType
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Modifies the metric with the specified update message. For example, if the
|
|
353
|
+
* metric were a gauge, the update would increment the method by the provided
|
|
354
|
+
* amount.
|
|
355
|
+
*
|
|
356
|
+
* @since 3.6.5
|
|
357
|
+
* @category utils
|
|
358
|
+
*/
|
|
359
|
+
export const modify: {
|
|
360
|
+
<In>(input: In): <Type, Out>(self: Metric<Type, In, Out>) => Effect.Effect<void>
|
|
361
|
+
<Type, In, Out>(self: Metric<Type, In, Out>, input: In): Effect.Effect<void>
|
|
362
|
+
} = internal.modify
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* @since 2.0.0
|
|
366
|
+
* @category aspects
|
|
367
|
+
*/
|
|
368
|
+
export const set: {
|
|
369
|
+
(value: number): (self: Metric.Gauge<number>) => Effect.Effect<void>
|
|
370
|
+
(value: bigint): (self: Metric.Gauge<bigint>) => Effect.Effect<void>
|
|
371
|
+
(self: Metric.Gauge<number>, value: number): Effect.Effect<void>
|
|
372
|
+
(self: Metric.Gauge<bigint>, value: bigint): Effect.Effect<void>
|
|
373
|
+
} = internal.set
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Captures a snapshot of all metrics recorded by the application.
|
|
377
|
+
*
|
|
378
|
+
* @since 2.0.0
|
|
379
|
+
* @category getters
|
|
380
|
+
*/
|
|
381
|
+
export const snapshot: Effect.Effect<Array<MetricPair.MetricPair.Untyped>> = internal.snapshot
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Creates a metric that ignores input and produces constant output.
|
|
385
|
+
*
|
|
386
|
+
* @since 2.0.0
|
|
387
|
+
* @category constructors
|
|
388
|
+
*/
|
|
389
|
+
export const succeed: <Out>(out: Out) => Metric<void, unknown, Out> = internal.succeed
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Creates a metric that ignores input and produces constant output.
|
|
393
|
+
*
|
|
394
|
+
* @since 2.0.0
|
|
395
|
+
* @category constructors
|
|
396
|
+
*/
|
|
397
|
+
export const sync: <Out>(evaluate: LazyArg<Out>) => Metric<void, unknown, Out> = internal.sync
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Creates a Summary metric that records observations and calculates quantiles.
|
|
401
|
+
* Summary metrics provide statistical information about a set of values, including quantiles.
|
|
402
|
+
*
|
|
403
|
+
* **Options**
|
|
404
|
+
*
|
|
405
|
+
* - name - The name of the Summary metric.
|
|
406
|
+
* - maxAge - The maximum age of observations to retain.
|
|
407
|
+
* - maxSize - The maximum number of observations to keep.
|
|
408
|
+
* - error - The error percentage when calculating quantiles.
|
|
409
|
+
* - quantiles - An `Chunk` of quantiles to calculate (e.g., [0.5, 0.9]).
|
|
410
|
+
* - description - An optional description of the Summary metric.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* import { Metric, Chunk } from "effect"
|
|
415
|
+
*
|
|
416
|
+
* const responseTimesSummary = Metric.summary({
|
|
417
|
+
* name: "response_times_summary",
|
|
418
|
+
* maxAge: "60 seconds", // Retain observations for 60 seconds.
|
|
419
|
+
* maxSize: 1000, // Keep a maximum of 1000 observations.
|
|
420
|
+
* error: 0.01, // Allow a 1% error when calculating quantiles.
|
|
421
|
+
* quantiles: [0.5, 0.9, 0.99], // Calculate 50th, 90th, and 99th percentiles.
|
|
422
|
+
* description: "Measures the distribution of response times."
|
|
423
|
+
* });
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @since 2.0.0
|
|
427
|
+
* @category constructors
|
|
428
|
+
*/
|
|
429
|
+
export const summary: (
|
|
430
|
+
options: {
|
|
431
|
+
readonly name: string
|
|
432
|
+
readonly maxAge: Duration.DurationInput
|
|
433
|
+
readonly maxSize: number
|
|
434
|
+
readonly error: number
|
|
435
|
+
readonly quantiles: ReadonlyArray<number>
|
|
436
|
+
readonly description?: string | undefined
|
|
437
|
+
}
|
|
438
|
+
) => Metric.Summary<number> = internal.summary
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* @since 2.0.0
|
|
442
|
+
* @category constructors
|
|
443
|
+
*/
|
|
444
|
+
export const summaryTimestamp: (
|
|
445
|
+
options: {
|
|
446
|
+
readonly name: string
|
|
447
|
+
readonly maxAge: Duration.DurationInput
|
|
448
|
+
readonly maxSize: number
|
|
449
|
+
readonly error: number
|
|
450
|
+
readonly quantiles: ReadonlyArray<number>
|
|
451
|
+
readonly description?: string | undefined
|
|
452
|
+
}
|
|
453
|
+
) => Metric.Summary<readonly [value: number, timestamp: number]> // readonly because contravariant
|
|
454
|
+
= internal.summaryTimestamp
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Returns a new metric, which is identical in every way to this one, except
|
|
458
|
+
* the specified tags have been added to the tags of this metric.
|
|
459
|
+
*
|
|
460
|
+
* @since 2.0.0
|
|
461
|
+
* @category utils
|
|
462
|
+
*/
|
|
463
|
+
export const tagged: {
|
|
464
|
+
<Type, In, Out>(key: string, value: string): (self: Metric<Type, In, Out>) => Metric<Type, In, Out>
|
|
465
|
+
<Type, In, Out>(self: Metric<Type, In, Out>, key: string, value: string): Metric<Type, In, Out>
|
|
466
|
+
} = internal.tagged
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Returns a new metric, which is identical in every way to this one, except
|
|
470
|
+
* dynamic tags are added based on the update values. Note that the metric
|
|
471
|
+
* returned by this method does not return any useful information, due to the
|
|
472
|
+
* dynamic nature of the added tags.
|
|
473
|
+
*
|
|
474
|
+
* @since 2.0.0
|
|
475
|
+
* @category utils
|
|
476
|
+
*/
|
|
477
|
+
export const taggedWithLabelsInput: {
|
|
478
|
+
<In>(
|
|
479
|
+
f: (input: In) => Iterable<MetricLabel.MetricLabel>
|
|
480
|
+
): <Type, Out>(self: Metric<Type, In, Out>) => Metric<Type, In, void>
|
|
481
|
+
<Type, In, Out>(
|
|
482
|
+
self: Metric<Type, In, Out>,
|
|
483
|
+
f: (input: In) => Iterable<MetricLabel.MetricLabel>
|
|
484
|
+
): Metric<Type, In, void>
|
|
485
|
+
} = internal.taggedWithLabelsInput
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Returns a new metric, which is identical in every way to this one, except
|
|
489
|
+
* the specified tags have been added to the tags of this metric.
|
|
490
|
+
*
|
|
491
|
+
* @since 2.0.0
|
|
492
|
+
* @category utils
|
|
493
|
+
*/
|
|
494
|
+
export const taggedWithLabels: {
|
|
495
|
+
<Type, In, Out>(extraTags: Iterable<MetricLabel.MetricLabel>): (self: Metric<Type, In, Out>) => Metric<Type, In, Out>
|
|
496
|
+
<Type, In, Out>(self: Metric<Type, In, Out>, extraTags: Iterable<MetricLabel.MetricLabel>): Metric<Type, In, Out>
|
|
497
|
+
} = internal.taggedWithLabels
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Creates a timer metric, based on a histogram, which keeps track of
|
|
501
|
+
* durations in milliseconds. The unit of time will automatically be added to
|
|
502
|
+
* the metric as a tag (i.e. `"time_unit: milliseconds"`).
|
|
503
|
+
*
|
|
504
|
+
* @since 2.0.0
|
|
505
|
+
* @category constructors
|
|
506
|
+
*/
|
|
507
|
+
export const timer: (
|
|
508
|
+
name: string,
|
|
509
|
+
description?: string
|
|
510
|
+
) => Metric<MetricKeyType.MetricKeyType.Histogram, Duration.Duration, MetricState.MetricState.Histogram> =
|
|
511
|
+
internal.timer
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Creates a timer metric, based on a histogram created from the provided
|
|
515
|
+
* boundaries, which keeps track of durations in milliseconds. The unit of time
|
|
516
|
+
* will automatically be added to the metric as a tag (i.e.
|
|
517
|
+
* `"time_unit: milliseconds"`).
|
|
518
|
+
*
|
|
519
|
+
* @since 2.0.0
|
|
520
|
+
* @category constructors
|
|
521
|
+
*/
|
|
522
|
+
export const timerWithBoundaries: (
|
|
523
|
+
name: string,
|
|
524
|
+
boundaries: ReadonlyArray<number>,
|
|
525
|
+
description?: string
|
|
526
|
+
) => Metric<MetricKeyType.MetricKeyType.Histogram, Duration.Duration, MetricState.MetricState.Histogram> =
|
|
527
|
+
internal.timerWithBoundaries
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Returns an aspect that will update this metric with the specified constant
|
|
531
|
+
* value every time the aspect is applied to an effect, regardless of whether
|
|
532
|
+
* that effect fails or succeeds.
|
|
533
|
+
*
|
|
534
|
+
* @since 2.0.0
|
|
535
|
+
* @category aspects
|
|
536
|
+
*/
|
|
537
|
+
export const trackAll: {
|
|
538
|
+
<In>(
|
|
539
|
+
input: In
|
|
540
|
+
): <Type, Out>(self: Metric<Type, In, Out>) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
541
|
+
<Type, In, Out>(
|
|
542
|
+
self: Metric<Type, In, Out>,
|
|
543
|
+
input: In
|
|
544
|
+
): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
545
|
+
} = internal.trackAll
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Returns an aspect that will update this metric with the defects of the
|
|
549
|
+
* effects that it is applied to.
|
|
550
|
+
*
|
|
551
|
+
* @since 2.0.0
|
|
552
|
+
* @category aspects
|
|
553
|
+
*/
|
|
554
|
+
export const trackDefect: {
|
|
555
|
+
<Type, Out>(metric: Metric<Type, unknown, Out>): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
556
|
+
<A, E, R, Type, Out>(self: Effect.Effect<A, E, R>, metric: Metric<Type, unknown, Out>): Effect.Effect<A, E, R>
|
|
557
|
+
} = internal.trackDefect
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Returns an aspect that will update this metric with the result of applying
|
|
561
|
+
* the specified function to the defect throwables of the effects that the
|
|
562
|
+
* aspect is applied to.
|
|
563
|
+
*
|
|
564
|
+
* @since 2.0.0
|
|
565
|
+
* @category aspects
|
|
566
|
+
*/
|
|
567
|
+
export const trackDefectWith: {
|
|
568
|
+
<Type, In, Out>(
|
|
569
|
+
metric: Metric<Type, In, Out>,
|
|
570
|
+
f: (defect: unknown) => In
|
|
571
|
+
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
572
|
+
<A, E, R, Type, In, Out>(
|
|
573
|
+
self: Effect.Effect<A, E, R>,
|
|
574
|
+
metric: Metric<Type, In, Out>,
|
|
575
|
+
f: (defect: unknown) => In
|
|
576
|
+
): Effect.Effect<A, E, R>
|
|
577
|
+
} = internal.trackDefectWith
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Returns an aspect that will update this metric with the duration that the
|
|
581
|
+
* effect takes to execute. To call this method, the input type of the metric
|
|
582
|
+
* must be `Duration`.
|
|
583
|
+
*
|
|
584
|
+
* @since 2.0.0
|
|
585
|
+
* @category aspects
|
|
586
|
+
*/
|
|
587
|
+
export const trackDuration: {
|
|
588
|
+
<Type, Out>(
|
|
589
|
+
metric: Metric<Type, Duration.Duration, Out>
|
|
590
|
+
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
591
|
+
<A, E, R, Type, Out>(
|
|
592
|
+
self: Effect.Effect<A, E, R>,
|
|
593
|
+
metric: Metric<Type, Duration.Duration, Out>
|
|
594
|
+
): Effect.Effect<A, E, R>
|
|
595
|
+
} = internal.trackDuration
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Returns an aspect that will update this metric with the duration that the
|
|
599
|
+
* effect takes to execute. To call this method, you must supply a function
|
|
600
|
+
* that can convert the `Duration` to the input type of this metric.
|
|
601
|
+
*
|
|
602
|
+
* @since 2.0.0
|
|
603
|
+
* @category aspects
|
|
604
|
+
*/
|
|
605
|
+
export const trackDurationWith: {
|
|
606
|
+
<Type, In, Out>(
|
|
607
|
+
metric: Metric<Type, In, Out>,
|
|
608
|
+
f: (duration: Duration.Duration) => In
|
|
609
|
+
): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
610
|
+
<A, E, R, Type, In, Out>(
|
|
611
|
+
self: Effect.Effect<A, E, R>,
|
|
612
|
+
metric: Metric<Type, In, Out>,
|
|
613
|
+
f: (duration: Duration.Duration) => In
|
|
614
|
+
): Effect.Effect<A, E, R>
|
|
615
|
+
} = internal.trackDurationWith
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Returns an aspect that will update this metric with the failure value of
|
|
619
|
+
* the effects that it is applied to.
|
|
620
|
+
*
|
|
621
|
+
* @since 2.0.0
|
|
622
|
+
* @category aspects
|
|
623
|
+
*/
|
|
624
|
+
export const trackError: {
|
|
625
|
+
<Type, In, Out>(
|
|
626
|
+
metric: Metric<Type, In, Out>
|
|
627
|
+
): <A, E extends In, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
628
|
+
<A, E extends In, R, Type, In, Out>(
|
|
629
|
+
self: Effect.Effect<A, E, R>,
|
|
630
|
+
metric: Metric<Type, In, Out>
|
|
631
|
+
): Effect.Effect<A, E, R>
|
|
632
|
+
} = internal.trackError
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Returns an aspect that will update this metric with the result of applying
|
|
636
|
+
* the specified function to the error value of the effects that the aspect is
|
|
637
|
+
* applied to.
|
|
638
|
+
*
|
|
639
|
+
* @since 2.0.0
|
|
640
|
+
* @category aspects
|
|
641
|
+
*/
|
|
642
|
+
export const trackErrorWith: {
|
|
643
|
+
<Type, In, Out, In2>(
|
|
644
|
+
metric: Metric<Type, In, Out>,
|
|
645
|
+
f: (error: In2) => In
|
|
646
|
+
): <A, E extends In2, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
647
|
+
<A, E extends In2, R, Type, In, Out, In2>(
|
|
648
|
+
self: Effect.Effect<A, E, R>,
|
|
649
|
+
metric: Metric<Type, In, Out>,
|
|
650
|
+
f: (error: In2) => In
|
|
651
|
+
): Effect.Effect<A, E, R>
|
|
652
|
+
} = internal.trackErrorWith
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Returns an aspect that will update this metric with the success value of
|
|
656
|
+
* the effects that it is applied to.
|
|
657
|
+
*
|
|
658
|
+
* @since 2.0.0
|
|
659
|
+
* @category aspects
|
|
660
|
+
*/
|
|
661
|
+
export const trackSuccess: {
|
|
662
|
+
<Type, In, Out>(
|
|
663
|
+
metric: Metric<Type, In, Out>
|
|
664
|
+
): <A extends In, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
665
|
+
<A extends In, E, R, Type, In, Out>(
|
|
666
|
+
self: Effect.Effect<A, E, R>,
|
|
667
|
+
metric: Metric<Type, In, Out>
|
|
668
|
+
): Effect.Effect<A, E, R>
|
|
669
|
+
} = internal.trackSuccess
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Returns an aspect that will update this metric with the result of applying
|
|
673
|
+
* the specified function to the success value of the effects that the aspect is
|
|
674
|
+
* applied to.
|
|
675
|
+
*
|
|
676
|
+
* @since 2.0.0
|
|
677
|
+
* @category aspects
|
|
678
|
+
*/
|
|
679
|
+
export const trackSuccessWith: {
|
|
680
|
+
<Type, In, Out, A>(
|
|
681
|
+
metric: Metric<Type, In, Out>,
|
|
682
|
+
f: (value: Types.NoInfer<A>) => In
|
|
683
|
+
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
684
|
+
<A, E, R, Type, In, Out>(
|
|
685
|
+
self: Effect.Effect<A, E, R>,
|
|
686
|
+
metric: Metric<Type, In, Out>,
|
|
687
|
+
f: (value: Types.NoInfer<A>) => In
|
|
688
|
+
): Effect.Effect<A, E, R>
|
|
689
|
+
} = internal.trackSuccessWith
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Updates the metric with the specified update message. For example, if the
|
|
693
|
+
* metric were a counter, the update would increment the method by the
|
|
694
|
+
* provided amount.
|
|
695
|
+
*
|
|
696
|
+
* @since 2.0.0
|
|
697
|
+
* @category utils
|
|
698
|
+
*/
|
|
699
|
+
export const update: {
|
|
700
|
+
<In>(input: In): <Type, Out>(self: Metric<Type, In, Out>) => Effect.Effect<void>
|
|
701
|
+
<Type, In, Out>(self: Metric<Type, In, Out>, input: In): Effect.Effect<void>
|
|
702
|
+
} = internal.update
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Retrieves a snapshot of the value of the metric at this moment in time.
|
|
706
|
+
*
|
|
707
|
+
* @since 2.0.0
|
|
708
|
+
* @category getters
|
|
709
|
+
*/
|
|
710
|
+
export const value: <Type, In, Out>(self: Metric<Type, In, Out>) => Effect.Effect<Out> = internal.value
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* @since 2.0.0
|
|
714
|
+
* @category utils
|
|
715
|
+
*/
|
|
716
|
+
export const withNow: <Type, In, Out>(self: Metric<Type, readonly [In, number], Out>) => Metric<Type, In, Out> =
|
|
717
|
+
internal.withNow
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* @since 2.0.0
|
|
721
|
+
* @category zipping
|
|
722
|
+
*/
|
|
723
|
+
export const zip: {
|
|
724
|
+
<Type2, In2, Out2>(
|
|
725
|
+
that: Metric<Type2, In2, Out2>
|
|
726
|
+
): <Type, In, Out>(
|
|
727
|
+
self: Metric<Type, In, Out>
|
|
728
|
+
) => Metric<
|
|
729
|
+
readonly [Type, Type2], // readonly because invariant
|
|
730
|
+
readonly [In, In2], // readonly because contravariant
|
|
731
|
+
[Out, Out2]
|
|
732
|
+
>
|
|
733
|
+
<Type, In, Out, Type2, In2, Out2>(
|
|
734
|
+
self: Metric<Type, In, Out>,
|
|
735
|
+
that: Metric<Type2, In2, Out2>
|
|
736
|
+
): Metric<
|
|
737
|
+
readonly [Type, Type2], // readonly because invariant
|
|
738
|
+
readonly [In, In2], // readonly because contravariant
|
|
739
|
+
[Out, Out2]
|
|
740
|
+
>
|
|
741
|
+
} = internal.zip
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Unsafely captures a snapshot of all metrics recorded by the application.
|
|
745
|
+
*
|
|
746
|
+
* @since 2.0.0
|
|
747
|
+
* @category unsafe
|
|
748
|
+
*/
|
|
749
|
+
export const unsafeSnapshot: (_: void) => ReadonlyArray<MetricPair.MetricPair.Untyped> = internal.unsafeSnapshot
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* @since 2.0.0
|
|
753
|
+
* @category metrics
|
|
754
|
+
*/
|
|
755
|
+
export const fiberStarted: Metric.Counter<number> = fiberRuntime.fiberStarted
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* @since 2.0.0
|
|
759
|
+
* @category metrics
|
|
760
|
+
*/
|
|
761
|
+
export const fiberSuccesses: Metric.Counter<number> = fiberRuntime.fiberSuccesses
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* @since 2.0.0
|
|
765
|
+
* @category metrics
|
|
766
|
+
*/
|
|
767
|
+
export const fiberFailures: Metric.Counter<number> = fiberRuntime.fiberFailures
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* @since 2.0.0
|
|
771
|
+
* @category metrics
|
|
772
|
+
*/
|
|
773
|
+
export const fiberLifetimes: Metric<MetricKeyType.MetricKeyType.Histogram, number, MetricState.MetricState.Histogram> =
|
|
774
|
+
fiberRuntime.fiberLifetimes
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* @since 2.0.0
|
|
778
|
+
* @category metrics
|
|
779
|
+
*/
|
|
780
|
+
export const fiberActive: Metric.Counter<number> = fiberRuntime.fiberActive
|