effect 4.1.5 → 4.1.6

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 (309) hide show
  1. package/ai-docs/package.json +2 -2
  2. package/dist/Channel.d.ts +104 -7
  3. package/dist/Channel.d.ts.map +1 -1
  4. package/dist/Channel.js +73 -4
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Codegen.d.ts +7 -2
  7. package/dist/Codegen.d.ts.map +1 -1
  8. package/dist/Codegen.js +7 -2
  9. package/dist/Codegen.js.map +1 -1
  10. package/dist/Effect.d.ts +139 -18
  11. package/dist/Effect.d.ts.map +1 -1
  12. package/dist/Effect.js +10 -2
  13. package/dist/Effect.js.map +1 -1
  14. package/dist/Equal.d.ts +4 -4
  15. package/dist/Equal.d.ts.map +1 -1
  16. package/dist/Equal.js +78 -65
  17. package/dist/Equal.js.map +1 -1
  18. package/dist/Hash.d.ts.map +1 -1
  19. package/dist/Hash.js +24 -17
  20. package/dist/Hash.js.map +1 -1
  21. package/dist/LayerRef.d.ts +1 -1
  22. package/dist/LayerRef.d.ts.map +1 -1
  23. package/dist/LayerRef.js +3 -3
  24. package/dist/LayerRef.js.map +1 -1
  25. package/dist/Logger.d.ts +37 -13
  26. package/dist/Logger.d.ts.map +1 -1
  27. package/dist/Logger.js +39 -10
  28. package/dist/Logger.js.map +1 -1
  29. package/dist/Match.d.ts +23 -23
  30. package/dist/Match.d.ts.map +1 -1
  31. package/dist/Match.js.map +1 -1
  32. package/dist/Order.js +1 -1
  33. package/dist/Order.js.map +1 -1
  34. package/dist/Schema.d.ts +41 -0
  35. package/dist/Schema.d.ts.map +1 -1
  36. package/dist/Schema.js +51 -390
  37. package/dist/Schema.js.map +1 -1
  38. package/dist/SchemaAST.d.ts.map +1 -1
  39. package/dist/SchemaAST.js +0 -3
  40. package/dist/SchemaAST.js.map +1 -1
  41. package/dist/ScopedCache.d.ts.map +1 -1
  42. package/dist/ScopedCache.js +6 -4
  43. package/dist/ScopedCache.js.map +1 -1
  44. package/dist/Stream.d.ts +128 -5
  45. package/dist/Stream.d.ts.map +1 -1
  46. package/dist/Stream.js +124 -29
  47. package/dist/Stream.js.map +1 -1
  48. package/dist/String.js +1 -1
  49. package/dist/String.js.map +1 -1
  50. package/dist/Tracer.d.ts +10 -0
  51. package/dist/Tracer.d.ts.map +1 -1
  52. package/dist/Tracer.js +2 -0
  53. package/dist/Tracer.js.map +1 -1
  54. package/dist/ai/McpSchema.d.ts +88 -88
  55. package/dist/ai/McpSchema.d.ts.map +1 -1
  56. package/dist/ai/McpServer.d.ts +152 -2
  57. package/dist/ai/McpServer.d.ts.map +1 -1
  58. package/dist/ai/McpServer.js +8 -2
  59. package/dist/ai/McpServer.js.map +1 -1
  60. package/dist/ai/Prompt.d.ts +3 -1
  61. package/dist/ai/Prompt.d.ts.map +1 -1
  62. package/dist/ai/Prompt.js +17 -3
  63. package/dist/ai/Prompt.js.map +1 -1
  64. package/dist/ai/Skill.d.ts +172 -0
  65. package/dist/ai/Skill.d.ts.map +1 -0
  66. package/dist/ai/Skill.js +209 -0
  67. package/dist/ai/Skill.js.map +1 -0
  68. package/dist/ai/index.d.ts +5 -0
  69. package/dist/ai/index.d.ts.map +1 -1
  70. package/dist/ai/index.js +5 -0
  71. package/dist/ai/index.js.map +1 -1
  72. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  73. package/dist/cluster/ClusterWorkflowEngine.js +155 -83
  74. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  75. package/dist/cluster/MessageStorage.d.ts +56 -0
  76. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  77. package/dist/cluster/MessageStorage.js +18 -2
  78. package/dist/cluster/MessageStorage.js.map +1 -1
  79. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  80. package/dist/cluster/SqlMessageStorage.js +45 -22
  81. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  82. package/dist/cluster/internal/entityActivation.js +2 -0
  83. package/dist/cluster/internal/entityActivation.js.map +1 -1
  84. package/dist/cluster/internal/entityManager.js +8 -5
  85. package/dist/cluster/internal/entityManager.js.map +1 -1
  86. package/dist/encoding/Base64.js +5 -1
  87. package/dist/encoding/Base64.js.map +1 -1
  88. package/dist/encoding/Base64Url.d.ts.map +1 -1
  89. package/dist/encoding/Base64Url.js +6 -1
  90. package/dist/encoding/Base64Url.js.map +1 -1
  91. package/dist/encoding/Xml.d.ts +38 -9
  92. package/dist/encoding/Xml.d.ts.map +1 -1
  93. package/dist/encoding/Xml.js +63 -31
  94. package/dist/encoding/Xml.js.map +1 -1
  95. package/dist/http/FetchHttpClient.d.ts +2 -1
  96. package/dist/http/FetchHttpClient.d.ts.map +1 -1
  97. package/dist/http/FetchHttpClient.js +14 -10
  98. package/dist/http/FetchHttpClient.js.map +1 -1
  99. package/dist/http/Headers.d.ts +201 -3
  100. package/dist/http/Headers.d.ts.map +1 -1
  101. package/dist/http/Headers.js +205 -3
  102. package/dist/http/Headers.js.map +1 -1
  103. package/dist/http/HttpClient.d.ts.map +1 -1
  104. package/dist/http/HttpClient.js +11 -7
  105. package/dist/http/HttpClient.js.map +1 -1
  106. package/dist/http/HttpClientError.d.ts +1 -0
  107. package/dist/http/HttpClientError.d.ts.map +1 -1
  108. package/dist/http/HttpClientError.js +32 -9
  109. package/dist/http/HttpClientError.js.map +1 -1
  110. package/dist/http/HttpClientRequest.d.ts +46 -0
  111. package/dist/http/HttpClientRequest.d.ts.map +1 -1
  112. package/dist/http/HttpClientRequest.js +15 -0
  113. package/dist/http/HttpClientRequest.js.map +1 -1
  114. package/dist/http/HttpClientResponse.d.ts +132 -0
  115. package/dist/http/HttpClientResponse.d.ts.map +1 -1
  116. package/dist/http/HttpClientResponse.js +83 -0
  117. package/dist/http/HttpClientResponse.js.map +1 -1
  118. package/dist/http/HttpMiddleware.js +1 -1
  119. package/dist/http/HttpMiddleware.js.map +1 -1
  120. package/dist/http/HttpServerResponse.d.ts +118 -0
  121. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  122. package/dist/http/HttpServerResponse.js +43 -0
  123. package/dist/http/HttpServerResponse.js.map +1 -1
  124. package/dist/http/Multipart.d.ts.map +1 -1
  125. package/dist/http/Multipart.js +0 -5
  126. package/dist/http/Multipart.js.map +1 -1
  127. package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
  128. package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
  129. package/dist/http/MultipartParser/internal/contentType.js +1 -1
  130. package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
  131. package/dist/http/internal/clientPath.d.ts +2 -0
  132. package/dist/http/internal/clientPath.d.ts.map +1 -0
  133. package/dist/http/internal/clientPath.js +24 -0
  134. package/dist/http/internal/clientPath.js.map +1 -0
  135. package/dist/http/internal/redactedPath.js +2 -0
  136. package/dist/http/internal/redactedPath.js.map +1 -1
  137. package/dist/http/internal/tracing.js +5 -3
  138. package/dist/http/internal/tracing.js.map +1 -1
  139. package/dist/http-api/HttpApi.d.ts +2 -2
  140. package/dist/http-api/HttpApi.d.ts.map +1 -1
  141. package/dist/http-api/HttpApi.js +30 -7
  142. package/dist/http-api/HttpApi.js.map +1 -1
  143. package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
  144. package/dist/http-api/HttpApiBuilder.js +5 -2
  145. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  146. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  147. package/dist/http-api/HttpApiClient.js +23 -6
  148. package/dist/http-api/HttpApiClient.js.map +1 -1
  149. package/dist/http-api/internal/redactedKeys.d.ts +2 -0
  150. package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
  151. package/dist/http-api/internal/redactedKeys.js +37 -0
  152. package/dist/http-api/internal/redactedKeys.js.map +1 -0
  153. package/dist/internal/base64.js +34 -2
  154. package/dist/internal/base64.js.map +1 -1
  155. package/dist/internal/dateTime.js +35 -17
  156. package/dist/internal/dateTime.js.map +1 -1
  157. package/dist/internal/effect.js +9 -1
  158. package/dist/internal/effect.js.map +1 -1
  159. package/dist/internal/equal.js +14 -13
  160. package/dist/internal/equal.js.map +1 -1
  161. package/dist/internal/hash.js +4 -1
  162. package/dist/internal/hash.js.map +1 -1
  163. package/dist/internal/matcher.js +17 -17
  164. package/dist/internal/matcher.js.map +1 -1
  165. package/dist/internal/schema/schemaCodegen.js +3 -2
  166. package/dist/internal/schema/schemaCodegen.js.map +1 -1
  167. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
  168. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
  169. package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
  170. package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
  171. package/dist/internal/schema/toEquivalence.js +3 -4
  172. package/dist/internal/schema/toEquivalence.js.map +1 -1
  173. package/dist/internal/version.js +1 -1
  174. package/dist/jose/JoseError.d.ts +51 -1
  175. package/dist/jose/JoseError.d.ts.map +1 -1
  176. package/dist/jose/JoseError.js +25 -18
  177. package/dist/jose/JoseError.js.map +1 -1
  178. package/dist/jose/internal/compact.js +10 -5
  179. package/dist/jose/internal/compact.js.map +1 -1
  180. package/dist/observability/Otlp.d.ts +19 -0
  181. package/dist/observability/Otlp.d.ts.map +1 -1
  182. package/dist/observability/Otlp.js +10 -0
  183. package/dist/observability/Otlp.js.map +1 -1
  184. package/dist/observability/OtlpExporter.d.ts +49 -13
  185. package/dist/observability/OtlpExporter.d.ts.map +1 -1
  186. package/dist/observability/OtlpExporter.js +135 -54
  187. package/dist/observability/OtlpExporter.js.map +1 -1
  188. package/dist/observability/OtlpLogger.d.ts +14 -0
  189. package/dist/observability/OtlpLogger.d.ts.map +1 -1
  190. package/dist/observability/OtlpLogger.js +10 -2
  191. package/dist/observability/OtlpLogger.js.map +1 -1
  192. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  193. package/dist/observability/OtlpMetrics.js +2 -0
  194. package/dist/observability/OtlpMetrics.js.map +1 -1
  195. package/dist/observability/OtlpTracer.d.ts +14 -0
  196. package/dist/observability/OtlpTracer.d.ts.map +1 -1
  197. package/dist/observability/OtlpTracer.js +10 -2
  198. package/dist/observability/OtlpTracer.js.map +1 -1
  199. package/dist/persistence/KeyValueStore.d.ts.map +1 -1
  200. package/dist/persistence/KeyValueStore.js +6 -4
  201. package/dist/persistence/KeyValueStore.js.map +1 -1
  202. package/dist/reactivity/Atom.d.ts.map +1 -1
  203. package/dist/reactivity/Atom.js +10 -9
  204. package/dist/reactivity/Atom.js.map +1 -1
  205. package/dist/rpc/RpcClient.d.ts.map +1 -1
  206. package/dist/rpc/RpcClient.js +32 -1
  207. package/dist/rpc/RpcClient.js.map +1 -1
  208. package/dist/rpc/RpcGroup.d.ts +1 -1
  209. package/dist/rpc/RpcGroup.d.ts.map +1 -1
  210. package/dist/rpc/RpcGroup.js +4 -0
  211. package/dist/rpc/RpcGroup.js.map +1 -1
  212. package/dist/sql/Migrator.d.ts.map +1 -1
  213. package/dist/sql/Migrator.js +2 -5
  214. package/dist/sql/Migrator.js.map +1 -1
  215. package/dist/sql/SqlClient.d.ts.map +1 -1
  216. package/dist/sql/SqlClient.js +5 -1
  217. package/dist/sql/SqlClient.js.map +1 -1
  218. package/dist/workflow/Activity.d.ts +18 -0
  219. package/dist/workflow/Activity.d.ts.map +1 -1
  220. package/dist/workflow/Activity.js +13 -4
  221. package/dist/workflow/Activity.js.map +1 -1
  222. package/dist/workflow/Workflow.d.ts +10 -9
  223. package/dist/workflow/Workflow.d.ts.map +1 -1
  224. package/dist/workflow/Workflow.js +33 -22
  225. package/dist/workflow/Workflow.js.map +1 -1
  226. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  227. package/dist/workflow/WorkflowEngine.js +26 -12
  228. package/dist/workflow/WorkflowEngine.js.map +1 -1
  229. package/dist/workflow/internal/retry.d.ts +2 -0
  230. package/dist/workflow/internal/retry.d.ts.map +1 -0
  231. package/dist/workflow/internal/retry.js +11 -0
  232. package/dist/workflow/internal/retry.js.map +1 -0
  233. package/dist/workflow/internal/scope.d.ts +2 -0
  234. package/dist/workflow/internal/scope.d.ts.map +1 -0
  235. package/dist/workflow/internal/scope.js +26 -0
  236. package/dist/workflow/internal/scope.js.map +1 -0
  237. package/package.json +3 -3
  238. package/src/Channel.ts +105 -8
  239. package/src/Codegen.ts +7 -2
  240. package/src/Effect.ts +224 -48
  241. package/src/Equal.ts +85 -79
  242. package/src/Hash.ts +30 -22
  243. package/src/LayerRef.ts +6 -4
  244. package/src/Logger.ts +68 -25
  245. package/src/Match.ts +78 -50
  246. package/src/Order.ts +1 -1
  247. package/src/Schema.ts +79 -296
  248. package/src/SchemaAST.ts +0 -1
  249. package/src/ScopedCache.ts +6 -4
  250. package/src/Stream.ts +167 -33
  251. package/src/String.ts +1 -1
  252. package/src/Tracer.ts +10 -0
  253. package/src/ai/McpServer.ts +161 -4
  254. package/src/ai/Prompt.ts +20 -3
  255. package/src/ai/Skill.ts +236 -0
  256. package/src/ai/index.ts +6 -0
  257. package/src/cluster/ClusterWorkflowEngine.ts +172 -96
  258. package/src/cluster/MessageStorage.ts +51 -2
  259. package/src/cluster/SqlMessageStorage.ts +81 -34
  260. package/src/cluster/internal/entityActivation.ts +6 -0
  261. package/src/cluster/internal/entityManager.ts +8 -4
  262. package/src/encoding/Base64.ts +5 -1
  263. package/src/encoding/Base64Url.ts +6 -1
  264. package/src/encoding/Xml.ts +96 -26
  265. package/src/http/FetchHttpClient.ts +8 -5
  266. package/src/http/Headers.ts +309 -3
  267. package/src/http/HttpClient.ts +19 -7
  268. package/src/http/HttpClientError.ts +42 -9
  269. package/src/http/HttpClientRequest.ts +51 -0
  270. package/src/http/HttpClientResponse.ts +156 -0
  271. package/src/http/HttpMiddleware.ts +1 -1
  272. package/src/http/HttpServerResponse.ts +126 -0
  273. package/src/http/Multipart.ts +0 -5
  274. package/src/http/MultipartParser/internal/contentType.ts +1 -1
  275. package/src/http/internal/clientPath.ts +39 -0
  276. package/src/http/internal/redactedPath.ts +4 -0
  277. package/src/http/internal/tracing.ts +6 -3
  278. package/src/http-api/HttpApi.ts +29 -8
  279. package/src/http-api/HttpApiBuilder.ts +7 -2
  280. package/src/http-api/HttpApiClient.ts +30 -7
  281. package/src/http-api/internal/redactedKeys.ts +40 -0
  282. package/src/internal/base64.ts +57 -2
  283. package/src/internal/dateTime.ts +43 -24
  284. package/src/internal/effect.ts +31 -102
  285. package/src/internal/equal.ts +37 -17
  286. package/src/internal/hash.ts +5 -1
  287. package/src/internal/matcher.ts +34 -113
  288. package/src/internal/schema/schemaCodegen.ts +5 -4
  289. package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
  290. package/src/internal/schema/toEquivalence.ts +3 -5
  291. package/src/internal/version.ts +1 -1
  292. package/src/jose/JoseError.ts +34 -0
  293. package/src/jose/internal/compact.ts +14 -5
  294. package/src/observability/Otlp.ts +29 -0
  295. package/src/observability/OtlpExporter.ts +206 -75
  296. package/src/observability/OtlpLogger.ts +24 -2
  297. package/src/observability/OtlpMetrics.ts +2 -0
  298. package/src/observability/OtlpTracer.ts +24 -3
  299. package/src/persistence/KeyValueStore.ts +17 -14
  300. package/src/reactivity/Atom.ts +12 -18
  301. package/src/rpc/RpcClient.ts +26 -1
  302. package/src/rpc/RpcGroup.ts +4 -1
  303. package/src/sql/Migrator.ts +2 -11
  304. package/src/sql/SqlClient.ts +14 -8
  305. package/src/workflow/Activity.ts +28 -4
  306. package/src/workflow/Workflow.ts +68 -44
  307. package/src/workflow/WorkflowEngine.ts +38 -15
  308. package/src/workflow/internal/retry.ts +12 -0
  309. package/src/workflow/internal/scope.ts +36 -0
