effect 4.0.0-beta.102 → 4.0.0-beta.103
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/dist/Array.d.ts +971 -1037
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +381 -407
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +433 -756
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +200 -325
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +207 -267
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +107 -135
- package/dist/BigInt.js.map +1 -1
- package/dist/Boolean.d.ts +146 -188
- package/dist/Boolean.d.ts.map +1 -1
- package/dist/Boolean.js +64 -84
- package/dist/Boolean.js.map +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +405 -254
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +166 -101
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +167 -277
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +122 -176
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +729 -768
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +514 -440
- package/dist/Channel.js.map +1 -1
- package/dist/ChannelSchema.d.ts +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/ChannelSchema.js.map +1 -1
- package/dist/Chunk.d.ts +834 -1173
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +326 -439
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +180 -49
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +96 -31
- package/dist/Clock.js.map +1 -1
- package/dist/Combiner.d.ts +20 -33
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +18 -30
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +225 -173
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +336 -265
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +194 -68
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +115 -80
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +233 -33
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js +232 -32
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +151 -274
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +171 -214
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +68 -77
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +57 -66
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +13 -15
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +9 -10
- package/dist/Crypto.js.map +1 -1
- package/dist/Data.d.ts +60 -80
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +16 -23
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +562 -660
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +307 -362
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +253 -256
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +104 -96
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +216 -308
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +132 -186
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +2841 -3247
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1322 -1546
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +22 -40
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +22 -40
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +33 -37
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +29 -21
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +103 -105
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +77 -79
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +51 -27
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +50 -26
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +13 -55
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +7 -28
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Exit.d.ts +116 -192
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +82 -130
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +82 -146
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +48 -87
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +152 -105
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +106 -73
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +213 -168
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +114 -89
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +123 -81
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +85 -59
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +153 -264
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +42 -147
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +61 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +26 -15
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +25 -33
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +48 -49
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +76 -145
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +40 -57
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +360 -714
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +168 -297
- package/dist/Graph.js.map +1 -1
- package/dist/HKT.d.ts +12 -6
- package/dist/HKT.d.ts.map +1 -1
- package/dist/Hash.d.ts +47 -83
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +46 -68
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +319 -411
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +122 -166
- package/dist/HashMap.js.map +1 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +1 -0
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +177 -284
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js +68 -109
- package/dist/HashSet.js.map +1 -1
- package/dist/Inspectable.d.ts +12 -12
- package/dist/Inspectable.js +8 -8
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts +620 -786
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +228 -306
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts +11 -13
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +44 -102
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +8 -8
- package/dist/JsonPointer.js +8 -8
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.d.ts +98 -44
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +297 -234
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +23 -35
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +16 -28
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +359 -260
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +195 -175
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +42 -29
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +31 -21
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +6 -2
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +6 -2
- package/dist/LayerRef.js.map +1 -1
- package/dist/LogLevel.d.ts +114 -214
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +41 -76
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +218 -467
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +204 -450
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +7 -5
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +7 -5
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +217 -252
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +150 -183
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +442 -993
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +198 -642
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +144 -173
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +68 -79
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +84 -89
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +44 -47
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +71 -370
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +59 -284
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts +420 -243
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +209 -120
- package/dist/MutableRef.js.map +1 -1
- package/dist/Newtype.d.ts +21 -14
- package/dist/Newtype.d.ts.map +1 -1
- package/dist/Newtype.js +15 -13
- package/dist/Newtype.js.map +1 -1
- package/dist/NonEmptyIterable.d.ts +7 -137
- package/dist/NonEmptyIterable.d.ts.map +1 -1
- package/dist/NonEmptyIterable.js +5 -93
- package/dist/NonEmptyIterable.js.map +1 -1
- package/dist/Number.d.ts +196 -233
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +90 -109
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +97 -189
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +187 -290
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +447 -812
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +211 -392
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +109 -109
- package/dist/Order.js +91 -91
- package/dist/Order.js.map +1 -1
- package/dist/Ordering.d.ts +20 -23
- package/dist/Ordering.d.ts.map +1 -1
- package/dist/Ordering.js +8 -9
- package/dist/Ordering.js.map +1 -1
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +38 -41
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +3 -4
- package/dist/Path.js.map +1 -1
- package/dist/Pipeable.d.ts +6 -5
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +2 -2
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +4 -4
- package/dist/PlatformError.js +3 -3
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +4 -2
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +4 -2
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +200 -181
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +100 -108
- package/dist/Predicate.js.map +1 -1
- package/dist/PrimaryKey.d.ts +7 -7
- package/dist/PrimaryKey.js +5 -5
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +425 -494
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +373 -362
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts +24 -18
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +11 -9
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +200 -159
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +162 -132
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +49 -74
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +35 -54
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +121 -63
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +42 -21
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +24 -13
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/RcRef.js +15 -9
- package/dist/RcRef.js.map +1 -1
- package/dist/Record.d.ts +291 -488
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +111 -202
- package/dist/Record.js.map +1 -1
- package/dist/Redactable.d.ts +6 -2
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +7 -2
- package/dist/Redactable.js.map +1 -1
- package/dist/Redacted.d.ts +25 -25
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +19 -20
- package/dist/Redacted.js.map +1 -1
- package/dist/Reducer.d.ts +8 -15
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +6 -12
- package/dist/Reducer.js.map +1 -1
- package/dist/Ref.d.ts +95 -165
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +75 -122
- package/dist/Ref.js.map +1 -1
- package/dist/References.d.ts +102 -168
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +102 -168
- package/dist/References.js.map +1 -1
- package/dist/RegExp.d.ts +10 -14
- package/dist/RegExp.d.ts.map +1 -1
- package/dist/RegExp.js +10 -14
- package/dist/RegExp.js.map +1 -1
- package/dist/Request.d.ts +31 -21
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +16 -13
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +201 -90
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +87 -41
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +302 -470
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +133 -217
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +50 -75
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +39 -60
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +290 -1636
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +162 -803
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +5 -5
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +18 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +644 -642
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +491 -527
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +27 -50
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +366 -279
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +7 -6
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +7 -6
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +217 -174
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +218 -185
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +62 -190
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +73 -265
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +2 -2
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +123 -75
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +22 -36
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +20 -26
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +114 -74
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +120 -85
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +123 -151
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +72 -92
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/ScopedRef.d.ts +3 -3
- package/dist/ScopedRef.js +2 -2
- package/dist/ScopedRef.js.map +1 -1
- package/dist/Semaphore.d.ts +96 -10
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +78 -39
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts +117 -107
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +107 -100
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +1 -1
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +2415 -2949
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +1078 -1381
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +262 -308
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +184 -215
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +109 -114
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +41 -50
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +282 -250
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +104 -92
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Symbol.d.ts +3 -3
- package/dist/Symbol.js +3 -3
- package/dist/Symbol.js.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Take.js.map +1 -1
- package/dist/Terminal.d.ts +2 -2
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +100 -54
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +41 -24
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +287 -679
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +109 -251
- package/dist/Trie.js.map +1 -1
- package/dist/Tuple.d.ts +92 -127
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js +42 -57
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +201 -121
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +85 -56
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +62 -46
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +30 -22
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +631 -779
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +268 -330
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +297 -236
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +130 -100
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +126 -95
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +74 -56
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +101 -88
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +87 -66
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +200 -180
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +160 -136
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +97 -66
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +67 -45
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +51 -32
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +23 -15
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +129 -95
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +85 -70
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +97 -70
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +44 -34
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +126 -67
- package/dist/Types.d.ts.map +1 -1
- package/dist/UndefinedOr.js.map +1 -1
- package/dist/Unify.d.ts +45 -65
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js +6 -9
- package/dist/Unify.js.map +1 -1
- package/dist/Utils.d.ts +23 -16
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +3 -7
- package/dist/Utils.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/array.js.map +1 -1
- package/dist/internal/core.js +1 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +4 -0
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/doNotation.js.map +1 -1
- package/dist/internal/effect.js +77 -40
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/persistence.d.ts +2 -0
- package/dist/internal/persistence.d.ts.map +1 -0
- package/dist/internal/persistence.js +3 -0
- package/dist/internal/persistence.js.map +1 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/redacted.js.map +1 -1
- package/dist/internal/references.js +3 -0
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/cause.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +13 -11
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +8 -15
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/parser.d.ts +14 -0
- package/dist/internal/schema/parser.d.ts.map +1 -0
- package/dist/internal/schema/parser.js +13 -0
- package/dist/internal/schema/parser.js.map +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/toArbitrary.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +48 -6
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +87 -107
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +13 -9
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/FastCheck.d.ts +8 -7
- package/dist/testing/FastCheck.d.ts.map +1 -1
- package/dist/testing/FastCheck.js +8 -7
- package/dist/testing/FastCheck.js.map +1 -1
- package/dist/testing/TestClock.d.ts +57 -28
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +50 -18
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +32 -31
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +24 -22
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +29 -29
- package/dist/testing/TestSchema.js +25 -25
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +95 -118
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +94 -117
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +132 -97
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +55 -51
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/IdGenerator.d.ts +32 -28
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +26 -21
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +107 -67
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +104 -64
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpProtocol.d.ts +30 -0
- package/dist/unstable/ai/McpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/McpProtocol.js +20 -0
- package/dist/unstable/ai/McpProtocol.js.map +1 -0
- package/dist/unstable/ai/McpSchema.d.ts +141 -75
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +58 -50
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +68 -59
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +694 -241
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +8 -19
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +9 -20
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +112 -38
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +53 -17
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +28 -14
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +9 -4
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -1
- package/dist/unstable/ai/Telemetry.d.ts +46 -13
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +18 -7
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +14 -3
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +10 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +59 -44
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +48 -39
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +26 -8
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +18 -4
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/mcpProtocol.d.ts +21 -0
- package/dist/unstable/ai/internal/mcpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocol.js +22 -0
- package/dist/unstable/ai/internal/mcpProtocol.js.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts +2 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js +32 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +14 -15
- package/dist/unstable/ai/internal/structured-output.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +273 -69
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +111 -33
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliConfig.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +69 -76
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +57 -61
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +35 -54
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +26 -42
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +705 -107
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +238 -42
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +418 -138
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +197 -71
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +1 -1
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +12 -4
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +292 -78
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +128 -46
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +370 -149
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +344 -136
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +23 -14
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +23 -14
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/auto-suggest.js.map +1 -1
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/lexer.js +17 -7
- package/dist/unstable/cli/internal/lexer.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +2 -2
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.js.map +1 -1
- package/dist/unstable/cluster/ClusterMetrics.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +8 -8
- package/dist/unstable/cluster/ClusterSchema.js +8 -8
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +5 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +10 -10
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +8 -8
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityId.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.d.ts +4 -2
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +4 -2
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/EntityType.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/Envelope.js +3 -3
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts +2 -2
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +6 -4
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/MachineId.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +9 -9
- package/dist/unstable/cluster/Message.js +6 -6
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +15 -15
- package/dist/unstable/cluster/MessageStorage.js +5 -5
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -4
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +1 -1
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +2 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +16 -16
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +2 -2
- package/dist/unstable/cluster/RunnerStorage.js +1 -1
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +6 -6
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +19 -10
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +3 -2
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +3 -3
- package/dist/unstable/cluster/ShardingConfig.js +3 -3
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/ShardingRegistrationEvent.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/Singleton.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +1 -1
- package/dist/unstable/cluster/SingletonAddress.js +1 -1
- package/dist/unstable/cluster/SingletonAddress.js.map +1 -1
- package/dist/unstable/cluster/Snowflake.d.ts +8 -8
- package/dist/unstable/cluster/Snowflake.js +8 -8
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +20 -5
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/TestRunner.js.map +1 -1
- package/dist/unstable/cluster/index.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +5 -5
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/hash.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -1
- package/dist/unstable/devtools/DevTools.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/devtools/DevToolsServer.js.map +1 -1
- package/dist/unstable/devtools/index.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +6 -8
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +72 -8
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +58 -8
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +20 -20
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +4 -4
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +15 -15
- package/dist/unstable/eventlog/EventJournal.js +13 -13
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +3 -3
- package/dist/unstable/eventlog/EventLog.js +3 -3
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +2 -2
- package/dist/unstable/eventlog/EventLogMessage.js +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/eventlog/EventLogRemote.js +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +11 -2
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +45 -21
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +4 -4
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +13 -5
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +5 -5
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +14 -6
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +2 -2
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +30 -18
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +1 -1
- package/dist/unstable/http/Etag.js +1 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +2 -2
- package/dist/unstable/http/Headers.js +2 -2
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +5 -3
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +11 -5
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +51 -44
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +46 -17
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +2 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +4 -4
- package/dist/unstable/http/HttpClientResponse.js +2 -2
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +6 -6
- package/dist/unstable/http/HttpEffect.js +3 -3
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +6 -9
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +6 -9
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +75 -9
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +164 -39
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +76 -0
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +32 -0
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +88 -89
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +78 -79
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +13 -13
- package/dist/unstable/http/HttpServer.js +6 -6
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -2
- package/dist/unstable/http/HttpServerError.js +2 -2
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +4 -4
- package/dist/unstable/http/HttpServerRequest.js +4 -4
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +22 -0
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +10 -0
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +35 -7
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +35 -7
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +6 -6
- package/dist/unstable/http/Multipart.js +5 -5
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/Url.d.ts +33 -63
- package/dist/unstable/http/Url.d.ts.map +1 -1
- package/dist/unstable/http/Url.js +14 -28
- package/dist/unstable/http/Url.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +10 -18
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +9 -17
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.d.ts +2 -0
- package/dist/unstable/http/internal/compression.d.ts.map +1 -0
- package/dist/unstable/http/internal/compression.js +155 -0
- package/dist/unstable/http/internal/compression.js.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +10 -11
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -5
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +11 -13
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +42 -42
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +13 -13
- package/dist/unstable/httpapi/HttpApiError.js +13 -13
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +15 -15
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +71 -24
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +57 -10
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +0 -12
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +6 -6
- package/dist/unstable/httpapi/HttpApiSchema.js +4 -4
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +13 -13
- package/dist/unstable/httpapi/OpenApi.js +13 -13
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/httpapi/index.js.map +1 -1
- package/dist/unstable/httpapi/internal/html.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/internal/mediaType.js.map +1 -1
- package/dist/unstable/observability/Otlp.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +12 -14
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +17 -4
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts +16 -7
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +21 -12
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +13 -4
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +10 -3
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/observability/index.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +3 -0
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +8 -3
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +22 -13
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +8 -8
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +6 -6
- package/dist/unstable/persistence/PersistedQueue.js +6 -6
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +3 -3
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +91 -15
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +26 -15
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +24 -13
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +2 -2
- package/dist/unstable/persistence/Redis.js +1 -1
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/persistence/index.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +64 -21
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +14 -5
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +21 -10
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/process/index.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +8 -8
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +10 -10
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +25 -22
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +14 -13
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +4 -1
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRef.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +24 -3
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +4 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +1 -1
- package/dist/unstable/reactivity/Hydration.js +1 -1
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +35 -33
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -2
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +12 -12
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +12 -11
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +8 -8
- package/dist/unstable/rpc/RpcGroup.js +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +31 -30
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +6 -6
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +10 -10
- package/dist/unstable/rpc/RpcMiddleware.js +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +4 -4
- package/dist/unstable/rpc/RpcSchema.js +3 -3
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +58 -7
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +175 -96
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +13 -13
- package/dist/unstable/rpc/RpcServer.js +17 -13
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcTest.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +5 -5
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/rpc/index.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +52 -50
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +35 -33
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +5 -5
- package/dist/unstable/schema/VariantSchema.js +2 -2
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/schema/index.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +11 -3
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +9 -4
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/socket/index.js.map +1 -1
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +2 -2
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.js +2 -2
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +5 -5
- package/dist/unstable/sql/SqlResolver.js +2 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/SqlStream.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +6 -6
- package/dist/unstable/sql/Statement.js +15 -15
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/sql/index.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +2 -2
- package/dist/unstable/workers/Worker.js +2 -2
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +7 -7
- package/dist/unstable/workers/WorkerError.js +6 -6
- package/dist/unstable/workers/WorkerError.js.map +1 -1
- package/dist/unstable/workers/WorkerRunner.d.ts +1 -1
- package/dist/unstable/workers/WorkerRunner.js +1 -1
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workers/index.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.js +2 -2
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +10 -10
- package/dist/unstable/workflow/DurableDeferred.js +5 -5
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +22 -20
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +22 -20
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +21 -21
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +13 -14
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts +4 -2
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.js +4 -2
- package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/dist/unstable/workflow/index.js.map +1 -1
- package/dist/unstable/workflow/internal/crypto.js.map +1 -1
- package/package.json +5 -6
- package/src/Array.ts +982 -1045
- package/src/BigDecimal.ts +433 -756
- package/src/BigInt.ts +213 -269
- package/src/Boolean.ts +146 -188
- package/src/Cache.ts +409 -255
- package/src/Cause.ts +167 -277
- package/src/Channel.ts +891 -816
- package/src/ChannelSchema.ts +1 -1
- package/src/Chunk.ts +841 -1181
- package/src/Clock.ts +181 -49
- package/src/Combiner.ts +20 -33
- package/src/Config.ts +615 -332
- package/src/ConfigProvider.ts +214 -120
- package/src/Console.ts +289 -39
- package/src/Context.ts +319 -378
- package/src/Cron.ts +68 -77
- package/src/Crypto.ts +13 -15
- package/src/Data.ts +60 -80
- package/src/DateTime.ts +564 -660
- package/src/Deferred.ts +253 -256
- package/src/Duration.ts +216 -308
- package/src/Effect.ts +2893 -3279
- package/src/Encoding.ts +22 -40
- package/src/Equal.ts +49 -39
- package/src/Equivalence.ts +103 -105
- package/src/ErrorReporter.ts +51 -27
- package/src/ExecutionPlan.ts +13 -55
- package/src/Exit.ts +116 -192
- package/src/Fiber.ts +81 -148
- package/src/FiberHandle.ts +152 -105
- package/src/FiberMap.ts +225 -174
- package/src/FiberSet.ts +124 -82
- package/src/FileSystem.ts +155 -263
- package/src/Filter.ts +61 -33
- package/src/Formatter.ts +54 -56
- package/src/Function.ts +76 -145
- package/src/Graph.ts +416 -770
- package/src/HKT.ts +12 -6
- package/src/Hash.ts +52 -83
- package/src/HashMap.ts +319 -411
- package/src/HashRing.ts +1 -0
- package/src/HashSet.ts +177 -284
- package/src/Inspectable.ts +12 -12
- package/src/Iterable.ts +620 -786
- package/src/JsonPatch.ts +58 -112
- package/src/JsonPointer.ts +8 -8
- package/src/JsonSchema.ts +402 -244
- package/src/Latch.ts +23 -35
- package/src/Layer.ts +359 -260
- package/src/LayerMap.ts +49 -29
- package/src/LayerRef.ts +6 -2
- package/src/LogLevel.ts +114 -214
- package/src/Logger.ts +344 -697
- package/src/ManagedRuntime.ts +7 -5
- package/src/Match.ts +217 -252
- package/src/Metric.ts +516 -1089
- package/src/MutableHashMap.ts +218 -255
- package/src/MutableHashSet.ts +84 -89
- package/src/MutableList.ts +73 -370
- package/src/MutableRef.ts +420 -243
- package/src/Newtype.ts +21 -14
- package/src/NonEmptyIterable.ts +7 -137
- package/src/Number.ts +196 -233
- package/src/Optic.ts +243 -383
- package/src/Option.ts +447 -812
- package/src/Order.ts +109 -109
- package/src/Ordering.ts +20 -23
- package/src/Path.ts +38 -41
- package/src/Pipeable.ts +6 -5
- package/src/PlatformError.ts +4 -4
- package/src/Pool.ts +4 -2
- package/src/Predicate.ts +200 -181
- package/src/PrimaryKey.ts +7 -7
- package/src/PubSub.ts +526 -552
- package/src/Pull.ts +24 -18
- package/src/Queue.ts +200 -159
- package/src/Random.ts +49 -74
- package/src/RcMap.ts +121 -63
- package/src/RcRef.ts +24 -13
- package/src/Record.ts +291 -488
- package/src/Redactable.ts +10 -3
- package/src/Redacted.ts +25 -25
- package/src/Reducer.ts +8 -15
- package/src/Ref.ts +221 -361
- package/src/References.ts +102 -168
- package/src/RegExp.ts +10 -14
- package/src/Request.ts +31 -21
- package/src/RequestResolver.ts +202 -91
- package/src/Result.ts +312 -484
- package/src/Runtime.ts +50 -75
- package/src/Schedule.ts +308 -1734
- package/src/Scheduler.ts +20 -7
- package/src/Schema.ts +716 -745
- package/src/SchemaAST.ts +466 -358
- package/src/SchemaError.ts +7 -6
- package/src/SchemaGetter.ts +242 -190
- package/src/SchemaIssue.ts +89 -275
- package/src/SchemaParser.ts +180 -93
- package/src/SchemaRepresentation.ts +22 -40
- package/src/SchemaTransformation.ts +129 -88
- package/src/Scope.ts +123 -151
- package/src/ScopedRef.ts +4 -4
- package/src/Semaphore.ts +152 -51
- package/src/Sink.ts +128 -113
- package/src/Stdio.ts +1 -1
- package/src/Stream.ts +2602 -3123
- package/src/String.ts +275 -312
- package/src/Struct.ts +109 -114
- package/src/SubscriptionRef.ts +284 -252
- package/src/Symbol.ts +3 -3
- package/src/Terminal.ts +2 -2
- package/src/Tracer.ts +102 -55
- package/src/Trie.ts +287 -679
- package/src/Tuple.ts +92 -127
- package/src/TxChunk.ts +201 -121
- package/src/TxDeferred.ts +62 -46
- package/src/TxHashMap.ts +645 -799
- package/src/TxHashSet.ts +443 -356
- package/src/TxPriorityQueue.ts +130 -98
- package/src/TxPubSub.ts +107 -80
- package/src/TxQueue.ts +214 -183
- package/src/TxReentrantLock.ts +97 -66
- package/src/TxRef.ts +51 -32
- package/src/TxSemaphore.ts +129 -95
- package/src/TxSubscriptionRef.ts +97 -70
- package/src/Types.ts +126 -67
- package/src/Unify.ts +45 -65
- package/src/Utils.ts +23 -16
- package/src/internal/core.ts +2 -2
- package/src/internal/dateTime.ts +6 -0
- package/src/internal/effect.ts +93 -48
- package/src/internal/persistence.ts +2 -0
- package/src/internal/references.ts +3 -2
- package/src/internal/schema/fromJsonSchemaDocument.ts +15 -13
- package/src/internal/schema/fromRepresentation.ts +10 -16
- package/src/internal/schema/parser.ts +22 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +60 -6
- package/src/internal/schema/toRepresentation.ts +104 -119
- package/src/internal/trie.ts +10 -11
- package/src/testing/FastCheck.ts +8 -7
- package/src/testing/TestClock.ts +72 -30
- package/src/testing/TestConsole.ts +32 -31
- package/src/testing/TestSchema.ts +29 -29
- package/src/unstable/ai/AiError.ts +95 -118
- package/src/unstable/ai/AnthropicStructuredOutput.ts +1 -1
- package/src/unstable/ai/Chat.ts +132 -97
- package/src/unstable/ai/IdGenerator.ts +32 -28
- package/src/unstable/ai/LanguageModel.ts +107 -67
- package/src/unstable/ai/McpProtocol.ts +48 -0
- package/src/unstable/ai/McpSchema.ts +60 -50
- package/src/unstable/ai/McpServer.ts +930 -304
- package/src/unstable/ai/Model.ts +9 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +1 -1
- package/src/unstable/ai/Prompt.ts +145 -43
- package/src/unstable/ai/Response.ts +28 -14
- package/src/unstable/ai/Telemetry.ts +46 -13
- package/src/unstable/ai/Tokenizer.ts +14 -3
- package/src/unstable/ai/Tool.ts +59 -44
- package/src/unstable/ai/Toolkit.ts +26 -8
- package/src/unstable/ai/index.ts +5 -0
- package/src/unstable/ai/internal/mcpProtocol.ts +85 -0
- package/src/unstable/ai/internal/mcpProtocolRegistry.ts +70 -0
- package/src/unstable/ai/internal/structured-output.ts +13 -18
- package/src/unstable/cli/Argument.ts +273 -69
- package/src/unstable/cli/CliError.ts +69 -76
- package/src/unstable/cli/CliOutput.ts +44 -58
- package/src/unstable/cli/Command.ts +705 -107
- package/src/unstable/cli/Flag.ts +418 -138
- package/src/unstable/cli/GlobalFlag.ts +1 -1
- package/src/unstable/cli/HelpDoc.ts +12 -4
- package/src/unstable/cli/Param.ts +292 -78
- package/src/unstable/cli/Primitive.ts +370 -149
- package/src/unstable/cli/Prompt.ts +28 -14
- package/src/unstable/cli/internal/lexer.ts +8 -2
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +8 -8
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -1
- package/src/unstable/cluster/Entity.ts +15 -16
- package/src/unstable/cluster/EntityProxy.ts +4 -2
- package/src/unstable/cluster/EntityResource.ts +2 -2
- package/src/unstable/cluster/Envelope.ts +3 -3
- package/src/unstable/cluster/HttpRunner.ts +6 -4
- package/src/unstable/cluster/Message.ts +9 -9
- package/src/unstable/cluster/MessageStorage.ts +15 -15
- package/src/unstable/cluster/Reply.ts +4 -6
- package/src/unstable/cluster/RunnerHealth.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +41 -8
- package/src/unstable/cluster/RunnerStorage.ts +2 -2
- package/src/unstable/cluster/Runners.ts +23 -12
- package/src/unstable/cluster/Sharding.ts +7 -8
- package/src/unstable/cluster/ShardingConfig.ts +3 -3
- package/src/unstable/cluster/SingletonAddress.ts +1 -1
- package/src/unstable/cluster/Snowflake.ts +8 -8
- package/src/unstable/cluster/SqlMessageStorage.ts +1 -1
- package/src/unstable/cluster/SqlRunnerStorage.ts +21 -5
- package/src/unstable/cluster/internal/entityManager.ts +11 -15
- package/src/unstable/encoding/Msgpack.ts +6 -8
- package/src/unstable/encoding/Sse.ts +98 -16
- package/src/unstable/eventlog/Event.ts +20 -20
- package/src/unstable/eventlog/EventGroup.ts +4 -4
- package/src/unstable/eventlog/EventJournal.ts +15 -15
- package/src/unstable/eventlog/EventLog.ts +3 -3
- package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
- package/src/unstable/eventlog/EventLogMessage.ts +2 -2
- package/src/unstable/eventlog/EventLogRemote.ts +1 -1
- package/src/unstable/eventlog/EventLogServer.ts +41 -7
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +13 -5
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +14 -6
- package/src/unstable/eventlog/EventLogSessionAuth.ts +1 -1
- package/src/unstable/http/Cookies.ts +35 -21
- package/src/unstable/http/Etag.ts +1 -1
- package/src/unstable/http/FetchHttpClient.ts +3 -1
- package/src/unstable/http/Headers.ts +2 -2
- package/src/unstable/http/HttpBody.ts +20 -5
- package/src/unstable/http/HttpClient.ts +83 -55
- package/src/unstable/http/HttpClientRequest.ts +2 -0
- package/src/unstable/http/HttpClientResponse.ts +4 -4
- package/src/unstable/http/HttpEffect.ts +8 -8
- package/src/unstable/http/HttpMethod.ts +6 -9
- package/src/unstable/http/HttpMiddleware.ts +202 -39
- package/src/unstable/http/HttpPlatform.ts +95 -0
- package/src/unstable/http/HttpRouter.ts +102 -98
- package/src/unstable/http/HttpServer.ts +13 -13
- package/src/unstable/http/HttpServerError.ts +2 -2
- package/src/unstable/http/HttpServerRequest.ts +4 -4
- package/src/unstable/http/HttpServerResponse.ts +30 -0
- package/src/unstable/http/HttpStaticServer.ts +35 -7
- package/src/unstable/http/Multipart.ts +6 -6
- package/src/unstable/http/Url.ts +33 -63
- package/src/unstable/http/UrlParams.ts +10 -18
- package/src/unstable/http/internal/compression.ts +196 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +10 -9
- package/src/unstable/httpapi/HttpApiClient.ts +14 -14
- package/src/unstable/httpapi/HttpApiEndpoint.ts +42 -42
- package/src/unstable/httpapi/HttpApiError.ts +13 -13
- package/src/unstable/httpapi/HttpApiGroup.ts +15 -15
- package/src/unstable/httpapi/HttpApiMiddleware.ts +71 -24
- package/src/unstable/httpapi/HttpApiScalar.ts +0 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +6 -6
- package/src/unstable/httpapi/OpenApi.ts +13 -13
- package/src/unstable/observability/OtlpExporter.ts +31 -19
- package/src/unstable/observability/OtlpMetrics.ts +4 -1
- package/src/unstable/observability/OtlpResource.ts +26 -17
- package/src/unstable/observability/PrometheusMetrics.ts +13 -4
- package/src/unstable/observability/internal/otlpEnv.ts +1 -1
- package/src/unstable/observability/internal/protobuf.ts +3 -0
- package/src/unstable/persistence/KeyValueStore.ts +72 -49
- package/src/unstable/persistence/Persistable.ts +8 -8
- package/src/unstable/persistence/PersistedQueue.ts +6 -6
- package/src/unstable/persistence/Persistence.ts +126 -19
- package/src/unstable/persistence/RateLimiter.ts +26 -15
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcess.ts +64 -21
- package/src/unstable/process/ChildProcessSpawner.ts +21 -10
- package/src/unstable/reactivity/AsyncResult.ts +12 -13
- package/src/unstable/reactivity/Atom.ts +28 -25
- package/src/unstable/reactivity/AtomHttpApi.ts +5 -4
- package/src/unstable/reactivity/AtomRegistry.ts +24 -3
- package/src/unstable/reactivity/AtomRpc.ts +5 -4
- package/src/unstable/reactivity/Hydration.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +35 -33
- package/src/unstable/rpc/RpcClient.ts +16 -15
- package/src/unstable/rpc/RpcGroup.ts +8 -8
- package/src/unstable/rpc/RpcMessage.ts +31 -30
- package/src/unstable/rpc/RpcMiddleware.ts +10 -10
- package/src/unstable/rpc/RpcSchema.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +167 -68
- package/src/unstable/rpc/RpcServer.ts +18 -15
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/schema/Model.ts +52 -50
- package/src/unstable/schema/VariantSchema.ts +5 -5
- package/src/unstable/socket/Socket.ts +17 -4
- package/src/unstable/sql/SqlClient.ts +5 -6
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +5 -5
- package/src/unstable/sql/Statement.ts +24 -23
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +2 -2
- package/src/unstable/workers/WorkerError.ts +7 -7
- package/src/unstable/workers/WorkerRunner.ts +1 -1
- package/src/unstable/workflow/Activity.ts +2 -2
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +10 -10
- package/src/unstable/workflow/DurableQueue.ts +22 -20
- package/src/unstable/workflow/Workflow.ts +23 -23
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
- package/src/unstable/workflow/WorkflowProxy.ts +4 -2
- package/dist/internal/version.d.ts +0 -3
- package/dist/internal/version.d.ts.map +0 -1
- package/dist/internal/version.js +0 -2
- package/dist/internal/version.js.map +0 -1
- package/src/internal/version.ts +0 -2
package/src/Metric.ts
CHANGED
|
@@ -49,12 +49,8 @@ import type { Contravariant, Covariant } from "./Types.ts"
|
|
|
49
49
|
*
|
|
50
50
|
* **Example** (Using multiple metric types)
|
|
51
51
|
*
|
|
52
|
-
* ```ts
|
|
53
|
-
* import {
|
|
54
|
-
*
|
|
55
|
-
* class MetricExample extends Data.TaggedError("MetricExample")<{
|
|
56
|
-
* readonly operation: string
|
|
57
|
-
* }> {}
|
|
52
|
+
* ```ts import.meta.vitest
|
|
53
|
+
* import { Effect, Metric } from "effect"
|
|
58
54
|
*
|
|
59
55
|
* const program = Effect.gen(function*() {
|
|
60
56
|
* // Create different types of metrics
|
|
@@ -100,6 +96,13 @@ import type { Contravariant, Covariant } from "./Types.ts"
|
|
|
100
96
|
* }
|
|
101
97
|
* }
|
|
102
98
|
* })
|
|
99
|
+
*
|
|
100
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
101
|
+
* const values = [
|
|
102
|
+
* result.counter.state.count,
|
|
103
|
+
* result.gauge.state.value,
|
|
104
|
+
* result.frequency.state.occurrences.get("200")
|
|
105
|
+
* ] // => [1, 128, 1]
|
|
103
106
|
* ```
|
|
104
107
|
*
|
|
105
108
|
* @category models
|
|
@@ -128,12 +131,8 @@ export interface Metric<in Input, out State> extends Pipeable {
|
|
|
128
131
|
*
|
|
129
132
|
* **Example** (Using counter metrics)
|
|
130
133
|
*
|
|
131
|
-
* ```ts
|
|
132
|
-
* import {
|
|
133
|
-
*
|
|
134
|
-
* class CounterInterfaceError extends Data.TaggedError("CounterInterfaceError")<{
|
|
135
|
-
* readonly operation: string
|
|
136
|
-
* }> {}
|
|
134
|
+
* ```ts import.meta.vitest
|
|
135
|
+
* import { Effect, Metric } from "effect"
|
|
137
136
|
*
|
|
138
137
|
* const program = Effect.gen(function*() {
|
|
139
138
|
* // Create different types of counters
|
|
@@ -179,9 +178,12 @@ export interface Metric<in Input, out State> extends Pipeable {
|
|
|
179
178
|
* bytes: { count: bytesState.count, incremental: bytesState.incremental }
|
|
180
179
|
* }
|
|
181
180
|
* })
|
|
181
|
+
*
|
|
182
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
183
|
+
* const counts = [result.requests.count, result.bytes.count] // => [6, 1024n]
|
|
182
184
|
* ```
|
|
183
185
|
*
|
|
184
|
-
* @category
|
|
186
|
+
* @category models
|
|
185
187
|
* @since 2.0.0
|
|
186
188
|
*/
|
|
187
189
|
export interface Counter<in Input extends number | bigint> extends Metric<Input, CounterState<Input>> {}
|
|
@@ -191,12 +193,8 @@ export interface Counter<in Input extends number | bigint> extends Metric<Input,
|
|
|
191
193
|
*
|
|
192
194
|
* **Example** (Reading counter state)
|
|
193
195
|
*
|
|
194
|
-
* ```ts
|
|
195
|
-
* import {
|
|
196
|
-
*
|
|
197
|
-
* class CounterStateError extends Data.TaggedError("CounterStateError")<{
|
|
198
|
-
* readonly operation: string
|
|
199
|
-
* }> {}
|
|
196
|
+
* ```ts import.meta.vitest
|
|
197
|
+
* import { Effect, Metric } from "effect"
|
|
200
198
|
*
|
|
201
199
|
* const program = Effect.gen(function*() {
|
|
202
200
|
* // Create different types of counters
|
|
@@ -221,7 +219,6 @@ export interface Counter<in Input extends number | bigint> extends Metric<Input,
|
|
|
221
219
|
* const byteState: Metric.CounterState<bigint> = yield* Metric.value(
|
|
222
220
|
* byteCounter
|
|
223
221
|
* )
|
|
224
|
-
*
|
|
225
222
|
* // CounterState contains:
|
|
226
223
|
* // - count: current count value (number or bigint based on counter type)
|
|
227
224
|
* // - incremental: whether counter only allows increases
|
|
@@ -241,9 +238,12 @@ export interface Counter<in Input extends number | bigint> extends Metric<Input,
|
|
|
241
238
|
* }
|
|
242
239
|
* }
|
|
243
240
|
* })
|
|
241
|
+
*
|
|
242
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
243
|
+
* const counts = [result.requests.total, result.errors.total, result.bytes.total] // => [3, 3, 1024000n]
|
|
244
244
|
* ```
|
|
245
245
|
*
|
|
246
|
-
* @category
|
|
246
|
+
* @category models
|
|
247
247
|
* @since 4.0.0
|
|
248
248
|
*/
|
|
249
249
|
export interface CounterState<in Input extends number | bigint> {
|
|
@@ -262,32 +262,16 @@ export interface CounterState<in Input extends number | bigint> {
|
|
|
262
262
|
*
|
|
263
263
|
* **Example** (Using frequency metrics)
|
|
264
264
|
*
|
|
265
|
-
* ```ts
|
|
266
|
-
* import {
|
|
267
|
-
*
|
|
268
|
-
* class FrequencyInterfaceError
|
|
269
|
-
* extends Data.TaggedError("FrequencyInterfaceError")<{
|
|
270
|
-
* readonly operation: string
|
|
271
|
-
* }>
|
|
272
|
-
* {}
|
|
265
|
+
* ```ts import.meta.vitest
|
|
266
|
+
* import { Effect, Metric } from "effect"
|
|
273
267
|
*
|
|
274
268
|
* // Function that accepts any Frequency metric
|
|
275
|
-
* const
|
|
269
|
+
* const analyzeFrequencyMetric = (freq: Metric.Frequency) =>
|
|
276
270
|
* Effect.gen(function*() {
|
|
277
271
|
* const state = yield* Metric.value(freq)
|
|
278
272
|
*
|
|
279
|
-
* yield* Effect.log(`Frequency Metric: ${freq.id}`)
|
|
280
|
-
* yield* Effect.log(`Description: ${freq.description ?? "No description"}`)
|
|
281
|
-
* yield* Effect.log(`Type: ${freq.type}`) // "Frequency"
|
|
282
|
-
*
|
|
283
273
|
* // Access the frequency state
|
|
284
274
|
* const occurrences: ReadonlyMap<string, number> = state.occurrences
|
|
285
|
-
* yield* Effect.log(`Total unique values: ${occurrences.size}`)
|
|
286
|
-
*
|
|
287
|
-
* // Iterate through all occurrences
|
|
288
|
-
* for (const [value, count] of occurrences) {
|
|
289
|
-
* yield* Effect.log(` "${value}": ${count} occurrences`)
|
|
290
|
-
* }
|
|
291
275
|
*
|
|
292
276
|
* // Find most frequent value
|
|
293
277
|
* let maxCount = 0
|
|
@@ -324,14 +308,16 @@ export interface CounterState<in Input extends number | bigint> {
|
|
|
324
308
|
* yield* Metric.update(userActions, "login")
|
|
325
309
|
*
|
|
326
310
|
* // Use the function with different frequency metrics
|
|
327
|
-
* const statusAnalysis = yield*
|
|
328
|
-
* const actionAnalysis = yield*
|
|
329
|
-
*
|
|
311
|
+
* const statusAnalysis = yield* analyzeFrequencyMetric(statusCodes)
|
|
312
|
+
* const actionAnalysis = yield* analyzeFrequencyMetric(userActions)
|
|
330
313
|
* return { statusAnalysis, actionAnalysis }
|
|
331
314
|
* })
|
|
315
|
+
*
|
|
316
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
317
|
+
* const values = [result.statusAnalysis.mostFrequent, result.actionAnalysis.mostFrequent] // => ["200", "login"]
|
|
332
318
|
* ```
|
|
333
319
|
*
|
|
334
|
-
* @category
|
|
320
|
+
* @category models
|
|
335
321
|
* @since 2.0.0
|
|
336
322
|
*/
|
|
337
323
|
export interface Frequency extends Metric<string, FrequencyState> {}
|
|
@@ -341,12 +327,8 @@ export interface Frequency extends Metric<string, FrequencyState> {}
|
|
|
341
327
|
*
|
|
342
328
|
* **Example** (Reading frequency state)
|
|
343
329
|
*
|
|
344
|
-
* ```ts
|
|
345
|
-
* import {
|
|
346
|
-
*
|
|
347
|
-
* class FrequencyStateError extends Data.TaggedError("FrequencyStateError")<{
|
|
348
|
-
* readonly operation: string
|
|
349
|
-
* }> {}
|
|
330
|
+
* ```ts import.meta.vitest
|
|
331
|
+
* import { Effect, Metric } from "effect"
|
|
350
332
|
*
|
|
351
333
|
* const program = Effect.gen(function*() {
|
|
352
334
|
* // Create frequency metrics for different categories
|
|
@@ -394,7 +376,6 @@ export interface Frequency extends Metric<string, FrequencyState> {}
|
|
|
394
376
|
*
|
|
395
377
|
* const topStatus = getMostFrequent(statusState.occurrences)
|
|
396
378
|
* const topAction = getMostFrequent(actionState.occurrences)
|
|
397
|
-
*
|
|
398
379
|
* return {
|
|
399
380
|
* statusCodes: {
|
|
400
381
|
* totalResponses: Array.from(statusState.occurrences.values()).reduce(
|
|
@@ -414,9 +395,13 @@ export interface Frequency extends Metric<string, FrequencyState> {}
|
|
|
414
395
|
* }
|
|
415
396
|
* }
|
|
416
397
|
* })
|
|
398
|
+
*
|
|
399
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
400
|
+
* const mostCommon = [result.statusCodes.mostCommon, result.userActions.mostCommon]
|
|
401
|
+
* mostCommon.map(({ key, count }) => [key, count]) // => [["200", 3], ["click", 3]]
|
|
417
402
|
* ```
|
|
418
403
|
*
|
|
419
|
-
* @category
|
|
404
|
+
* @category models
|
|
420
405
|
* @since 4.0.0
|
|
421
406
|
*/
|
|
422
407
|
export interface FrequencyState {
|
|
@@ -433,12 +418,8 @@ export interface FrequencyState {
|
|
|
433
418
|
*
|
|
434
419
|
* **Example** (Using gauge metrics)
|
|
435
420
|
*
|
|
436
|
-
* ```ts
|
|
437
|
-
* import {
|
|
438
|
-
*
|
|
439
|
-
* class GaugeInterfaceError extends Data.TaggedError("GaugeInterfaceError")<{
|
|
440
|
-
* readonly operation: string
|
|
441
|
-
* }> {}
|
|
421
|
+
* ```ts import.meta.vitest
|
|
422
|
+
* import { Effect, Metric } from "effect"
|
|
442
423
|
*
|
|
443
424
|
* const program = Effect.gen(function*() {
|
|
444
425
|
* // Create different types of gauges
|
|
@@ -468,7 +449,6 @@ export interface FrequencyState {
|
|
|
468
449
|
* const diskState: Metric.GaugeState<bigint> = yield* Metric.value(
|
|
469
450
|
* diskSpaceGauge
|
|
470
451
|
* )
|
|
471
|
-
*
|
|
472
452
|
* // Gauge state contains:
|
|
473
453
|
* // - value: current instantaneous value
|
|
474
454
|
*
|
|
@@ -477,9 +457,12 @@ export interface FrequencyState {
|
|
|
477
457
|
* disk: { currentValue: diskState.value } // 5000000000n
|
|
478
458
|
* }
|
|
479
459
|
* })
|
|
460
|
+
*
|
|
461
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
462
|
+
* const values = [result.memory.currentValue, result.disk.currentValue] // => [704, 5000000000n]
|
|
480
463
|
* ```
|
|
481
464
|
*
|
|
482
|
-
* @category
|
|
465
|
+
* @category models
|
|
483
466
|
* @since 2.0.0
|
|
484
467
|
*/
|
|
485
468
|
export interface Gauge<in Input extends number | bigint> extends Metric<Input, GaugeState<Input>> {}
|
|
@@ -489,12 +472,8 @@ export interface Gauge<in Input extends number | bigint> extends Metric<Input, G
|
|
|
489
472
|
*
|
|
490
473
|
* **Example** (Reading gauge state)
|
|
491
474
|
*
|
|
492
|
-
* ```ts
|
|
493
|
-
* import {
|
|
494
|
-
*
|
|
495
|
-
* class GaugeStateError extends Data.TaggedError("GaugeStateError")<{
|
|
496
|
-
* readonly operation: string
|
|
497
|
-
* }> {}
|
|
475
|
+
* ```ts import.meta.vitest
|
|
476
|
+
* import { Effect, Metric } from "effect"
|
|
498
477
|
*
|
|
499
478
|
* const program = Effect.gen(function*() {
|
|
500
479
|
* // Create different types of gauges
|
|
@@ -530,7 +509,6 @@ export interface Gauge<in Input extends number | bigint> extends Metric<Input, G
|
|
|
530
509
|
* const queueState: Metric.GaugeState<number> = yield* Metric.value(
|
|
531
510
|
* queueSizeGauge
|
|
532
511
|
* )
|
|
533
|
-
*
|
|
534
512
|
* // GaugeState contains:
|
|
535
513
|
* // - value: current instantaneous value (number or bigint based on gauge type)
|
|
536
514
|
*
|
|
@@ -546,9 +524,13 @@ export interface Gauge<in Input extends number | bigint> extends Metric<Input, G
|
|
|
546
524
|
* }
|
|
547
525
|
* }
|
|
548
526
|
* })
|
|
527
|
+
*
|
|
528
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
529
|
+
* const values = [result.environment.temperature, result.system.diskUsage, result.system.queueSize]
|
|
530
|
+
* values // => [23.1, 5000000000n, 15]
|
|
549
531
|
* ```
|
|
550
532
|
*
|
|
551
|
-
* @category
|
|
533
|
+
* @category models
|
|
552
534
|
* @since 4.0.0
|
|
553
535
|
*/
|
|
554
536
|
export interface GaugeState<in Input extends number | bigint> {
|
|
@@ -565,14 +547,8 @@ export interface GaugeState<in Input extends number | bigint> {
|
|
|
565
547
|
*
|
|
566
548
|
* **Example** (Using histogram metrics)
|
|
567
549
|
*
|
|
568
|
-
* ```ts
|
|
569
|
-
* import {
|
|
570
|
-
*
|
|
571
|
-
* class HistogramInterfaceError
|
|
572
|
-
* extends Data.TaggedError("HistogramInterfaceError")<{
|
|
573
|
-
* readonly operation: string
|
|
574
|
-
* }>
|
|
575
|
-
* {}
|
|
550
|
+
* ```ts import.meta.vitest
|
|
551
|
+
* import { Effect, Metric } from "effect"
|
|
576
552
|
*
|
|
577
553
|
* const program = Effect.gen(function*() {
|
|
578
554
|
* // Create histograms with different boundary strategies
|
|
@@ -580,7 +556,7 @@ export interface GaugeState<in Input extends number | bigint> {
|
|
|
580
556
|
* "http_response_time_ms",
|
|
581
557
|
* {
|
|
582
558
|
* description: "HTTP response time distribution in milliseconds",
|
|
583
|
-
* boundaries: Metric.linearBoundaries({ start: 0, width: 50, count: 20 }) //
|
|
559
|
+
* boundaries: Metric.linearBoundaries({ start: 0, width: 50, count: 20 }) // 50, 100, ..., 900, Infinity
|
|
584
560
|
* }
|
|
585
561
|
* )
|
|
586
562
|
*
|
|
@@ -613,7 +589,6 @@ export interface GaugeState<in Input extends number | bigint> {
|
|
|
613
589
|
* const fileSizeState: Metric.HistogramState = yield* Metric.value(
|
|
614
590
|
* fileSizeHistogram
|
|
615
591
|
* )
|
|
616
|
-
*
|
|
617
592
|
* // Histogram state contains:
|
|
618
593
|
* // - buckets: Array of [boundary, cumulativeCount] pairs
|
|
619
594
|
* // - count: total number of observations
|
|
@@ -637,9 +612,13 @@ export interface GaugeState<in Input extends number | bigint> {
|
|
|
637
612
|
* }
|
|
638
613
|
* }
|
|
639
614
|
* })
|
|
615
|
+
*
|
|
616
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
617
|
+
* const values = [result.responseTime.totalRequests, result.responseTime.totalTime, result.fileSize.totalBytes]
|
|
618
|
+
* values // => [4, 445, 118]
|
|
640
619
|
* ```
|
|
641
620
|
*
|
|
642
|
-
* @category
|
|
621
|
+
* @category models
|
|
643
622
|
* @since 2.0.0
|
|
644
623
|
*/
|
|
645
624
|
export interface Histogram<Input> extends Metric<Input, HistogramState> {}
|
|
@@ -649,18 +628,14 @@ export interface Histogram<Input> extends Metric<Input, HistogramState> {}
|
|
|
649
628
|
*
|
|
650
629
|
* **Example** (Reading histogram state)
|
|
651
630
|
*
|
|
652
|
-
* ```ts
|
|
653
|
-
* import {
|
|
654
|
-
*
|
|
655
|
-
* class HistogramStateError extends Data.TaggedError("HistogramStateError")<{
|
|
656
|
-
* readonly operation: string
|
|
657
|
-
* }> {}
|
|
631
|
+
* ```ts import.meta.vitest
|
|
632
|
+
* import { Effect, Metric } from "effect"
|
|
658
633
|
*
|
|
659
634
|
* const program = Effect.gen(function*() {
|
|
660
635
|
* // Create histogram with linear boundaries
|
|
661
636
|
* const responseTimeHistogram = Metric.histogram("api_response_time_ms", {
|
|
662
637
|
* description: "API response time distribution",
|
|
663
|
-
* boundaries: Metric.linearBoundaries({ start: 0, width: 100, count: 10 }) //
|
|
638
|
+
* boundaries: Metric.linearBoundaries({ start: 0, width: 100, count: 10 }) // 100, 200, ..., 800, Infinity
|
|
664
639
|
* })
|
|
665
640
|
*
|
|
666
641
|
* // Record observations
|
|
@@ -707,7 +682,6 @@ export interface Histogram<Input> extends Metric<Input, HistogramState> {}
|
|
|
707
682
|
* }
|
|
708
683
|
*
|
|
709
684
|
* const bucketAnalysis = analyzeBuckets(state.buckets)
|
|
710
|
-
*
|
|
711
685
|
* return {
|
|
712
686
|
* responseTime: {
|
|
713
687
|
* totalRequests: state.count, // 5
|
|
@@ -724,9 +698,14 @@ export interface Histogram<Input> extends Metric<Input, HistogramState> {}
|
|
|
724
698
|
* }
|
|
725
699
|
* }
|
|
726
700
|
* })
|
|
701
|
+
*
|
|
702
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
703
|
+
* const stats = result.responseTime
|
|
704
|
+
* const values = [stats.totalRequests, stats.fastestResponse, stats.slowestResponse, stats.totalTime]
|
|
705
|
+
* values // => [5, 50, 750, 1295]
|
|
727
706
|
* ```
|
|
728
707
|
*
|
|
729
|
-
* @category
|
|
708
|
+
* @category models
|
|
730
709
|
* @since 4.0.0
|
|
731
710
|
*/
|
|
732
711
|
export interface HistogramState {
|
|
@@ -748,12 +727,8 @@ export interface HistogramState {
|
|
|
748
727
|
*
|
|
749
728
|
* **Example** (Using summary metrics)
|
|
750
729
|
*
|
|
751
|
-
* ```ts
|
|
752
|
-
* import {
|
|
753
|
-
*
|
|
754
|
-
* class SummaryInterfaceError extends Data.TaggedError("SummaryInterfaceError")<{
|
|
755
|
-
* readonly operation: string
|
|
756
|
-
* }> {}
|
|
730
|
+
* ```ts import.meta.vitest
|
|
731
|
+
* import { Effect, Metric } from "effect"
|
|
757
732
|
*
|
|
758
733
|
* const program = Effect.gen(function*() {
|
|
759
734
|
* // Create summaries with different quantile configurations
|
|
@@ -812,7 +787,6 @@ export interface HistogramState {
|
|
|
812
787
|
* const median = getQuantileValue(responseTimeState.quantiles, 0.5)
|
|
813
788
|
* const p95 = getQuantileValue(responseTimeState.quantiles, 0.95)
|
|
814
789
|
* const p99 = getQuantileValue(responseTimeState.quantiles, 0.99)
|
|
815
|
-
*
|
|
816
790
|
* return {
|
|
817
791
|
* responseTime: {
|
|
818
792
|
* totalRequests: responseTimeState.count, // 5
|
|
@@ -830,9 +804,13 @@ export interface HistogramState {
|
|
|
830
804
|
* }
|
|
831
805
|
* }
|
|
832
806
|
* })
|
|
807
|
+
*
|
|
808
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
809
|
+
* const counts = [result.responseTime.totalRequests, result.responseTime.totalTime, result.requestSize.totalRequests]
|
|
810
|
+
* counts // => [5, 1461, 3]
|
|
833
811
|
* ```
|
|
834
812
|
*
|
|
835
|
-
* @category
|
|
813
|
+
* @category models
|
|
836
814
|
* @since 2.0.0
|
|
837
815
|
*/
|
|
838
816
|
export interface Summary<Input> extends Metric<Input, SummaryState> {}
|
|
@@ -842,12 +820,8 @@ export interface Summary<Input> extends Metric<Input, SummaryState> {}
|
|
|
842
820
|
*
|
|
843
821
|
* **Example** (Reading summary state)
|
|
844
822
|
*
|
|
845
|
-
* ```ts
|
|
846
|
-
* import {
|
|
847
|
-
*
|
|
848
|
-
* class SummaryStateError extends Data.TaggedError("SummaryStateError")<{
|
|
849
|
-
* readonly operation: string
|
|
850
|
-
* }> {}
|
|
823
|
+
* ```ts import.meta.vitest
|
|
824
|
+
* import { Effect, Metric } from "effect"
|
|
851
825
|
*
|
|
852
826
|
* const program = Effect.gen(function*() {
|
|
853
827
|
* // Create summary with specific quantiles
|
|
@@ -890,7 +864,6 @@ export interface Summary<Input> extends Metric<Input, SummaryState> {}
|
|
|
890
864
|
* }
|
|
891
865
|
*
|
|
892
866
|
* const quantileValues = extractQuantiles(state.quantiles)
|
|
893
|
-
*
|
|
894
867
|
* return {
|
|
895
868
|
* latencyAnalysis: {
|
|
896
869
|
* totalRequests: state.count, // 7
|
|
@@ -912,9 +885,14 @@ export interface Summary<Input> extends Metric<Input, SummaryState> {}
|
|
|
912
885
|
* }
|
|
913
886
|
* }
|
|
914
887
|
* })
|
|
888
|
+
*
|
|
889
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
890
|
+
* const analysis = result.latencyAnalysis
|
|
891
|
+
* const values = [analysis.totalRequests, analysis.fastestResponse, analysis.slowestResponse, analysis.totalLatency]
|
|
892
|
+
* values // => [7, 45, 890, 1879]
|
|
915
893
|
* ```
|
|
916
894
|
*
|
|
917
|
-
* @category
|
|
895
|
+
* @category models
|
|
918
896
|
* @since 4.0.0
|
|
919
897
|
*/
|
|
920
898
|
export interface SummaryState {
|
|
@@ -931,12 +909,8 @@ export interface SummaryState {
|
|
|
931
909
|
*
|
|
932
910
|
* **Example** (Collecting application metrics)
|
|
933
911
|
*
|
|
934
|
-
* ```ts
|
|
935
|
-
* import {
|
|
936
|
-
*
|
|
937
|
-
* class MetricsError extends Data.TaggedError("MetricsError")<{
|
|
938
|
-
* readonly operation: string
|
|
939
|
-
* }> {}
|
|
912
|
+
* ```ts import.meta.vitest
|
|
913
|
+
* import { Effect, Metric } from "effect"
|
|
940
914
|
*
|
|
941
915
|
* const program = Effect.gen(function*() {
|
|
942
916
|
* // Create different types of metrics
|
|
@@ -966,6 +940,9 @@ export interface SummaryState {
|
|
|
966
940
|
* frequency: frequencyValue
|
|
967
941
|
* }
|
|
968
942
|
* })
|
|
943
|
+
*
|
|
944
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
945
|
+
* const values = [result.counter.count, result.gauge.value] // => [1, 12]
|
|
969
946
|
* ```
|
|
970
947
|
*
|
|
971
948
|
* @since 2.0.0
|
|
@@ -976,78 +953,28 @@ export declare namespace Metric {
|
|
|
976
953
|
*
|
|
977
954
|
* **Example** (Inspecting metric types)
|
|
978
955
|
*
|
|
979
|
-
* ```ts
|
|
980
|
-
* import {
|
|
981
|
-
*
|
|
982
|
-
* class MetricTypeError extends Data.TaggedError("MetricTypeError")<{
|
|
983
|
-
* readonly operation: string
|
|
984
|
-
* }> {}
|
|
956
|
+
* ```ts import.meta.vitest
|
|
957
|
+
* import { Metric } from "effect"
|
|
985
958
|
*
|
|
986
|
-
* const
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* const histogram = Metric.histogram("response_time", {
|
|
959
|
+
* const metrics: ReadonlyArray<Metric.Metric<any, any>> = [
|
|
960
|
+
* Metric.counter("requests_total"),
|
|
961
|
+
* Metric.gauge("cpu_usage"),
|
|
962
|
+
* Metric.frequency("status_codes"),
|
|
963
|
+
* Metric.histogram("response_time", {
|
|
992
964
|
* boundaries: Metric.linearBoundaries({ start: 0, width: 50, count: 10 })
|
|
993
|
-
* })
|
|
994
|
-
*
|
|
965
|
+
* }),
|
|
966
|
+
* Metric.summary("latency", {
|
|
995
967
|
* maxAge: "5 minutes",
|
|
996
968
|
* maxSize: 1000,
|
|
997
969
|
* quantiles: [0.5, 0.95, 0.99]
|
|
998
970
|
* })
|
|
971
|
+
* ]
|
|
999
972
|
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
* name: metric.id,
|
|
1003
|
-
* type: metric.type
|
|
1004
|
-
* })
|
|
1005
|
-
*
|
|
1006
|
-
* // Get type information for each metric
|
|
1007
|
-
* const counterInfo = getMetricInfo(counter) // { name: "requests_total", type: "Counter" }
|
|
1008
|
-
* const gaugeInfo = getMetricInfo(gauge) // { name: "cpu_usage", type: "Gauge" }
|
|
1009
|
-
* const frequencyInfo = getMetricInfo(frequency) // { name: "status_codes", type: "Frequency" }
|
|
1010
|
-
* const histogramInfo = getMetricInfo(histogram) // { name: "response_time", type: "Histogram" }
|
|
1011
|
-
* const summaryInfo = getMetricInfo(summary) // { name: "latency", type: "Summary" }
|
|
1012
|
-
*
|
|
1013
|
-
* // Pattern match on metric type
|
|
1014
|
-
* const describeMetric = (type: string): string => {
|
|
1015
|
-
* switch (type) {
|
|
1016
|
-
* case "Counter":
|
|
1017
|
-
* return "Cumulative values that increase over time"
|
|
1018
|
-
* case "Gauge":
|
|
1019
|
-
* return "Instantaneous values that can go up or down"
|
|
1020
|
-
* case "Frequency":
|
|
1021
|
-
* return "Counts of discrete string occurrences"
|
|
1022
|
-
* case "Histogram":
|
|
1023
|
-
* return "Distribution of values across buckets"
|
|
1024
|
-
* case "Summary":
|
|
1025
|
-
* return "Quantile calculations over time windows"
|
|
1026
|
-
* default:
|
|
1027
|
-
* return "Unknown metric type"
|
|
1028
|
-
* }
|
|
1029
|
-
* }
|
|
1030
|
-
*
|
|
1031
|
-
* return {
|
|
1032
|
-
* metrics: [
|
|
1033
|
-
* counterInfo,
|
|
1034
|
-
* gaugeInfo,
|
|
1035
|
-
* frequencyInfo,
|
|
1036
|
-
* histogramInfo,
|
|
1037
|
-
* summaryInfo
|
|
1038
|
-
* ],
|
|
1039
|
-
* descriptions: {
|
|
1040
|
-
* Counter: describeMetric("Counter"),
|
|
1041
|
-
* Gauge: describeMetric("Gauge"),
|
|
1042
|
-
* Frequency: describeMetric("Frequency"),
|
|
1043
|
-
* Histogram: describeMetric("Histogram"),
|
|
1044
|
-
* Summary: describeMetric("Summary")
|
|
1045
|
-
* }
|
|
1046
|
-
* }
|
|
1047
|
-
* })
|
|
973
|
+
* const types: ReadonlyArray<Metric.Metric.Type> = metrics.map((metric) => metric.type)
|
|
974
|
+
* const actual = types // => ["Counter", "Gauge", "Frequency", "Histogram", "Summary"]
|
|
1048
975
|
* ```
|
|
1049
976
|
*
|
|
1050
|
-
* @category
|
|
977
|
+
* @category models
|
|
1051
978
|
* @since 4.0.0
|
|
1052
979
|
*/
|
|
1053
980
|
export type Type = "Counter" | "Frequency" | "Gauge" | "Histogram" | "Summary"
|
|
@@ -1057,12 +984,8 @@ export declare namespace Metric {
|
|
|
1057
984
|
*
|
|
1058
985
|
* **Example** (Providing attributes in different formats)
|
|
1059
986
|
*
|
|
1060
|
-
* ```ts
|
|
1061
|
-
* import {
|
|
1062
|
-
*
|
|
1063
|
-
* class AttributesError extends Data.TaggedError("AttributesError")<{
|
|
1064
|
-
* readonly operation: string
|
|
1065
|
-
* }> {}
|
|
987
|
+
* ```ts import.meta.vitest
|
|
988
|
+
* import { Effect, Metric } from "effect"
|
|
1066
989
|
*
|
|
1067
990
|
* const program = Effect.gen(function*() {
|
|
1068
991
|
* // Different ways to specify attributes
|
|
@@ -1111,19 +1034,22 @@ export declare namespace Metric {
|
|
|
1111
1034
|
* // Both formats result in the same internal representation
|
|
1112
1035
|
* const normalizedObject = normalizeAttributes(attributesAsObject)
|
|
1113
1036
|
* const normalizedArray = normalizeAttributes(attributesAsArray)
|
|
1114
|
-
*
|
|
1115
1037
|
* return {
|
|
1116
1038
|
* attributeFormats: {
|
|
1117
1039
|
* object: normalizedObject, // { service: "api", environment: "production", version: "1.2.3" }
|
|
1118
|
-
* array: normalizedArray
|
|
1119
|
-
* areEqual:
|
|
1120
|
-
* JSON.stringify(normalizedObject) === JSON.stringify(normalizedArray) // true
|
|
1040
|
+
* array: normalizedArray // { service: "api", environment: "production", version: "1.2.3" }
|
|
1121
1041
|
* }
|
|
1122
1042
|
* }
|
|
1123
1043
|
* })
|
|
1044
|
+
*
|
|
1045
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1046
|
+
* const objectAttributes = result.attributeFormats.object
|
|
1047
|
+
* const arrayAttributes = result.attributeFormats.array
|
|
1048
|
+
* const sameAttributes = [objectAttributes, arrayAttributes]
|
|
1049
|
+
* sameAttributes // => [{ service: "api", environment: "production", version: "1.2.3" }, { service: "api", environment: "production", version: "1.2.3" }]
|
|
1124
1050
|
* ```
|
|
1125
1051
|
*
|
|
1126
|
-
* @category
|
|
1052
|
+
* @category models
|
|
1127
1053
|
* @since 4.0.0
|
|
1128
1054
|
*/
|
|
1129
1055
|
export type Attributes = AttributeSet | ReadonlyArray<[string, string]>
|
|
@@ -1133,12 +1059,8 @@ export declare namespace Metric {
|
|
|
1133
1059
|
*
|
|
1134
1060
|
* **Example** (Combining metric attribute sets)
|
|
1135
1061
|
*
|
|
1136
|
-
* ```ts
|
|
1137
|
-
* import {
|
|
1138
|
-
*
|
|
1139
|
-
* class AttributeSetError extends Data.TaggedError("AttributeSetError")<{
|
|
1140
|
-
* readonly operation: string
|
|
1141
|
-
* }> {}
|
|
1062
|
+
* ```ts import.meta.vitest
|
|
1063
|
+
* import { Effect, Metric } from "effect"
|
|
1142
1064
|
*
|
|
1143
1065
|
* const program = Effect.gen(function*() {
|
|
1144
1066
|
* // Define attribute sets for different contexts
|
|
@@ -1199,9 +1121,12 @@ export declare namespace Metric {
|
|
|
1199
1121
|
* }
|
|
1200
1122
|
* }
|
|
1201
1123
|
* })
|
|
1124
|
+
*
|
|
1125
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1126
|
+
* const validation = [result.attributes.isValid, result.attributes.totalKeys] // => [true, 9]
|
|
1202
1127
|
* ```
|
|
1203
1128
|
*
|
|
1204
|
-
* @category
|
|
1129
|
+
* @category models
|
|
1205
1130
|
* @since 4.0.0
|
|
1206
1131
|
*/
|
|
1207
1132
|
export type AttributeSet = Readonly<Record<string, string>>
|
|
@@ -1211,7 +1136,7 @@ export declare namespace Metric {
|
|
|
1211
1136
|
*
|
|
1212
1137
|
* **Example** (Extracting metric input types)
|
|
1213
1138
|
*
|
|
1214
|
-
* ```ts
|
|
1139
|
+
* ```ts import.meta.vitest
|
|
1215
1140
|
* import { Metric } from "effect"
|
|
1216
1141
|
*
|
|
1217
1142
|
* // Create various metric types
|
|
@@ -1249,9 +1174,11 @@ export declare namespace Metric {
|
|
|
1249
1174
|
* // Metric.update(numberCounter, "abc") // ✗ Type error
|
|
1250
1175
|
* // Metric.update(stringFrequency, "ok") // ✓ Valid (string)
|
|
1251
1176
|
* // Metric.update(stringFrequency, 404) // ✗ Type error
|
|
1177
|
+
* const metricIds = metrics.map(({ id, type }) => `${id}:${type}`)
|
|
1178
|
+
* metricIds // => ["requests:Counter", "bytes:Counter", "status_codes:Frequency", "cpu_usage:Gauge", "response_time:Histogram"]
|
|
1252
1179
|
* ```
|
|
1253
1180
|
*
|
|
1254
|
-
* @category types
|
|
1181
|
+
* @category utility types
|
|
1255
1182
|
* @since 4.0.0
|
|
1256
1183
|
*/
|
|
1257
1184
|
export type Input<A> = A extends Metric<infer _Input, infer _State> ? _Input
|
|
@@ -1262,7 +1189,7 @@ export declare namespace Metric {
|
|
|
1262
1189
|
*
|
|
1263
1190
|
* **Example** (Extracting metric state types)
|
|
1264
1191
|
*
|
|
1265
|
-
* ```ts
|
|
1192
|
+
* ```ts import.meta.vitest
|
|
1266
1193
|
* import { Effect, Metric } from "effect"
|
|
1267
1194
|
*
|
|
1268
1195
|
* // Create various metric types
|
|
@@ -1300,7 +1227,6 @@ export declare namespace Metric {
|
|
|
1300
1227
|
* const frequencyState = yield* Metric.value(statusFrequency)
|
|
1301
1228
|
* const histogramState = yield* Metric.value(responseHistogram)
|
|
1302
1229
|
* const summaryState = yield* Metric.value(latencySummary)
|
|
1303
|
-
*
|
|
1304
1230
|
* return {
|
|
1305
1231
|
* counter: { count: counterState.count }, // { count: 10 }
|
|
1306
1232
|
* gauge: { value: gaugeState.value }, // { value: 85.5 }
|
|
@@ -1309,9 +1235,13 @@ export declare namespace Metric {
|
|
|
1309
1235
|
* summary: { observations: summaryState.count } // { observations: 1 }
|
|
1310
1236
|
* }
|
|
1311
1237
|
* })
|
|
1238
|
+
*
|
|
1239
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1240
|
+
* const values = [result.counter.count, result.gauge.value, result.frequency.uniqueValues]
|
|
1241
|
+
* values // => [10, 85.5, 1]
|
|
1312
1242
|
* ```
|
|
1313
1243
|
*
|
|
1314
|
-
* @category types
|
|
1244
|
+
* @category utility types
|
|
1315
1245
|
* @since 4.0.0
|
|
1316
1246
|
*/
|
|
1317
1247
|
export type State<A> = A extends Metric<infer _Input, infer _State> ? _State
|
|
@@ -1322,12 +1252,8 @@ export declare namespace Metric {
|
|
|
1322
1252
|
*
|
|
1323
1253
|
* **Example** (Using metric hooks)
|
|
1324
1254
|
*
|
|
1325
|
-
* ```ts
|
|
1326
|
-
* import {
|
|
1327
|
-
*
|
|
1328
|
-
* class HooksError extends Data.TaggedError("HooksError")<{
|
|
1329
|
-
* readonly operation: string
|
|
1330
|
-
* }> {}
|
|
1255
|
+
* ```ts import.meta.vitest
|
|
1256
|
+
* import { Effect, Metric } from "effect"
|
|
1331
1257
|
*
|
|
1332
1258
|
* const program = Effect.gen(function*() {
|
|
1333
1259
|
* // Create a counter metric
|
|
@@ -1355,9 +1281,12 @@ export declare namespace Metric {
|
|
|
1355
1281
|
* isIncremental: state.incremental // false
|
|
1356
1282
|
* }
|
|
1357
1283
|
* })
|
|
1284
|
+
*
|
|
1285
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1286
|
+
* const state = result // => { currentCount: 6, isIncremental: false }
|
|
1358
1287
|
* ```
|
|
1359
1288
|
*
|
|
1360
|
-
* @category
|
|
1289
|
+
* @category models
|
|
1361
1290
|
* @since 4.0.0
|
|
1362
1291
|
*/
|
|
1363
1292
|
export interface Hooks<in Input, out State> {
|
|
@@ -1371,12 +1300,8 @@ export declare namespace Metric {
|
|
|
1371
1300
|
*
|
|
1372
1301
|
* **Example** (Inspecting metric metadata)
|
|
1373
1302
|
*
|
|
1374
|
-
* ```ts
|
|
1375
|
-
* import {
|
|
1376
|
-
*
|
|
1377
|
-
* class MetadataError extends Data.TaggedError("MetadataError")<{
|
|
1378
|
-
* readonly operation: string
|
|
1379
|
-
* }> {}
|
|
1303
|
+
* ```ts import.meta.vitest
|
|
1304
|
+
* import { Effect, Metric } from "effect"
|
|
1380
1305
|
*
|
|
1381
1306
|
* const program = Effect.gen(function*() {
|
|
1382
1307
|
* // Create metrics with different configurations
|
|
@@ -1421,9 +1346,12 @@ export declare namespace Metric {
|
|
|
1421
1346
|
* }
|
|
1422
1347
|
* }
|
|
1423
1348
|
* })
|
|
1349
|
+
*
|
|
1350
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1351
|
+
* const types = [result.counter.type, result.gauge.type, result.frequency.type] // => ["Counter", "Gauge", "Frequency"]
|
|
1424
1352
|
* ```
|
|
1425
1353
|
*
|
|
1426
|
-
* @category
|
|
1354
|
+
* @category models
|
|
1427
1355
|
* @since 4.0.0
|
|
1428
1356
|
*/
|
|
1429
1357
|
export interface Metadata<in Input, out State> {
|
|
@@ -1439,12 +1367,8 @@ export declare namespace Metric {
|
|
|
1439
1367
|
*
|
|
1440
1368
|
* **Example** (Inspecting metric snapshot protocols)
|
|
1441
1369
|
*
|
|
1442
|
-
* ```ts
|
|
1443
|
-
* import {
|
|
1444
|
-
*
|
|
1445
|
-
* class SnapshotProtoError extends Data.TaggedError("SnapshotProtoError")<{
|
|
1446
|
-
* readonly operation: string
|
|
1447
|
-
* }> {}
|
|
1370
|
+
* ```ts import.meta.vitest
|
|
1371
|
+
* import { Effect, Metric } from "effect"
|
|
1448
1372
|
*
|
|
1449
1373
|
* const program = Effect.gen(function*() {
|
|
1450
1374
|
* // Create and update metrics
|
|
@@ -1494,9 +1418,12 @@ export declare namespace Metric {
|
|
|
1494
1418
|
* null
|
|
1495
1419
|
* }
|
|
1496
1420
|
* })
|
|
1421
|
+
*
|
|
1422
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1423
|
+
* const counts = [result.counter?.count, result.histogram?.observations] // => [25, 2]
|
|
1497
1424
|
* ```
|
|
1498
1425
|
*
|
|
1499
|
-
* @category
|
|
1426
|
+
* @category models
|
|
1500
1427
|
* @since 4.0.0
|
|
1501
1428
|
*/
|
|
1502
1429
|
export interface SnapshotProto<T extends Type, State> {
|
|
@@ -1512,12 +1439,8 @@ export declare namespace Metric {
|
|
|
1512
1439
|
*
|
|
1513
1440
|
* **Example** (Analyzing metric snapshots)
|
|
1514
1441
|
*
|
|
1515
|
-
* ```ts
|
|
1516
|
-
* import {
|
|
1517
|
-
*
|
|
1518
|
-
* class SnapshotError extends Data.TaggedError("SnapshotError")<{
|
|
1519
|
-
* readonly operation: string
|
|
1520
|
-
* }> {}
|
|
1442
|
+
* ```ts import.meta.vitest
|
|
1443
|
+
* import { Effect, Metric } from "effect"
|
|
1521
1444
|
*
|
|
1522
1445
|
* const program = Effect.gen(function*() {
|
|
1523
1446
|
* // Create different types of metrics
|
|
@@ -1571,9 +1494,12 @@ export declare namespace Metric {
|
|
|
1571
1494
|
* analysis
|
|
1572
1495
|
* }
|
|
1573
1496
|
* })
|
|
1497
|
+
*
|
|
1498
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1499
|
+
* const types = result.metricTypes // => ["Counter", "Gauge", "Frequency", "Histogram", "Summary"]
|
|
1574
1500
|
* ```
|
|
1575
1501
|
*
|
|
1576
|
-
* @category
|
|
1502
|
+
* @category models
|
|
1577
1503
|
* @since 4.0.0
|
|
1578
1504
|
*/
|
|
1579
1505
|
export type Snapshot =
|
|
@@ -1589,12 +1515,8 @@ export declare namespace Metric {
|
|
|
1589
1515
|
*
|
|
1590
1516
|
* **Example** (Accessing the current metric attributes key)
|
|
1591
1517
|
*
|
|
1592
|
-
* ```ts
|
|
1593
|
-
* import {
|
|
1594
|
-
*
|
|
1595
|
-
* class AttributesKeyError extends Data.TaggedError("AttributesKeyError")<{
|
|
1596
|
-
* readonly operation: string
|
|
1597
|
-
* }> {}
|
|
1518
|
+
* ```ts import.meta.vitest
|
|
1519
|
+
* import { Effect, Metric } from "effect"
|
|
1598
1520
|
*
|
|
1599
1521
|
* const program = Effect.gen(function*() {
|
|
1600
1522
|
* // The key is used internally by the Effect runtime to manage metric attributes
|
|
@@ -1628,9 +1550,12 @@ export declare namespace Metric {
|
|
|
1628
1550
|
* isConstant: key === "effect/Metric/CurrentMetricAttributes" // true
|
|
1629
1551
|
* }
|
|
1630
1552
|
* })
|
|
1553
|
+
*
|
|
1554
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
1555
|
+
* const key = result // => { keyValue: "effect/Metric/CurrentMetricAttributes", keyType: "string", isConstant: true }
|
|
1631
1556
|
* ```
|
|
1632
1557
|
*
|
|
1633
|
-
* @category
|
|
1558
|
+
* @category constants
|
|
1634
1559
|
* @since 4.0.0
|
|
1635
1560
|
*/
|
|
1636
1561
|
export const CurrentMetricAttributesKey = "effect/Metric/CurrentMetricAttributes" as const
|
|
@@ -1652,17 +1577,12 @@ export const CurrentMetricAttributesKey = "effect/Metric/CurrentMetricAttributes
|
|
|
1652
1577
|
*
|
|
1653
1578
|
* **Example** (Providing current metric attributes)
|
|
1654
1579
|
*
|
|
1655
|
-
* ```ts
|
|
1656
|
-
* import {
|
|
1657
|
-
*
|
|
1658
|
-
* class AttributesError extends Data.TaggedError("AttributesError")<{
|
|
1659
|
-
* readonly operation: string
|
|
1660
|
-
* }> {}
|
|
1580
|
+
* ```ts import.meta.vitest
|
|
1581
|
+
* import { Effect, Metric } from "effect"
|
|
1661
1582
|
*
|
|
1662
1583
|
* const program = Effect.gen(function*() {
|
|
1663
1584
|
* // Access current metric attributes
|
|
1664
|
-
*
|
|
1665
|
-
* console.log("Current attributes:", attributes)
|
|
1585
|
+
* yield* Metric.CurrentMetricAttributes
|
|
1666
1586
|
*
|
|
1667
1587
|
* // Set new attributes context
|
|
1668
1588
|
* const newAttributes = { service: "api", version: "1.0" }
|
|
@@ -1677,9 +1597,12 @@ export const CurrentMetricAttributesKey = "effect/Metric/CurrentMetricAttributes
|
|
|
1677
1597
|
*
|
|
1678
1598
|
* return result
|
|
1679
1599
|
* })
|
|
1600
|
+
*
|
|
1601
|
+
* const attributes = await Effect.runPromise(program)
|
|
1602
|
+
* const actual = attributes // => { service: "api", version: "1.0" }
|
|
1680
1603
|
* ```
|
|
1681
1604
|
*
|
|
1682
|
-
* @category
|
|
1605
|
+
* @category services
|
|
1683
1606
|
* @since 4.0.0
|
|
1684
1607
|
*/
|
|
1685
1608
|
export const CurrentMetricAttributes = Context.Reference<Metric.AttributeSet>(CurrentMetricAttributesKey, {
|
|
@@ -1711,7 +1634,7 @@ const MetricRegistryKey = "~effect/observability/Metric/MetricRegistryKey"
|
|
|
1711
1634
|
* @see {@link snapshot} for reading all registered metrics from the current `Effect` context
|
|
1712
1635
|
* @see {@link snapshotUnsafe} for reading all registered metrics from an explicit `Context`
|
|
1713
1636
|
*
|
|
1714
|
-
* @category
|
|
1637
|
+
* @category services
|
|
1715
1638
|
* @since 4.0.0
|
|
1716
1639
|
*/
|
|
1717
1640
|
export const MetricRegistry = Context.Reference<Map<string, Metric.Metadata<any, any>>>(
|
|
@@ -2022,8 +1945,8 @@ class SummaryMetric extends Metric$<readonly [value: number, timestamp: number],
|
|
|
2022
1945
|
return sortedQuantiles.map((q) => [q, undefined])
|
|
2023
1946
|
}
|
|
2024
1947
|
// Compute the value of the quantile in terms of rank:
|
|
2025
|
-
//
|
|
2026
|
-
//
|
|
1948
|
+
// For a given quantile `q`, return the maximum value `v` such that at
|
|
1949
|
+
// most `q * n` values are less than or equal to `v`.
|
|
2027
1950
|
return sortedQuantiles.map((q) => {
|
|
2028
1951
|
if (q <= 0) return [q, samples[0]]
|
|
2029
1952
|
if (q >= 1) return [q, samples[sampleSize - 1]]
|
|
@@ -2095,24 +2018,18 @@ class MetricTransform<in Input, out State, in Input2> extends Metric$<Input2, St
|
|
|
2095
2018
|
*
|
|
2096
2019
|
* **Example** (Checking metric values)
|
|
2097
2020
|
*
|
|
2098
|
-
* ```ts
|
|
2021
|
+
* ```ts import.meta.vitest
|
|
2099
2022
|
* import { Metric } from "effect"
|
|
2100
2023
|
*
|
|
2101
|
-
*
|
|
2102
|
-
*
|
|
2103
|
-
* const notAMetric = { name: "fake-metric" }
|
|
2104
|
-
*
|
|
2105
|
-
* console.log(Metric.isMetric(counter)) // true
|
|
2106
|
-
* console.log(Metric.isMetric(gauge)) // true
|
|
2107
|
-
* console.log(Metric.isMetric(notAMetric)) // false
|
|
2108
|
-
* console.log(Metric.isMetric(null)) // false
|
|
2024
|
+
* Metric.isMetric(Metric.counter("requests")) // => true
|
|
2025
|
+
* Metric.isMetric({ name: "requests" }) // => false
|
|
2109
2026
|
* ```
|
|
2110
2027
|
*
|
|
2111
2028
|
* @category guards
|
|
2112
2029
|
* @since 4.0.0
|
|
2113
2030
|
*/
|
|
2114
|
-
export const isMetric = (u: unknown): u is Metric<
|
|
2115
|
-
Predicate.hasProperty(u,
|
|
2031
|
+
export const isMetric = (u: unknown): u is Metric<never, unknown> =>
|
|
2032
|
+
Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId
|
|
2116
2033
|
|
|
2117
2034
|
/**
|
|
2118
2035
|
* Represents a Counter metric that tracks cumulative numerical values over
|
|
@@ -2128,12 +2045,8 @@ export const isMetric = (u: unknown): u is Metric<unknown, never> =>
|
|
|
2128
2045
|
*
|
|
2129
2046
|
* **Example** (Creating counter metrics)
|
|
2130
2047
|
*
|
|
2131
|
-
* ```ts
|
|
2132
|
-
* import {
|
|
2133
|
-
*
|
|
2134
|
-
* class CounterError extends Data.TaggedError("CounterError")<{
|
|
2135
|
-
* readonly operation: string
|
|
2136
|
-
* }> {}
|
|
2048
|
+
* ```ts import.meta.vitest
|
|
2049
|
+
* import { Effect, Metric } from "effect"
|
|
2137
2050
|
*
|
|
2138
2051
|
* const program = Effect.gen(function*() {
|
|
2139
2052
|
* // Create a basic counter for tracking requests
|
|
@@ -2167,6 +2080,9 @@ export const isMetric = (u: unknown): u is Metric<unknown, never> =>
|
|
|
2167
2080
|
*
|
|
2168
2081
|
* return { requestValue, eventValue, bytesValue }
|
|
2169
2082
|
* })
|
|
2083
|
+
*
|
|
2084
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2085
|
+
* const counts = [result.requestValue.count, result.eventValue.count, result.bytesValue.count] // => [6, 1, 1024n]
|
|
2170
2086
|
* ```
|
|
2171
2087
|
*
|
|
2172
2088
|
* @category constructors
|
|
@@ -2187,12 +2103,8 @@ export const counter: {
|
|
|
2187
2103
|
*
|
|
2188
2104
|
* **Example** (Creating counter metrics)
|
|
2189
2105
|
*
|
|
2190
|
-
* ```ts
|
|
2191
|
-
* import {
|
|
2192
|
-
*
|
|
2193
|
-
* class CounterError extends Data.TaggedError("CounterError")<{
|
|
2194
|
-
* readonly operation: string
|
|
2195
|
-
* }> {}
|
|
2106
|
+
* ```ts import.meta.vitest
|
|
2107
|
+
* import { Effect, Metric } from "effect"
|
|
2196
2108
|
*
|
|
2197
2109
|
* const program = Effect.gen(function*() {
|
|
2198
2110
|
* // Create a basic counter for tracking requests
|
|
@@ -2226,6 +2138,9 @@ export const counter: {
|
|
|
2226
2138
|
*
|
|
2227
2139
|
* return { requestValue, eventValue, bytesValue }
|
|
2228
2140
|
* })
|
|
2141
|
+
*
|
|
2142
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2143
|
+
* const counts = [result.requestValue.count, result.eventValue.count, result.bytesValue.count] // => [6, 1, 1024n]
|
|
2229
2144
|
* ```
|
|
2230
2145
|
*
|
|
2231
2146
|
* @category constructors
|
|
@@ -2254,12 +2169,8 @@ export const counter: {
|
|
|
2254
2169
|
*
|
|
2255
2170
|
* **Example** (Creating counter metrics)
|
|
2256
2171
|
*
|
|
2257
|
-
* ```ts
|
|
2258
|
-
* import {
|
|
2259
|
-
*
|
|
2260
|
-
* class CounterError extends Data.TaggedError("CounterError")<{
|
|
2261
|
-
* readonly operation: string
|
|
2262
|
-
* }> {}
|
|
2172
|
+
* ```ts import.meta.vitest
|
|
2173
|
+
* import { Effect, Metric } from "effect"
|
|
2263
2174
|
*
|
|
2264
2175
|
* const program = Effect.gen(function*() {
|
|
2265
2176
|
* // Create a basic counter for tracking requests
|
|
@@ -2293,6 +2204,9 @@ export const counter: {
|
|
|
2293
2204
|
*
|
|
2294
2205
|
* return { requestValue, eventValue, bytesValue }
|
|
2295
2206
|
* })
|
|
2207
|
+
*
|
|
2208
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2209
|
+
* const counts = [result.requestValue.count, result.eventValue.count, result.bytesValue.count] // => [6, 1, 1024n]
|
|
2296
2210
|
* ```
|
|
2297
2211
|
*
|
|
2298
2212
|
* @category constructors
|
|
@@ -2326,12 +2240,8 @@ export const counter: {
|
|
|
2326
2240
|
*
|
|
2327
2241
|
* **Example** (Creating gauge metrics)
|
|
2328
2242
|
*
|
|
2329
|
-
* ```ts
|
|
2330
|
-
* import {
|
|
2331
|
-
*
|
|
2332
|
-
* class GaugeError extends Data.TaggedError("GaugeError")<{
|
|
2333
|
-
* readonly operation: string
|
|
2334
|
-
* }> {}
|
|
2243
|
+
* ```ts import.meta.vitest
|
|
2244
|
+
* import { Effect, Metric } from "effect"
|
|
2335
2245
|
*
|
|
2336
2246
|
* const program = Effect.gen(function*() {
|
|
2337
2247
|
* // Create a gauge for tracking memory usage
|
|
@@ -2370,6 +2280,9 @@ export const counter: {
|
|
|
2370
2280
|
*
|
|
2371
2281
|
* return { memoryValue, cpuValue, diskValue }
|
|
2372
2282
|
* })
|
|
2283
|
+
*
|
|
2284
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2285
|
+
* const values = [result.memoryValue.value, result.cpuValue.value, result.diskValue.value] // => [800, 75, 1024000000n]
|
|
2373
2286
|
* ```
|
|
2374
2287
|
*
|
|
2375
2288
|
* @category constructors
|
|
@@ -2393,12 +2306,8 @@ export const gauge: {
|
|
|
2393
2306
|
*
|
|
2394
2307
|
* **Example** (Creating gauge metrics)
|
|
2395
2308
|
*
|
|
2396
|
-
* ```ts
|
|
2397
|
-
* import {
|
|
2398
|
-
*
|
|
2399
|
-
* class GaugeError extends Data.TaggedError("GaugeError")<{
|
|
2400
|
-
* readonly operation: string
|
|
2401
|
-
* }> {}
|
|
2309
|
+
* ```ts import.meta.vitest
|
|
2310
|
+
* import { Effect, Metric } from "effect"
|
|
2402
2311
|
*
|
|
2403
2312
|
* const program = Effect.gen(function*() {
|
|
2404
2313
|
* // Create a gauge for tracking memory usage
|
|
@@ -2437,6 +2346,9 @@ export const gauge: {
|
|
|
2437
2346
|
*
|
|
2438
2347
|
* return { memoryValue, cpuValue, diskValue }
|
|
2439
2348
|
* })
|
|
2349
|
+
*
|
|
2350
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2351
|
+
* const values = [result.memoryValue.value, result.cpuValue.value, result.diskValue.value] // => [800, 75, 1024000000n]
|
|
2440
2352
|
* ```
|
|
2441
2353
|
*
|
|
2442
2354
|
* @category constructors
|
|
@@ -2467,12 +2379,8 @@ export const gauge: {
|
|
|
2467
2379
|
*
|
|
2468
2380
|
* **Example** (Creating gauge metrics)
|
|
2469
2381
|
*
|
|
2470
|
-
* ```ts
|
|
2471
|
-
* import {
|
|
2472
|
-
*
|
|
2473
|
-
* class GaugeError extends Data.TaggedError("GaugeError")<{
|
|
2474
|
-
* readonly operation: string
|
|
2475
|
-
* }> {}
|
|
2382
|
+
* ```ts import.meta.vitest
|
|
2383
|
+
* import { Effect, Metric } from "effect"
|
|
2476
2384
|
*
|
|
2477
2385
|
* const program = Effect.gen(function*() {
|
|
2478
2386
|
* // Create a gauge for tracking memory usage
|
|
@@ -2511,6 +2419,9 @@ export const gauge: {
|
|
|
2511
2419
|
*
|
|
2512
2420
|
* return { memoryValue, cpuValue, diskValue }
|
|
2513
2421
|
* })
|
|
2422
|
+
*
|
|
2423
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2424
|
+
* const values = [result.memoryValue.value, result.cpuValue.value, result.diskValue.value] // => [800, 75, 1024000000n]
|
|
2514
2425
|
* ```
|
|
2515
2426
|
*
|
|
2516
2427
|
* @category constructors
|
|
@@ -2543,12 +2454,8 @@ export const gauge: {
|
|
|
2543
2454
|
*
|
|
2544
2455
|
* **Example** (Creating frequency metrics)
|
|
2545
2456
|
*
|
|
2546
|
-
* ```ts
|
|
2547
|
-
* import {
|
|
2548
|
-
*
|
|
2549
|
-
* class FrequencyError extends Data.TaggedError("FrequencyError")<{
|
|
2550
|
-
* readonly operation: string
|
|
2551
|
-
* }> {}
|
|
2457
|
+
* ```ts import.meta.vitest
|
|
2458
|
+
* import { Effect, Metric } from "effect"
|
|
2552
2459
|
*
|
|
2553
2460
|
* const program = Effect.gen(function*() {
|
|
2554
2461
|
* // Create a frequency metric for HTTP status codes
|
|
@@ -2598,6 +2505,14 @@ export const gauge: {
|
|
|
2598
2505
|
*
|
|
2599
2506
|
* return { statusCounts, actionCounts, errorCounts }
|
|
2600
2507
|
* })
|
|
2508
|
+
*
|
|
2509
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2510
|
+
* const counts = [
|
|
2511
|
+
* result.statusCounts.occurrences.get("200"),
|
|
2512
|
+
* result.actionCounts.occurrences.get("login"),
|
|
2513
|
+
* result.errorCounts.occurrences.get("ValidationError")
|
|
2514
|
+
* ]
|
|
2515
|
+
* counts // => [3, 2, 2]
|
|
2601
2516
|
* ```
|
|
2602
2517
|
*
|
|
2603
2518
|
* @category constructors
|
|
@@ -2625,19 +2540,15 @@ export const frequency = (name: string, options?: {
|
|
|
2625
2540
|
*
|
|
2626
2541
|
* **Example** (Creating histogram metrics)
|
|
2627
2542
|
*
|
|
2628
|
-
* ```ts
|
|
2629
|
-
* import {
|
|
2630
|
-
*
|
|
2631
|
-
* class HistogramError extends Data.TaggedError("HistogramError")<{
|
|
2632
|
-
* readonly operation: string
|
|
2633
|
-
* }> {}
|
|
2543
|
+
* ```ts import.meta.vitest
|
|
2544
|
+
* import { Effect, Metric } from "effect"
|
|
2634
2545
|
*
|
|
2635
2546
|
* const program = Effect.gen(function*() {
|
|
2636
2547
|
* // Create a histogram for API response times
|
|
2637
2548
|
* const responseTimeHistogram = Metric.histogram("api_response_time", {
|
|
2638
2549
|
* description: "Distribution of API response times in milliseconds",
|
|
2639
2550
|
* boundaries: Metric.linearBoundaries({ start: 0, width: 50, count: 10 })
|
|
2640
|
-
* // Creates buckets: 0-50ms, 50-100ms, 100-150ms, ...,
|
|
2551
|
+
* // Creates buckets: 0-50ms, 50-100ms, 100-150ms, ..., 350-400ms, 400ms+
|
|
2641
2552
|
* })
|
|
2642
2553
|
*
|
|
2643
2554
|
* // Create a histogram for request payload sizes
|
|
@@ -2677,6 +2588,10 @@ export const frequency = (name: string, options?: {
|
|
|
2677
2588
|
*
|
|
2678
2589
|
* return { responseTimeState, payloadSizeState }
|
|
2679
2590
|
* })
|
|
2591
|
+
*
|
|
2592
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2593
|
+
* const values = [result.responseTimeState.count, result.responseTimeState.sum, result.payloadSizeState.count]
|
|
2594
|
+
* values // => [5, 500, 3]
|
|
2680
2595
|
* ```
|
|
2681
2596
|
*
|
|
2682
2597
|
* @category constructors
|
|
@@ -2706,12 +2621,8 @@ export const histogram = (name: string, options: {
|
|
|
2706
2621
|
*
|
|
2707
2622
|
* **Example** (Creating summary metrics)
|
|
2708
2623
|
*
|
|
2709
|
-
* ```ts
|
|
2710
|
-
* import {
|
|
2711
|
-
*
|
|
2712
|
-
* class SummaryError extends Data.TaggedError("SummaryError")<{
|
|
2713
|
-
* readonly operation: string
|
|
2714
|
-
* }> {}
|
|
2624
|
+
* ```ts import.meta.vitest
|
|
2625
|
+
* import { Duration, Effect, Metric } from "effect"
|
|
2715
2626
|
*
|
|
2716
2627
|
* const program = Effect.gen(function*() {
|
|
2717
2628
|
* // Create a summary for API response times
|
|
@@ -2747,24 +2658,16 @@ export const histogram = (name: string, options: {
|
|
|
2747
2658
|
* const responseStats = yield* Metric.value(responseTimeSummary)
|
|
2748
2659
|
* const payloadStats = yield* Metric.value(payloadSizeSummary)
|
|
2749
2660
|
*
|
|
2750
|
-
* console.log({
|
|
2751
|
-
* count: responseStats.count,
|
|
2752
|
-
* min: responseStats.min,
|
|
2753
|
-
* max: responseStats.max,
|
|
2754
|
-
* sum: responseStats.sum
|
|
2755
|
-
* }) // { count: 8, min: 82, max: 240, sum: 1155 }
|
|
2756
|
-
*
|
|
2757
|
-
* console.log({
|
|
2758
|
-
* count: payloadStats.count,
|
|
2759
|
-
* min: payloadStats.min,
|
|
2760
|
-
* max: payloadStats.max,
|
|
2761
|
-
* sum: payloadStats.sum
|
|
2762
|
-
* }) // { count: 4, min: 1.2, max: 15.6, sum: 26 }
|
|
2763
|
-
*
|
|
2764
2661
|
* // Both summaries include quantile information for their configured windows.
|
|
2765
2662
|
*
|
|
2766
2663
|
* return { responseStats, payloadStats }
|
|
2767
2664
|
* })
|
|
2665
|
+
*
|
|
2666
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
2667
|
+
* const response = result.responseStats
|
|
2668
|
+
* const payload = result.payloadStats
|
|
2669
|
+
* const responseValues = [response.count, response.min, response.max, response.sum] // => [8, 82, 240, 1155]
|
|
2670
|
+
* const payloadValues = [payload.count, payload.min, payload.max, payload.sum] // => [4, 1.2, 15.6, 26]
|
|
2768
2671
|
* ```
|
|
2769
2672
|
*
|
|
2770
2673
|
* @category constructors
|
|
@@ -2804,7 +2707,7 @@ export const summary = (name: string, options: {
|
|
|
2804
2707
|
*
|
|
2805
2708
|
* **Example** (Creating summaries with explicit timestamps)
|
|
2806
2709
|
*
|
|
2807
|
-
* ```ts
|
|
2710
|
+
* ```ts import.meta.vitest
|
|
2808
2711
|
* import { Metric } from "effect"
|
|
2809
2712
|
*
|
|
2810
2713
|
* const responseTimesSummary = Metric.summaryWithTimestamp(
|
|
@@ -2816,6 +2719,7 @@ export const summary = (name: string, options: {
|
|
|
2816
2719
|
* quantiles: [0.5, 0.9, 0.99] // Calculate 50th, 90th, and 99th quantiles.
|
|
2817
2720
|
* }
|
|
2818
2721
|
* )
|
|
2722
|
+
* const metadata = [responseTimesSummary.id, responseTimesSummary.type] // => ["response_times_summary", "Summary"]
|
|
2819
2723
|
* ```
|
|
2820
2724
|
*
|
|
2821
2725
|
* @category constructors
|
|
@@ -2843,12 +2747,8 @@ export const summaryWithTimestamp = (name: string, options: {
|
|
|
2843
2747
|
*
|
|
2844
2748
|
* **Example** (Recording durations with a timer)
|
|
2845
2749
|
*
|
|
2846
|
-
* ```ts
|
|
2847
|
-
* import {
|
|
2848
|
-
*
|
|
2849
|
-
* class TimerError extends Data.TaggedError("TimerError")<{
|
|
2850
|
-
* readonly operation: string
|
|
2851
|
-
* }> {}
|
|
2750
|
+
* ```ts import.meta.vitest
|
|
2751
|
+
* import { Duration, Effect, Metric } from "effect"
|
|
2852
2752
|
*
|
|
2853
2753
|
* // Create a timer metric to track API request durations
|
|
2854
2754
|
* const apiRequestTimer = Metric.timer("api_request_duration", {
|
|
@@ -2862,13 +2762,17 @@ export const summaryWithTimestamp = (name: string, options: {
|
|
|
2862
2762
|
* yield* Metric.update(apiRequestTimer, duration)
|
|
2863
2763
|
*
|
|
2864
2764
|
* const state = yield* Metric.value(apiRequestTimer)
|
|
2865
|
-
*
|
|
2765
|
+
* return {
|
|
2866
2766
|
* count: state.count,
|
|
2867
2767
|
* min: state.min,
|
|
2868
2768
|
* max: state.max,
|
|
2869
2769
|
* sum: state.sum
|
|
2870
|
-
* }
|
|
2770
|
+
* }
|
|
2871
2771
|
* })
|
|
2772
|
+
*
|
|
2773
|
+
* await Effect.runPromise(
|
|
2774
|
+
* Effect.provideService(apiOperation, Metric.MetricRegistry, new Map())
|
|
2775
|
+
* ) // => { count: 1, min: 120, max: 120, sum: 120 }
|
|
2872
2776
|
* ```
|
|
2873
2777
|
*
|
|
2874
2778
|
* @category constructors
|
|
@@ -2901,10 +2805,10 @@ export const timer = (name: string, options?: {
|
|
|
2901
2805
|
*
|
|
2902
2806
|
* **Example** (Reading metric state)
|
|
2903
2807
|
*
|
|
2904
|
-
* ```ts
|
|
2808
|
+
* ```ts import.meta.vitest
|
|
2905
2809
|
* import { Effect, Metric } from "effect"
|
|
2906
2810
|
*
|
|
2907
|
-
* const requestCounter = Metric.counter("
|
|
2811
|
+
* const requestCounter = Metric.counter("modify_requests")
|
|
2908
2812
|
* const responseTime = Metric.histogram("response_time", {
|
|
2909
2813
|
* boundaries: [100, 500, 1000, 2000]
|
|
2910
2814
|
* })
|
|
@@ -2916,16 +2820,19 @@ export const timer = (name: string, options?: {
|
|
|
2916
2820
|
*
|
|
2917
2821
|
* // Get current values
|
|
2918
2822
|
* const counterState = yield* Metric.value(requestCounter)
|
|
2919
|
-
* console.log(`Request count: ${counterState.count}`)
|
|
2920
|
-
*
|
|
2921
2823
|
* const histogramState = yield* Metric.value(responseTime)
|
|
2922
|
-
*
|
|
2824
|
+
* return {
|
|
2825
|
+
* requestCount: counterState.count,
|
|
2923
2826
|
* count: histogramState.count,
|
|
2924
2827
|
* min: histogramState.min,
|
|
2925
2828
|
* max: histogramState.max,
|
|
2926
2829
|
* average: histogramState.sum / histogramState.count
|
|
2927
|
-
* }
|
|
2830
|
+
* }
|
|
2928
2831
|
* })
|
|
2832
|
+
*
|
|
2833
|
+
* await Effect.runPromise(
|
|
2834
|
+
* Effect.provideService(program, Metric.MetricRegistry, new Map())
|
|
2835
|
+
* ) // => { requestCount: 1, count: 1, min: 750, max: 750, average: 750 }
|
|
2929
2836
|
* ```
|
|
2930
2837
|
*
|
|
2931
2838
|
* @category getters
|
|
@@ -2952,7 +2859,7 @@ export const value = <Input, State>(
|
|
|
2952
2859
|
*
|
|
2953
2860
|
* **Example** (Modifying metric values)
|
|
2954
2861
|
*
|
|
2955
|
-
* ```ts
|
|
2862
|
+
* ```ts import.meta.vitest
|
|
2956
2863
|
* import { Effect, Metric } from "effect"
|
|
2957
2864
|
*
|
|
2958
2865
|
* const temperatureGauge = Metric.gauge("temperature")
|
|
@@ -2972,10 +2879,10 @@ export const value = <Input, State>(
|
|
|
2972
2879
|
*
|
|
2973
2880
|
* const temp = yield* Metric.value(temperatureGauge)
|
|
2974
2881
|
* const requests = yield* Metric.value(requestCounter)
|
|
2975
|
-
*
|
|
2976
|
-
* console.log(`Temperature: ${temp.value}°C`) // 22°C
|
|
2977
|
-
* console.log(`Requests: ${requests.count}`) // 15
|
|
2882
|
+
* return [temp.value, requests.count] as const
|
|
2978
2883
|
* })
|
|
2884
|
+
*
|
|
2885
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [22, 15]
|
|
2979
2886
|
* ```
|
|
2980
2887
|
*
|
|
2981
2888
|
* @category mutations
|
|
@@ -2995,7 +2902,7 @@ export const modify: {
|
|
|
2995
2902
|
*
|
|
2996
2903
|
* **Example** (Modifying metric values)
|
|
2997
2904
|
*
|
|
2998
|
-
* ```ts
|
|
2905
|
+
* ```ts import.meta.vitest
|
|
2999
2906
|
* import { Effect, Metric } from "effect"
|
|
3000
2907
|
*
|
|
3001
2908
|
* const temperatureGauge = Metric.gauge("temperature")
|
|
@@ -3015,10 +2922,10 @@ export const modify: {
|
|
|
3015
2922
|
*
|
|
3016
2923
|
* const temp = yield* Metric.value(temperatureGauge)
|
|
3017
2924
|
* const requests = yield* Metric.value(requestCounter)
|
|
3018
|
-
*
|
|
3019
|
-
* console.log(`Temperature: ${temp.value}°C`) // 22°C
|
|
3020
|
-
* console.log(`Requests: ${requests.count}`) // 15
|
|
2925
|
+
* return [temp.value, requests.count] as const
|
|
3021
2926
|
* })
|
|
2927
|
+
*
|
|
2928
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [22, 15]
|
|
3022
2929
|
* ```
|
|
3023
2930
|
*
|
|
3024
2931
|
* @category mutations
|
|
@@ -3038,7 +2945,7 @@ export const modify: {
|
|
|
3038
2945
|
*
|
|
3039
2946
|
* **Example** (Modifying metric values)
|
|
3040
2947
|
*
|
|
3041
|
-
* ```ts
|
|
2948
|
+
* ```ts import.meta.vitest
|
|
3042
2949
|
* import { Effect, Metric } from "effect"
|
|
3043
2950
|
*
|
|
3044
2951
|
* const temperatureGauge = Metric.gauge("temperature")
|
|
@@ -3058,10 +2965,10 @@ export const modify: {
|
|
|
3058
2965
|
*
|
|
3059
2966
|
* const temp = yield* Metric.value(temperatureGauge)
|
|
3060
2967
|
* const requests = yield* Metric.value(requestCounter)
|
|
3061
|
-
*
|
|
3062
|
-
* console.log(`Temperature: ${temp.value}°C`) // 22°C
|
|
3063
|
-
* console.log(`Requests: ${requests.count}`) // 15
|
|
2968
|
+
* return [temp.value, requests.count] as const
|
|
3064
2969
|
* })
|
|
2970
|
+
*
|
|
2971
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [22, 15]
|
|
3065
2972
|
* ```
|
|
3066
2973
|
*
|
|
3067
2974
|
* @category mutations
|
|
@@ -3082,7 +2989,7 @@ export const modify: {
|
|
|
3082
2989
|
*
|
|
3083
2990
|
* **Example** (Modifying metric values)
|
|
3084
2991
|
*
|
|
3085
|
-
* ```ts
|
|
2992
|
+
* ```ts import.meta.vitest
|
|
3086
2993
|
* import { Effect, Metric } from "effect"
|
|
3087
2994
|
*
|
|
3088
2995
|
* const temperatureGauge = Metric.gauge("temperature")
|
|
@@ -3102,10 +3009,10 @@ export const modify: {
|
|
|
3102
3009
|
*
|
|
3103
3010
|
* const temp = yield* Metric.value(temperatureGauge)
|
|
3104
3011
|
* const requests = yield* Metric.value(requestCounter)
|
|
3105
|
-
*
|
|
3106
|
-
* console.log(`Temperature: ${temp.value}°C`) // 22°C
|
|
3107
|
-
* console.log(`Requests: ${requests.count}`) // 15
|
|
3012
|
+
* return [temp.value, requests.count] as const
|
|
3108
3013
|
* })
|
|
3014
|
+
*
|
|
3015
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [22, 15]
|
|
3109
3016
|
* ```
|
|
3110
3017
|
*
|
|
3111
3018
|
* @category mutations
|
|
@@ -3125,7 +3032,7 @@ export const modify: {
|
|
|
3125
3032
|
*
|
|
3126
3033
|
* **Example** (Modifying metric values)
|
|
3127
3034
|
*
|
|
3128
|
-
* ```ts
|
|
3035
|
+
* ```ts import.meta.vitest
|
|
3129
3036
|
* import { Effect, Metric } from "effect"
|
|
3130
3037
|
*
|
|
3131
3038
|
* const temperatureGauge = Metric.gauge("temperature")
|
|
@@ -3145,10 +3052,10 @@ export const modify: {
|
|
|
3145
3052
|
*
|
|
3146
3053
|
* const temp = yield* Metric.value(temperatureGauge)
|
|
3147
3054
|
* const requests = yield* Metric.value(requestCounter)
|
|
3148
|
-
*
|
|
3149
|
-
* console.log(`Temperature: ${temp.value}°C`) // 22°C
|
|
3150
|
-
* console.log(`Requests: ${requests.count}`) // 15
|
|
3055
|
+
* return [temp.value, requests.count] as const
|
|
3151
3056
|
* })
|
|
3057
|
+
*
|
|
3058
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [22, 15]
|
|
3152
3059
|
* ```
|
|
3153
3060
|
*
|
|
3154
3061
|
* @category mutations
|
|
@@ -3174,7 +3081,7 @@ export const modify: {
|
|
|
3174
3081
|
*
|
|
3175
3082
|
* **Example** (Updating metric values)
|
|
3176
3083
|
*
|
|
3177
|
-
* ```ts
|
|
3084
|
+
* ```ts import.meta.vitest
|
|
3178
3085
|
* import { Effect, Metric } from "effect"
|
|
3179
3086
|
*
|
|
3180
3087
|
* const cpuUsage = Metric.gauge("cpu_usage_percent")
|
|
@@ -3202,11 +3109,10 @@ export const modify: {
|
|
|
3202
3109
|
* const cpu = yield* Metric.value(cpuUsage)
|
|
3203
3110
|
* const statuses = yield* Metric.value(httpStatus)
|
|
3204
3111
|
* const times = yield* Metric.value(responseTime)
|
|
3205
|
-
*
|
|
3206
|
-
* console.log(`CPU Usage: ${cpu.value}%`)
|
|
3207
|
-
* console.log(`Status 200 count: ${statuses.occurrences.get("200")}`) // 2
|
|
3208
|
-
* console.log(`Response time samples: ${times.count}`) // 3
|
|
3112
|
+
* return [cpu.value, statuses.occurrences.get("200"), times.count] as const
|
|
3209
3113
|
* })
|
|
3114
|
+
*
|
|
3115
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [67.8, 2, 3]
|
|
3210
3116
|
* ```
|
|
3211
3117
|
*
|
|
3212
3118
|
* @category mutations
|
|
@@ -3226,7 +3132,7 @@ export const update: {
|
|
|
3226
3132
|
*
|
|
3227
3133
|
* **Example** (Updating metric values)
|
|
3228
3134
|
*
|
|
3229
|
-
* ```ts
|
|
3135
|
+
* ```ts import.meta.vitest
|
|
3230
3136
|
* import { Effect, Metric } from "effect"
|
|
3231
3137
|
*
|
|
3232
3138
|
* const cpuUsage = Metric.gauge("cpu_usage_percent")
|
|
@@ -3254,11 +3160,10 @@ export const update: {
|
|
|
3254
3160
|
* const cpu = yield* Metric.value(cpuUsage)
|
|
3255
3161
|
* const statuses = yield* Metric.value(httpStatus)
|
|
3256
3162
|
* const times = yield* Metric.value(responseTime)
|
|
3257
|
-
*
|
|
3258
|
-
* console.log(`CPU Usage: ${cpu.value}%`)
|
|
3259
|
-
* console.log(`Status 200 count: ${statuses.occurrences.get("200")}`) // 2
|
|
3260
|
-
* console.log(`Response time samples: ${times.count}`) // 3
|
|
3163
|
+
* return [cpu.value, statuses.occurrences.get("200"), times.count] as const
|
|
3261
3164
|
* })
|
|
3165
|
+
*
|
|
3166
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [67.8, 2, 3]
|
|
3262
3167
|
* ```
|
|
3263
3168
|
*
|
|
3264
3169
|
* @category mutations
|
|
@@ -3278,7 +3183,7 @@ export const update: {
|
|
|
3278
3183
|
*
|
|
3279
3184
|
* **Example** (Updating metric values)
|
|
3280
3185
|
*
|
|
3281
|
-
* ```ts
|
|
3186
|
+
* ```ts import.meta.vitest
|
|
3282
3187
|
* import { Effect, Metric } from "effect"
|
|
3283
3188
|
*
|
|
3284
3189
|
* const cpuUsage = Metric.gauge("cpu_usage_percent")
|
|
@@ -3306,11 +3211,10 @@ export const update: {
|
|
|
3306
3211
|
* const cpu = yield* Metric.value(cpuUsage)
|
|
3307
3212
|
* const statuses = yield* Metric.value(httpStatus)
|
|
3308
3213
|
* const times = yield* Metric.value(responseTime)
|
|
3309
|
-
*
|
|
3310
|
-
* console.log(`CPU Usage: ${cpu.value}%`)
|
|
3311
|
-
* console.log(`Status 200 count: ${statuses.occurrences.get("200")}`) // 2
|
|
3312
|
-
* console.log(`Response time samples: ${times.count}`) // 3
|
|
3214
|
+
* return [cpu.value, statuses.occurrences.get("200"), times.count] as const
|
|
3313
3215
|
* })
|
|
3216
|
+
*
|
|
3217
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [67.8, 2, 3]
|
|
3314
3218
|
* ```
|
|
3315
3219
|
*
|
|
3316
3220
|
* @category mutations
|
|
@@ -3331,7 +3235,7 @@ export const update: {
|
|
|
3331
3235
|
*
|
|
3332
3236
|
* **Example** (Updating metric values)
|
|
3333
3237
|
*
|
|
3334
|
-
* ```ts
|
|
3238
|
+
* ```ts import.meta.vitest
|
|
3335
3239
|
* import { Effect, Metric } from "effect"
|
|
3336
3240
|
*
|
|
3337
3241
|
* const cpuUsage = Metric.gauge("cpu_usage_percent")
|
|
@@ -3359,11 +3263,10 @@ export const update: {
|
|
|
3359
3263
|
* const cpu = yield* Metric.value(cpuUsage)
|
|
3360
3264
|
* const statuses = yield* Metric.value(httpStatus)
|
|
3361
3265
|
* const times = yield* Metric.value(responseTime)
|
|
3362
|
-
*
|
|
3363
|
-
* console.log(`CPU Usage: ${cpu.value}%`)
|
|
3364
|
-
* console.log(`Status 200 count: ${statuses.occurrences.get("200")}`) // 2
|
|
3365
|
-
* console.log(`Response time samples: ${times.count}`) // 3
|
|
3266
|
+
* return [cpu.value, statuses.occurrences.get("200"), times.count] as const
|
|
3366
3267
|
* })
|
|
3268
|
+
*
|
|
3269
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [67.8, 2, 3]
|
|
3367
3270
|
* ```
|
|
3368
3271
|
*
|
|
3369
3272
|
* @category mutations
|
|
@@ -3383,7 +3286,7 @@ export const update: {
|
|
|
3383
3286
|
*
|
|
3384
3287
|
* **Example** (Updating metric values)
|
|
3385
3288
|
*
|
|
3386
|
-
* ```ts
|
|
3289
|
+
* ```ts import.meta.vitest
|
|
3387
3290
|
* import { Effect, Metric } from "effect"
|
|
3388
3291
|
*
|
|
3389
3292
|
* const cpuUsage = Metric.gauge("cpu_usage_percent")
|
|
@@ -3411,11 +3314,10 @@ export const update: {
|
|
|
3411
3314
|
* const cpu = yield* Metric.value(cpuUsage)
|
|
3412
3315
|
* const statuses = yield* Metric.value(httpStatus)
|
|
3413
3316
|
* const times = yield* Metric.value(responseTime)
|
|
3414
|
-
*
|
|
3415
|
-
* console.log(`CPU Usage: ${cpu.value}%`)
|
|
3416
|
-
* console.log(`Status 200 count: ${statuses.occurrences.get("200")}`) // 2
|
|
3417
|
-
* console.log(`Response time samples: ${times.count}`) // 3
|
|
3317
|
+
* return [cpu.value, statuses.occurrences.get("200"), times.count] as const
|
|
3418
3318
|
* })
|
|
3319
|
+
*
|
|
3320
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => [67.8, 2, 3]
|
|
3419
3321
|
* ```
|
|
3420
3322
|
*
|
|
3421
3323
|
* @category mutations
|
|
@@ -3435,36 +3337,30 @@ export const update: {
|
|
|
3435
3337
|
*
|
|
3436
3338
|
* **Example** (Mapping metric inputs)
|
|
3437
3339
|
*
|
|
3438
|
-
* ```ts
|
|
3439
|
-
* import {
|
|
3440
|
-
*
|
|
3441
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3442
|
-
* readonly operation: string
|
|
3443
|
-
* }> {}
|
|
3340
|
+
* ```ts import.meta.vitest
|
|
3341
|
+
* import { Effect, Metric } from "effect"
|
|
3444
3342
|
*
|
|
3445
|
-
* // Create a histogram that expects Duration values
|
|
3446
3343
|
* const durationHistogram = Metric.histogram("request_duration_ms", {
|
|
3447
3344
|
* description: "Request duration in milliseconds",
|
|
3448
3345
|
* boundaries: Metric.linearBoundaries({ start: 0, width: 100, count: 10 })
|
|
3449
3346
|
* })
|
|
3450
3347
|
*
|
|
3451
|
-
* //
|
|
3452
|
-
* const
|
|
3348
|
+
* // Accept duration strings while recording numeric milliseconds
|
|
3349
|
+
* const durationStringHistogram = Metric.mapInput(
|
|
3453
3350
|
* durationHistogram,
|
|
3454
|
-
* (
|
|
3351
|
+
* (input: string) => Number(input)
|
|
3455
3352
|
* )
|
|
3456
3353
|
*
|
|
3457
3354
|
* const program = Effect.gen(function*() {
|
|
3458
|
-
*
|
|
3459
|
-
* yield* Metric.
|
|
3460
|
-
*
|
|
3461
|
-
* // Get metric value to see the recorded state
|
|
3462
|
-
* const value = yield* Metric.value(numberHistogram)
|
|
3463
|
-
* return value
|
|
3355
|
+
* yield* Metric.update(durationStringHistogram, "250")
|
|
3356
|
+
* return yield* Metric.value(durationStringHistogram)
|
|
3464
3357
|
* })
|
|
3358
|
+
*
|
|
3359
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3360
|
+
* const values = [value.count, value.sum] // => [1, 250]
|
|
3465
3361
|
* ```
|
|
3466
3362
|
*
|
|
3467
|
-
* @category
|
|
3363
|
+
* @category annotations
|
|
3468
3364
|
* @since 2.0.0
|
|
3469
3365
|
*/
|
|
3470
3366
|
export const mapInput: {
|
|
@@ -3475,36 +3371,30 @@ export const mapInput: {
|
|
|
3475
3371
|
*
|
|
3476
3372
|
* **Example** (Mapping metric inputs)
|
|
3477
3373
|
*
|
|
3478
|
-
* ```ts
|
|
3479
|
-
* import {
|
|
3480
|
-
*
|
|
3481
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3482
|
-
* readonly operation: string
|
|
3483
|
-
* }> {}
|
|
3374
|
+
* ```ts import.meta.vitest
|
|
3375
|
+
* import { Effect, Metric } from "effect"
|
|
3484
3376
|
*
|
|
3485
|
-
* // Create a histogram that expects Duration values
|
|
3486
3377
|
* const durationHistogram = Metric.histogram("request_duration_ms", {
|
|
3487
3378
|
* description: "Request duration in milliseconds",
|
|
3488
3379
|
* boundaries: Metric.linearBoundaries({ start: 0, width: 100, count: 10 })
|
|
3489
3380
|
* })
|
|
3490
3381
|
*
|
|
3491
|
-
* //
|
|
3492
|
-
* const
|
|
3382
|
+
* // Accept duration strings while recording numeric milliseconds
|
|
3383
|
+
* const durationStringHistogram = Metric.mapInput(
|
|
3493
3384
|
* durationHistogram,
|
|
3494
|
-
* (
|
|
3385
|
+
* (input: string) => Number(input)
|
|
3495
3386
|
* )
|
|
3496
3387
|
*
|
|
3497
3388
|
* const program = Effect.gen(function*() {
|
|
3498
|
-
*
|
|
3499
|
-
* yield* Metric.
|
|
3500
|
-
*
|
|
3501
|
-
* // Get metric value to see the recorded state
|
|
3502
|
-
* const value = yield* Metric.value(numberHistogram)
|
|
3503
|
-
* return value
|
|
3389
|
+
* yield* Metric.update(durationStringHistogram, "250")
|
|
3390
|
+
* return yield* Metric.value(durationStringHistogram)
|
|
3504
3391
|
* })
|
|
3392
|
+
*
|
|
3393
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3394
|
+
* const values = [value.count, value.sum] // => [1, 250]
|
|
3505
3395
|
* ```
|
|
3506
3396
|
*
|
|
3507
|
-
* @category
|
|
3397
|
+
* @category annotations
|
|
3508
3398
|
* @since 2.0.0
|
|
3509
3399
|
*/
|
|
3510
3400
|
<Input, Input2 extends Input>(f: (input: Input2, context: Context.Context<never>) => Input): <State>(self: Metric<Input, State>) => Metric<Input2, State>
|
|
@@ -3515,36 +3405,30 @@ export const mapInput: {
|
|
|
3515
3405
|
*
|
|
3516
3406
|
* **Example** (Mapping metric inputs)
|
|
3517
3407
|
*
|
|
3518
|
-
* ```ts
|
|
3519
|
-
* import {
|
|
3520
|
-
*
|
|
3521
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3522
|
-
* readonly operation: string
|
|
3523
|
-
* }> {}
|
|
3408
|
+
* ```ts import.meta.vitest
|
|
3409
|
+
* import { Effect, Metric } from "effect"
|
|
3524
3410
|
*
|
|
3525
|
-
* // Create a histogram that expects Duration values
|
|
3526
3411
|
* const durationHistogram = Metric.histogram("request_duration_ms", {
|
|
3527
3412
|
* description: "Request duration in milliseconds",
|
|
3528
3413
|
* boundaries: Metric.linearBoundaries({ start: 0, width: 100, count: 10 })
|
|
3529
3414
|
* })
|
|
3530
3415
|
*
|
|
3531
|
-
* //
|
|
3532
|
-
* const
|
|
3416
|
+
* // Accept duration strings while recording numeric milliseconds
|
|
3417
|
+
* const durationStringHistogram = Metric.mapInput(
|
|
3533
3418
|
* durationHistogram,
|
|
3534
|
-
* (
|
|
3419
|
+
* (input: string) => Number(input)
|
|
3535
3420
|
* )
|
|
3536
3421
|
*
|
|
3537
3422
|
* const program = Effect.gen(function*() {
|
|
3538
|
-
*
|
|
3539
|
-
* yield* Metric.
|
|
3540
|
-
*
|
|
3541
|
-
* // Get metric value to see the recorded state
|
|
3542
|
-
* const value = yield* Metric.value(numberHistogram)
|
|
3543
|
-
* return value
|
|
3423
|
+
* yield* Metric.update(durationStringHistogram, "250")
|
|
3424
|
+
* return yield* Metric.value(durationStringHistogram)
|
|
3544
3425
|
* })
|
|
3426
|
+
*
|
|
3427
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3428
|
+
* const values = [value.count, value.sum] // => [1, 250]
|
|
3545
3429
|
* ```
|
|
3546
3430
|
*
|
|
3547
|
-
* @category
|
|
3431
|
+
* @category annotations
|
|
3548
3432
|
* @since 2.0.0
|
|
3549
3433
|
*/
|
|
3550
3434
|
<Input, State, Input2>(
|
|
@@ -3559,36 +3443,30 @@ export const mapInput: {
|
|
|
3559
3443
|
*
|
|
3560
3444
|
* **Example** (Mapping metric inputs)
|
|
3561
3445
|
*
|
|
3562
|
-
* ```ts
|
|
3563
|
-
* import {
|
|
3564
|
-
*
|
|
3565
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3566
|
-
* readonly operation: string
|
|
3567
|
-
* }> {}
|
|
3446
|
+
* ```ts import.meta.vitest
|
|
3447
|
+
* import { Effect, Metric } from "effect"
|
|
3568
3448
|
*
|
|
3569
|
-
* // Create a histogram that expects Duration values
|
|
3570
3449
|
* const durationHistogram = Metric.histogram("request_duration_ms", {
|
|
3571
3450
|
* description: "Request duration in milliseconds",
|
|
3572
3451
|
* boundaries: Metric.linearBoundaries({ start: 0, width: 100, count: 10 })
|
|
3573
3452
|
* })
|
|
3574
3453
|
*
|
|
3575
|
-
* //
|
|
3576
|
-
* const
|
|
3454
|
+
* // Accept duration strings while recording numeric milliseconds
|
|
3455
|
+
* const durationStringHistogram = Metric.mapInput(
|
|
3577
3456
|
* durationHistogram,
|
|
3578
|
-
* (
|
|
3457
|
+
* (input: string) => Number(input)
|
|
3579
3458
|
* )
|
|
3580
3459
|
*
|
|
3581
3460
|
* const program = Effect.gen(function*() {
|
|
3582
|
-
*
|
|
3583
|
-
* yield* Metric.
|
|
3584
|
-
*
|
|
3585
|
-
* // Get metric value to see the recorded state
|
|
3586
|
-
* const value = yield* Metric.value(numberHistogram)
|
|
3587
|
-
* return value
|
|
3461
|
+
* yield* Metric.update(durationStringHistogram, "250")
|
|
3462
|
+
* return yield* Metric.value(durationStringHistogram)
|
|
3588
3463
|
* })
|
|
3464
|
+
*
|
|
3465
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3466
|
+
* const values = [value.count, value.sum] // => [1, 250]
|
|
3589
3467
|
* ```
|
|
3590
3468
|
*
|
|
3591
|
-
* @category
|
|
3469
|
+
* @category annotations
|
|
3592
3470
|
* @since 2.0.0
|
|
3593
3471
|
*/
|
|
3594
3472
|
<Input, Input2 extends Input>(f: (input: Input2, context: Context.Context<never>) => Input) => <State>(self: Metric<Input, State>) => Metric<Input2, State>,
|
|
@@ -3599,36 +3477,30 @@ export const mapInput: {
|
|
|
3599
3477
|
*
|
|
3600
3478
|
* **Example** (Mapping metric inputs)
|
|
3601
3479
|
*
|
|
3602
|
-
* ```ts
|
|
3603
|
-
* import {
|
|
3604
|
-
*
|
|
3605
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3606
|
-
* readonly operation: string
|
|
3607
|
-
* }> {}
|
|
3480
|
+
* ```ts import.meta.vitest
|
|
3481
|
+
* import { Effect, Metric } from "effect"
|
|
3608
3482
|
*
|
|
3609
|
-
* // Create a histogram that expects Duration values
|
|
3610
3483
|
* const durationHistogram = Metric.histogram("request_duration_ms", {
|
|
3611
3484
|
* description: "Request duration in milliseconds",
|
|
3612
3485
|
* boundaries: Metric.linearBoundaries({ start: 0, width: 100, count: 10 })
|
|
3613
3486
|
* })
|
|
3614
3487
|
*
|
|
3615
|
-
* //
|
|
3616
|
-
* const
|
|
3488
|
+
* // Accept duration strings while recording numeric milliseconds
|
|
3489
|
+
* const durationStringHistogram = Metric.mapInput(
|
|
3617
3490
|
* durationHistogram,
|
|
3618
|
-
* (
|
|
3491
|
+
* (input: string) => Number(input)
|
|
3619
3492
|
* )
|
|
3620
3493
|
*
|
|
3621
3494
|
* const program = Effect.gen(function*() {
|
|
3622
|
-
*
|
|
3623
|
-
* yield* Metric.
|
|
3624
|
-
*
|
|
3625
|
-
* // Get metric value to see the recorded state
|
|
3626
|
-
* const value = yield* Metric.value(numberHistogram)
|
|
3627
|
-
* return value
|
|
3495
|
+
* yield* Metric.update(durationStringHistogram, "250")
|
|
3496
|
+
* return yield* Metric.value(durationStringHistogram)
|
|
3628
3497
|
* })
|
|
3498
|
+
*
|
|
3499
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3500
|
+
* const values = [value.count, value.sum] // => [1, 250]
|
|
3629
3501
|
* ```
|
|
3630
3502
|
*
|
|
3631
|
-
* @category
|
|
3503
|
+
* @category annotations
|
|
3632
3504
|
* @since 2.0.0
|
|
3633
3505
|
*/
|
|
3634
3506
|
<Input, State, Input2>(
|
|
@@ -3653,12 +3525,8 @@ export const mapInput: {
|
|
|
3653
3525
|
*
|
|
3654
3526
|
* **Example** (Ignoring inputs with a constant value)
|
|
3655
3527
|
*
|
|
3656
|
-
* ```ts
|
|
3657
|
-
* import {
|
|
3658
|
-
*
|
|
3659
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3660
|
-
* readonly operation: string
|
|
3661
|
-
* }> {}
|
|
3528
|
+
* ```ts import.meta.vitest
|
|
3529
|
+
* import { Effect, Metric } from "effect"
|
|
3662
3530
|
*
|
|
3663
3531
|
* // Create a counter that normally expects a number increment
|
|
3664
3532
|
* const requestCounter = Metric.counter("total_requests", {
|
|
@@ -3677,9 +3545,12 @@ export const mapInput: {
|
|
|
3677
3545
|
* const value = yield* Metric.value(simpleRequestCounter)
|
|
3678
3546
|
* return value // Counter state will show count: 3
|
|
3679
3547
|
* })
|
|
3548
|
+
*
|
|
3549
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3550
|
+
* const count = value.count // => 3
|
|
3680
3551
|
* ```
|
|
3681
3552
|
*
|
|
3682
|
-
* @category
|
|
3553
|
+
* @category mapping
|
|
3683
3554
|
* @since 2.0.0
|
|
3684
3555
|
*/
|
|
3685
3556
|
export const withConstantInput: {
|
|
@@ -3690,12 +3561,8 @@ export const withConstantInput: {
|
|
|
3690
3561
|
*
|
|
3691
3562
|
* **Example** (Ignoring inputs with a constant value)
|
|
3692
3563
|
*
|
|
3693
|
-
* ```ts
|
|
3694
|
-
* import {
|
|
3695
|
-
*
|
|
3696
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3697
|
-
* readonly operation: string
|
|
3698
|
-
* }> {}
|
|
3564
|
+
* ```ts import.meta.vitest
|
|
3565
|
+
* import { Effect, Metric } from "effect"
|
|
3699
3566
|
*
|
|
3700
3567
|
* // Create a counter that normally expects a number increment
|
|
3701
3568
|
* const requestCounter = Metric.counter("total_requests", {
|
|
@@ -3714,9 +3581,12 @@ export const withConstantInput: {
|
|
|
3714
3581
|
* const value = yield* Metric.value(simpleRequestCounter)
|
|
3715
3582
|
* return value // Counter state will show count: 3
|
|
3716
3583
|
* })
|
|
3584
|
+
*
|
|
3585
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3586
|
+
* const count = value.count // => 3
|
|
3717
3587
|
* ```
|
|
3718
3588
|
*
|
|
3719
|
-
* @category
|
|
3589
|
+
* @category mapping
|
|
3720
3590
|
* @since 2.0.0
|
|
3721
3591
|
*/
|
|
3722
3592
|
<Input>(input: Input): <State>(self: Metric<Input, State>) => Metric<unknown, State>
|
|
@@ -3727,12 +3597,8 @@ export const withConstantInput: {
|
|
|
3727
3597
|
*
|
|
3728
3598
|
* **Example** (Ignoring inputs with a constant value)
|
|
3729
3599
|
*
|
|
3730
|
-
* ```ts
|
|
3731
|
-
* import {
|
|
3732
|
-
*
|
|
3733
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3734
|
-
* readonly operation: string
|
|
3735
|
-
* }> {}
|
|
3600
|
+
* ```ts import.meta.vitest
|
|
3601
|
+
* import { Effect, Metric } from "effect"
|
|
3736
3602
|
*
|
|
3737
3603
|
* // Create a counter that normally expects a number increment
|
|
3738
3604
|
* const requestCounter = Metric.counter("total_requests", {
|
|
@@ -3751,9 +3617,12 @@ export const withConstantInput: {
|
|
|
3751
3617
|
* const value = yield* Metric.value(simpleRequestCounter)
|
|
3752
3618
|
* return value // Counter state will show count: 3
|
|
3753
3619
|
* })
|
|
3620
|
+
*
|
|
3621
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3622
|
+
* const count = value.count // => 3
|
|
3754
3623
|
* ```
|
|
3755
3624
|
*
|
|
3756
|
-
* @category
|
|
3625
|
+
* @category mapping
|
|
3757
3626
|
* @since 2.0.0
|
|
3758
3627
|
*/
|
|
3759
3628
|
<Input, State>(self: Metric<Input, State>, input: Input): Metric<unknown, State>
|
|
@@ -3765,12 +3634,8 @@ export const withConstantInput: {
|
|
|
3765
3634
|
*
|
|
3766
3635
|
* **Example** (Ignoring inputs with a constant value)
|
|
3767
3636
|
*
|
|
3768
|
-
* ```ts
|
|
3769
|
-
* import {
|
|
3770
|
-
*
|
|
3771
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3772
|
-
* readonly operation: string
|
|
3773
|
-
* }> {}
|
|
3637
|
+
* ```ts import.meta.vitest
|
|
3638
|
+
* import { Effect, Metric } from "effect"
|
|
3774
3639
|
*
|
|
3775
3640
|
* // Create a counter that normally expects a number increment
|
|
3776
3641
|
* const requestCounter = Metric.counter("total_requests", {
|
|
@@ -3789,9 +3654,12 @@ export const withConstantInput: {
|
|
|
3789
3654
|
* const value = yield* Metric.value(simpleRequestCounter)
|
|
3790
3655
|
* return value // Counter state will show count: 3
|
|
3791
3656
|
* })
|
|
3657
|
+
*
|
|
3658
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3659
|
+
* const count = value.count // => 3
|
|
3792
3660
|
* ```
|
|
3793
3661
|
*
|
|
3794
|
-
* @category
|
|
3662
|
+
* @category mapping
|
|
3795
3663
|
* @since 2.0.0
|
|
3796
3664
|
*/
|
|
3797
3665
|
<Input>(input: Input) => <State>(self: Metric<Input, State>) => Metric<unknown, State>,
|
|
@@ -3802,12 +3670,8 @@ export const withConstantInput: {
|
|
|
3802
3670
|
*
|
|
3803
3671
|
* **Example** (Ignoring inputs with a constant value)
|
|
3804
3672
|
*
|
|
3805
|
-
* ```ts
|
|
3806
|
-
* import {
|
|
3807
|
-
*
|
|
3808
|
-
* class MetricError extends Data.TaggedError("MetricError")<{
|
|
3809
|
-
* readonly operation: string
|
|
3810
|
-
* }> {}
|
|
3673
|
+
* ```ts import.meta.vitest
|
|
3674
|
+
* import { Effect, Metric } from "effect"
|
|
3811
3675
|
*
|
|
3812
3676
|
* // Create a counter that normally expects a number increment
|
|
3813
3677
|
* const requestCounter = Metric.counter("total_requests", {
|
|
@@ -3826,9 +3690,12 @@ export const withConstantInput: {
|
|
|
3826
3690
|
* const value = yield* Metric.value(simpleRequestCounter)
|
|
3827
3691
|
* return value // Counter state will show count: 3
|
|
3828
3692
|
* })
|
|
3693
|
+
*
|
|
3694
|
+
* const value = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
3695
|
+
* const count = value.count // => 3
|
|
3829
3696
|
* ```
|
|
3830
3697
|
*
|
|
3831
|
-
* @category
|
|
3698
|
+
* @category mapping
|
|
3832
3699
|
* @since 2.0.0
|
|
3833
3700
|
*/
|
|
3834
3701
|
<Input, State>(self: Metric<Input, State>, input: Input) => Metric<unknown, State>
|
|
@@ -3845,7 +3712,7 @@ export const withConstantInput: {
|
|
|
3845
3712
|
*
|
|
3846
3713
|
* **Example** (Applying metric attributes)
|
|
3847
3714
|
*
|
|
3848
|
-
* ```ts
|
|
3715
|
+
* ```ts import.meta.vitest
|
|
3849
3716
|
* import { Effect, Metric } from "effect"
|
|
3850
3717
|
*
|
|
3851
3718
|
* const requestCounter = Metric.counter("http_requests_total", {
|
|
@@ -3878,18 +3745,17 @@ export const withConstantInput: {
|
|
|
3878
3745
|
* yield* Metric.update(taggedMetric, 1) // http_requests_total{service="user-api", version="v1"}
|
|
3879
3746
|
* })
|
|
3880
3747
|
*
|
|
3881
|
-
*
|
|
3882
|
-
*
|
|
3883
|
-
* const
|
|
3884
|
-
*
|
|
3885
|
-
*
|
|
3886
|
-
* console.log(`${metric.id}`, metric.attributes, metric.state)
|
|
3887
|
-
* }
|
|
3888
|
-
* }
|
|
3748
|
+
* const result = Effect.gen(function*() {
|
|
3749
|
+
* yield* program
|
|
3750
|
+
* const get = yield* Metric.value(getRequests)
|
|
3751
|
+
* const post = yield* Metric.value(postRequests)
|
|
3752
|
+
* return [get.count, post.count] as const
|
|
3889
3753
|
* })
|
|
3754
|
+
*
|
|
3755
|
+
* await Effect.runPromise(Effect.provideService(result, Metric.MetricRegistry, new Map())) // => [2, 1]
|
|
3890
3756
|
* ```
|
|
3891
3757
|
*
|
|
3892
|
-
* @category
|
|
3758
|
+
* @category mapping
|
|
3893
3759
|
* @since 4.0.0
|
|
3894
3760
|
*/
|
|
3895
3761
|
export const withAttributes: {
|
|
@@ -3904,7 +3770,7 @@ export const withAttributes: {
|
|
|
3904
3770
|
*
|
|
3905
3771
|
* **Example** (Applying metric attributes)
|
|
3906
3772
|
*
|
|
3907
|
-
* ```ts
|
|
3773
|
+
* ```ts import.meta.vitest
|
|
3908
3774
|
* import { Effect, Metric } from "effect"
|
|
3909
3775
|
*
|
|
3910
3776
|
* const requestCounter = Metric.counter("http_requests_total", {
|
|
@@ -3937,18 +3803,17 @@ export const withAttributes: {
|
|
|
3937
3803
|
* yield* Metric.update(taggedMetric, 1) // http_requests_total{service="user-api", version="v1"}
|
|
3938
3804
|
* })
|
|
3939
3805
|
*
|
|
3940
|
-
*
|
|
3941
|
-
*
|
|
3942
|
-
* const
|
|
3943
|
-
*
|
|
3944
|
-
*
|
|
3945
|
-
* console.log(`${metric.id}`, metric.attributes, metric.state)
|
|
3946
|
-
* }
|
|
3947
|
-
* }
|
|
3806
|
+
* const result = Effect.gen(function*() {
|
|
3807
|
+
* yield* program
|
|
3808
|
+
* const get = yield* Metric.value(getRequests)
|
|
3809
|
+
* const post = yield* Metric.value(postRequests)
|
|
3810
|
+
* return [get.count, post.count] as const
|
|
3948
3811
|
* })
|
|
3812
|
+
*
|
|
3813
|
+
* await Effect.runPromise(Effect.provideService(result, Metric.MetricRegistry, new Map())) // => [2, 1]
|
|
3949
3814
|
* ```
|
|
3950
3815
|
*
|
|
3951
|
-
* @category
|
|
3816
|
+
* @category mapping
|
|
3952
3817
|
* @since 4.0.0
|
|
3953
3818
|
*/
|
|
3954
3819
|
(attributes: Metric.Attributes): <Input, State>(self: Metric<Input, State>) => Metric<Input, State>
|
|
@@ -3963,7 +3828,7 @@ export const withAttributes: {
|
|
|
3963
3828
|
*
|
|
3964
3829
|
* **Example** (Applying metric attributes)
|
|
3965
3830
|
*
|
|
3966
|
-
* ```ts
|
|
3831
|
+
* ```ts import.meta.vitest
|
|
3967
3832
|
* import { Effect, Metric } from "effect"
|
|
3968
3833
|
*
|
|
3969
3834
|
* const requestCounter = Metric.counter("http_requests_total", {
|
|
@@ -3996,18 +3861,17 @@ export const withAttributes: {
|
|
|
3996
3861
|
* yield* Metric.update(taggedMetric, 1) // http_requests_total{service="user-api", version="v1"}
|
|
3997
3862
|
* })
|
|
3998
3863
|
*
|
|
3999
|
-
*
|
|
4000
|
-
*
|
|
4001
|
-
* const
|
|
4002
|
-
*
|
|
4003
|
-
*
|
|
4004
|
-
* console.log(`${metric.id}`, metric.attributes, metric.state)
|
|
4005
|
-
* }
|
|
4006
|
-
* }
|
|
3864
|
+
* const result = Effect.gen(function*() {
|
|
3865
|
+
* yield* program
|
|
3866
|
+
* const get = yield* Metric.value(getRequests)
|
|
3867
|
+
* const post = yield* Metric.value(postRequests)
|
|
3868
|
+
* return [get.count, post.count] as const
|
|
4007
3869
|
* })
|
|
3870
|
+
*
|
|
3871
|
+
* await Effect.runPromise(Effect.provideService(result, Metric.MetricRegistry, new Map())) // => [2, 1]
|
|
4008
3872
|
* ```
|
|
4009
3873
|
*
|
|
4010
|
-
* @category
|
|
3874
|
+
* @category mapping
|
|
4011
3875
|
* @since 4.0.0
|
|
4012
3876
|
*/
|
|
4013
3877
|
<Input, State>(self: Metric<Input, State>, attributes: Metric.Attributes): Metric<Input, State>
|
|
@@ -4023,7 +3887,7 @@ export const withAttributes: {
|
|
|
4023
3887
|
*
|
|
4024
3888
|
* **Example** (Applying metric attributes)
|
|
4025
3889
|
*
|
|
4026
|
-
* ```ts
|
|
3890
|
+
* ```ts import.meta.vitest
|
|
4027
3891
|
* import { Effect, Metric } from "effect"
|
|
4028
3892
|
*
|
|
4029
3893
|
* const requestCounter = Metric.counter("http_requests_total", {
|
|
@@ -4056,18 +3920,17 @@ export const withAttributes: {
|
|
|
4056
3920
|
* yield* Metric.update(taggedMetric, 1) // http_requests_total{service="user-api", version="v1"}
|
|
4057
3921
|
* })
|
|
4058
3922
|
*
|
|
4059
|
-
*
|
|
4060
|
-
*
|
|
4061
|
-
* const
|
|
4062
|
-
*
|
|
4063
|
-
*
|
|
4064
|
-
* console.log(`${metric.id}`, metric.attributes, metric.state)
|
|
4065
|
-
* }
|
|
4066
|
-
* }
|
|
3923
|
+
* const result = Effect.gen(function*() {
|
|
3924
|
+
* yield* program
|
|
3925
|
+
* const get = yield* Metric.value(getRequests)
|
|
3926
|
+
* const post = yield* Metric.value(postRequests)
|
|
3927
|
+
* return [get.count, post.count] as const
|
|
4067
3928
|
* })
|
|
3929
|
+
*
|
|
3930
|
+
* await Effect.runPromise(Effect.provideService(result, Metric.MetricRegistry, new Map())) // => [2, 1]
|
|
4068
3931
|
* ```
|
|
4069
3932
|
*
|
|
4070
|
-
* @category
|
|
3933
|
+
* @category mapping
|
|
4071
3934
|
* @since 4.0.0
|
|
4072
3935
|
*/
|
|
4073
3936
|
(attributes: Metric.Attributes) => <Input, State>(self: Metric<Input, State>) => Metric<Input, State>,
|
|
@@ -4082,7 +3945,7 @@ export const withAttributes: {
|
|
|
4082
3945
|
*
|
|
4083
3946
|
* **Example** (Applying metric attributes)
|
|
4084
3947
|
*
|
|
4085
|
-
* ```ts
|
|
3948
|
+
* ```ts import.meta.vitest
|
|
4086
3949
|
* import { Effect, Metric } from "effect"
|
|
4087
3950
|
*
|
|
4088
3951
|
* const requestCounter = Metric.counter("http_requests_total", {
|
|
@@ -4115,18 +3978,17 @@ export const withAttributes: {
|
|
|
4115
3978
|
* yield* Metric.update(taggedMetric, 1) // http_requests_total{service="user-api", version="v1"}
|
|
4116
3979
|
* })
|
|
4117
3980
|
*
|
|
4118
|
-
*
|
|
4119
|
-
*
|
|
4120
|
-
* const
|
|
4121
|
-
*
|
|
4122
|
-
*
|
|
4123
|
-
* console.log(`${metric.id}`, metric.attributes, metric.state)
|
|
4124
|
-
* }
|
|
4125
|
-
* }
|
|
3981
|
+
* const result = Effect.gen(function*() {
|
|
3982
|
+
* yield* program
|
|
3983
|
+
* const get = yield* Metric.value(getRequests)
|
|
3984
|
+
* const post = yield* Metric.value(postRequests)
|
|
3985
|
+
* return [get.count, post.count] as const
|
|
4126
3986
|
* })
|
|
3987
|
+
*
|
|
3988
|
+
* await Effect.runPromise(Effect.provideService(result, Metric.MetricRegistry, new Map())) // => [2, 1]
|
|
4127
3989
|
* ```
|
|
4128
3990
|
*
|
|
4129
|
-
* @category
|
|
3991
|
+
* @category mapping
|
|
4130
3992
|
* @since 4.0.0
|
|
4131
3993
|
*/
|
|
4132
3994
|
<Input, State>(self: Metric<Input, State>, attributes: Metric.Attributes) => Metric<Input, State>
|
|
@@ -4153,12 +4015,8 @@ export const withAttributes: {
|
|
|
4153
4015
|
*
|
|
4154
4016
|
* **Example** (Capturing metric snapshots)
|
|
4155
4017
|
*
|
|
4156
|
-
* ```ts
|
|
4157
|
-
* import {
|
|
4158
|
-
*
|
|
4159
|
-
* class SnapshotError extends Data.TaggedError("SnapshotError")<{
|
|
4160
|
-
* readonly operation: string
|
|
4161
|
-
* }> {}
|
|
4018
|
+
* ```ts import.meta.vitest
|
|
4019
|
+
* import { Effect, Metric } from "effect"
|
|
4162
4020
|
*
|
|
4163
4021
|
* const program = Effect.gen(function*() {
|
|
4164
4022
|
* // Create and update some metrics
|
|
@@ -4179,19 +4037,16 @@ export const withAttributes: {
|
|
|
4179
4037
|
* // Take a snapshot of all metrics
|
|
4180
4038
|
* const snapshots = yield* Metric.snapshot
|
|
4181
4039
|
*
|
|
4182
|
-
* // Examine the snapshots
|
|
4183
|
-
* for (const snapshot of snapshots) {
|
|
4184
|
-
* yield* Console.log(`Metric: ${snapshot.id}`)
|
|
4185
|
-
* yield* Console.log(`Description: ${snapshot.description}`)
|
|
4186
|
-
* yield* Console.log(`Type: ${snapshot.type}`)
|
|
4187
|
-
* yield* Console.log(`State:`, snapshot.state)
|
|
4188
|
-
* }
|
|
4189
|
-
*
|
|
4190
4040
|
* return snapshots
|
|
4191
4041
|
* })
|
|
4042
|
+
*
|
|
4043
|
+
* const snapshots = await Effect.runPromise(
|
|
4044
|
+
* Effect.provideService(program, Metric.MetricRegistry, new Map())
|
|
4045
|
+
* )
|
|
4046
|
+
* const ids = snapshots.map((snapshot) => snapshot.id).sort() // => ["http_requests", "response_time_ms"]
|
|
4192
4047
|
* ```
|
|
4193
4048
|
*
|
|
4194
|
-
* @category
|
|
4049
|
+
* @category snapshotting
|
|
4195
4050
|
* @since 2.0.0
|
|
4196
4051
|
*/
|
|
4197
4052
|
export const snapshot: Effect<ReadonlyArray<Metric.Snapshot>> = InternalEffect.map(
|
|
@@ -4211,12 +4066,8 @@ export const snapshot: Effect<ReadonlyArray<Metric.Snapshot>> = InternalEffect.m
|
|
|
4211
4066
|
*
|
|
4212
4067
|
* **Example** (Dumping metrics as text)
|
|
4213
4068
|
*
|
|
4214
|
-
* ```ts
|
|
4215
|
-
* import {
|
|
4216
|
-
*
|
|
4217
|
-
* class DumpError extends Data.TaggedError("DumpError")<{
|
|
4218
|
-
* readonly operation: string
|
|
4219
|
-
* }> {}
|
|
4069
|
+
* ```ts import.meta.vitest
|
|
4070
|
+
* import { Effect, Metric } from "effect"
|
|
4220
4071
|
*
|
|
4221
4072
|
* const program = Effect.gen(function*() {
|
|
4222
4073
|
* // Create and update some metrics for demonstration
|
|
@@ -4240,20 +4091,21 @@ export const snapshot: Effect<ReadonlyArray<Metric.Snapshot>> = InternalEffect.m
|
|
|
4240
4091
|
*
|
|
4241
4092
|
* // Get formatted dump of all metrics
|
|
4242
4093
|
* const metricsReport = yield* Metric.dump
|
|
4243
|
-
* yield* Console.log("Current Metrics:")
|
|
4244
|
-
* yield* Console.log(metricsReport)
|
|
4245
|
-
*
|
|
4246
|
-
* // Output will look like a formatted table:
|
|
4247
|
-
* // Name Description Type State
|
|
4248
|
-
* // http_requests_total Total HTTP requests Counter [count: 2]
|
|
4249
|
-
* // response_time_ms Current response time in milliseconds Gauge [value: 125]
|
|
4250
|
-
* // http_status_codes Frequency of HTTP status codes Frequency [occurrences: 200 -> 2, 404 -> 1]
|
|
4251
|
-
*
|
|
4252
4094
|
* return metricsReport
|
|
4253
4095
|
* })
|
|
4096
|
+
*
|
|
4097
|
+
* const report = await Effect.runPromise(
|
|
4098
|
+
* Effect.provideService(program, Metric.MetricRegistry, new Map())
|
|
4099
|
+
* )
|
|
4100
|
+
* const included = [
|
|
4101
|
+
* report.includes("http_requests_total"),
|
|
4102
|
+
* report.includes("response_time_ms"),
|
|
4103
|
+
* report.includes("http_status_codes")
|
|
4104
|
+
* ]
|
|
4105
|
+
* included // => [true, true, true]
|
|
4254
4106
|
* ```
|
|
4255
4107
|
*
|
|
4256
|
-
* @category
|
|
4108
|
+
* @category formatting
|
|
4257
4109
|
* @since 4.0.0
|
|
4258
4110
|
*/
|
|
4259
4111
|
export const dump: Effect<string> = InternalEffect.flatMap(InternalEffect.context(), (context) => {
|
|
@@ -4308,56 +4160,20 @@ export const dump: Effect<string> = InternalEffect.flatMap(InternalEffect.contex
|
|
|
4308
4160
|
*
|
|
4309
4161
|
* **Example** (Capturing snapshots from a context)
|
|
4310
4162
|
*
|
|
4311
|
-
* ```ts
|
|
4312
|
-
* import {
|
|
4313
|
-
*
|
|
4314
|
-
* class UnsafeSnapshotError extends Data.TaggedError("UnsafeSnapshotError")<{
|
|
4315
|
-
* readonly operation: string
|
|
4316
|
-
* }> {}
|
|
4317
|
-
*
|
|
4318
|
-
* // Use unsafeSnapshot in performance-critical scenarios or internal implementations
|
|
4319
|
-
* const performanceMetricsExporter = Effect.gen(function*() {
|
|
4320
|
-
* // Create some metrics first
|
|
4321
|
-
* const requestCounter = Metric.counter("http_requests", {
|
|
4322
|
-
* description: "Total HTTP requests"
|
|
4323
|
-
* })
|
|
4324
|
-
* const responseTime = Metric.gauge("response_time_ms", {
|
|
4325
|
-
* description: "Current response time"
|
|
4326
|
-
* })
|
|
4163
|
+
* ```ts import.meta.vitest
|
|
4164
|
+
* import { Effect, Metric } from "effect"
|
|
4327
4165
|
*
|
|
4328
|
-
*
|
|
4166
|
+
* const requestCounter = Metric.counter("http_requests")
|
|
4167
|
+
* const program = Effect.gen(function*() {
|
|
4329
4168
|
* yield* Metric.update(requestCounter, 1)
|
|
4330
|
-
* yield*
|
|
4331
|
-
*
|
|
4332
|
-
* // Get services context for unsafe operations
|
|
4333
|
-
* const services = yield* Effect.context()
|
|
4334
|
-
*
|
|
4335
|
-
* // Use snapshotUnsafe for direct, synchronous access
|
|
4336
|
-
* const snapshots = Metric.snapshotUnsafe(services)
|
|
4337
|
-
* const exportBatchCreatedAt = 1_700_000_000_000
|
|
4338
|
-
*
|
|
4339
|
-
* // Process snapshots immediately (useful for exporters, debugging tools)
|
|
4340
|
-
* const exportData = snapshots.map((snapshot) => ({
|
|
4341
|
-
* name: snapshot.id,
|
|
4342
|
-
* type: snapshot.type,
|
|
4343
|
-
* value: snapshot.state,
|
|
4344
|
-
* timestamp: exportBatchCreatedAt
|
|
4345
|
-
* }))
|
|
4346
|
-
*
|
|
4347
|
-
* // This is synchronous and doesn't involve Effect overhead
|
|
4348
|
-
* // Useful for performance-critical metric export operations
|
|
4349
|
-
* return exportData
|
|
4169
|
+
* const context = yield* Effect.context()
|
|
4170
|
+
* return Metric.snapshotUnsafe(context).map((snapshot) => snapshot.id)
|
|
4350
4171
|
* })
|
|
4351
4172
|
*
|
|
4352
|
-
*
|
|
4353
|
-
* const safeSnapshotExample = Effect.gen(function*() {
|
|
4354
|
-
* // This automatically handles the services context
|
|
4355
|
-
* const snapshots = yield* Metric.snapshot
|
|
4356
|
-
* return snapshots
|
|
4357
|
-
* })
|
|
4173
|
+
* await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map())) // => ["http_requests"]
|
|
4358
4174
|
* ```
|
|
4359
4175
|
*
|
|
4360
|
-
* @category
|
|
4176
|
+
* @category snapshotting
|
|
4361
4177
|
* @since 4.0.0
|
|
4362
4178
|
*/
|
|
4363
4179
|
export const snapshotUnsafe = (context: Context.Context<never>): ReadonlyArray<Metric.Snapshot> => {
|
|
@@ -4440,60 +4256,13 @@ const attributesToString = (attributes: Metric.AttributeSet): string => {
|
|
|
4440
4256
|
*
|
|
4441
4257
|
* **Example** (Creating boundaries from values)
|
|
4442
4258
|
*
|
|
4443
|
-
* ```ts
|
|
4444
|
-
* import {
|
|
4445
|
-
*
|
|
4446
|
-
* class BoundaryError extends Data.TaggedError("BoundaryError")<{
|
|
4447
|
-
* readonly operation: string
|
|
4448
|
-
* }> {}
|
|
4449
|
-
*
|
|
4450
|
-
* // Create boundaries from an array of custom values
|
|
4451
|
-
* const customBoundaries = Metric.boundariesFromIterable([
|
|
4452
|
-
* 10,
|
|
4453
|
-
* 25,
|
|
4454
|
-
* 50,
|
|
4455
|
-
* 100,
|
|
4456
|
-
* 250,
|
|
4457
|
-
* 500,
|
|
4458
|
-
* 1000
|
|
4459
|
-
* ])
|
|
4460
|
-
* console.log(customBoundaries) // [10, 25, 50, 100, 250, 500, 1000, Infinity]
|
|
4461
|
-
*
|
|
4462
|
-
* // Automatically removes duplicates and negative values
|
|
4463
|
-
* const messyBoundaries = Metric.boundariesFromIterable([
|
|
4464
|
-
* -5,
|
|
4465
|
-
* 0,
|
|
4466
|
-
* 10,
|
|
4467
|
-
* 10,
|
|
4468
|
-
* 25,
|
|
4469
|
-
* 25,
|
|
4470
|
-
* 50,
|
|
4471
|
-
* -1
|
|
4472
|
-
* ])
|
|
4473
|
-
* console.log(messyBoundaries) // [10, 25, 50, Infinity]
|
|
4474
|
-
*
|
|
4475
|
-
* // Works with any iterable (Set, generator functions, etc.)
|
|
4476
|
-
* const setBoundaries = Metric.boundariesFromIterable(
|
|
4477
|
-
* new Set([100, 200, 300, 200, 100])
|
|
4478
|
-
* )
|
|
4479
|
-
* console.log(setBoundaries) // [100, 200, 300, Infinity]
|
|
4480
|
-
*
|
|
4481
|
-
* // Use with histogram metric
|
|
4482
|
-
* const responseTimeHistogram = Metric.histogram("response_times", {
|
|
4483
|
-
* description: "API response time distribution",
|
|
4484
|
-
* boundaries: customBoundaries
|
|
4485
|
-
* })
|
|
4486
|
-
*
|
|
4487
|
-
* const program = Effect.gen(function*() {
|
|
4488
|
-
* yield* Metric.update(responseTimeHistogram, 75) // Goes in 50-100ms bucket
|
|
4489
|
-
* yield* Metric.update(responseTimeHistogram, 150) // Goes in 100-250ms bucket
|
|
4259
|
+
* ```ts import.meta.vitest
|
|
4260
|
+
* import { Metric } from "effect"
|
|
4490
4261
|
*
|
|
4491
|
-
*
|
|
4492
|
-
* return value
|
|
4493
|
-
* })
|
|
4262
|
+
* Metric.boundariesFromIterable([-5, 0, 10, 10, 25, 50]) // => [10, 25, 50, Infinity]
|
|
4494
4263
|
* ```
|
|
4495
4264
|
*
|
|
4496
|
-
* @category
|
|
4265
|
+
* @category constructors
|
|
4497
4266
|
* @since 4.0.0
|
|
4498
4267
|
*/
|
|
4499
4268
|
export const boundariesFromIterable = (iterable: Iterable<number>): ReadonlyArray<number> =>
|
|
@@ -4505,46 +4274,20 @@ export const boundariesFromIterable = (iterable: Iterable<number>): ReadonlyArra
|
|
|
4505
4274
|
*
|
|
4506
4275
|
* **Details**
|
|
4507
4276
|
*
|
|
4508
|
-
* Generates `count - 1`
|
|
4277
|
+
* Generates `count - 1` candidate boundaries using `start + index * width` for
|
|
4509
4278
|
* each zero-based index, then applies the same normalization as
|
|
4510
4279
|
* `boundariesFromIterable`: non-positive values are removed, duplicates are
|
|
4511
4280
|
* collapsed, and `Infinity` is appended.
|
|
4512
4281
|
*
|
|
4513
4282
|
* **Example** (Creating linear boundaries)
|
|
4514
4283
|
*
|
|
4515
|
-
* ```ts
|
|
4516
|
-
* import {
|
|
4517
|
-
*
|
|
4518
|
-
* class BoundaryError extends Data.TaggedError("BoundaryError")<{
|
|
4519
|
-
* readonly operation: string
|
|
4520
|
-
* }> {}
|
|
4521
|
-
*
|
|
4522
|
-
* // Create boundaries for response time histogram
|
|
4523
|
-
* const responseBoundaries = Metric.linearBoundaries({
|
|
4524
|
-
* start: 0, // Starting point
|
|
4525
|
-
* width: 100, // Offset used for the first boundary
|
|
4526
|
-
* count: 5 // Creates 4 boundaries + infinity
|
|
4527
|
-
* })
|
|
4528
|
-
* console.log(responseBoundaries) // [100, 101, 102, 103, Infinity]
|
|
4529
|
-
*
|
|
4530
|
-
* // Create a histogram using these boundaries
|
|
4531
|
-
* const responseTimeHistogram = Metric.histogram("api_response_time", {
|
|
4532
|
-
* description: "API response time distribution",
|
|
4533
|
-
* boundaries: responseBoundaries
|
|
4534
|
-
* })
|
|
4535
|
-
*
|
|
4536
|
-
* const program = Effect.gen(function*() {
|
|
4537
|
-
* // Record some response times
|
|
4538
|
-
* yield* Metric.update(responseTimeHistogram, 85)
|
|
4539
|
-
* yield* Metric.update(responseTimeHistogram, 101)
|
|
4540
|
-
* yield* Metric.update(responseTimeHistogram, 450)
|
|
4284
|
+
* ```ts import.meta.vitest
|
|
4285
|
+
* import { Metric } from "effect"
|
|
4541
4286
|
*
|
|
4542
|
-
*
|
|
4543
|
-
* return value
|
|
4544
|
-
* })
|
|
4287
|
+
* Metric.linearBoundaries({ start: 10, width: 20, count: 5 }) // => [10, 30, 50, 70, Infinity]
|
|
4545
4288
|
* ```
|
|
4546
4289
|
*
|
|
4547
|
-
* @category
|
|
4290
|
+
* @category constructors
|
|
4548
4291
|
* @since 4.0.0
|
|
4549
4292
|
*/
|
|
4550
4293
|
export const linearBoundaries = (options: {
|
|
@@ -4552,7 +4295,7 @@ export const linearBoundaries = (options: {
|
|
|
4552
4295
|
readonly width: number
|
|
4553
4296
|
readonly count: number
|
|
4554
4297
|
}): ReadonlyArray<number> =>
|
|
4555
|
-
boundariesFromIterable(Arr.makeBy(options.count - 1, (n) => options.start + n
|
|
4298
|
+
boundariesFromIterable(Arr.makeBy(options.count - 1, (n) => options.start + n * options.width))
|
|
4556
4299
|
|
|
4557
4300
|
/**
|
|
4558
4301
|
* Creates histogram bucket boundaries with exponentially increasing values.
|
|
@@ -4564,47 +4307,13 @@ export const linearBoundaries = (options: {
|
|
|
4564
4307
|
*
|
|
4565
4308
|
* **Example** (Creating exponential boundaries)
|
|
4566
4309
|
*
|
|
4567
|
-
* ```ts
|
|
4568
|
-
* import {
|
|
4569
|
-
*
|
|
4570
|
-
* class BoundaryError extends Data.TaggedError("BoundaryError")<{
|
|
4571
|
-
* readonly operation: string
|
|
4572
|
-
* }> {}
|
|
4573
|
-
*
|
|
4574
|
-
* // Create exponential boundaries for request size histogram
|
|
4575
|
-
* // Buckets: 0-1KB, 1-2KB, 2-4KB, 4-8KB, 8KB+
|
|
4576
|
-
* const sizeBoundaries = Metric.exponentialBoundaries({
|
|
4577
|
-
* start: 1, // Starting at 1KB
|
|
4578
|
-
* factor: 2, // Each boundary doubles the previous
|
|
4579
|
-
* count: 5 // Creates 4 boundaries + infinity
|
|
4580
|
-
* })
|
|
4581
|
-
* console.log(sizeBoundaries) // [1, 2, 4, 8, Infinity]
|
|
4582
|
-
*
|
|
4583
|
-
* // Create a histogram for tracking request payload sizes
|
|
4584
|
-
* const requestSizeHistogram = Metric.histogram("request_size_kb", {
|
|
4585
|
-
* description: "Request payload size distribution in KB",
|
|
4586
|
-
* boundaries: sizeBoundaries
|
|
4587
|
-
* })
|
|
4588
|
-
*
|
|
4589
|
-
* // For very wide ranges, use larger factors
|
|
4590
|
-
* const latencyBoundaries = Metric.exponentialBoundaries({
|
|
4591
|
-
* start: 0.1, // Start at 0.1ms
|
|
4592
|
-
* factor: 10, // Each boundary is 10x larger
|
|
4593
|
-
* count: 6 // Creates ranges: 0.1ms, 1ms, 10ms, 100ms, 1000ms+
|
|
4594
|
-
* })
|
|
4595
|
-
*
|
|
4596
|
-
* const program = Effect.gen(function*() {
|
|
4597
|
-
* // Record different request sizes
|
|
4598
|
-
* yield* Metric.update(requestSizeHistogram, 1.5) // Goes in 1-2KB bucket
|
|
4599
|
-
* yield* Metric.update(requestSizeHistogram, 3.2) // Goes in 2-4KB bucket
|
|
4600
|
-
* yield* Metric.update(requestSizeHistogram, 12) // Goes in 8KB+ bucket
|
|
4310
|
+
* ```ts import.meta.vitest
|
|
4311
|
+
* import { Metric } from "effect"
|
|
4601
4312
|
*
|
|
4602
|
-
*
|
|
4603
|
-
* return value
|
|
4604
|
-
* })
|
|
4313
|
+
* Metric.exponentialBoundaries({ start: 1, factor: 2, count: 5 }) // => [1, 2, 4, 8, Infinity]
|
|
4605
4314
|
* ```
|
|
4606
4315
|
*
|
|
4607
|
-
* @category
|
|
4316
|
+
* @category constructors
|
|
4608
4317
|
* @since 4.0.0
|
|
4609
4318
|
*/
|
|
4610
4319
|
export const exponentialBoundaries = (options: {
|
|
@@ -4637,36 +4346,13 @@ const fiberFailures = counter("child_fiber_failures", {
|
|
|
4637
4346
|
*
|
|
4638
4347
|
* **Example** (Accessing the fiber runtime metrics key)
|
|
4639
4348
|
*
|
|
4640
|
-
* ```ts
|
|
4641
|
-
* import {
|
|
4642
|
-
*
|
|
4643
|
-
* class MetricsError extends Data.TaggedError("MetricsError")<{
|
|
4644
|
-
* readonly operation: string
|
|
4645
|
-
* }> {}
|
|
4646
|
-
*
|
|
4647
|
-
* const program = Effect.gen(function*() {
|
|
4648
|
-
* // The key is used internally by the Effect runtime to manage fiber metrics
|
|
4649
|
-
* const key = Metric.FiberRuntimeMetricsKey
|
|
4650
|
-
* console.log("Fiber metrics key:", key)
|
|
4651
|
-
*
|
|
4652
|
-
* // Enable runtime metrics using the key
|
|
4653
|
-
* const layer = Layer.succeed(Metric.FiberRuntimeMetrics)(
|
|
4654
|
-
* Metric.FiberRuntimeMetricsImpl
|
|
4655
|
-
* )
|
|
4656
|
-
*
|
|
4657
|
-
* return yield* Effect.gen(function*() {
|
|
4658
|
-
* // This Effect will have fiber metrics automatically collected
|
|
4659
|
-
* yield* Effect.sleep("100 millis")
|
|
4349
|
+
* ```ts import.meta.vitest
|
|
4350
|
+
* import { Metric } from "effect"
|
|
4660
4351
|
*
|
|
4661
|
-
*
|
|
4662
|
-
* const testCounter = Metric.counter("test_counter")
|
|
4663
|
-
* yield* Metric.update(testCounter, 1)
|
|
4664
|
-
* return yield* Metric.value(testCounter)
|
|
4665
|
-
* }).pipe(Effect.provide(layer))
|
|
4666
|
-
* })
|
|
4352
|
+
* Metric.FiberRuntimeMetricsKey // => "effect/observability/Metric/FiberRuntimeMetricsKey"
|
|
4667
4353
|
* ```
|
|
4668
4354
|
*
|
|
4669
|
-
* @category
|
|
4355
|
+
* @category constants
|
|
4670
4356
|
* @since 4.0.0
|
|
4671
4357
|
*/
|
|
4672
4358
|
export const FiberRuntimeMetricsKey: "effect/observability/Metric/FiberRuntimeMetricsKey" =
|
|
@@ -4677,38 +4363,25 @@ export const FiberRuntimeMetricsKey: "effect/observability/Metric/FiberRuntimeMe
|
|
|
4677
4363
|
*
|
|
4678
4364
|
* **Example** (Providing a custom fiber metrics service)
|
|
4679
4365
|
*
|
|
4680
|
-
* ```ts
|
|
4681
|
-
* import {
|
|
4682
|
-
* import type { Context, Exit } from "effect"
|
|
4366
|
+
* ```ts import.meta.vitest
|
|
4367
|
+
* import { Context, Exit, Metric } from "effect"
|
|
4683
4368
|
*
|
|
4684
|
-
*
|
|
4685
|
-
* readonly operation: string
|
|
4686
|
-
* }> {}
|
|
4687
|
-
*
|
|
4688
|
-
* // Custom implementation of the metrics service
|
|
4369
|
+
* const events: Array<string> = []
|
|
4689
4370
|
* const customMetricsService: Metric.FiberRuntimeMetricsService = {
|
|
4690
|
-
* recordFiberStart: (
|
|
4691
|
-
*
|
|
4692
|
-
* // Custom logic for tracking fiber starts
|
|
4371
|
+
* recordFiberStart: () => {
|
|
4372
|
+
* events.push("start")
|
|
4693
4373
|
* },
|
|
4694
|
-
* recordFiberEnd: (
|
|
4695
|
-
*
|
|
4696
|
-
* exit: Exit.Exit<unknown, unknown>
|
|
4697
|
-
* ) => {
|
|
4698
|
-
* console.log("Fiber completed with exit:", exit)
|
|
4699
|
-
* // Custom logic for tracking fiber completion based on exit status
|
|
4374
|
+
* recordFiberEnd: (_context, exit) => {
|
|
4375
|
+
* events.push(Exit.isSuccess(exit) ? "success" : "failure")
|
|
4700
4376
|
* }
|
|
4701
4377
|
* }
|
|
4702
4378
|
*
|
|
4703
|
-
*
|
|
4704
|
-
*
|
|
4705
|
-
*
|
|
4706
|
-
*
|
|
4707
|
-
* return yield* Effect.sleep("100 millis").pipe(Effect.provide(layer))
|
|
4708
|
-
* })
|
|
4379
|
+
* customMetricsService.recordFiberStart(Context.empty())
|
|
4380
|
+
* customMetricsService.recordFiberEnd(Context.empty(), Exit.succeed("ok"))
|
|
4381
|
+
* events // => ["start", "success"]
|
|
4709
4382
|
* ```
|
|
4710
4383
|
*
|
|
4711
|
-
* @category
|
|
4384
|
+
* @category services
|
|
4712
4385
|
* @since 4.0.0
|
|
4713
4386
|
*/
|
|
4714
4387
|
export interface FiberRuntimeMetricsService {
|
|
@@ -4733,50 +4406,26 @@ export interface FiberRuntimeMetricsService {
|
|
|
4733
4406
|
*
|
|
4734
4407
|
* **Example** (Accessing the fiber runtime metrics service)
|
|
4735
4408
|
*
|
|
4736
|
-
* ```ts
|
|
4737
|
-
* import {
|
|
4738
|
-
*
|
|
4739
|
-
* class MetricsError extends Data.TaggedError("MetricsError")<{
|
|
4740
|
-
* readonly operation: string
|
|
4741
|
-
* }> {}
|
|
4409
|
+
* ```ts import.meta.vitest
|
|
4410
|
+
* import { Effect, Metric } from "effect"
|
|
4742
4411
|
*
|
|
4743
4412
|
* const program = Effect.gen(function*() {
|
|
4744
|
-
* // Access the fiber runtime metrics service
|
|
4745
4413
|
* const metricsService = yield* Metric.FiberRuntimeMetrics
|
|
4746
|
-
*
|
|
4747
|
-
* if (metricsService) {
|
|
4748
|
-
* console.log("Runtime metrics are enabled")
|
|
4749
|
-
* } else {
|
|
4750
|
-
* console.log("Runtime metrics are disabled")
|
|
4751
|
-
* }
|
|
4752
|
-
*
|
|
4753
|
-
* // Enable runtime metrics for the application
|
|
4754
|
-
* const enabledLayer = Metric.enableRuntimeMetricsLayer
|
|
4755
|
-
*
|
|
4756
|
-
* return yield* Effect.gen(function*() {
|
|
4757
|
-
* // Create some concurrent fibers to see metrics in action
|
|
4758
|
-
* yield* Effect.all([
|
|
4759
|
-
* Effect.sleep("100 millis"),
|
|
4760
|
-
* Effect.sleep("200 millis"),
|
|
4761
|
-
* Effect.sleep("300 millis")
|
|
4762
|
-
* ], { concurrency: "unbounded" })
|
|
4763
|
-
*
|
|
4764
|
-
* // Create test metrics to demonstrate the service
|
|
4765
|
-
* const testCounter = Metric.counter("test_counter")
|
|
4766
|
-
* yield* Metric.update(testCounter, 5)
|
|
4767
|
-
* const counterValue = yield* Metric.value(testCounter)
|
|
4768
|
-
*
|
|
4769
|
-
* return { counterValue, metricsEnabled: true }
|
|
4770
|
-
* }).pipe(Effect.provide(enabledLayer))
|
|
4414
|
+
* return metricsService === Metric.FiberRuntimeMetricsImpl
|
|
4771
4415
|
* })
|
|
4416
|
+
*
|
|
4417
|
+
* const result = await Effect.runPromise(
|
|
4418
|
+
* Effect.provideService(program, Metric.FiberRuntimeMetrics, Metric.FiberRuntimeMetricsImpl)
|
|
4419
|
+
* )
|
|
4420
|
+
* const isDefault = result // => true
|
|
4772
4421
|
* ```
|
|
4773
4422
|
*
|
|
4774
|
-
* @category
|
|
4423
|
+
* @category services
|
|
4775
4424
|
* @since 4.0.0
|
|
4776
4425
|
*/
|
|
4777
4426
|
export const FiberRuntimeMetrics = Context.Reference<FiberRuntimeMetricsService | undefined>(
|
|
4778
4427
|
InternalMetric.FiberRuntimeMetricsKey,
|
|
4779
|
-
{ defaultValue: constUndefined }
|
|
4428
|
+
{ fiberCached: true, defaultValue: constUndefined }
|
|
4780
4429
|
)
|
|
4781
4430
|
|
|
4782
4431
|
/**
|
|
@@ -4784,44 +4433,16 @@ export const FiberRuntimeMetrics = Context.Reference<FiberRuntimeMetricsService
|
|
|
4784
4433
|
*
|
|
4785
4434
|
* **Example** (Accessing the default fiber metrics implementation)
|
|
4786
4435
|
*
|
|
4787
|
-
* ```ts
|
|
4788
|
-
* import {
|
|
4789
|
-
*
|
|
4790
|
-
* class MetricsError extends Data.TaggedError("MetricsError")<{
|
|
4791
|
-
* readonly operation: string
|
|
4792
|
-
* }> {}
|
|
4793
|
-
*
|
|
4794
|
-
* const program = Effect.gen(function*() {
|
|
4795
|
-
* // Use the default metrics implementation
|
|
4796
|
-
* const metrics = Metric.FiberRuntimeMetricsImpl
|
|
4797
|
-
* console.log("Metrics implementation:", metrics)
|
|
4798
|
-
*
|
|
4799
|
-
* // Enable runtime metrics using the default implementation
|
|
4800
|
-
* const layer = Layer.succeed(Metric.FiberRuntimeMetrics)(metrics)
|
|
4801
|
-
*
|
|
4802
|
-
* return yield* Effect.gen(function*() {
|
|
4803
|
-
* // Run some Effects to trigger metric collection
|
|
4804
|
-
* yield* Effect.forkChild(Effect.sleep("50 millis"))
|
|
4805
|
-
* yield* Effect.forkChild(Effect.sleep("100 millis"))
|
|
4806
|
-
*
|
|
4807
|
-
* // Wait a bit and check the metrics
|
|
4808
|
-
* yield* Effect.sleep("200 millis")
|
|
4809
|
-
*
|
|
4810
|
-
* // Create test metrics to demonstrate the implementation
|
|
4811
|
-
* const testCounter = Metric.counter("test_counter")
|
|
4812
|
-
* const testGauge = Metric.gauge("test_gauge")
|
|
4813
|
-
* yield* Metric.update(testCounter, 3)
|
|
4814
|
-
* yield* Metric.update(testGauge, 42)
|
|
4815
|
-
*
|
|
4816
|
-
* const counterValue = yield* Metric.value(testCounter)
|
|
4817
|
-
* const gaugeValue = yield* Metric.value(testGauge)
|
|
4436
|
+
* ```ts import.meta.vitest
|
|
4437
|
+
* import { Metric } from "effect"
|
|
4818
4438
|
*
|
|
4819
|
-
*
|
|
4820
|
-
*
|
|
4821
|
-
*
|
|
4439
|
+
* [
|
|
4440
|
+
* typeof Metric.FiberRuntimeMetricsImpl.recordFiberStart,
|
|
4441
|
+
* typeof Metric.FiberRuntimeMetricsImpl.recordFiberEnd
|
|
4442
|
+
* ] // => ["function", "function"]
|
|
4822
4443
|
* ```
|
|
4823
4444
|
*
|
|
4824
|
-
* @category
|
|
4445
|
+
* @category services
|
|
4825
4446
|
* @since 4.0.0
|
|
4826
4447
|
*/
|
|
4827
4448
|
export const FiberRuntimeMetricsImpl: FiberRuntimeMetricsService = {
|
|
@@ -4850,91 +4471,18 @@ export const FiberRuntimeMetricsImpl: FiberRuntimeMetricsService = {
|
|
|
4850
4471
|
*
|
|
4851
4472
|
* **Example** (Enabling runtime metrics with a layer)
|
|
4852
4473
|
*
|
|
4853
|
-
* ```ts
|
|
4854
|
-
* import {
|
|
4855
|
-
*
|
|
4856
|
-
* class AppError extends Data.TaggedError("AppError")<{
|
|
4857
|
-
* readonly operation: string
|
|
4858
|
-
* }> {}
|
|
4859
|
-
*
|
|
4860
|
-
* // Define your application logic
|
|
4861
|
-
* const userService = Effect.gen(function*() {
|
|
4862
|
-
* // Simulate user operations with concurrent processing
|
|
4863
|
-
* const fetchUser = (id: number) =>
|
|
4864
|
-
* Effect.gen(function*() {
|
|
4865
|
-
* yield* Effect.sleep(`${50 + id * 10} millis`)
|
|
4866
|
-
* if (id % 7 === 0) {
|
|
4867
|
-
* return yield* new AppError({ operation: `fetch-user-${id}` })
|
|
4868
|
-
* }
|
|
4869
|
-
* return { id, name: `User ${id}`, email: `user${id}@example.com` }
|
|
4870
|
-
* })
|
|
4871
|
-
*
|
|
4872
|
-
* // Process multiple users concurrently (ignoring failures for demo)
|
|
4873
|
-
* const userIds = Array.from({ length: 10 }, (_, i) => i + 1)
|
|
4874
|
-
* const userTasks = userIds.map((id) =>
|
|
4875
|
-
* fetchUser(id).pipe(Effect.catchTag("AppError", () => Effect.succeed(null)))
|
|
4876
|
-
* )
|
|
4877
|
-
* const allUsers = yield* Effect.all(userTasks, { concurrency: 4 })
|
|
4878
|
-
* const successfulUsers = allUsers.filter((user) => user !== null)
|
|
4879
|
-
* return successfulUsers
|
|
4880
|
-
* })
|
|
4881
|
-
*
|
|
4882
|
-
* const analyticsService = Effect.gen(function*() {
|
|
4883
|
-
* // Simulate analytics processing
|
|
4884
|
-
* const tasks = Array.from({ length: 8 }, (_, i) =>
|
|
4885
|
-
* Effect.gen(function*() {
|
|
4886
|
-
* yield* Effect.sleep(`${100 + i * 25} millis`)
|
|
4887
|
-
* return `Analytics task ${i} completed`
|
|
4888
|
-
* }))
|
|
4889
|
-
* return yield* Effect.all(tasks, { concurrency: 3 })
|
|
4890
|
-
* })
|
|
4891
|
-
*
|
|
4892
|
-
* // Main application that uses multiple services
|
|
4893
|
-
* const application = Effect.gen(function*() {
|
|
4894
|
-
* yield* Console.log("Starting application with runtime metrics...")
|
|
4895
|
-
*
|
|
4896
|
-
* // Run services concurrently
|
|
4897
|
-
* const [users, analytics] = yield* Effect.all([
|
|
4898
|
-
* userService,
|
|
4899
|
-
* analyticsService
|
|
4900
|
-
* ], { concurrency: 2 })
|
|
4901
|
-
*
|
|
4902
|
-
* yield* Console.log(
|
|
4903
|
-
* `Processed ${users.length} users and ${analytics.length} analytics tasks`
|
|
4904
|
-
* )
|
|
4905
|
-
*
|
|
4906
|
-
* // Inspect the automatically collected runtime metrics
|
|
4907
|
-
* const metrics = yield* Metric.snapshot
|
|
4908
|
-
* const runtimeMetrics = metrics.filter((m) => m.id.startsWith("child_fiber"))
|
|
4909
|
-
*
|
|
4910
|
-
* yield* Console.log("Runtime Metrics Collected:")
|
|
4911
|
-
* for (const metric of runtimeMetrics) {
|
|
4912
|
-
* yield* Console.log(` ${metric.id}: ${JSON.stringify(metric.state)}`)
|
|
4913
|
-
* }
|
|
4474
|
+
* ```ts import.meta.vitest
|
|
4475
|
+
* import { Effect, Metric } from "effect"
|
|
4914
4476
|
*
|
|
4915
|
-
*
|
|
4477
|
+
* const program = Effect.gen(function*() {
|
|
4478
|
+
* const service = yield* Metric.FiberRuntimeMetrics
|
|
4479
|
+
* return service === Metric.FiberRuntimeMetricsImpl
|
|
4916
4480
|
* })
|
|
4917
4481
|
*
|
|
4918
|
-
*
|
|
4919
|
-
* const AppLayer = Layer.empty // Add your application layers here (database, HTTP, etc.)
|
|
4920
|
-
*
|
|
4921
|
-
* // Add runtime metrics layer at the end
|
|
4922
|
-
* const AppLayerWithMetrics = AppLayer.pipe(
|
|
4923
|
-
* Layer.provide(Metric.enableRuntimeMetricsLayer)
|
|
4924
|
-
* )
|
|
4925
|
-
*
|
|
4926
|
-
* // Run the application with runtime metrics enabled
|
|
4927
|
-
* const program = application.pipe(
|
|
4928
|
-
* Effect.provide(AppLayerWithMetrics)
|
|
4929
|
-
* )
|
|
4930
|
-
*
|
|
4931
|
-
* // Alternative: Provide runtime metrics directly to the application
|
|
4932
|
-
* const programWithDirectMetrics = application.pipe(
|
|
4933
|
-
* Effect.provide(Metric.enableRuntimeMetricsLayer)
|
|
4934
|
-
* )
|
|
4482
|
+
* await Effect.runPromise(Effect.provide(program, Metric.enableRuntimeMetricsLayer)) // => true
|
|
4935
4483
|
* ```
|
|
4936
4484
|
*
|
|
4937
|
-
* @category
|
|
4485
|
+
* @category layers
|
|
4938
4486
|
* @since 4.0.0
|
|
4939
4487
|
*/
|
|
4940
4488
|
export const enableRuntimeMetricsLayer = Layer.succeed(FiberRuntimeMetrics)(FiberRuntimeMetricsImpl)
|
|
@@ -4944,12 +4492,8 @@ export const enableRuntimeMetricsLayer = Layer.succeed(FiberRuntimeMetrics)(Fibe
|
|
|
4944
4492
|
*
|
|
4945
4493
|
* **Example** (Disabling runtime metrics with a layer)
|
|
4946
4494
|
*
|
|
4947
|
-
* ```ts
|
|
4948
|
-
* import {
|
|
4949
|
-
*
|
|
4950
|
-
* class MetricsError extends Data.TaggedError("MetricsError")<{
|
|
4951
|
-
* readonly operation: string
|
|
4952
|
-
* }> {}
|
|
4495
|
+
* ```ts import.meta.vitest
|
|
4496
|
+
* import { Effect, Metric } from "effect"
|
|
4953
4497
|
*
|
|
4954
4498
|
* const program = Effect.gen(function*() {
|
|
4955
4499
|
* // Disable runtime metrics collection
|
|
@@ -4958,7 +4502,6 @@ export const enableRuntimeMetricsLayer = Layer.succeed(FiberRuntimeMetrics)(Fibe
|
|
|
4958
4502
|
* return yield* Effect.gen(function*() {
|
|
4959
4503
|
* // Check that metrics service is disabled
|
|
4960
4504
|
* const metricsService = yield* Metric.FiberRuntimeMetrics
|
|
4961
|
-
* console.log("Metrics enabled:", metricsService !== undefined) // false
|
|
4962
4505
|
*
|
|
4963
4506
|
* // Run some Effects - no metrics will be collected
|
|
4964
4507
|
* yield* Effect.forkChild(Effect.sleep("50 millis"))
|
|
@@ -4973,9 +4516,12 @@ export const enableRuntimeMetricsLayer = Layer.succeed(FiberRuntimeMetrics)(Fibe
|
|
|
4973
4516
|
* return { counterValue, metricsEnabled: metricsService !== undefined }
|
|
4974
4517
|
* }).pipe(Effect.provide(disabledLayer))
|
|
4975
4518
|
* })
|
|
4519
|
+
*
|
|
4520
|
+
* const result = await Effect.runPromise(Effect.provideService(program, Metric.MetricRegistry, new Map()))
|
|
4521
|
+
* const values = [result.counterValue.count, result.metricsEnabled] // => [1, false]
|
|
4976
4522
|
* ```
|
|
4977
4523
|
*
|
|
4978
|
-
* @category
|
|
4524
|
+
* @category layers
|
|
4979
4525
|
* @since 4.0.0
|
|
4980
4526
|
*/
|
|
4981
4527
|
export const disableRuntimeMetricsLayer = Layer.succeed(FiberRuntimeMetrics)(undefined)
|
|
@@ -4991,75 +4537,18 @@ export const disableRuntimeMetricsLayer = Layer.succeed(FiberRuntimeMetrics)(und
|
|
|
4991
4537
|
*
|
|
4992
4538
|
* **Example** (Enabling runtime metrics for an effect)
|
|
4993
4539
|
*
|
|
4994
|
-
* ```ts
|
|
4995
|
-
* import {
|
|
4996
|
-
*
|
|
4997
|
-
* class RuntimeMetricsError extends Data.TaggedError("RuntimeMetricsError")<{
|
|
4998
|
-
* readonly operation: string
|
|
4999
|
-
* }> {}
|
|
4540
|
+
* ```ts import.meta.vitest
|
|
4541
|
+
* import { Effect, Metric } from "effect"
|
|
5000
4542
|
*
|
|
5001
4543
|
* const program = Effect.gen(function*() {
|
|
5002
|
-
*
|
|
5003
|
-
*
|
|
5004
|
-
* // Simulate concurrent operations
|
|
5005
|
-
* const tasks = Array.from({ length: 10 }, (_, i) =>
|
|
5006
|
-
* Effect.gen(function*() {
|
|
5007
|
-
* yield* Effect.sleep(`${100 + i * 50} millis`)
|
|
5008
|
-
* if (i % 4 === 0) {
|
|
5009
|
-
* // Simulate some failures
|
|
5010
|
-
* return yield* new RuntimeMetricsError({ operation: `task-${i}` })
|
|
5011
|
-
* }
|
|
5012
|
-
* return `Task ${i} completed`
|
|
5013
|
-
* }).pipe(
|
|
5014
|
-
* Effect.catchTag("RuntimeMetricsError", () =>
|
|
5015
|
-
* Effect.succeed(`Task ${i} failed`))
|
|
5016
|
-
* ))
|
|
5017
|
-
*
|
|
5018
|
-
* // Run tasks concurrently
|
|
5019
|
-
* const results = yield* Effect.all(tasks, { concurrency: 5 })
|
|
5020
|
-
* return results
|
|
5021
|
-
* })
|
|
5022
|
-
*
|
|
5023
|
-
* // Enable runtime metrics collection for our workload
|
|
5024
|
-
* const workloadWithMetrics = Metric.enableRuntimeMetrics(heavyWorkload)
|
|
5025
|
-
*
|
|
5026
|
-
* // Execute the workload
|
|
5027
|
-
* const results = yield* workloadWithMetrics
|
|
5028
|
-
*
|
|
5029
|
-
* // After execution, we can inspect the runtime metrics
|
|
5030
|
-
* // The following metrics are automatically collected:
|
|
5031
|
-
* // - child_fibers_active: Current number of active child fibers (Gauge)
|
|
5032
|
-
* // - child_fibers_started: Total child fibers started (Counter, incremental)
|
|
5033
|
-
* // - child_fiber_successes: Total successful child fibers (Counter, incremental)
|
|
5034
|
-
* // - child_fiber_failures: Total failed child fibers (Counter, incremental)
|
|
5035
|
-
*
|
|
5036
|
-
* yield* Console.log(`Workload completed with ${results.length} results`)
|
|
5037
|
-
*
|
|
5038
|
-
* // Get all metrics including the runtime metrics
|
|
5039
|
-
* const allMetrics = yield* Metric.snapshot
|
|
5040
|
-
* const runtimeMetrics = allMetrics.filter((m) =>
|
|
5041
|
-
* m.id.startsWith("child_fiber") || m.id.includes("fiber")
|
|
5042
|
-
* )
|
|
5043
|
-
*
|
|
5044
|
-
* yield* Console.log("Runtime Metrics:")
|
|
5045
|
-
* for (const metric of runtimeMetrics) {
|
|
5046
|
-
* yield* Console.log(` ${metric.id}: ${JSON.stringify(metric.state)}`)
|
|
5047
|
-
* }
|
|
5048
|
-
*
|
|
5049
|
-
* return results
|
|
4544
|
+
* const service = yield* Metric.FiberRuntimeMetrics
|
|
4545
|
+
* return service === Metric.FiberRuntimeMetricsImpl
|
|
5050
4546
|
* })
|
|
5051
4547
|
*
|
|
5052
|
-
*
|
|
5053
|
-
* const BaseAppLayer = Layer.empty // Your base application layers
|
|
5054
|
-
* const AppLayerWithMetrics = BaseAppLayer.pipe(
|
|
5055
|
-
* Layer.provide(Metric.enableRuntimeMetricsLayer)
|
|
5056
|
-
* )
|
|
5057
|
-
* const programWithLayer = program.pipe(
|
|
5058
|
-
* Effect.provide(AppLayerWithMetrics)
|
|
5059
|
-
* )
|
|
4548
|
+
* await Effect.runPromise(Metric.enableRuntimeMetrics(program)) // => true
|
|
5060
4549
|
* ```
|
|
5061
4550
|
*
|
|
5062
|
-
* @category
|
|
4551
|
+
* @category providing services
|
|
5063
4552
|
* @since 4.0.0
|
|
5064
4553
|
*/
|
|
5065
4554
|
export const enableRuntimeMetrics: <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R> = InternalEffect.provideService(
|
|
@@ -5077,76 +4566,18 @@ export const enableRuntimeMetrics: <A, E, R>(self: Effect<A, E, R>) => Effect<A,
|
|
|
5077
4566
|
*
|
|
5078
4567
|
* **Example** (Disabling runtime metrics for an effect)
|
|
5079
4568
|
*
|
|
5080
|
-
* ```ts
|
|
5081
|
-
* import {
|
|
5082
|
-
*
|
|
5083
|
-
* class DisableMetricsError extends Data.TaggedError("DisableMetricsError")<{
|
|
5084
|
-
* readonly operation: string
|
|
5085
|
-
* }> {}
|
|
4569
|
+
* ```ts import.meta.vitest
|
|
4570
|
+
* import { Effect, Metric } from "effect"
|
|
5086
4571
|
*
|
|
5087
4572
|
* const program = Effect.gen(function*() {
|
|
5088
|
-
*
|
|
5089
|
-
*
|
|
5090
|
-
* const tasks = Array.from({ length: 5 }, (_, i) =>
|
|
5091
|
-
* Effect.gen(function*() {
|
|
5092
|
-
* yield* Effect.sleep(`${100 + i * 20} millis`)
|
|
5093
|
-
* return `Normal task ${i} completed`
|
|
5094
|
-
* }))
|
|
5095
|
-
* return yield* Effect.all(tasks, { concurrency: 3 })
|
|
5096
|
-
* })
|
|
5097
|
-
*
|
|
5098
|
-
* // This section will have runtime metrics disabled for performance
|
|
5099
|
-
* const highPerformanceOperation = Metric.disableRuntimeMetrics(
|
|
5100
|
-
* Effect.gen(function*() {
|
|
5101
|
-
* // Performance-critical code where metrics overhead should be avoided
|
|
5102
|
-
* const hotPath = Array.from(
|
|
5103
|
-
* { length: 1000 },
|
|
5104
|
-
* (_, i) =>
|
|
5105
|
-
* Effect.gen(function*() {
|
|
5106
|
-
* // Simulate intensive computation
|
|
5107
|
-
* const result = i * i + (i % 10) / 10
|
|
5108
|
-
* return result
|
|
5109
|
-
* })
|
|
5110
|
-
* )
|
|
5111
|
-
* return yield* Effect.all(hotPath, { concurrency: 100 })
|
|
5112
|
-
* })
|
|
5113
|
-
* )
|
|
5114
|
-
*
|
|
5115
|
-
* yield* Console.log("Running operations with selective metrics...")
|
|
5116
|
-
*
|
|
5117
|
-
* // Run both operations
|
|
5118
|
-
* const [normalResults, performanceResults] = yield* Effect.all([
|
|
5119
|
-
* normalOperation, // Will generate fiber metrics
|
|
5120
|
-
* highPerformanceOperation // Will NOT generate fiber metrics
|
|
5121
|
-
* ])
|
|
5122
|
-
*
|
|
5123
|
-
* // Check collected metrics - should only see metrics from normalOperation
|
|
5124
|
-
* const metrics = yield* Metric.snapshot
|
|
5125
|
-
* const runtimeMetrics = metrics.filter((m) => m.id.startsWith("child_fiber"))
|
|
5126
|
-
*
|
|
5127
|
-
* yield* Console.log(`Normal operation results: ${normalResults.length}`)
|
|
5128
|
-
* yield* Console.log(
|
|
5129
|
-
* `Performance operation results: ${performanceResults.length}`
|
|
5130
|
-
* )
|
|
5131
|
-
* yield* Console.log(`Runtime metrics collected: ${runtimeMetrics.length}`)
|
|
5132
|
-
*
|
|
5133
|
-
* // The runtime metrics will only reflect the fibers from normalOperation
|
|
5134
|
-
* // The highPerformanceOperation fibers were not tracked due to disableRuntimeMetrics
|
|
5135
|
-
*
|
|
5136
|
-
* return { normalResults, performanceResults, runtimeMetrics }
|
|
4573
|
+
* const service = yield* Metric.FiberRuntimeMetrics
|
|
4574
|
+
* return service === undefined
|
|
5137
4575
|
* })
|
|
5138
4576
|
*
|
|
5139
|
-
*
|
|
5140
|
-
* const BaseAppLayer = Layer.empty // Your base application layers
|
|
5141
|
-
* const AppLayerWithMetrics = BaseAppLayer.pipe(
|
|
5142
|
-
* Layer.provide(Metric.enableRuntimeMetricsLayer)
|
|
5143
|
-
* )
|
|
5144
|
-
* const finalProgram = program.pipe(
|
|
5145
|
-
* Effect.provide(AppLayerWithMetrics)
|
|
5146
|
-
* )
|
|
4577
|
+
* await Effect.runPromise(Metric.disableRuntimeMetrics(program)) // => true
|
|
5147
4578
|
* ```
|
|
5148
4579
|
*
|
|
5149
|
-
* @category
|
|
4580
|
+
* @category providing services
|
|
5150
4581
|
* @since 4.0.0
|
|
5151
4582
|
*/
|
|
5152
4583
|
export const disableRuntimeMetrics: <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R> = InternalEffect.provideService(
|
|
@@ -5179,11 +4610,7 @@ function makeHooks<Input, State>(
|
|
|
5179
4610
|
}
|
|
5180
4611
|
|
|
5181
4612
|
function serializeAttributes(attributes: Metric.Attributes): string {
|
|
5182
|
-
return
|
|
5183
|
-
}
|
|
5184
|
-
|
|
5185
|
-
function serializeEntries(entries: ReadonlyArray<[string, string]>): string {
|
|
5186
|
-
return entries.map(([key, value]) => `${key}=${value}`).join(",")
|
|
4613
|
+
return JSON.stringify(Array.isArray(attributes) ? attributes : Object.entries(attributes))
|
|
5187
4614
|
}
|
|
5188
4615
|
|
|
5189
4616
|
function mergeAttributes(
|