effect 4.0.0-beta.102 → 4.0.0-beta.103

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