@@ -1,2 +1,2 @@
1
1
  /** @internal */
2
- export const version = "4.1.5"
2
+ export const version = "4.1.6"
@@ -16,6 +16,7 @@
16
16
  * @stability unstable
17
17
  * @since 4.1.1
18
18
  */
19
+ import type * as CryptoError from "../crypto/CryptoError.ts"
19
20
  import * as Data from "../Data.ts"
20
21
  import * as Predicate from "../Predicate.ts"
21
22
 
@@ -69,6 +70,38 @@ export class InvalidKey extends Data.TaggedError("InvalidKey")<{
69
70
  }
70
71
  }
71
72
 
73
+ /**
74
+ * Reason for a crypto backend failure other than a rejected key, such as an
75
+ * algorithm the provider does not support.
76
+ *
77
+ * **Details**
78
+ *
79
+ * `module`, `method`, and `reason` identify the failed backend operation and
80
+ * reason tag. The backend description and cause are omitted because they may
81
+ * contain secret material.
82
+ *
83
+ * @stability unstable
84
+ * @category errors
85
+ * @since 4.1.6
86
+ */
87
+ export class CryptoFailed extends Data.TaggedError("CryptoFailed")<{
88
+ readonly description: string
89
+ readonly module: string
90
+ readonly method: string
91
+ readonly reason: CryptoError.CryptoErrorReason["_tag"]
92
+ }> {
93
+ /**
94
+ * Marks this value as a `JoseError` reason for runtime guards.
95
+ *
96
+ * @since 4.1.6
97
+ */
98
+ readonly [ReasonTypeId] = ReasonTypeId
99
+
100
+ override get message(): string {
101
+ return `${this.description} (${this.module}.${this.method}: ${this.reason})`
102
+ }
103
+ }
104
+
72
105
  /**
73
106
  * Reason for an option or configuration value that the operation rejects
74
107
  * before doing any work, such as a non-HTTPS key-set URL.
@@ -253,6 +286,7 @@ export class ClaimValidationFailed extends Data.TaggedError("ClaimValidationFail
253
286
  export type JoseErrorReason =
254
287
  | InvalidToken
255
288
  | InvalidKey
289
+ | CryptoFailed
256
290
  | InvalidArgument
257
291
  | AlgorithmNotAllowed
258
292
  | SignatureVerificationFailed
@@ -24,14 +24,23 @@ export const invalidArgument = (description: string, cause?: unknown) =>
24
24
  fail(new JoseError.InvalidArgument({ description, cause }))
25
25
 
26
26
  /**
27
- * Maps a failure of an operation on secret material, such as signing or
28
- * private-key import, to a fixed description. Backend messages and causes may
29
- * describe the secret, so they are dropped.
27
+ * Maps a backend failure without exposing its message or cause, which may
28
+ * describe secret material. `InvalidKey` stays `InvalidKey`; other reasons
29
+ * become `CryptoFailed`.
30
30
  *
31
31
  * @internal
32
32
  */
