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