33
- export const cryptoFailure = (description: string) => (_: CryptoError.CryptoError): JoseError.JoseError =>
34
- new JoseError.JoseError({ reason: new JoseError.InvalidKey({ description }) })
33
+ export const cryptoFailure = (description: string) => (error: CryptoError.CryptoError): JoseError.JoseError =>
34
+ new JoseError.JoseError({
35
+ reason: error.reason._tag === "InvalidKey"
36
+ ? new JoseError.InvalidKey({ description })
37
+ : new JoseError.CryptoFailed({
38
+ description,
39
+ module: error.module,
40
+ method: error.method,
41
+ reason: error.reason._tag
42
+ })
43
+ })
35
44
 
36
45
  /**
37
46
  * Maps a public-key import failure, keeping the backend diagnostic.
@@ -16,6 +16,7 @@ import type * as HttpClient from "../http/HttpClient.ts"
16
16
  import * as HttpClientRequest from "../http/HttpClientRequest.ts"
17
17
  import * as Layer from "../Layer.ts"
18
18
  import type * as Tracer from "../Tracer.ts"
19
+ import type { Concurrency } from "../Types.ts"
19
20
  import type * as OtlpExporter from "./OtlpExporter.ts"
20
21
  import * as OtlpLogger from "./OtlpLogger.ts"
21
22
  import type { AggregationTemporality } from "./OtlpMetrics.ts"
@@ -53,6 +54,11 @@ export const layer = (options: {
53
54
  */
54
55
  readonly compression?: "gzip" | "none" | undefined
55
56
  readonly maxBatchSize?: number | undefined
57
+ /** Maximum pending queued spans/logs (does not include in-flight batches). */
58
+ readonly maxQueueSize?: number | undefined
59
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
60
+ readonly concurrency?: Concurrency | undefined
61
+ readonly onDrop?: ((count: number) => void) | undefined
56
62
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
57
63
  readonly loggerExportInterval?: Duration.Input | undefined
58
64
  readonly loggerExcludeLogSpans?: boolean | undefined
@@ -72,6 +78,9 @@ export const layer = (options: {
72
78
  compression: options.compression,
73
79
  exportInterval: options.loggerExportInterval,
74
80
  maxBatchSize: options.maxBatchSize,
81
+ maxQueueSize: options.maxQueueSize,
82
+ concurrency: options.concurrency,
83
+ onDrop: options.onDrop,
75
84
  shutdownTimeout: options.shutdownTimeout,
76
85
  excludeLogSpans: options.loggerExcludeLogSpans,
77
86
  mergeWithExisting: options.loggerMergeWithExisting
@@ -92,6 +101,9 @@ export const layer = (options: {
92
101
  compression: options.compression,
93
102
  exportInterval: options.tracerExportInterval,
94
103
  maxBatchSize: options.maxBatchSize,
104
+ maxQueueSize: options.maxQueueSize,
105
+ concurrency: options.concurrency,
106
+ onDrop: options.onDrop,
95
107
  context: options.tracerContext,
96
108
  shutdownTimeout: options.shutdownTimeout
97
109
  })
@@ -119,6 +131,9 @@ export const layerFromConfig = (options?: {
119
131
  readonly attributes?: Record<string, unknown>
120
132
  } | undefined
121
133
  readonly headers?: Headers.Input | undefined
134
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
135
+ readonly concurrency?: Concurrency | undefined
136
+ readonly onDrop?: ((count: number) => void) | undefined
122
137
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
123
138
  readonly loggerExcludeLogSpans?: boolean | undefined
124
139
  readonly loggerMergeWithExisting?: boolean | undefined
@@ -127,6 +142,8 @@ export const layerFromConfig = (options?: {
127
142
  OtlpLogger.layerFromConfig({
128
143
  resource: options?.resource,
129
144
  headers: options?.headers,
145
+ concurrency: options?.concurrency,
146
+ onDrop: options?.onDrop,
130
147
  excludeLogSpans: options?.loggerExcludeLogSpans,
131
148
  mergeWithExisting: options?.loggerMergeWithExisting
132
149
  }),
@@ -137,6 +154,8 @@ export const layerFromConfig = (options?: {
137
154
  OtlpTracer.layerFromConfig({
138
155
  resource: options?.resource,
139
156
  headers: options?.headers,
157
+ concurrency: options?.concurrency,
158
+ onDrop: options?.onDrop,
140
159
  context: options?.tracerContext
141
160
  })
142
161
  )
@@ -163,6 +182,11 @@ export const layerJson: (options: {
163
182
  */
164
183
  readonly compression?: "gzip" | "none" | undefined
165
184
  readonly maxBatchSize?: number | undefined
185
+ /** Maximum pending queued spans/logs (does not include in-flight batches). */
186
+ readonly maxQueueSize?: number | undefined
187
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
188
+ readonly concurrency?: Concurrency | undefined
189
+ readonly onDrop?: ((count: number) => void) | undefined
166
190
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
167
191
  readonly loggerExportInterval?: Duration.Input | undefined
168
192
  readonly loggerExcludeLogSpans?: boolean | undefined
@@ -198,6 +222,11 @@ export const layerProtobuf: (options: {
198
222
  */
199
223
  readonly compression?: "gzip" | "none" | undefined
200
224
  readonly maxBatchSize?: number | undefined
225
+ /** Maximum pending queued spans/logs (does not include in-flight batches). */
226
+ readonly maxQueueSize?: number | undefined
227
+ /** Maximum concurrent export requests for spans/logs, or `"unbounded"`. Defaults to `4`. */
228
+ readonly concurrency?: Concurrency | undefined
229
+ readonly onDrop?: ((count: number) => void) | undefined
201
230
  readonly tracerContext?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
202
231
  readonly loggerExportInterval?: Duration.Input | undefined
203
232
  readonly loggerExcludeLogSpans?: boolean | undefined
@@ -13,19 +13,21 @@ import { Clock } from "../Clock.ts"
13
13
  import * as Context from "../Context.ts"
14
14
  import * as Duration from "../Duration.ts"
15
15
  import * as Effect from "../Effect.ts"
16
- import * as Fiber from "../Fiber.ts"
17
- import * as FiberSet from "../FiberSet.ts"
16
+ import type * as Fiber from "../Fiber.ts"
18
17
  import { identity } from "../Function.ts"
19
18
  import * as Headers from "../http/Headers.ts"
20
19
  import type { HttpBody } from "../http/HttpBody.ts"
21
20
  import * as HttpClient from "../http/HttpClient.ts"
22
21
  import * as HttpClientError from "../http/HttpClientError.ts"
23
22
  import * as HttpClientRequest from "../http/HttpClientRequest.ts"
23
+ import * as Count from "../internal/count.ts"
24
24
  import * as Latch from "../Latch.ts"
25
25
  import * as Layer from "../Layer.ts"
26
+ import * as MutableList from "../MutableList.ts"
26
27
  import * as Result from "../Result.ts"
27
28
  import * as Schedule from "../Schedule.ts"
28
29
  import * as Scope from "../Scope.ts"
30
+ import type { Concurrency } from "../Types.ts"
29
31
  import * as Version from "../Version.ts"
30
32
 
31
33
  // A missing or invalid Retry-After falls back to a fixed delay.
@@ -60,11 +62,15 @@ const policy = Schedule.forever.pipe(
60
62
  *
61
63
  * **Details**
62
64
  *
63
- * Every exporter created by `make` registers its export operation here, so a
64
- * single `flush` drains all signals sharing the registry. `flush` returns only
65
- * after the exports it initiated have settled, cannot fail, and respects each
66
- * exporter's temporary-disable window. Wrap it with `Effect.timeoutOption` to
67
- * bound its duration at the call site.
65
+ * Every exporter created by `make` registers its flush operation here, so a
66
+ * single `flush` drains all signals sharing the registry concurrently while
67
+ * each exporter respects its own `concurrency` limit. For each exporter,
68
+ * `flush` returns once every export already in flight when it was called has
69
+ * settled and every item accepted before the call has been sent or discarded by
70
+ * a failed export (or after one fresh snapshot settles when `exportEmpty` is
71
+ * enabled). `flush` cannot fail and respects each exporter's temporary-disable
72
+ * window. Wrap it with `Effect.timeoutOption` to bound its duration at the call
73
+ * site.
68
74
  *
69
75
  * @stability unstable
70
76
  * @category services
@@ -76,8 +82,16 @@ export class Flusher extends Context.Service<Flusher, {
76
82
  *
77
83
  * **Details**
78
84
  *
85
+ * Each exporter runs up to its configured `concurrency` exports at a time.
86
+ * `flush` waits for every export already in flight when called to settle and
87
+ * drains items accepted before the call (items pushed while a flush is
88
+ * running may be included in a batch, but `flush` does not wait for them).
89
+ * Interrupting `flush` only stops the wait without cancelling in-flight
90
+ * exports or dropping queued items.
91
+ *
79
92
  * There is no built-in timeout; use `Effect.timeoutOption` to bound the
80
- * operation. Exporters in their 60-second `disabledUntil` window are skipped.
93
+ * operation. Exporters in their 60-second `disabledUntil` window start no new
94
+ * exports while still awaiting any export already in flight.
81
95
  *
82
96
  * **Example** (Flushing exporters)
83
97
  *
@@ -114,9 +128,10 @@ export class Flusher extends Context.Service<Flusher, {
114
128
  * Registration is scoped — an exporter is removed from the registry when its
115
129
  * own scope closes. Flushing with an empty registry is a no-op.
116
130
  *
117
- * Note that `flush` cannot await an export that was already in flight when it
118
- * was called (for example one started by the export interval); it only waits
119
- * for the exports it initiates.
131
+ * For each registered exporter, `flush` awaits all exports already in flight
132
+ * when it was called and drains every item accepted before the call (or sends
133
+ * one fresh snapshot when `exportEmpty` is enabled). Interrupting `flush` only
134
+ * stops waiting and does not cancel in-flight exports or drop queued items.
120
135
  *
121
136
  * @stability unstable
122
137
  * @category layers
@@ -150,10 +165,13 @@ export const layerFlusher: Layer.Layer<Flusher> = Layer.sync(Flusher, () => {
150
165
  *
151
166
  * **Details**
152
167
  *
153
- * The exporter buffers pushed data, periodically posts encoded batches to the
154
- * configured URL, retries transient failures, temporarily disables exporting
155
- * after unhandled failures, and flushes during scope finalization up to
156
- * `shutdownTimeout`.
168
+ * The exporter buffers pending pushed items up to `maxQueueSize` (dropping new
169
+ * arrivals on overflow and notifying `onDrop`), sends FIFO batches of at most
170
+ * `maxBatchSize` with up to `concurrency` exports (including retries) in flight
171
+ * at a time, temporarily disables exporting after unhandled failures, and
172
+ * drains remaining items during scope finalization up to `shutdownTimeout`.
173
+ * `maxQueueSize` bounds only pending queued items, not batches already in
174
+ * flight.
157
175
  *
158
176
  * The export interval starts with the first push and stops once an export
159
177
  * empties the buffer, so an idle exporter keeps no timer pending. With
@@ -178,6 +196,25 @@ export const make: (
178
196
  readonly label: string
179
197
  readonly exportInterval: Duration.Input
180
198
  readonly maxBatchSize: number | "disabled"
199
+ /**
200
+ * Maximum number of pending items buffered in the queue. Does not count
201
+ * items already dequeued into in-flight export batches. New items pushed
202
+ * while the queue is full are dropped and reported to `onDrop`.
203
+ *
204
+ * Defaults to `2048` (or `maxBatchSize` if larger).
205
+ */
206
+ readonly maxQueueSize?: number | undefined
207
+ /**
208
+ * Maximum number of export requests (including retries) allowed in flight
209
+ * concurrently, or `"unbounded"` for no limit.
210
+ *
211
+ * Defaults to `4`.
212
+ */
213
+ readonly concurrency?: Concurrency | undefined
214
+ /**
215
+ * Synchronous callback invoked when items are dropped due to queue overflow.
216
+ */
217
+ readonly onDrop?: ((count: number) => void) | undefined
181
218
  readonly exportEmpty?: boolean | undefined
182
219
  readonly body: (data: Array<any>) => readonly [body: HttpBody, onSuccess: Effect.Effect<void>]
183
220
  readonly shutdownTimeout: Duration.Input
@@ -191,6 +228,15 @@ export const make: (
191
228
  const clock = Context.get(services, Clock)
192
229
  const scope = Context.get(services, Scope.Scope)
193
230
  const exportInterval = Duration.max(Duration.fromInputUnsafe(options.exportInterval), Duration.zero)
231
+ const batchLimit = options.maxBatchSize === "disabled" ? Infinity : Count.normalizeNonEmpty(options.maxBatchSize)
232
+ const maxQueueSize = options.maxQueueSize === undefined || Number.isNaN(options.maxQueueSize)
233
+ ? Number.isFinite(batchLimit) ? Math.max(2048, batchLimit) : 2048
234
+ : Count.normalize(options.maxQueueSize)
235
+ const concurrency = options.concurrency === "unbounded"
236
+ ? Infinity
237
+ : options.concurrency === undefined || Number.isNaN(options.concurrency)
238
+ ? 4
239
+ : Count.normalizeNonEmpty(options.concurrency)
194
240
 
195
241
  const client = Context.get(services, HttpClient.HttpClient).pipe(
196
242
  HttpClient.tap((response) => Effect.ignore(response.arrayBuffer)),
@@ -211,93 +257,178 @@ export const make: (
211
257
 
212
258
  const request = HttpClientRequest.post(options.url, { headers })
213
259
  const exportsEmpty = options.maxBatchSize === "disabled" && options.exportEmpty === true
214
- let buffer: Array<any> = []
260
+ const queue = MutableList.make<any>()
215
261
  let disabledUntil: number | undefined = undefined
262
+ let closed = false
216
263
  const isDisabled = () => {
217
264
  if (disabledUntil === undefined) return false
218
265
  if (clock.currentTimeMillisUnsafe() < disabledUntil) return true
219
266
  disabledUntil = undefined
220
267
  return false
221
268
  }
269
+ const isStopped = () => closed || isDisabled()
270
+
271
+ // Progress is counted in items, or in snapshots when `exportsEmpty` is set:
272
+ // `requested` is how far callers asked to drain and `started` is how far the
273
+ // batches dequeued so far reach. `inFlight` maps each working fiber to the
274
+ // offset its batch starts at. Offsets only grow and a `Map` keeps insertion
275
+ // order, so its first entry is the earliest export in flight and everything
276
+ // before it has settled, even when batches complete out of order.
277
+ let requested = 0
278
+ let started = 0
279
+ const inFlight = new Map<Fiber.Fiber<unknown, unknown>, number>()
280
+ const settled = () => closed ? Infinity : inFlight.values().next().value ?? started
222
281
 
223
- const runExport = Effect.suspend(() => {
224
- if (isDisabled() || (buffer.length === 0 && !exportsEmpty)) {
225
- return Effect.void
282
+ interface Waiter {
283
+ readonly target: number
284
+ readonly resume: (effect: Effect.Effect<void>) => void
285
+ }
286
+ const waiters = new Set<Waiter>()
287
+ const notifyWaiters = () => {
288
+ const reached = settled()
289
+ for (const waiter of waiters) {
290
+ if (reached >= waiter.target) {
291
+ waiters.delete(waiter)
292
+ waiter.resume(Effect.void)
293
+ }
226
294
  }
227
- const items = buffer
228
- buffer = []
229
- const [body, onSuccess] = options.body(items)
230
- const batchRequest = HttpClientRequest.setBody(request, body)
231
- // Compress before client.execute so transient retries reuse the encoded bytes.
232
- const response = options.compression === "gzip"
233
- ? HttpClientRequest.compressBody(batchRequest, "gzip").pipe(Effect.flatMap(client.execute))
234
- : client.execute(batchRequest)
235
- return response.pipe(
236
- Effect.andThen(onSuccess),
237
- Effect.asVoid,
238
- Effect.withTracerEnabled(false)
239
- )
240
- }).pipe(
241
- Effect.catchCause((cause) => {
242
- if (disabledUntil !== undefined) return Effect.void
243
- disabledUntil = clock.currentTimeMillisUnsafe() + 60_000
244
- buffer = []
245
- return Effect.logWarning("Disabling exporter for 60 seconds", cause)
246
- }),
247
- Effect.annotateLogs({
248
- package: "@effect/opentelemetry",
249
- module: options.label
295
+ }
296
+ const awaitSettled = (target: number): Effect.Effect<void> =>
297
+ Effect.callback((resume) => {
298
+ if (settled() >= target) return resume(Effect.void)
299
+ const waiter: Waiter = { target, resume }
300
+ waiters.add(waiter)
301
+ return Effect.sync(() => {
302
+ waiters.delete(waiter)
303
+ })
250
304
  })
251
- )
252
305
 
253
- const exportFibers = yield* FiberSet.make<void, never>()
254
- const runExportFork = yield* FiberSet.runtime(exportFibers)<never>()
306
+ // `armed` is open while there is something to export. It changes in the
307
+ // same synchronous step as the queue check, so a push is never stranded.
308
+ const armed = yield* Latch.make(exportsEmpty)
309
+ const wake = yield* Latch.make()
255
310
 
256
- yield* Scope.addFinalizer(
257
- scope,
311
+ const exportBatch = (items: Array<any>): Effect.Effect<void> =>
258
312
  Effect.suspend(() => {
259
- if (disabledUntil !== undefined) return Effect.void
260
- runExportFork(runExport)
261
- return FiberSet.awaitEmpty(exportFibers)
313
+ const [body, onSuccess] = options.body(items)
314
+ const batchRequest = HttpClientRequest.setBody(request, body)
315
+ // Compress before client.execute so transient retries reuse the encoded bytes.
316
+ const response = options.compression === "gzip"
317
+ ? HttpClientRequest.compressBody(batchRequest, "gzip").pipe(Effect.flatMap(client.execute))
318
+ : client.execute(batchRequest)
319
+ return response.pipe(
320
+ Effect.andThen(onSuccess),
321
+ Effect.withTracerEnabled(false)
322
+ )
262
323
  }).pipe(
263
- Effect.ignore,
264
- Effect.interruptible,
265
- Effect.timeoutOption(options.shutdownTimeout)
324
+ Effect.catchCause((cause) => {
325
+ MutableList.clear(queue)
326
+ // Nothing queued or requested will start now. Count it as started so
327
+ // waiters only wait for the exports still in flight.
328
+ requested = started = Math.max(started, requested)
329
+ if (isDisabled()) return Effect.void
330
+ disabledUntil = clock.currentTimeMillisUnsafe() + 60_000
331
+ return Effect.logWarning("Disabling exporter for 60 seconds", cause)
332
+ }),
333
+ Effect.annotateLogs({
334
+ package: "@effect/opentelemetry",
335
+ module: options.label
336
+ })
266
337
  )
267
- )
268
338
 
269
- // `armed` is open while there is something to export. It changes in the
270
- // same synchronous step as the buffer check, so a push is never stranded.
271
- const armed = yield* Latch.make(exportsEmpty)
272
- const wake = yield* Latch.make()
273
- const disarmIfEmpty = Effect.sync(() => {
274
- if (exportsEmpty || buffer.length > 0 || !armed.closeUnsafe()) return
275
- wake.openUnsafe()
339
+ // Up to `concurrency` workers run on demand while there is work. The
340
+ // exporter owns them, so interrupting a flush never cancels a request.
341
+ const canStart = () =>
342
+ inFlight.size < concurrency && !isStopped() && (requested > started || queue.length >= batchLimit)
343
+ const workerLoop: Effect.Effect<void> = Effect.withFiber((fiber) => {
344
+ if (!canStart()) return Effect.void
345
+ const items = MutableList.takeN(queue, batchLimit)
346
+ inFlight.set(fiber, started)
347
+ started += exportsEmpty ? 1 : items.length
348
+ // `exit` keeps the worker alive if the failure handler itself dies, for
349
+ // example when a logger throws.
350
+ return Effect.exit(exportBatch(items)).pipe(
351
+ Effect.ensuring(Effect.sync(() => {
352
+ inFlight.delete(fiber)
353
+ if (inFlight.size === 0 && !exportsEmpty && queue.length === 0 && armed.closeUnsafe()) {
354
+ wake.openUnsafe()
355
+ }
356
+ notifyWaiters()
357
+ })),
358
+ Effect.andThen(workerLoop)
359
+ )
276
360
  })
277
- // Forked after the shutdown finalizer, so the loop stops before the shutdown flush.
278
- if (Duration.isFinite(exportInterval)) {
279
- yield* Effect.gen(function*() {
361
+ const runFork = Effect.runForkWith(services)
362
+ // A worker normally claims its batch before `runFork` returns. Stop when it
363
+ // has not, so a scheduler that yields first cannot make this loop spin.
364
+ const startWorkers = () => {
365
+ while (canStart() && inFlight.has(runFork(workerLoop))) {
366
+ // keep starting workers
367
+ }
368
+ }
369
+
370
+ // Exports everything accepted so far, or one fresh snapshot, and waits for
371
+ // it to settle together with every export already in flight. During cooldown,
372
+ // no new export starts, but any surviving in-flight export is still awaited.
373
+ const drain: Effect.Effect<void> = Effect.suspend(() => {
374
+ if (isStopped()) return awaitSettled(started)
375
+ const target = started + (exportsEmpty ? 1 : queue.length)
376
+ requested = Math.max(requested, target)
377
+ startWorkers()
378
+ return awaitSettled(target)
379
+ })
380
+
381
+ const timer = Duration.isFinite(exportInterval)
382
+ ? runFork(Effect.gen(function*() {
280
383
  while (true) {
281
384
  wake.closeUnsafe()
282
385
  yield* armed.await
283
- yield* Effect.race(Effect.sleep(exportInterval), wake.await)
284
- yield* Fiber.await(yield* FiberSet.run(exportFibers, runExport))
285
- yield* disarmIfEmpty
386
+ const expired = yield* Effect.race(
387
+ Effect.as(Effect.sleep(exportInterval), true),
388
+ Effect.as(wake.await, false)
389
+ )
390
+ if (expired) yield* drain
286
391
  }
287
- }).pipe(Effect.forkIn(scope))
288
- }
289
- const exportNow = Effect.andThen(runExport, disarmIfEmpty)
392
+ }))
393
+ : undefined
394
+
395
+ // A single finalizer stops the timer, drains, then stops active workers in
396
+ // that order even in a parallel scope. Workers are interrupted without
397
+ // waiting for them, so shutdown ends at `shutdownTimeout` even if the HTTP
398
+ // client is uninterruptible.
399
+ yield* Scope.addFinalizer(
400
+ scope,
401
+ Effect.suspend(() => {
402
+ timer?.interruptUnsafe()
403
+ return drain.pipe(
404
+ Effect.interruptible,
405
+ Effect.timeoutOption(options.shutdownTimeout),
406
+ Effect.andThen(Effect.sync(() => {
407
+ closed = true
408
+ MutableList.clear(queue)
409
+ notifyWaiters()
410
+ for (const fiber of inFlight.keys()) {
411
+ fiber.interruptUnsafe()
412
+ }
413
+ }))
414
+ )
415
+ })
416
+ )
290
417
 
291
418
  const flusher = yield* Flusher
292
- yield* flusher.register(exportNow)
419
+ yield* flusher.register(drain)
293
420
 
294
421
  return {
295
422
  push(data) {
296
423
  // With no idle timer, the next push ends the disabled window.
297
- if (isDisabled()) return
298
- buffer.push(data)
299
- if (options.maxBatchSize !== "disabled" && buffer.length >= options.maxBatchSize) {
300
- runExportFork(exportNow)
424
+ if (isStopped()) return
425
+ if (queue.length >= maxQueueSize) {
426
+ options.onDrop?.(1)
427
+ return
428
+ }
429
+ MutableList.append(queue, data)
430
+ if (queue.length >= batchLimit) {
431
+ startWorkers()
301
432
  } else {
302
433
  armed.openUnsafe()
303
434
  }
@@ -24,6 +24,7 @@ import type * as LogLevel from "../LogLevel.ts"
24
24
  import * as Option from "../Option.ts"
25
25
  import { CurrentLogAnnotations, CurrentLogSpans } from "../References.ts"
26
26
  import type * as Scope from "../Scope.ts"
27
+ import type { Concurrency } from "../Types.ts"
27
28
  import * as Version from "../Version.ts"
28
29
  import * as OtlpEnv from "./internal/otlpEnv.ts"
29
30
  import * as Exporter from "./OtlpExporter.ts"
@@ -60,6 +61,11 @@ export const make: (
60
61
  readonly compression?: "gzip" | "none" | undefined
61
62
  readonly exportInterval?: Duration.Input | undefined
62
63
  readonly maxBatchSize?: number | undefined
64
+ /** Maximum pending queued log records (does not include in-flight batches). */
65
+ readonly maxQueueSize?: number | undefined
66
+ /** Maximum concurrent export requests, or `"unbounded"`. Defaults to `4`. */
67
+ readonly concurrency?: Concurrency | undefined
68
+ readonly onDrop?: ((count: number) => void) | undefined
63
69
  readonly shutdownTimeout?: Duration.Input | undefined
64
70
  readonly excludeLogSpans?: boolean | undefined
65
71
  }
@@ -81,6 +87,9 @@ export const make: (
81
87
  headers: options.headers,
82
88
  compression: options.compression,
83
89
  maxBatchSize: options.maxBatchSize ?? 1000,
90
+ maxQueueSize: options.maxQueueSize,
91
+ concurrency: options.concurrency,
92
+ onDrop: options.onDrop,
84
93
  exportInterval: options.exportInterval ?? Duration.seconds(1),
85
94
  body: (data) => [
86
95
  serialization.logs({
@@ -132,6 +141,11 @@ export const layer = (options: {
132
141
  readonly compression?: "gzip" | "none" | undefined
133
142
  readonly exportInterval?: Duration.Input | undefined
134
143
  readonly maxBatchSize?: number | undefined
144
+ /** Maximum pending queued log records (does not include in-flight batches). */
145
+ readonly maxQueueSize?: number | undefined
146
+ /** Maximum concurrent export requests, or `"unbounded"`. Defaults to `4`. */
147
+ readonly concurrency?: Concurrency | undefined
148
+ readonly onDrop?: ((count: number) => void) | undefined
135
149
  readonly shutdownTimeout?: Duration.Input | undefined
136
150
  readonly excludeLogSpans?: boolean | undefined
137
151
  readonly mergeWithExisting?: boolean | undefined
@@ -161,6 +175,9 @@ export const layerFromConfig = (options?: {
161
175
  readonly attributes?: Record<string, unknown>
162
176
  } | undefined
163
177
  readonly headers?: Headers.Input | undefined
178
+ /** Maximum concurrent export requests, or `"unbounded"`. Defaults to `4`. */
179
+ readonly concurrency?: Concurrency | undefined
180
+ readonly onDrop?: ((count: number) => void) | undefined
164
181
  readonly excludeLogSpans?: boolean | undefined
165
182
  readonly mergeWithExisting?: boolean | undefined
166
183
  }): Layer.Layer<Exporter.Flusher, never, HttpClient.HttpClient | OtlpSerialization> =>
@@ -182,7 +199,8 @@ export const layerFromConfig = (options?: {
182
199
  logsTimeout,
183
200
  exportTimeout,
184
201
  scheduleDelay,
185
- maxBatchSize
202
+ maxBatchSize,
203
+ maxQueueSize
186
204
  } = yield* Config.all({
187
205
  baseCompression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
188
206
  compression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_LOGS_COMPRESSION")),
@@ -190,7 +208,8 @@ export const layerFromConfig = (options?: {
190
208
  logsTimeout: Config.option(Config.Int("OTEL_EXPORTER_OTLP_LOGS_TIMEOUT")),
191
209
  exportTimeout: Config.option(Config.Int("OTEL_BLRP_EXPORT_TIMEOUT")),
192
210
  scheduleDelay: Config.option(Config.Int("OTEL_BLRP_SCHEDULE_DELAY")),
193
- maxBatchSize: Config.option(Config.Int("OTEL_BLRP_MAX_EXPORT_BATCH_SIZE"))
211
+ maxBatchSize: Config.option(Config.Int("OTEL_BLRP_MAX_EXPORT_BATCH_SIZE")),
212
+ maxQueueSize: Config.option(Config.Int("OTEL_BLRP_MAX_QUEUE_SIZE"))
194
213
  })
195
214
 
196
215
  const shutdownTimeout = Option.firstSomeOf([logsTimeout, baseTimeout, exportTimeout]).pipe(
@@ -205,6 +224,9 @@ export const layerFromConfig = (options?: {
205
224
  compression: Option.getOrElse(Option.firstSomeOf([compression, baseCompression]), () => "none" as const),
206
225
  exportInterval: Option.getOrUndefined(exportInterval),
207
226
  maxBatchSize: Option.getOrUndefined(maxBatchSize),
227
+ maxQueueSize: Option.getOrUndefined(maxQueueSize),
228
+ concurrency: options?.concurrency,
229
+ onDrop: options?.onDrop,
208
230
  shutdownTimeout: Option.getOrUndefined(shutdownTimeout),
209
231
  excludeLogSpans: options?.excludeLogSpans,
210
232
  mergeWithExisting: options?.mergeWithExisting
@@ -396,6 +396,8 @@ export const make: (options: {
396
396
  headers: options.headers,
397
397
  compression: options.compression,
398
398
  maxBatchSize: "disabled",
399
+ // Each snapshot builds on the last one committed, so they go out one at a time.
400
+ concurrency: 1,
399
401
  exportEmpty: true,
400
402
  exportInterval: options.exportInterval ?? Duration.seconds(10),
401
403
  body: snapshot,