apps 0.0.1-beta.14 → 0.0.1-beta.140

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 (201) hide show
  1. package/README.md +60 -42
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-M3B3DE4K.js → chunk-2XDCAXAR.js} +612 -246
  4. package/js/{chunk-IPI4MFSN.js → chunk-34RH47V5.js} +2 -2
  5. package/js/chunk-5JBDHSLK.js +449 -0
  6. package/js/{chunk-KUMBKVJD.js → chunk-6QZVXLF2.js} +2 -2
  7. package/js/chunk-7MPPHKRW.js +5418 -0
  8. package/js/chunk-DQ6FIDC3.js +335 -0
  9. package/js/{chunk-5T57N25Q.js → chunk-EKXBHVMR.js} +697 -70
  10. package/js/chunk-EYZHR4UA.js +1945 -0
  11. package/js/chunk-GJG5G6CH.js +1022 -0
  12. package/js/chunk-H2K7OZ47.js +90 -0
  13. package/js/chunk-I6QAWNUM.js +161 -0
  14. package/js/{chunk-ODEIDRGW.js → chunk-JH3MOQZR.js} +1166 -504
  15. package/js/{chunk-QS6CAHKC.js → chunk-JHAHT26O.js} +4 -3
  16. package/js/{chunk-RFVIONFX.js → chunk-JIXIOWZP.js} +136 -45
  17. package/js/chunk-LSOHA2RH.js +88 -0
  18. package/js/{chunk-UK573G7W.js → chunk-MB6L5YZE.js} +1817 -632
  19. package/js/chunk-OBT33ZDK.js +95 -0
  20. package/js/{chunk-JU7VHODU.js → chunk-QTX7OUFH.js} +65 -10
  21. package/js/chunk-RBSXSRPU.js +175 -0
  22. package/js/chunk-SB2DNKDL.js +593 -0
  23. package/js/{chunk-VFZKSM3T.js → chunk-VX36SA7Y.js} +3 -3
  24. package/js/chunk-YF7TYPDS.js +49 -0
  25. package/js/{chunk-CDL5PM2Q.js → chunk-YFSOSNF3.js} +17265 -12477
  26. package/js/{chunk-IJX4CYZO.js → chunk-YVN2AMAU.js} +976 -447
  27. package/js/chunk-Z6DSU4VL.js +724 -0
  28. package/js/client.js +333 -98
  29. package/js/contracts.js +154 -21
  30. package/js/effect.js +18 -19
  31. package/js/graphql.js +231 -188
  32. package/js/host.js +138 -80
  33. package/js/index.js +153 -300
  34. package/js/mcp/effect.js +21 -21
  35. package/js/mcp.js +91 -57
  36. package/js/openapi.js +4950 -4201
  37. package/js/react.js +2 -3
  38. package/js/skills/effect.js +6 -3
  39. package/js/skills.js +220 -81
  40. package/js/storage/facet.js +1 -540
  41. package/js/ui/auth/contracts.js +2 -2
  42. package/js/ui/auth.js +5 -5
  43. package/js/ui/contracts.js +9 -8
  44. package/js/ui/serving.js +8618 -235
  45. package/package.json +3 -8
  46. package/runtime.json +1 -1
  47. package/types/app-cache/src/contracts/cache.d.ts +18 -0
  48. package/types/app-cache/src/index.d.ts +34 -2
  49. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  50. package/types/apps/src/contracts/app.d.ts +56 -11
  51. package/types/apps/src/contracts/cache.d.ts +20 -0
  52. package/types/apps/src/contracts/context.d.ts +60 -17
  53. package/types/apps/src/contracts/elicitation.d.ts +23 -7
  54. package/types/apps/src/contracts/events.d.ts +94 -0
  55. package/types/apps/src/contracts/failure.d.ts +30 -1
  56. package/types/apps/src/contracts/graphql.d.ts +40 -2
  57. package/types/apps/src/contracts/help-text.d.ts +31 -0
  58. package/types/apps/src/contracts/host.d.ts +1493 -20
  59. package/types/apps/src/contracts/icons.d.ts +28 -0
  60. package/types/apps/src/contracts/live.d.ts +2 -0
  61. package/types/apps/src/contracts/mcp.d.ts +81 -20
  62. package/types/apps/src/contracts/network.d.ts +120 -0
  63. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  64. package/types/apps/src/contracts/openapi-document.d.ts +1 -1
  65. package/types/apps/src/contracts/openapi.d.ts +47 -8
  66. package/types/apps/src/contracts/operations.d.ts +14 -7
  67. package/types/apps/src/contracts/placement.d.ts +102 -0
  68. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  69. package/types/apps/src/contracts/protocols/1.d.ts +513 -15
  70. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  71. package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
  72. package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
  73. package/types/apps/src/contracts/protocols/13.d.ts +6001 -0
  74. package/types/apps/src/contracts/protocols/2.d.ts +9 -8
  75. package/types/apps/src/contracts/protocols/3.d.ts +73 -15
  76. package/types/apps/src/contracts/protocols/4.d.ts +22 -15
  77. package/types/apps/src/contracts/protocols/5.d.ts +37 -11
  78. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  79. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  80. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  81. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  82. package/types/apps/src/contracts/protocols/current.d.ts +7114 -0
  83. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  84. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  85. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  86. package/types/apps/src/contracts/provider.d.ts +56 -0
  87. package/types/apps/src/contracts/router.d.ts +2 -1
  88. package/types/apps/src/contracts/schedules.d.ts +7 -1
  89. package/types/apps/src/contracts/schema.d.ts +21 -0
  90. package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
  91. package/types/apps/src/contracts/skills.d.ts +50 -13
  92. package/types/apps/src/contracts/sql.d.ts +63 -0
  93. package/types/apps/src/contracts/ui.d.ts +70 -30
  94. package/types/apps/src/contracts/webhooks.d.ts +24 -7
  95. package/types/apps/src/contracts/workflows.d.ts +56 -34
  96. package/types/apps/src/facet.d.ts +4 -5
  97. package/types/apps/src/host.d.ts +5 -0
  98. package/types/apps/src/implementation/account-router.d.ts +20 -3
  99. package/types/apps/src/implementation/app.d.ts +41 -14
  100. package/types/apps/src/implementation/authoring.d.ts +25 -5
  101. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  102. package/types/apps/src/implementation/cache.d.ts +29 -2
  103. package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
  104. package/types/apps/src/implementation/elicitation.d.ts +16 -13
  105. package/types/apps/src/implementation/events.d.ts +64 -0
  106. package/types/apps/src/implementation/failure-detail.d.ts +28 -5
  107. package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
  108. package/types/apps/src/implementation/graphql.d.ts +4 -3
  109. package/types/apps/src/implementation/help-text.d.ts +5 -0
  110. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  111. package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
  112. package/types/apps/src/implementation/live.d.ts +2 -2
  113. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  114. package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
  115. package/types/apps/src/implementation/mcp-client.d.ts +17 -9
  116. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  117. package/types/apps/src/implementation/mcp.d.ts +20 -9
  118. package/types/apps/src/implementation/network.d.ts +16 -0
  119. package/types/apps/src/implementation/openapi-compile.d.ts +33 -5
  120. package/types/apps/src/implementation/openapi-document.d.ts +35 -18
  121. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  122. package/types/apps/src/implementation/openapi-request.d.ts +2 -1
  123. package/types/apps/src/implementation/openapi-source.d.ts +23 -1
  124. package/types/apps/src/implementation/operations.d.ts +58 -7
  125. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  126. package/types/apps/src/implementation/placement.d.ts +60 -0
  127. package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
  128. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  129. package/types/apps/src/implementation/provider.d.ts +20 -4
  130. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  131. package/types/apps/src/implementation/router-catalog.d.ts +22 -97
  132. package/types/apps/src/implementation/router.d.ts +26 -6
  133. package/types/apps/src/implementation/schedules.d.ts +39 -8
  134. package/types/apps/src/implementation/schema.d.ts +148 -17
  135. package/types/apps/src/implementation/skills.d.ts +18 -24
  136. package/types/apps/src/implementation/sql.d.ts +71 -0
  137. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  138. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  139. package/types/apps/src/implementation/ui-client.d.ts +3 -3
  140. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  141. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  142. package/types/apps/src/implementation/ui-serving.d.ts +38 -12
  143. package/types/apps/src/implementation/upstream-error.d.ts +17 -0
  144. package/types/apps/src/implementation/webhooks.d.ts +15 -6
  145. package/types/apps/src/implementation/workflow-context.d.ts +6 -2
  146. package/types/apps/src/implementation/workflows.d.ts +11 -4
  147. package/types/apps/src/index.d.ts +67 -17
  148. package/types/apps/src/mcp.d.ts +20 -1
  149. package/types/apps/src/openapi.d.ts +22 -1
  150. package/types/apps/src/react.d.ts +1 -1
  151. package/types/apps/src/skills.d.ts +10 -8
  152. package/types/apps/src/ui-serving.d.ts +1 -2
  153. package/types/telemetry/src/app-records.d.ts +42 -0
  154. package/types/telemetry/src/browser-operations.d.ts +2 -2
  155. package/types/telemetry/src/browser.d.ts +8 -3
  156. package/types/telemetry/src/config.d.ts +2 -2
  157. package/types/telemetry/src/index.d.ts +3 -2
  158. package/types/telemetry/src/keepalive.d.ts +53 -0
  159. package/types/telemetry/src/layer.d.ts +10 -4
  160. package/types/telemetry/src/measurements.d.ts +6 -2
  161. package/types/telemetry/src/ownership.d.ts +60 -0
  162. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  163. package/types/telemetry/src/relay.d.ts +32 -7
  164. package/types/telemetry/src/span-attributes.d.ts +22 -3
  165. package/types/telemetry/src/transport.d.ts +10 -1
  166. package/types/utils/src/api-error.d.ts +55 -0
  167. package/types/utils/src/connection-failure.d.ts +33 -0
  168. package/types/utils/src/legacy-keys.d.ts +20 -0
  169. package/types/utils/src/random-uuid.d.ts +6 -0
  170. package/types/utils/src/recorded-message.d.ts +18 -0
  171. package/types/utils/src/schema-definitions.d.ts +13 -0
  172. package/types/utils/src/user-facing-error.d.ts +83 -0
  173. package/js/chunk-27F7W2LG.js +0 -34
  174. package/js/chunk-4ASNKGCV.js +0 -242
  175. package/js/chunk-4DWF4ZWI.js +0 -1280
  176. package/js/chunk-57RKNWL2.js +0 -75
  177. package/js/chunk-6HSH75OI.js +0 -2688
  178. package/js/chunk-G4FT53I7.js +0 -224
  179. package/js/chunk-MKWZPDR6.js +0 -63
  180. package/js/chunk-N7YDVXYJ.js +0 -186
  181. package/js/chunk-NKLWZJLE.js +0 -172
  182. package/js/chunk-PJJ24GU7.js +0 -877
  183. package/js/chunk-PZB6T6KU.js +0 -19
  184. package/js/chunk-R3EV5FTO.js +0 -97
  185. package/js/chunk-S73JGVR5.js +0 -507
  186. package/js/chunk-TG6DOCRO.js +0 -299
  187. package/js/chunk-YPKG2QO5.js +0 -209
  188. package/js/chunk-ZQINWV4W.js +0 -630
  189. package/js/mcp/stdio.js +0 -128
  190. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  191. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  192. package/types/app-data/src/implementation/promise.d.ts +0 -68
  193. package/types/app-data/src/implementation/range.d.ts +0 -8
  194. package/types/app-data/src/implementation/schema.d.ts +0 -18
  195. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  196. package/types/app-data/src/index.d.ts +0 -4
  197. package/types/apps/src/contracts/storage.d.ts +0 -68
  198. package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
  199. package/types/apps/src/implementation/storage.d.ts +0 -15
  200. package/types/apps/src/implementation/ui-watch.d.ts +0 -2
  201. package/types/apps/src/mcp-stdio.d.ts +0 -5
@@ -1,32 +1,41 @@
1
1
  import {
2
2
  FetchHttpClient_exports
3
- } from "./chunk-57RKNWL2.js";
3
+ } from "./chunk-I6QAWNUM.js";
4
+ import {
5
+ recordedMessage
6
+ } from "./chunk-LSOHA2RH.js";
4
7
  import {
5
8
  HttpBody_exports,
6
9
  HttpClient,
7
10
  HttpClientError_exports,
8
11
  HttpClientRequest_exports,
9
12
  HttpClient_exports,
13
+ HttpMiddleware_exports,
10
14
  HttpServerResponse_exports,
11
15
  HttpTraceContext_exports,
12
16
  TracerPropagationEnabled,
17
+ compressBody,
13
18
  filterStatusOk,
14
19
  isHttpClientError,
15
- jsonUnsafe,
16
20
  post,
17
21
  retryTransient,
18
22
  setBody,
23
+ tap,
24
+ tapError,
25
+ text,
19
26
  transformResponse,
20
27
  uint8Array
21
- } from "./chunk-UK573G7W.js";
28
+ } from "./chunk-MB6L5YZE.js";
22
29
  import {
23
30
  Array as Array2,
24
31
  Boolean2 as Boolean,
32
+ Cause_exports,
25
33
  Clock,
26
34
  Clock_exports,
27
35
  Context_exports,
28
36
  CurrentLogAnnotations,
29
37
  CurrentLogSpans,
38
+ Duration_exports,
30
39
  Effect_exports,
31
40
  Exit_exports,
32
41
  FiberSet_exports,
@@ -37,10 +46,12 @@ import {
37
46
  Logger_exports,
38
47
  Metric_exports,
39
48
  Option_exports,
49
+ Predicate_exports,
40
50
  Record2 as Record,
41
51
  Redacted_exports,
42
52
  Schema_exports,
43
53
  Scope,
54
+ Scope_exports,
44
55
  Semaphore_exports,
45
56
  Service,
46
57
  Stream_exports,
@@ -53,65 +64,68 @@ import {
53
64
  UndefinedOr,
54
65
  addDelay,
55
66
  addFinalizer,
56
- all,
57
- allocate,
67
+ all2 as all,
58
68
  andThen,
59
69
  annotateLogs,
60
70
  asVoid,
61
71
  awaitEmpty,
62
72
  await_,
63
73
  catchCause,
74
+ concat,
64
75
  context,
65
76
  effect,
66
77
  effectDiscard,
78
+ encode,
67
79
  ensure,
68
80
  firstSomeOf,
69
- flatMap,
70
- flatMap2,
81
+ flatMap2 as flatMap,
71
82
  flow,
72
83
  fnUntraced,
73
84
  forEach,
74
85
  forever,
75
- forever2,
76
86
  forkIn,
77
87
  format,
78
88
  fromInput2 as fromInput,
79
89
  fromInputUnsafe,
80
- fromRecordUnsafe,
81
- fromUndefinedOr,
82
90
  gen,
83
91
  get,
92
+ getCurrentVersion,
93
+ getOrElse,
84
94
  getOrUndefined,
85
95
  hasInterruptsOnly,
86
96
  identity,
87
97
  ignore,
88
98
  interruptible,
99
+ isFailure,
100
+ isFinite,
89
101
  isSome,
90
102
  layer,
91
103
  logDebug,
92
- make2 as make,
93
- make7 as make2,
94
- make8 as make3,
104
+ make,
105
+ make4 as make2,
106
+ make5 as make3,
107
+ make6 as make4,
95
108
  map,
96
- map3 as map2,
97
- map5 as map3,
109
+ map4 as map2,
110
+ map7 as map3,
98
111
  max,
99
- merge3 as merge,
100
112
  millis,
101
113
  option,
102
114
  orDie,
103
115
  orElse,
104
- parse,
116
+ parseRetryAfter,
105
117
  passthrough,
106
- pretty,
107
118
  prettyErrors,
108
119
  provideMerge,
109
120
  provideService,
110
- randomHex,
121
+ race,
122
+ random,
123
+ retryAfterDelay,
111
124
  run2 as run,
112
125
  runtime,
113
126
  schema,
114
127
  seconds,
128
+ set3 as set,
115
129
  sleep,
116
130
  snapshotUnsafe,
117
131
  succeed3 as succeed,
@@ -125,11 +139,172 @@ import {
125
139
  withDefault2 as withDefault,
126
140
  withTracerEnabled,
127
141
  zero
128
- } from "./chunk-CDL5PM2Q.js";
142
+ } from "./chunk-YFSOSNF3.js";
129
143
  import {
130
144
  __export
131
145
  } from "./chunk-CZ7CSFO4.js";
132
146
 
147
+ // ../telemetry/src/ownership.ts
148
+ var ownerAttribute = "executor.owner";
149
+ var SpanOwner = Context_exports.Reference("@executor-js/telemetry/SpanOwner", {
150
+ defaultValue: () => void 0
151
+ });
152
+ var declaredOwner = (annotations) => Context_exports.get(annotations, SpanOwner);
153
+ var ownedBy = (owner, options = {}) => ({
154
+ ...options,
155
+ annotations: Context_exports.add(options.annotations ?? Context_exports.empty(), SpanOwner, owner)
156
+ });
157
+ var owned = (owner, name, options) => (effect2) => effect2.pipe(Effect_exports.withSpan(name, ownedBy(owner, options)));
158
+ var measuredSpan = (name, options, measure) => (effect2) => Effect_exports.useSpan(name, options, (span) => {
159
+ const inner = Effect_exports.withParentSpan(effect2, span);
160
+ if (span.status._tag === "Ended") return inner;
161
+ const { around, end } = measure(span.status.startTime);
162
+ return (around === void 0 ? inner : around(inner)).pipe(
163
+ Effect_exports.onExit(
164
+ (exit) => Effect_exports.flatMap(
165
+ Clock_exports.currentTimeNanos,
166
+ (now) => Effect_exports.sync(() => {
167
+ end(now, span);
168
+ span.end(now, exit);
169
+ })
170
+ )
171
+ )
172
+ );
173
+ });
174
+ var concurrent = ["executor", "person", "upstream", "lease", "app"];
175
+ var noTime = () => ({
176
+ executor: 0,
177
+ app: 0,
178
+ upstream: 0,
179
+ person: 0,
180
+ lease: 0,
181
+ background: 0
182
+ });
183
+ var makeOwnershipAccounting = (origin, owner) => {
184
+ const totals = noTime();
185
+ const innermost = noTime();
186
+ const boundaries2 = /* @__PURE__ */ new WeakMap();
187
+ let reached = origin;
188
+ let done = false;
189
+ let background = 0;
190
+ const advance = (time) => {
191
+ if (time <= reached) return;
192
+ const current = concurrent.find((candidate) => innermost[candidate] > 0) ?? owner;
193
+ const elapsed = Number(time - reached) / 1e6;
194
+ totals[current] += elapsed;
195
+ if (background > 0) totals.background += elapsed;
196
+ reached = time;
197
+ };
198
+ const enclosing = (boundary) => {
199
+ let found = boundary.parent;
200
+ while (found !== void 0 && !found.open) found = found.parent;
201
+ boundary.parent = found;
202
+ return found;
203
+ };
204
+ const opened = (boundary) => {
205
+ if (boundary.owner === "background") {
206
+ background += 1;
207
+ return;
208
+ }
209
+ const parent = enclosing(boundary);
210
+ if (parent !== void 0 && parent.children++ === 0) innermost[parent.owner] -= 1;
211
+ innermost[boundary.owner] += 1;
212
+ };
213
+ const closed = (boundary) => {
214
+ boundary.open = false;
215
+ if (boundary.owner === "background") {
216
+ background -= 1;
217
+ return;
218
+ }
219
+ if (boundary.children === 0) innermost[boundary.owner] -= 1;
220
+ const parent = enclosing(boundary);
221
+ if (parent === void 0) return;
222
+ parent.children += boundary.children - 1;
223
+ if (parent.children === 0) innermost[parent.owner] += 1;
224
+ };
225
+ const observed = (tracer) => ({
226
+ ...tracer,
227
+ span: (options) => {
228
+ const span = tracer.span(options);
229
+ if (done) return span;
230
+ const parent = Option_exports.getOrUndefined(options.parent);
231
+ const enclosingBoundary = parent === void 0 ? void 0 : boundaries2.get(parent);
232
+ const inBackground = enclosingBoundary?.owner === "background";
233
+ const declared = inBackground ? "background" : declaredOwner(options.annotations);
234
+ const boundary = {
235
+ owner: declared ?? enclosingBoundary?.owner ?? owner,
236
+ // Background work runs beside its caller, which stays innermost meanwhile.
237
+ parent: declared === "background" ? void 0 : enclosingBoundary,
238
+ open: true,
239
+ children: 0
240
+ };
241
+ advance(options.startTime);
242
+ opened(boundary);
243
+ const tracked = {
244
+ _tag: "Span",
245
+ get name() {
246
+ return span.name;
247
+ },
248
+ get spanId() {
249
+ return span.spanId;
250
+ },
251
+ get traceId() {
252
+ return span.traceId;
253
+ },
254
+ get parent() {
255
+ return span.parent;
256
+ },
257
+ get annotations() {
258
+ return span.annotations;
259
+ },
260
+ get status() {
261
+ return span.status;
262
+ },
263
+ get attributes() {
264
+ return span.attributes;
265
+ },
266
+ get links() {
267
+ return span.links;
268
+ },
269
+ get sampled() {
270
+ return span.sampled;
271
+ },
272
+ get kind() {
273
+ return span.kind;
274
+ },
275
+ end: (endTime, exit) => {
276
+ if (boundary.open && !done) {
277
+ advance(endTime);
278
+ closed(boundary);
279
+ }
280
+ span.end(endTime, exit);
281
+ },
282
+ attribute: (key, value) => span.attribute(key, value),
283
+ event: (name, startTime, attributes2) => span.event(name, startTime, attributes2),
284
+ addLinks: (links) => span.addLinks(links)
285
+ };
286
+ boundaries2.set(tracked, boundary);
287
+ return tracked;
288
+ }
289
+ });
290
+ return {
291
+ /** Run `effect` with the spans it opens observed, including spans it hands to later work. */
292
+ observe: (effect2) => Effect_exports.gen(function* () {
293
+ const tracer = yield* Tracer_exports.Tracer;
294
+ return yield* effect2.pipe(Effect_exports.provideService(Tracer_exports.Tracer, observed(tracer)));
295
+ }),
296
+ /**
297
+ * Close the window at `end` and return its milliseconds by owner, each instant counted once.
298
+ * Spans still open count up to `end`; spans that open or end afterwards are ignored.
299
+ */
300
+ read: (end) => {
301
+ if (!done) advance(end);
302
+ done = true;
303
+ return totals;
304
+ }
305
+ };
306
+ };
307
+
133
308
  // ../telemetry/src/context.ts
134
309
  var captureTelemetry = Effect_exports.gen(function* () {
135
310
  let context2 = Context_exports.make(Tracer_exports.Tracer, yield* Tracer_exports.Tracer).pipe(
@@ -161,9 +336,10 @@ var invocationFetch = (signal) => Effect_exports.gen(function* () {
161
336
  const request = yield* Effect_exports.try(() => new Request(input, init));
162
337
  const client = yield* HttpClient_exports.HttpClient;
163
338
  const response = yield* client.execute(HttpClientRequest_exports.fromWeb(request)).pipe(
164
- Effect_exports.withSpan("provider.http.request", {
165
- attributes: { "http.request.method": request.method }
166
- }),
339
+ Effect_exports.withSpan(
340
+ "provider.http.request",
341
+ ownedBy("upstream", { attributes: { "http.request.method": request.method } })
342
+ ),
167
343
  Effect_exports.provideService(FetchHttpClient_exports.RequestInit, {
168
344
  cache: request.cache,
169
345
  credentials: request.credentials,
@@ -192,9 +368,12 @@ var invocationFetch = (signal) => Effect_exports.gen(function* () {
192
368
  streamed,
193
369
  HttpBody_exports.stream(
194
370
  body.stream.pipe(
195
- Stream_exports.withSpan("provider.http.response.read", {
196
- attributes: { "http.response.status_code": response.status }
197
- })
371
+ Stream_exports.withSpan(
372
+ "provider.http.response.read",
373
+ ownedBy("upstream", {
374
+ attributes: { "http.response.status_code": response.status }
375
+ })
376
+ )
198
377
  ),
199
378
  body.contentType,
200
379
  body.contentLength
@@ -487,15 +666,15 @@ function getTextEncoding() {
487
666
  const te = new globalThis.TextEncoder();
488
667
  const td = new globalThis.TextDecoder();
489
668
  globalThis[symbol] = {
490
- encodeUtf8(text) {
491
- return te.encode(text);
669
+ encodeUtf8(text3) {
670
+ return te.encode(text3);
492
671
  },
493
672
  decodeUtf8(bytes) {
494
673
  return td.decode(bytes);
495
674
  },
496
- checkUtf8(text) {
675
+ checkUtf8(text3) {
497
676
  try {
498
- encodeURIComponent(text);
677
+ encodeURIComponent(text3);
499
678
  return true;
500
679
  } catch (_) {
501
680
  return false;
@@ -700,8 +879,9 @@ var workerWall = Metric_exports.histogram("executor.worker.wall_ms", {
700
879
  attributes: { unit: "ms" },
701
880
  description: "Native Worker invocation wall time, including stream and cleanup lifetime, in milliseconds."
702
881
  });
703
- var recordExportFailure = (path, reason = "transport", records = 0) => {
704
- const signal = path.endsWith("/traces") ? "traces" : path.endsWith("/logs") ? "logs" : path.endsWith("/metrics") ? "metrics" : "other";
882
+ var signalOf = (path) => path.endsWith("/traces") ? "traces" : path.endsWith("/logs") ? "logs" : path.endsWith("/metrics") ? "metrics" : path === "app" ? "app" : "other";
883
+ var recordExportFailure = (path, reason, records = 0, elapsedMs) => {
884
+ const signal = signalOf(path);
705
885
  return Metric_exports.update(Metric_exports.withAttributes(exportFailures, { signal, reason }), 1).pipe(
706
886
  Effect_exports.andThen(
707
887
  Metric_exports.update(Metric_exports.withAttributes(rejectedRecords, { signal, reason }), records)
@@ -711,7 +891,8 @@ var recordExportFailure = (path, reason = "transport", records = 0) => {
711
891
  Effect_exports.annotateLogs({
712
892
  "executor.telemetry.signal": signal,
713
893
  "executor.telemetry.failure": reason,
714
- "executor.telemetry.rejected_records": records
894
+ "executor.telemetry.rejected_records": records,
895
+ ...elapsedMs === void 0 ? {} : { "executor.telemetry.elapsed_ms": elapsedMs }
715
896
  })
716
897
  )
717
898
  )
@@ -815,35 +996,40 @@ var telemetryHttpClient = Layer_exports.effect(
815
996
  (client) => client.pipe(
816
997
  HttpClient_exports.filterStatusOk,
817
998
  HttpClient_exports.transform(
818
- (response, request) => response.pipe(
819
- Effect_exports.tap(acknowledge),
820
- Effect_exports.timeout(telemetryRequestTimeout),
821
- Effect_exports.catchTag(
822
- "TimeoutError",
823
- () => Effect_exports.fail(
824
- new HttpClientError_exports.HttpClientError({
825
- reason: new HttpClientError_exports.TransportError({
826
- request,
827
- description: "Telemetry collector acknowledgement timed out"
999
+ (response, request) => Effect_exports.flatMap(Clock_exports.currentTimeMillis, (started) => {
1000
+ const path = new URL(request.url).pathname;
1001
+ const elapsed = Effect_exports.map(Clock_exports.currentTimeMillis, (now) => now - started);
1002
+ return response.pipe(
1003
+ Effect_exports.tap(acknowledge),
1004
+ Effect_exports.timeout(telemetryRequestTimeout),
1005
+ Effect_exports.catchTag(
1006
+ "TimeoutError",
1007
+ () => Effect_exports.fail(
1008
+ new HttpClientError_exports.HttpClientError({
1009
+ reason: new HttpClientError_exports.TransportError({
1010
+ request,
1011
+ description: "Telemetry collector acknowledgement timed out"
1012
+ })
828
1013
  })
829
- })
830
- )
831
- ),
832
- Effect_exports.tapError(
833
- (error) => recordExportFailure(
834
- new URL(request.url).pathname,
835
- HttpClientError_exports.isHttpClientError(error) && error.reason instanceof HttpClientError_exports.DecodeError ? "acknowledgement" : "transport"
836
- ).pipe(
837
- Effect_exports.annotateLogs({
838
- "executor.telemetry.http_status": error.response?.status ?? 0,
839
- "executor.telemetry.timed_out": error.reason instanceof HttpClientError_exports.TransportError && error.reason.description === "Telemetry collector acknowledgement timed out"
840
- })
1014
+ )
1015
+ ),
1016
+ Effect_exports.tapError((error) => {
1017
+ const reason = HttpClientError_exports.isHttpClientError(error) && error.reason instanceof HttpClientError_exports.DecodeError ? "acknowledgement" : "transport";
1018
+ return Effect_exports.flatMap(
1019
+ elapsed,
1020
+ (ms) => recordExportFailure(path, reason, 0, ms)
1021
+ ).pipe(
1022
+ Effect_exports.annotateLogs({
1023
+ "executor.telemetry.http_status": error.response?.status ?? 0,
1024
+ "executor.telemetry.timed_out": error.reason instanceof HttpClientError_exports.TransportError && error.reason.description === "Telemetry collector acknowledgement timed out"
1025
+ })
1026
+ );
1027
+ }),
1028
+ Effect_exports.onInterrupt(
1029
+ () => Effect_exports.flatMap(elapsed, (ms) => recordExportFailure(path, "interrupted", 0, ms))
841
1030
  )
842
- ),
843
- Effect_exports.onInterrupt(
844
- () => recordExportFailure(new URL(request.url).pathname, "interrupted")
845
- )
846
- )
1031
+ );
1032
+ })
847
1033
  ),
848
1034
  HttpClient_exports.withScope,
849
1035
  HttpClient_exports.transformResponse(Effect_exports.scoped)
@@ -851,6 +1037,67 @@ var telemetryHttpClient = Layer_exports.effect(
851
1037
  )
852
1038
  )
853
1039
  ).pipe(Layer_exports.provide(selectedClient));
1040
+ var retryDelay = (error) => Effect_exports.gen(function* () {
1041
+ if (!HttpClientError_exports.isHttpClientError(error) || error.reason._tag !== "StatusCodeError" || error.reason.response.status !== 429 && error.reason.response.status !== 503)
1042
+ return Duration_exports.seconds(1);
1043
+ const header = error.reason.response.headers["retry-after"]?.trim();
1044
+ if (header === void 0 || header === "")
1045
+ return Duration_exports.seconds(error.reason.response.status === 429 ? 5 : 1);
1046
+ const seconds2 = Number(header);
1047
+ if (Number.isFinite(seconds2)) return Duration_exports.seconds(seconds2 >= 0 ? seconds2 : 5);
1048
+ const date = Date.parse(header);
1049
+ if (Number.isNaN(date)) return Duration_exports.seconds(5);
1050
+ return Duration_exports.millis(Math.max(date - (yield* Clock_exports.currentTimeMillis), 1));
1051
+ });
1052
+ var retries = 3;
1053
+ var exportBudget = Duration_exports.seconds(27);
1054
+ var retryTelemetryExport = (client) => client.pipe(
1055
+ HttpClient_exports.transformResponse(
1056
+ (response) => Effect_exports.flatMap(Clock_exports.currentTimeMillis, (started) => {
1057
+ const attemptMs = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(telemetryRequestTimeout));
1058
+ const deadline = started + Duration_exports.toMillis(exportBudget);
1059
+ const attempt = (made) => response.pipe(
1060
+ Effect_exports.catchIf(
1061
+ (error) => made < retries && HttpClient_exports.isTransientError(error),
1062
+ (error) => Effect_exports.gen(function* () {
1063
+ const wanted = Duration_exports.toMillis(yield* retryDelay(error));
1064
+ const left = deadline - (yield* Clock_exports.currentTimeMillis) - attemptMs;
1065
+ if (left < 0) return yield* Effect_exports.fail(error);
1066
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(wanted, left)));
1067
+ return yield* attempt(made + 1);
1068
+ })
1069
+ )
1070
+ );
1071
+ return attempt(0);
1072
+ })
1073
+ )
1074
+ );
1075
+
1076
+ // ../telemetry/src/recorded-failure.ts
1077
+ var tagOf = (error) => Predicate_exports.hasProperty(error, "_tag") && Predicate_exports.isString(error._tag) ? error._tag : void 0;
1078
+ var recorded = (name, message) => {
1079
+ const error = new Error(message);
1080
+ error.name = name;
1081
+ error.stack = message === "" ? name : `${name}: ${message}`;
1082
+ return error;
1083
+ };
1084
+ var recordedError = (error) => {
1085
+ const tag = tagOf(error);
1086
+ if (tag !== void 0) return recorded(tag, recordedMessage(error) ?? "");
1087
+ if (!(error instanceof Error)) return recorded("UnrecognizedFailure", "");
1088
+ if (error.cause === void 0) return error;
1089
+ const copy = new Error(error.message, { cause: recordedError(error.cause) });
1090
+ copy.name = error.name;
1091
+ if (error.stack !== void 0) copy.stack = error.stack;
1092
+ return copy;
1093
+ };
1094
+ var recordedCause = (cause) => Cause_exports.fromReasons(
1095
+ cause.reasons.flatMap((reason) => {
1096
+ if (Cause_exports.isInterruptReason(reason)) return [reason];
1097
+ const replaced = Cause_exports.isFailReason(reason) ? Cause_exports.fail(recordedError(reason.error)) : Cause_exports.die(recordedError(reason.defect));
1098
+ return Cause_exports.annotate(replaced, Cause_exports.reasonAnnotations(reason)).reasons;
1099
+ })
1100
+ );
854
1101
 
855
1102
  // ../telemetry/src/span-attributes.ts
856
1103
  var LogicalOperationFailed = class extends Schema_exports.TaggedError()(
@@ -865,75 +1112,112 @@ var httpSpanAttributeAllowlist = /* @__PURE__ */ new Set([
865
1112
  "server.address",
866
1113
  "url.scheme",
867
1114
  // Path only. `url.full` and `url.query` carry the query string, so neither is listed.
1115
+ // Once a route is recorded, the path is that route's template (`allowlistedSpan`).
868
1116
  "url.path",
1117
+ // The router's matched path template, such as `/api/organizations/:organization`; no values.
1118
+ "http.route",
869
1119
  "http.request.header.content-type",
870
1120
  "http.request.header.content-length",
871
1121
  "http.request.header.user-agent",
872
1122
  "http.response.header.content-type",
873
1123
  "http.response.header.content-length",
874
1124
  // The server tracer records the user agent a second time under its own name.
875
- "user_agent.original"
1125
+ "user_agent.original",
1126
+ // The server tracer's remote address: the peer the host saw, or on Cloud the address
1127
+ // Cloudflare saw (`cf-connecting-ip`, which Cloudflare overwrites on every incoming request).
1128
+ "client.address"
876
1129
  ]);
877
1130
  var spanAttributeAllowed = (key) => {
878
1131
  const name = key.toLowerCase();
879
1132
  return !httpNamespaces.some((namespace) => name.startsWith(namespace)) || httpSpanAttributeAllowlist.has(name);
880
1133
  };
881
- var allowedEntries = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([key]) => spanAttributeAllowed(key)));
882
- var allowlistedSpan = (span) => ({
883
- _tag: "Span",
884
- get name() {
885
- return span.name;
886
- },
887
- get spanId() {
888
- return span.spanId;
889
- },
890
- get traceId() {
891
- return span.traceId;
892
- },
893
- get parent() {
894
- return span.parent;
895
- },
896
- get annotations() {
897
- return span.annotations;
898
- },
899
- get status() {
900
- return span.status;
901
- },
902
- get attributes() {
903
- return span.attributes;
904
- },
905
- get links() {
906
- return span.links;
907
- },
908
- get sampled() {
909
- return span.sampled;
910
- },
911
- get kind() {
912
- return span.kind;
913
- },
914
- // A successful transport can carry a failed domain operation. The producer
915
- // explicitly marks that outcome; arbitrary result payloads are never inspected.
916
- end: (endTime, exit) => span.end(
917
- endTime,
918
- Exit_exports.isSuccess(exit) && span.attributes.get("executor.outcome") === "failed" ? Exit_exports.fail(new LogicalOperationFailed()) : exit
919
- ),
920
- attribute: (key, value) => {
921
- if (spanAttributeAllowed(key)) span.attribute(key, value);
922
- },
923
- event: (name, startTime, attributes) => span.event(name, startTime, attributes === void 0 ? void 0 : allowedEntries(attributes)),
924
- addLinks: (links) => span.addLinks(links)
925
- });
926
- var spanAttributes = (clock, recordAll = false) => Layer_exports.effect(Tracer_exports.Tracer)(
1134
+ var allowedEntries = (attributes2) => Object.fromEntries(Object.entries(attributes2).filter(([key]) => spanAttributeAllowed(key)));
1135
+ var allowlistedSpan = (span, ended) => {
1136
+ let path = false;
1137
+ let route;
1138
+ return {
1139
+ _tag: "Span",
1140
+ get name() {
1141
+ return span.name;
1142
+ },
1143
+ get spanId() {
1144
+ return span.spanId;
1145
+ },
1146
+ get traceId() {
1147
+ return span.traceId;
1148
+ },
1149
+ get parent() {
1150
+ return span.parent;
1151
+ },
1152
+ get annotations() {
1153
+ return span.annotations;
1154
+ },
1155
+ get status() {
1156
+ return span.status;
1157
+ },
1158
+ get attributes() {
1159
+ return span.attributes;
1160
+ },
1161
+ get links() {
1162
+ return span.links;
1163
+ },
1164
+ get sampled() {
1165
+ return span.sampled;
1166
+ },
1167
+ get kind() {
1168
+ return span.kind;
1169
+ },
1170
+ // A successful transport can carry a failed domain operation. The producer
1171
+ // explicitly marks that outcome; arbitrary result payloads are never inspected.
1172
+ // A failure records the fixed message an error declares in place of an app's text.
1173
+ end: (endTime, exit) => {
1174
+ span.end(
1175
+ endTime,
1176
+ Exit_exports.isSuccess(exit) ? span.attributes.get("executor.outcome") === "failed" ? Exit_exports.fail(new LogicalOperationFailed()) : exit : Exit_exports.failCause(recordedCause(exit.cause))
1177
+ );
1178
+ ended();
1179
+ },
1180
+ attribute: (key, value) => {
1181
+ if (!spanAttributeAllowed(key)) return;
1182
+ if (key === "url.path" && typeof value === "string") {
1183
+ path = true;
1184
+ span.attribute(key, route ?? value);
1185
+ return;
1186
+ }
1187
+ if (key === "http.route" && typeof value === "string") {
1188
+ route = value;
1189
+ if (path) span.attribute("url.path", value);
1190
+ }
1191
+ span.attribute(key, value);
1192
+ },
1193
+ event: (name, startTime, attributes2) => span.event(
1194
+ name,
1195
+ startTime,
1196
+ attributes2 === void 0 ? void 0 : allowedEntries(attributes2)
1197
+ ),
1198
+ addLinks: (links) => span.addLinks(links)
1199
+ };
1200
+ };
1201
+ var httpSpanNames = Layer_exports.mergeAll(
1202
+ Layer_exports.succeed(HttpMiddleware_exports.SpanNameGenerator, (request) => `http.server ${request.method}`),
1203
+ Layer_exports.succeed(HttpClient_exports.SpanNameGenerator, (request) => `http.client ${request.method}`)
1204
+ );
1205
+ var spanAttributes = (clock, recordAll = false, ended = () => {
1206
+ }) => Layer_exports.merge(httpSpanNames, tracerWithAllowlist(clock, recordAll, ended));
1207
+ var tracerWithAllowlist = (clock, recordAll, ended) => Layer_exports.effect(Tracer_exports.Tracer)(
927
1208
  Tracer_exports.Tracer.pipe(
928
1209
  Effect_exports.map((tracer) => ({
929
1210
  ...tracer,
930
1211
  span: (options) => {
931
1212
  const span = allowlistedSpan(
932
- tracer.span(recordAll ? { ...options, sampled: true } : options)
1213
+ tracer.span(recordAll ? { ...options, sampled: true } : options),
1214
+ ended
933
1215
  );
934
1216
  if (recordAll && Option_exports.isSome(options.parent) && options.parent.value._tag === "ExternalSpan")
935
1217
  span.attribute("executor.trace.parent_sampled", options.parent.value.sampled);
936
1218
  if (clock !== void 0) span.attribute("executor.clock.type", clock);
1219
+ const owner = declaredOwner(options.annotations);
1220
+ if (owner !== void 0) span.attribute(ownerAttribute, owner);
937
1221
  return span;
938
1222
  }
939
1223
  }))
@@ -941,15 +1225,15 @@ var spanAttributes = (clock, recordAll = false) => Layer_exports.effect(Tracer_e
941
1225
  );
942
1226
  var allowlistedSpans = spanAttributes();
943
1227
 
944
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpLogger.js
1228
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpLogger.js
945
1229
  var OtlpLogger_exports = {};
946
1230
  __export(OtlpLogger_exports, {
947
1231
  layer: () => layer2,
948
1232
  layerFromConfig: () => layerFromConfig,
949
- make: () => make6
1233
+ make: () => make7
950
1234
  });
951
1235
 
952
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/internal/otlpEnv.js
1236
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/internal/otlpEnv.js
953
1237
  var exporterList = (path) => Array2(String2, path).pipe(map3((_) => _.map((_2) => _2.toLowerCase().trim()).filter((_2) => _2 !== "")));
954
1238
  var headersRecord = (path) => Record(String2, StringFromUriComponent, path);
955
1239
  var headers = (signal) => headersRecord(`OTEL_EXPORTER_OTLP_${signal}_HEADERS`).pipe(orElse(() => headersRecord("OTEL_EXPORTER_OTLP_HEADERS")), withDefault(void 0));
@@ -960,32 +1244,25 @@ var endpoint = (signal) => URL2(`OTEL_EXPORTER_OTLP_${signal}_ENDPOINT`).pipe(or
960
1244
  }))), withDefault(void 0));
961
1245
  var exporters = (signal) => exporterList(`OTEL_${signal}_EXPORTER`).pipe(withDefault([]));
962
1246
 
963
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpExporter.js
1247
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpExporter.js
964
1248
  var OtlpExporter_exports = {};
965
1249
  __export(OtlpExporter_exports, {
966
1250
  Flusher: () => Flusher,
967
1251
  layerFlusher: () => layerFlusher,
968
- make: () => make4
1252
+ make: () => make5
969
1253
  });
970
- var retryAfterDelay = (value) => {
971
- const seconds2 = fromUndefinedOr(value).pipe(flatMap(parse));
972
- if (isSome(seconds2)) {
973
- return succeed2(seconds(seconds2.value));
974
- }
975
- if (value === void 0) {
976
- return succeed2(seconds(5));
977
- }
978
- const timestamp = Date.parse(value);
979
- if (Number.isNaN(timestamp)) {
1254
+ var retryAfterDelay2 = (value) => {
1255
+ const retryAfter = value === void 0 ? void 0 : parseRetryAfter(value);
1256
+ if (retryAfter === void 0 || isFailure(retryAfter)) {
980
1257
  return succeed2(seconds(5));
981
1258
  }
982
- return map2(Clock, (clock) => millis(Math.max(timestamp - clock.currentTimeMillisUnsafe(), 1)));
1259
+ return map2(Clock, (clock) => retryAfterDelay(retryAfter.success, clock.currentTimeMillisUnsafe()));
983
1260
  };
984
1261
  var policy = /* @__PURE__ */ forever.pipe(passthrough, /* @__PURE__ */ addDelay(({
985
1262
  output: error
986
1263
  }) => {
987
1264
  if (isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429) {
988
- return retryAfterDelay(error.reason.response.headers["retry-after"]);
1265
+ return retryAfterDelay2(error.reason.response.headers["retry-after"]);
989
1266
  }
990
1267
  return succeed2(seconds(1));
991
1268
  }));
@@ -1003,45 +1280,47 @@ var layerFlusher = /* @__PURE__ */ sync(Flusher, () => {
1003
1280
  discard: true
1004
1281
  });
1005
1282
  }),
1006
- register: (run2) => flatMap2(Scope, (scope) => {
1283
+ register: (run2) => flatMap(Scope, (scope) => {
1007
1284
  registry.add(run2);
1008
1285
  return addFinalizer(scope, sync2(() => registry.delete(run2)));
1009
1286
  })
1010
1287
  };
1011
1288
  });
1012
- var make4 = /* @__PURE__ */ fnUntraced(function* (options) {
1289
+ var make5 = /* @__PURE__ */ fnUntraced(function* (options) {
1013
1290
  const services = yield* context();
1014
1291
  const clock = get(services, Clock);
1015
1292
  const scope = get(services, Scope);
1016
1293
  const exportInterval = max(fromInputUnsafe(options.exportInterval), zero);
1017
- let disabledUntil = void 0;
1018
- const client = filterStatusOk(get(services, HttpClient)).pipe(transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
1294
+ const client = get(services, HttpClient).pipe(tap((response) => ignore(response.arrayBuffer)), tapError((error) => error.response ? ignore(error.response.arrayBuffer) : void_), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
1019
1295
  schedule: policy,
1020
1296
  times: 3
1021
1297
  }));
1022
- let headers2 = fromRecordUnsafe({
1023
- "user-agent": `effect-opentelemetry-${options.label}/0.0.0`
1024
- });
1025
- if (options.headers) {
1026
- headers2 = merge(fromInput(options.headers), headers2);
1027
- }
1298
+ const exporterUserAgent = `OTel-OTLP-Exporter-JavaScript-Effect-${options.label}/${getCurrentVersion()}`;
1299
+ const userHeaders = fromInput(options.headers);
1300
+ const userAgent = userHeaders["user-agent"];
1301
+ const headers2 = set(userHeaders, "user-agent", userAgent ? `${userAgent} ${exporterUserAgent}` : exporterUserAgent);
1028
1302
  const request = post(options.url, {
1029
1303
  headers: headers2
1030
1304
  });
1305
+ const exportsEmpty = options.maxBatchSize === "disabled" && options.exportEmpty === true;
1031
1306
  let buffer = [];
1307
+ let disabledUntil = void 0;
1308
+ const isDisabled = () => {
1309
+ if (disabledUntil === void 0) return false;
1310
+ if (clock.currentTimeMillisUnsafe() < disabledUntil) return true;
1311
+ disabledUntil = void 0;
1312
+ return false;
1313
+ };
1032
1314
  const runExport = suspend(() => {
1033
- if (disabledUntil !== void 0 && clock.currentTimeMillisUnsafe() < disabledUntil) {
1034
- return void_;
1035
- } else if (disabledUntil !== void 0) {
1036
- disabledUntil = void 0;
1037
- }
1038
- if (buffer.length === 0 && (options.maxBatchSize !== "disabled" || options.exportEmpty !== true)) {
1315
+ if (isDisabled() || buffer.length === 0 && !exportsEmpty) {
1039
1316
  return void_;
1040
1317
  }
1041
1318
  const items = buffer;
1042
1319
  buffer = [];
1043
1320
  const [body, onSuccess] = options.body(items);
1044
- return client.execute(setBody(request, body)).pipe(andThen(onSuccess), asVoid, withTracerEnabled(false));
1321
+ const batchRequest = setBody(request, body);
1322
+ const response = options.compression === "gzip" ? compressBody(batchRequest, "gzip").pipe(flatMap(client.execute)) : client.execute(batchRequest);
1323
+ return response.pipe(andThen(onSuccess), asVoid, withTracerEnabled(false));
1045
1324
  }).pipe(catchCause((cause) => {
1046
1325
  if (disabledUntil !== void 0) return void_;
1047
1326
  disabledUntil = clock.currentTimeMillisUnsafe() + 6e4;
@@ -1051,63 +1330,81 @@ var make4 = /* @__PURE__ */ fnUntraced(function* (options) {
1051
1330
  package: "@effect/opentelemetry",
1052
1331
  module: options.label
1053
1332
  }));
1054
- const exportFibers = yield* make2();
1333
+ const exportFibers = yield* make3();
1055
1334
  const runExportFork = yield* runtime(exportFibers)();
1056
- const flusher = yield* Flusher;
1057
- yield* flusher.register(runExport);
1058
1335
  yield* addFinalizer(scope, suspend(() => {
1059
1336
  if (disabledUntil !== void 0) return void_;
1060
1337
  runExportFork(runExport);
1061
1338
  return awaitEmpty(exportFibers);
1062
1339
  }).pipe(ignore, interruptible, timeoutOption(options.shutdownTimeout)));
1063
- yield* sleep(exportInterval).pipe(andThen(run(exportFibers, runExport)), flatMap2(await_), forever2, forkIn(scope));
1340
+ const timed = isFinite(exportInterval);
1341
+ const armed = yield* make2(exportsEmpty);
1342
+ const wake = yield* make2();
1343
+ const disarmIfEmpty = sync2(() => {
1344
+ if (exportsEmpty || buffer.length > 0 || !armed.closeUnsafe()) return;
1345
+ wake.openUnsafe();
1346
+ });
1347
+ if (timed) {
1348
+ yield* gen(function* () {
1349
+ while (true) {
1350
+ wake.closeUnsafe();
1351
+ yield* armed.await;
1352
+ yield* race(sleep(exportInterval), wake.await);
1353
+ yield* await_(yield* run(exportFibers, runExport));
1354
+ yield* disarmIfEmpty;
1355
+ }
1356
+ }).pipe(forkIn(scope));
1357
+ }
1358
+ const exportNow = andThen(runExport, disarmIfEmpty);
1359
+ const flusher = yield* Flusher;
1360
+ yield* flusher.register(exportNow);
1064
1361
  return {
1065
1362
  push(data) {
1066
- if (disabledUntil !== void 0) return;
1363
+ if (isDisabled()) return;
1067
1364
  buffer.push(data);
1068
1365
  if (options.maxBatchSize !== "disabled" && buffer.length >= options.maxBatchSize) {
1069
- runExportFork(runExport);
1366
+ runExportFork(exportNow);
1367
+ } else if (timed) {
1368
+ armed.openUnsafe();
1070
1369
  }
1071
1370
  }
1072
1371
  };
1073
1372
  });
1074
1373
 
1075
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpResource.js
1076
- var make5 = (options) => {
1077
- const resourceAttributes = options.attributes ? entriesToAttributes(Object.entries(options.attributes)) : [];
1078
- resourceAttributes.push({
1079
- key: "service.name",
1080
- value: {
1081
- stringValue: options.serviceName
1082
- }
1083
- });
1084
- if (options.serviceVersion) {
1085
- resourceAttributes.push({
1086
- key: "service.version",
1087
- value: {
1088
- stringValue: options.serviceVersion
1089
- }
1090
- });
1091
- }
1092
- return {
1093
- attributes: resourceAttributes,
1094
- droppedAttributesCount: 0
1095
- };
1096
- };
1374
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpResource.js
1375
+ var isBrowser = "window" in globalThis || "importScripts" in globalThis;
1376
+ var make6 = (options) => ({
1377
+ attributes: entriesToAttributes(Object.entries({
1378
+ "telemetry.sdk.name": "effect",
1379
+ "telemetry.sdk.language": isBrowser ? "webjs" : "nodejs",
1380
+ "telemetry.sdk.version": getCurrentVersion(),
1381
+ ...options.attributes,
1382
+ ...options.serviceName ? {
1383
+ "service.name": options.serviceName
1384
+ } : void 0,
1385
+ ...options.serviceVersion ? {
1386
+ "service.version": options.serviceVersion
1387
+ } : void 0
1388
+ })),
1389
+ droppedAttributesCount: 0
1390
+ });
1097
1391
  var fromConfig = /* @__PURE__ */ fnUntraced(function* (options) {
1098
- const env = yield* Record(StringFromUriComponent, StringFromUriComponent, "OTEL_RESOURCE_ATTRIBUTES").pipe(withDefault(void 0));
1392
+ const env = yield* Record(StringFromUriComponent, StringFromUriComponent, "OTEL_RESOURCE_ATTRIBUTES", {
1393
+ trim: true,
1394
+ keepEmptyValues: true
1395
+ }).pipe(withDefault(void 0));
1099
1396
  const serviceName = options?.serviceName ?? options?.attributes?.["service.name"] ?? (yield* schema(UndefinedOr(String2), "OTEL_SERVICE_NAME")) ?? env?.["service.name"] ?? (yield* String3("OTEL_SERVICE_NAME"));
1100
1397
  const serviceVersion = options?.serviceVersion ?? options?.attributes?.["service.version"] ?? (yield* schema(UndefinedOr(String2), "OTEL_SERVICE_VERSION")) ?? env?.["service.version"];
1101
- const attributes = {
1398
+ const attributes2 = {
1102
1399
  ...env,
1103
1400
  ...options?.attributes
1104
1401
  };
1105
- delete attributes["service.name"];
1106
- delete attributes["service.version"];
1107
- return make5({
1402
+ delete attributes2["service.name"];
1403
+ delete attributes2["service.version"];
1404
+ return make6({
1108
1405
  serviceName,
1109
1406
  serviceVersion,
1110
- attributes
1407
+ attributes: attributes2
1111
1408
  });
1112
1409
  }, orDie);
1113
1410
  var serviceNameUnsafe = (resource) => {
@@ -1118,15 +1415,16 @@ var serviceNameUnsafe = (resource) => {
1118
1415
  return serviceNameAttribute.value.stringValue;
1119
1416
  };
1120
1417
  var entriesToAttributes = (entries) => {
1121
- const attributes = [];
1418
+ const attributes2 = [];
1122
1419
  for (const [key, value] of entries) {
1123
- attributes.push({
1420
+ attributes2.push({
1124
1421
  key,
1125
1422
  value: unknownToAttributeValue(value)
1126
1423
  });
1127
1424
  }
1128
- return attributes;
1425
+ return attributes2;
1129
1426
  };
1427
+ var int64Bound = 2 ** 63;
1130
1428
  var unknownToAttributeValue = (value) => {
1131
1429
  if (Array.isArray(value)) {
1132
1430
  return {
@@ -1141,12 +1439,15 @@ var unknownToAttributeValue = (value) => {
1141
1439
  stringValue: value
1142
1440
  };
1143
1441
  case "bigint":
1144
- return {
1442
+ return BigInt.asIntN(64, value) === value ? {
1145
1443
  intValue: String(value)
1444
+ } : {
1445
+ stringValue: String(value)
1146
1446
  };
1147
1447
  case "number":
1148
- return Number.isInteger(value) ? {
1149
- intValue: value
1448
+ return Number.isInteger(value) && value >= -int64Bound && value < int64Bound ? {
1449
+ // Unsafe integers would be rounded when written as JSON numbers
1450
+ intValue: Number.isSafeInteger(value) ? value : String(BigInt(value))
1150
1451
  } : {
1151
1452
  doubleValue: value
1152
1453
  };
@@ -1161,7 +1462,7 @@ var unknownToAttributeValue = (value) => {
1161
1462
  }
1162
1463
  };
1163
1464
 
1164
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpSerialization.js
1465
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpSerialization.js
1165
1466
  var OtlpSerialization_exports = {};
1166
1467
  __export(OtlpSerialization_exports, {
1167
1468
  OtlpSerialization: () => OtlpSerialization,
@@ -1169,7 +1470,7 @@ __export(OtlpSerialization_exports, {
1169
1470
  layerProtobuf: () => layerProtobuf
1170
1471
  });
1171
1472
 
1172
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/internal/protobuf.js
1473
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/internal/protobuf.js
1173
1474
  var WireType2 = {
1174
1475
  Varint: 0,
1175
1476
  Fixed64: 1,
@@ -1216,29 +1517,21 @@ var encodeHexBytes = (hex) => {
1216
1517
  }
1217
1518
  return bytes;
1218
1519
  };
1219
- var concat = (...arrays) => {
1220
- const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
1221
- const result = new Uint8Array(totalLength);
1222
- let offset = 0;
1223
- for (const arr of arrays) {
1224
- result.set(arr, offset);
1225
- offset += arr.length;
1226
- }
1227
- return result;
1228
- };
1229
- var varintField = (fieldNumber, value) => concat(encodeVarint(encodeTag(fieldNumber, WireType2.Varint)), encodeVarint(value));
1520
+ var concat2 = (...arrays) => concat(arrays);
1521
+ var varintField = (fieldNumber, value) => concat2(encodeVarint(encodeTag(fieldNumber, WireType2.Varint)), encodeVarint(value));
1230
1522
  var boolField = (fieldNumber, value) => varintField(fieldNumber, value ? 1 : 0);
1231
- var fixed64Field = (fieldNumber, value) => concat(encodeVarint(encodeTag(fieldNumber, WireType2.Fixed64)), encodeFixed64(value));
1232
- var fixed32Field = (fieldNumber, value) => concat(encodeVarint(encodeTag(fieldNumber, WireType2.Fixed32)), encodeFixed32(value));
1233
- var doubleField = (fieldNumber, value) => concat(encodeVarint(encodeTag(fieldNumber, WireType2.Fixed64)), encodeDouble(value));
1234
- var lengthDelimitedField = (fieldNumber, value) => concat(encodeVarint(encodeTag(fieldNumber, WireType2.LengthDelimited)), encodeVarint(value.length), value);
1523
+ var fixed64Field = (fieldNumber, value) => concat2(encodeVarint(encodeTag(fieldNumber, WireType2.Fixed64)), encodeFixed64(value));
1524
+ var fixed32Field = (fieldNumber, value) => concat2(encodeVarint(encodeTag(fieldNumber, WireType2.Fixed32)), encodeFixed32(value));
1525
+ var doubleField = (fieldNumber, value) => concat2(encodeVarint(encodeTag(fieldNumber, WireType2.Fixed64)), encodeDouble(value));
1526
+ var lengthDelimitedField = (fieldNumber, value) => concat2(encodeVarint(encodeTag(fieldNumber, WireType2.LengthDelimited)), encodeVarint(value.length), value);
1235
1527
  var stringField = (fieldNumber, value) => lengthDelimitedField(fieldNumber, encodeString(value));
1236
1528
  var bytesFieldFromHex = (fieldNumber, hex) => lengthDelimitedField(fieldNumber, encodeHexBytes(hex));
1237
1529
  var messageField = (fieldNumber, message) => lengthDelimitedField(fieldNumber, message);
1238
- var repeatedField = (fieldNumber, values, encode) => concat(...values.map((v) => messageField(fieldNumber, encode(v))));
1530
+ var repeatedField = (fieldNumber, values, encode2) => concat2(...values.map((v) => messageField(fieldNumber, encode2(v))));
1239
1531
  var optionalStringField = (fieldNumber, value) => value !== void 0 && value !== "" ? stringField(fieldNumber, value) : new Uint8Array(0);
1532
+ var optionalFixed64Field = (fieldNumber, value) => value !== void 0 ? fixed64Field(fieldNumber, BigInt(value)) : new Uint8Array(0);
1240
1533
 
1241
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/internal/otlpProtobuf.js
1534
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/internal/otlpProtobuf.js
1242
1535
  var encodeAnyValue = (value) => {
1243
1536
  if (value.stringValue !== void 0 && value.stringValue !== null) {
1244
1537
  return stringField(1, value.stringValue);
@@ -1265,41 +1558,52 @@ var encodeAnyValue = (value) => {
1265
1558
  };
1266
1559
  var encodeArrayValue = (value) => repeatedField(1, value.values, encodeAnyValue);
1267
1560
  var encodeKeyValueList = (value) => repeatedField(1, value.values, encodeKeyValue);
1268
- var encodeKeyValue = (kv) => concat(stringField(1, kv.key), messageField(2, encodeAnyValue(kv.value)));
1269
- var encodeInstrumentationScope = (scope) => concat(stringField(1, scope.name), optionalStringField(2, scope.version), scope.attributes ? repeatedField(3, scope.attributes, encodeKeyValue) : new Uint8Array(0), scope.droppedAttributesCount ? varintField(4, scope.droppedAttributesCount) : new Uint8Array(0));
1270
- var encodeResource = (resource) => concat(repeatedField(1, resource.attributes, encodeKeyValue), resource.droppedAttributesCount > 0 ? varintField(2, resource.droppedAttributesCount) : new Uint8Array(0));
1271
- var encodeStatus = (status) => concat(optionalStringField(2, status.message), varintField(3, status.code));
1272
- var encodeEvent = (event) => concat(fixed64Field(1, BigInt(event.timeUnixNano)), stringField(2, event.name), repeatedField(3, event.attributes, encodeKeyValue), event.droppedAttributesCount > 0 ? varintField(4, event.droppedAttributesCount) : new Uint8Array(0));
1273
- var encodeLink = (link) => concat(bytesFieldFromHex(1, link.traceId), bytesFieldFromHex(2, link.spanId), optionalStringField(3, link.traceState), repeatedField(4, link.attributes, encodeKeyValue), link.droppedAttributesCount > 0 ? varintField(5, link.droppedAttributesCount) : new Uint8Array(0), link.flags !== void 0 ? fixed32Field(6, link.flags) : new Uint8Array(0));
1274
- var encodeSpan = (span) => concat(bytesFieldFromHex(1, span.traceId), bytesFieldFromHex(2, span.spanId), optionalStringField(3, span.traceState), span.parentSpanId !== void 0 ? bytesFieldFromHex(4, span.parentSpanId) : new Uint8Array(0), stringField(5, span.name), varintField(6, span.kind), fixed64Field(7, BigInt(span.startTimeUnixNano)), fixed64Field(8, BigInt(span.endTimeUnixNano)), repeatedField(9, span.attributes, encodeKeyValue), span.droppedAttributesCount > 0 ? varintField(10, span.droppedAttributesCount) : new Uint8Array(0), repeatedField(11, span.events, encodeEvent), span.droppedEventsCount > 0 ? varintField(12, span.droppedEventsCount) : new Uint8Array(0), repeatedField(13, span.links, encodeLink), span.droppedLinksCount > 0 ? varintField(14, span.droppedLinksCount) : new Uint8Array(0), messageField(15, encodeStatus(span.status)), span.flags !== void 0 ? fixed32Field(16, span.flags) : new Uint8Array(0));
1275
- var encodeScopeSpans = (scopeSpans) => concat(messageField(1, encodeInstrumentationScope(scopeSpans.scope)), repeatedField(2, scopeSpans.spans, encodeSpan), optionalStringField(3, scopeSpans.schemaUrl));
1276
- var encodeResourceSpans = (resourceSpans) => concat(messageField(1, encodeResource(resourceSpans.resource)), repeatedField(2, resourceSpans.scopeSpans, encodeScopeSpans), optionalStringField(3, resourceSpans.schemaUrl));
1561
+ var encodeKeyValue = (kv) => concat2(stringField(1, kv.key), messageField(2, encodeAnyValue(kv.value)));
1562
+ var encodeInstrumentationScope = (scope) => concat2(stringField(1, scope.name), optionalStringField(2, scope.version), scope.attributes ? repeatedField(3, scope.attributes, encodeKeyValue) : new Uint8Array(0), scope.droppedAttributesCount ? varintField(4, scope.droppedAttributesCount) : new Uint8Array(0));
1563
+ var encodeResource = (resource) => concat2(repeatedField(1, resource.attributes, encodeKeyValue), resource.droppedAttributesCount > 0 ? varintField(2, resource.droppedAttributesCount) : new Uint8Array(0));
1564
+ var encodeStatus = (status2) => concat2(optionalStringField(2, status2.message), varintField(3, status2.code));
1565
+ var encodeEvent = (event) => concat2(fixed64Field(1, BigInt(event.timeUnixNano)), stringField(2, event.name), repeatedField(3, event.attributes, encodeKeyValue), event.droppedAttributesCount > 0 ? varintField(4, event.droppedAttributesCount) : new Uint8Array(0));
1566
+ var encodeLink = (link) => concat2(bytesFieldFromHex(1, link.traceId), bytesFieldFromHex(2, link.spanId), optionalStringField(3, link.traceState), repeatedField(4, link.attributes, encodeKeyValue), link.droppedAttributesCount > 0 ? varintField(5, link.droppedAttributesCount) : new Uint8Array(0), link.flags !== void 0 ? fixed32Field(6, link.flags) : new Uint8Array(0));
1567
+ var encodeSpan = (span) => concat2(bytesFieldFromHex(1, span.traceId), bytesFieldFromHex(2, span.spanId), optionalStringField(3, span.traceState), span.parentSpanId !== void 0 ? bytesFieldFromHex(4, span.parentSpanId) : new Uint8Array(0), stringField(5, span.name), varintField(6, span.kind), fixed64Field(7, BigInt(span.startTimeUnixNano)), fixed64Field(8, BigInt(span.endTimeUnixNano)), repeatedField(9, span.attributes, encodeKeyValue), span.droppedAttributesCount > 0 ? varintField(10, span.droppedAttributesCount) : new Uint8Array(0), repeatedField(11, span.events, encodeEvent), span.droppedEventsCount > 0 ? varintField(12, span.droppedEventsCount) : new Uint8Array(0), repeatedField(13, span.links, encodeLink), span.droppedLinksCount > 0 ? varintField(14, span.droppedLinksCount) : new Uint8Array(0), messageField(15, encodeStatus(span.status)), span.flags !== void 0 ? fixed32Field(16, span.flags) : new Uint8Array(0));
1568
+ var encodeScopeSpans = (scopeSpans) => concat2(messageField(1, encodeInstrumentationScope(scopeSpans.scope)), repeatedField(2, scopeSpans.spans, encodeSpan), optionalStringField(3, scopeSpans.schemaUrl));
1569
+ var encodeResourceSpans = (resourceSpans) => concat2(messageField(1, encodeResource(resourceSpans.resource)), repeatedField(2, resourceSpans.scopeSpans, encodeScopeSpans), optionalStringField(3, resourceSpans.schemaUrl));
1277
1570
  var encodeTracesData = (tracesData) => repeatedField(1, tracesData.resourceSpans, encodeResourceSpans);
1278
- var encodeNumberDataPoint = (point) => concat(fixed64Field(2, BigInt(point.startTimeUnixNano)), fixed64Field(3, BigInt(point.timeUnixNano)), point.asDouble !== void 0 ? doubleField(4, point.asDouble) : new Uint8Array(0), point.asInt !== void 0 ? fixed64Field(6, BigInt(point.asInt)) : new Uint8Array(0), repeatedField(7, point.attributes, encodeKeyValue), point.flags !== void 0 ? varintField(8, point.flags) : new Uint8Array(0));
1571
+ var encodeNumberDataPoint = (point) => concat2(optionalFixed64Field(2, point.startTimeUnixNano), fixed64Field(3, BigInt(point.timeUnixNano)), point.asDouble !== void 0 ? doubleField(4, point.asDouble) : new Uint8Array(0), point.asInt !== void 0 ? fixed64Field(6, BigInt(point.asInt)) : new Uint8Array(0), repeatedField(7, point.attributes, encodeKeyValue), point.flags !== void 0 ? varintField(8, point.flags) : new Uint8Array(0));
1279
1572
  var encodeHistogramDataPoint = (point) => {
1280
- const bucketCountsEncoded = concat(...point.bucketCounts.map((count) => fixed64Field(6, BigInt(count))));
1281
- const explicitBoundsEncoded = concat(...point.explicitBounds.map((bound) => doubleField(7, bound)));
1282
- return concat(fixed64Field(2, BigInt(point.startTimeUnixNano)), fixed64Field(3, BigInt(point.timeUnixNano)), fixed64Field(4, BigInt(point.count)), point.sum !== void 0 ? doubleField(5, point.sum) : new Uint8Array(0), bucketCountsEncoded, explicitBoundsEncoded, repeatedField(9, point.attributes, encodeKeyValue), point.flags !== void 0 ? varintField(10, point.flags) : new Uint8Array(0), point.min !== void 0 ? doubleField(11, point.min) : new Uint8Array(0), point.max !== void 0 ? doubleField(12, point.max) : new Uint8Array(0));
1573
+ const bucketCountsEncoded = concat2(...point.bucketCounts.map((count2) => fixed64Field(6, BigInt(count2))));
1574
+ const explicitBoundsEncoded = concat2(...point.explicitBounds.map((bound) => doubleField(7, bound)));
1575
+ return concat2(optionalFixed64Field(2, point.startTimeUnixNano), fixed64Field(3, BigInt(point.timeUnixNano)), fixed64Field(4, BigInt(point.count)), point.sum !== void 0 ? doubleField(5, point.sum) : new Uint8Array(0), bucketCountsEncoded, explicitBoundsEncoded, repeatedField(9, point.attributes, encodeKeyValue), point.flags !== void 0 ? varintField(10, point.flags) : new Uint8Array(0), point.min !== void 0 ? doubleField(11, point.min) : new Uint8Array(0), point.max !== void 0 ? doubleField(12, point.max) : new Uint8Array(0));
1283
1576
  };
1284
1577
  var encodeGauge = (gauge) => repeatedField(1, gauge.dataPoints, encodeNumberDataPoint);
1285
- var encodeSum = (sum) => concat(repeatedField(1, sum.dataPoints, encodeNumberDataPoint), varintField(2, sum.aggregationTemporality), boolField(3, sum.isMonotonic));
1286
- var encodeHistogram = (histogram) => concat(repeatedField(1, histogram.dataPoints, encodeHistogramDataPoint), varintField(2, histogram.aggregationTemporality));
1287
- var encodeMetric = (metric) => concat(stringField(1, metric.name), optionalStringField(2, metric.description), optionalStringField(3, metric.unit), metric.gauge !== void 0 ? messageField(5, encodeGauge(metric.gauge)) : new Uint8Array(0), metric.sum !== void 0 ? messageField(7, encodeSum(metric.sum)) : new Uint8Array(0), metric.histogram !== void 0 ? messageField(9, encodeHistogram(metric.histogram)) : new Uint8Array(0));
1288
- var encodeScopeMetrics = (scopeMetrics) => concat(messageField(1, encodeInstrumentationScope(scopeMetrics.scope)), repeatedField(2, scopeMetrics.metrics, encodeMetric), optionalStringField(3, scopeMetrics.schemaUrl));
1289
- var encodeResourceMetrics = (resourceMetrics) => concat(messageField(1, encodeResource(resourceMetrics.resource)), repeatedField(2, resourceMetrics.scopeMetrics, encodeScopeMetrics), optionalStringField(3, resourceMetrics.schemaUrl));
1578
+ var encodeSum = (sum) => concat2(repeatedField(1, sum.dataPoints, encodeNumberDataPoint), varintField(2, sum.aggregationTemporality), boolField(3, sum.isMonotonic));
1579
+ var encodeHistogram = (histogram) => concat2(repeatedField(1, histogram.dataPoints, encodeHistogramDataPoint), varintField(2, histogram.aggregationTemporality));
1580
+ var encodeSummaryDataPoint = (point) => concat2(optionalFixed64Field(2, point.startTimeUnixNano), fixed64Field(3, BigInt(point.timeUnixNano)), fixed64Field(4, BigInt(point.count)), doubleField(5, point.sum), repeatedField(6, point.quantileValues, (q) => concat2(doubleField(1, q.quantile), doubleField(2, q.value))), repeatedField(7, point.attributes, encodeKeyValue), point.flags !== void 0 ? varintField(8, point.flags) : new Uint8Array(0));
1581
+ var encodeSummary = (summary) => repeatedField(1, summary.dataPoints, encodeSummaryDataPoint);
1582
+ var encodeMetric = (metric) => concat2(stringField(1, metric.name), optionalStringField(2, metric.description), optionalStringField(3, metric.unit), metric.gauge !== void 0 ? messageField(5, encodeGauge(metric.gauge)) : new Uint8Array(0), metric.sum !== void 0 ? messageField(7, encodeSum(metric.sum)) : new Uint8Array(0), metric.histogram !== void 0 ? messageField(9, encodeHistogram(metric.histogram)) : new Uint8Array(0), metric.summary !== void 0 ? messageField(11, encodeSummary(metric.summary)) : new Uint8Array(0));
1583
+ var encodeScopeMetrics = (scopeMetrics) => concat2(messageField(1, encodeInstrumentationScope(scopeMetrics.scope)), repeatedField(2, scopeMetrics.metrics, encodeMetric), optionalStringField(3, scopeMetrics.schemaUrl));
1584
+ var encodeResourceMetrics = (resourceMetrics) => concat2(messageField(1, encodeResource(resourceMetrics.resource)), repeatedField(2, resourceMetrics.scopeMetrics, encodeScopeMetrics), optionalStringField(3, resourceMetrics.schemaUrl));
1290
1585
  var encodeMetricsData = (metricsData) => repeatedField(1, metricsData.resourceMetrics, encodeResourceMetrics);
1291
- var encodeLogRecord = (record) => concat(fixed64Field(1, BigInt(record.timeUnixNano)), record.severityNumber !== void 0 ? varintField(2, record.severityNumber) : new Uint8Array(0), optionalStringField(3, record.severityText), record.body !== void 0 ? messageField(5, encodeAnyValue(record.body)) : new Uint8Array(0), repeatedField(6, record.attributes, encodeKeyValue), record.droppedAttributesCount !== void 0 && record.droppedAttributesCount > 0 ? varintField(7, record.droppedAttributesCount) : new Uint8Array(0), record.flags !== void 0 ? fixed32Field(8, record.flags) : new Uint8Array(0), record.traceId !== void 0 && record.traceId !== "" ? bytesFieldFromHex(9, record.traceId) : new Uint8Array(0), record.spanId !== void 0 && record.spanId !== "" ? bytesFieldFromHex(10, record.spanId) : new Uint8Array(0), record.observedTimeUnixNano !== void 0 ? fixed64Field(11, BigInt(record.observedTimeUnixNano)) : new Uint8Array(0));
1292
- var encodeScopeLogs = (scopeLogs) => concat(messageField(1, encodeInstrumentationScope(scopeLogs.scope)), repeatedField(2, scopeLogs.logRecords, encodeLogRecord), optionalStringField(3, scopeLogs.schemaUrl));
1293
- var encodeResourceLogs = (resourceLogs) => concat(messageField(1, encodeResource(resourceLogs.resource)), repeatedField(2, resourceLogs.scopeLogs, encodeScopeLogs), optionalStringField(3, resourceLogs.schemaUrl));
1586
+ var encodeLogRecord = (record) => concat2(fixed64Field(1, BigInt(record.timeUnixNano)), record.severityNumber !== void 0 ? varintField(2, record.severityNumber) : new Uint8Array(0), optionalStringField(3, record.severityText), record.body !== void 0 ? messageField(5, encodeAnyValue(record.body)) : new Uint8Array(0), repeatedField(6, record.attributes, encodeKeyValue), record.droppedAttributesCount !== void 0 && record.droppedAttributesCount > 0 ? varintField(7, record.droppedAttributesCount) : new Uint8Array(0), record.flags !== void 0 ? fixed32Field(8, record.flags) : new Uint8Array(0), record.traceId !== void 0 && record.traceId !== "" ? bytesFieldFromHex(9, record.traceId) : new Uint8Array(0), record.spanId !== void 0 && record.spanId !== "" ? bytesFieldFromHex(10, record.spanId) : new Uint8Array(0), record.observedTimeUnixNano !== void 0 ? fixed64Field(11, BigInt(record.observedTimeUnixNano)) : new Uint8Array(0));
1587
+ var encodeScopeLogs = (scopeLogs) => concat2(messageField(1, encodeInstrumentationScope(scopeLogs.scope)), repeatedField(2, scopeLogs.logRecords, encodeLogRecord), optionalStringField(3, scopeLogs.schemaUrl));
1588
+ var encodeResourceLogs = (resourceLogs) => concat2(messageField(1, encodeResource(resourceLogs.resource)), repeatedField(2, resourceLogs.scopeLogs, encodeScopeLogs), optionalStringField(3, resourceLogs.schemaUrl));
1294
1589
  var encodeLogsData = (logsData) => repeatedField(1, logsData.resourceLogs, encodeResourceLogs);
1295
1590
 
1296
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpSerialization.js
1591
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpSerialization.js
1297
1592
  var OtlpSerialization = class extends (/* @__PURE__ */ Service()("effect/observability/OtlpSerialization")) {
1298
1593
  };
1594
+ function jsonReplacer(key, value) {
1595
+ if (typeof value === "number" && !Number.isFinite(value)) return String(value);
1596
+ if (key === "bytesValue" && this[key] instanceof Uint8Array) return encode(this[key]);
1597
+ return value;
1598
+ }
1599
+ var jsonBody = (data) => {
1600
+ const json = JSON.stringify(data);
1601
+ return text(json.includes("null") || json.includes('"bytesValue":') ? JSON.stringify(data, jsonReplacer) : json, "application/json");
1602
+ };
1299
1603
  var layerJson = /* @__PURE__ */ succeed(OtlpSerialization, {
1300
- traces: (spans) => jsonUnsafe(spans),
1301
- metrics: (metrics) => jsonUnsafe(metrics),
1302
- logs: (logs) => jsonUnsafe(logs)
1604
+ traces: (spans) => jsonBody(spans),
1605
+ metrics: (metrics) => jsonBody(metrics),
1606
+ logs: (logs) => jsonBody(logs)
1303
1607
  });
1304
1608
  var layerProtobuf = /* @__PURE__ */ succeed(OtlpSerialization, {
1305
1609
  traces: (spans) => uint8Array(encodeTracesData(spans), "application/x-protobuf"),
@@ -1307,17 +1611,19 @@ var layerProtobuf = /* @__PURE__ */ succeed(OtlpSerialization, {
1307
1611
  logs: (logs) => uint8Array(encodeLogsData(logs), "application/x-protobuf")
1308
1612
  });
1309
1613
 
1310
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpLogger.js
1311
- var make6 = /* @__PURE__ */ fnUntraced(function* (options) {
1614
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpLogger.js
1615
+ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1312
1616
  const serialization = yield* OtlpSerialization;
1313
1617
  const otelResource = yield* fromConfig(options.resource);
1314
1618
  const scope = {
1315
- name: serviceNameUnsafe(otelResource)
1619
+ name: "effect",
1620
+ version: getCurrentVersion()
1316
1621
  };
1317
- const exporter = yield* make4({
1622
+ const exporter = yield* make5({
1318
1623
  label: "OtlpLogger",
1319
1624
  url: options.url,
1320
1625
  headers: options.headers,
1626
+ compression: options.compression,
1321
1627
  maxBatchSize: options.maxBatchSize ?? 1e3,
1322
1628
  exportInterval: options.exportInterval ?? seconds(1),
1323
1629
  body: (data) => [serialization.logs({
@@ -1335,11 +1641,11 @@ var make6 = /* @__PURE__ */ fnUntraced(function* (options) {
1335
1641
  excludeLogSpans: options.excludeLogSpans ?? false,
1336
1642
  clock: yield* Clock
1337
1643
  };
1338
- return make3((options2) => {
1644
+ return make4((options2) => {
1339
1645
  exporter.push(makeLogRecord(options2, opts));
1340
1646
  });
1341
1647
  });
1342
- var layer2 = (options) => layer([make6(options)], {
1648
+ var layer2 = (options) => layer([make7(options)], {
1343
1649
  mergeWithExisting: options.mergeWithExisting ?? true
1344
1650
  }).pipe(provideMerge(layerFlusher));
1345
1651
  var layerFromConfig = (options) => gen(function* () {
@@ -1356,12 +1662,16 @@ var layerFromConfig = (options) => gen(function* () {
1356
1662
  return layerFlusher;
1357
1663
  }
1358
1664
  const {
1665
+ baseCompression,
1666
+ compression,
1359
1667
  baseTimeout,
1360
1668
  logsTimeout,
1361
1669
  exportTimeout,
1362
1670
  scheduleDelay,
1363
1671
  maxBatchSize
1364
1672
  } = yield* all({
1673
+ baseCompression: option(Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
1674
+ compression: option(Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_LOGS_COMPRESSION")),
1365
1675
  baseTimeout: option(Int("OTEL_EXPORTER_OTLP_TIMEOUT")),
1366
1676
  logsTimeout: option(Int("OTEL_EXPORTER_OTLP_LOGS_TIMEOUT")),
1367
1677
  exportTimeout: option(Int("OTEL_BLRP_EXPORT_TIMEOUT")),
@@ -1374,6 +1684,7 @@ var layerFromConfig = (options) => gen(function* () {
1374
1684
  url: endpoint2.toString(),
1375
1685
  resource: options?.resource,
1376
1686
  headers: options?.headers ?? (yield* headers("LOGS")),
1687
+ compression: getOrElse(firstSomeOf([compression, baseCompression]), () => "none"),
1377
1688
  exportInterval: getOrUndefined(exportInterval),
1378
1689
  maxBatchSize: getOrUndefined(maxBatchSize),
1379
1690
  shutdownTimeout: getOrUndefined(shutdownTimeout),
@@ -1381,47 +1692,40 @@ var layerFromConfig = (options) => gen(function* () {
1381
1692
  mergeWithExisting: options?.mergeWithExisting
1382
1693
  });
1383
1694
  }).pipe(orDie, unwrap);
1695
+ var nanosPerMilli = /* @__PURE__ */ BigInt(1e6);
1384
1696
  var makeLogRecord = (options, opts) => {
1385
- const now = opts.clock.currentTimeNanosUnsafe();
1386
- const nanosString = now.toString();
1387
- const nowMillis = options.date.getTime();
1388
- const attributes = entriesToAttributes(Object.entries(options.fiber.getRef(CurrentLogAnnotations)));
1389
- attributes.push({
1390
- key: "fiberId",
1391
- value: {
1392
- intValue: options.fiber.id
1393
- }
1394
- });
1697
+ const observedTime = opts.clock.currentTimeNanosUnsafe().toString();
1698
+ const eventMillis = options.date.getTime();
1699
+ const eventTime = (BigInt(eventMillis) * nanosPerMilli).toString();
1700
+ const attributes2 = {
1701
+ ...options.fiber.getRef(CurrentLogAnnotations)
1702
+ };
1703
+ attributes2["effect.fiberId"] = options.fiber.id;
1395
1704
  if (!opts.excludeLogSpans) {
1396
1705
  for (const [label, startTime] of options.fiber.getRef(CurrentLogSpans)) {
1397
- attributes.push({
1398
- key: `logSpan.${label}`,
1399
- value: {
1400
- stringValue: `${nowMillis - startTime}ms`
1401
- }
1402
- });
1706
+ attributes2[`effect.log_span.${label}`] = eventMillis - startTime;
1403
1707
  }
1404
1708
  }
1405
- if (options.cause.reasons.length > 0) {
1406
- attributes.push({
1407
- key: "log.error",
1408
- value: {
1409
- stringValue: pretty(options.cause)
1410
- }
1411
- });
1709
+ const errors = prettyErrors(options.cause, {
1710
+ includeCauseInStack: true
1711
+ });
1712
+ if (errors.length > 0) {
1713
+ attributes2["exception.type"] = errors[0].name;
1714
+ attributes2["exception.message"] = errors[0].message;
1715
+ attributes2["exception.stacktrace"] = errors.map((error) => error.stack).join("\n");
1412
1716
  }
1413
1717
  const message = ensure(options.message);
1414
1718
  const logRecord = {
1415
1719
  severityNumber: logLevelToSeverityNumber(options.logLevel),
1416
1720
  severityText: options.logLevel,
1417
- timeUnixNano: nanosString,
1418
- observedTimeUnixNano: nanosString,
1419
- attributes,
1721
+ timeUnixNano: eventTime,
1722
+ observedTimeUnixNano: observedTime,
1723
+ attributes: entriesToAttributes(Object.entries(attributes2)),
1420
1724
  body: unknownToAttributeValue(message.length === 1 ? message[0] : message),
1421
1725
  droppedAttributesCount: 0
1422
1726
  };
1423
1727
  if (options.fiber.cache.span) {
1424
- logRecord.traceId = options.fiber.cache.span.traceId;
1728
+ logRecord.traceId = options.fiber.cache.span.traceId.padStart(32, "0");
1425
1729
  logRecord.spanId = options.fiber.cache.span.spanId;
1426
1730
  }
1427
1731
  return logRecord;
@@ -1473,14 +1777,14 @@ var ESeverityNumber = {
1473
1777
  SEVERITY_NUMBER_FATAL4: 24
1474
1778
  };
1475
1779
 
1476
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpMetrics.js
1780
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpMetrics.js
1477
1781
  var OtlpMetrics_exports = {};
1478
1782
  __export(OtlpMetrics_exports, {
1479
1783
  layer: () => layer3,
1480
1784
  layerFromConfig: () => layerFromConfig2,
1481
- make: () => make7
1785
+ make: () => make8
1482
1786
  });
1483
- var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1787
+ var make8 = /* @__PURE__ */ fnUntraced(function* (options) {
1484
1788
  const clock = yield* Clock;
1485
1789
  const serialization = yield* OtlpSerialization;
1486
1790
  const startTimeNanos = yield* clock.currentTimeNanos;
@@ -1495,7 +1799,6 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1495
1799
  let previousCounterState = /* @__PURE__ */ new Map();
1496
1800
  let previousHistogramState = /* @__PURE__ */ new Map();
1497
1801
  let previousFrequencyState = /* @__PURE__ */ new Map();
1498
- let previousSummaryState = /* @__PURE__ */ new Map();
1499
1802
  let snapshotSequence = 0;
1500
1803
  let committedSnapshotSequence = -1;
1501
1804
  const snapshot = () => {
@@ -1503,10 +1806,9 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1503
1806
  const currentSnapshotSequence = snapshotSequence++;
1504
1807
  const nowNanos = clock.currentTimeNanosUnsafe();
1505
1808
  const nowTime = String(nowNanos);
1506
- const nextCounterState = new Map(previousCounterState);
1507
- const nextHistogramState = new Map(previousHistogramState);
1508
- const nextFrequencyState = new Map(previousFrequencyState);
1509
- const nextSummaryState = new Map(previousSummaryState);
1809
+ const nextCounterState = /* @__PURE__ */ new Map();
1810
+ const nextHistogramState = /* @__PURE__ */ new Map();
1811
+ const nextFrequencyState = /* @__PURE__ */ new Map();
1510
1812
  const metricData = [];
1511
1813
  const metricDataByName = /* @__PURE__ */ new Map();
1512
1814
  const addMetricData = (data) => {
@@ -1518,8 +1820,8 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1518
1820
  const intervalStartTime = isDelta ? String(previousExportTimeNanos) : startTime;
1519
1821
  for (let i = 0, len = snapshot2.length; i < len; i++) {
1520
1822
  const state = snapshot2[i];
1521
- const unit = state.attributes?.unit ?? state.attributes?.time_unit ?? "1";
1522
- const attributes = state.attributes ? entriesToAttributes(Object.entries(state.attributes)) : [];
1823
+ const unit = toUcumUnit(state.attributes?.unit ?? state.attributes?.time_unit);
1824
+ const attributes2 = state.attributes ? entriesToAttributes(Object.entries(state.attributes)) : [];
1523
1825
  const metricKey = makeMetricKey(state.id, state.attributes);
1524
1826
  switch (state.type) {
1525
1827
  case "Counter": {
@@ -1545,12 +1847,12 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1545
1847
  nextCounterState.set(metricKey, currentCount);
1546
1848
  }
1547
1849
  const dataPoint = {
1548
- attributes,
1850
+ attributes: attributes2,
1549
1851
  startTimeUnixNano: intervalStartTime,
1550
1852
  timeUnixNano: nowTime
1551
1853
  };
1552
1854
  if (typeof reportValue === "bigint") {
1553
- dataPoint.asInt = Number(reportValue);
1855
+ dataPoint.asInt = bigintToInt64(reportValue);
1554
1856
  } else {
1555
1857
  dataPoint.asDouble = reportValue;
1556
1858
  }
@@ -1572,12 +1874,12 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1572
1874
  }
1573
1875
  case "Gauge": {
1574
1876
  const dataPoint = {
1575
- attributes,
1877
+ attributes: attributes2,
1576
1878
  startTimeUnixNano: startTime,
1577
1879
  timeUnixNano: nowTime
1578
1880
  };
1579
1881
  if (typeof state.state.value === "bigint") {
1580
- dataPoint.asInt = Number(state.state.value);
1882
+ dataPoint.asInt = bigintToInt64(state.state.value);
1581
1883
  } else {
1582
1884
  dataPoint.asDouble = state.state.value;
1583
1885
  }
@@ -1596,48 +1898,45 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1596
1898
  break;
1597
1899
  }
1598
1900
  case "Histogram": {
1599
- const size = state.state.buckets.length;
1600
1901
  const currentBuckets = {
1601
- boundaries: allocate(size - 1),
1602
- counts: allocate(size)
1902
+ boundaries: [],
1903
+ counts: []
1603
1904
  };
1604
- let idx = 0;
1605
1905
  let prev = 0;
1606
1906
  for (const [boundary, value] of state.state.buckets) {
1607
- if (idx < size - 1) {
1608
- currentBuckets.boundaries[idx] = boundary;
1609
- }
1610
- currentBuckets.counts[idx] = value - prev;
1907
+ if (boundary === Number.POSITIVE_INFINITY) break;
1908
+ currentBuckets.boundaries.push(boundary);
1909
+ currentBuckets.counts.push(value - prev);
1611
1910
  prev = value;
1612
- idx++;
1613
1911
  }
1912
+ currentBuckets.counts.push(state.state.count - prev);
1614
1913
  let reportCount = state.state.count;
1615
1914
  let reportSum = state.state.sum;
1616
1915
  let reportBucketCounts = currentBuckets.counts;
1617
- const reportMin = state.state.min;
1618
- const reportMax = state.state.max;
1916
+ let reportExtrema = true;
1619
1917
  if (isDelta) {
1620
1918
  const previousState = previousHistogramState.get(metricKey);
1621
1919
  if (previousState !== void 0) {
1622
1920
  reportCount = state.state.count - previousState.count;
1623
1921
  reportSum = state.state.sum - previousState.sum;
1624
1922
  reportBucketCounts = currentBuckets.counts.map((c, i2) => Math.max(0, c - (previousState.bucketCounts[i2] ?? 0)));
1923
+ reportExtrema = false;
1625
1924
  }
1626
1925
  nextHistogramState.set(metricKey, {
1627
1926
  count: state.state.count,
1628
1927
  sum: state.state.sum,
1629
- bucketCounts: currentBuckets.counts.slice(),
1630
- min: state.state.min,
1631
- max: state.state.max
1928
+ bucketCounts: currentBuckets.counts.slice()
1632
1929
  });
1633
1930
  }
1634
1931
  const dataPoint = {
1635
- attributes,
1932
+ attributes: attributes2,
1636
1933
  startTimeUnixNano: intervalStartTime,
1637
1934
  timeUnixNano: nowTime,
1638
1935
  count: reportCount,
1639
- min: reportMin,
1640
- max: reportMax,
1936
+ ...reportExtrema ? {
1937
+ min: state.state.min,
1938
+ max: state.state.max
1939
+ } : void 0,
1641
1940
  sum: reportSum,
1642
1941
  bucketCounts: reportBucketCounts,
1643
1942
  explicitBounds: currentBuckets.boundaries
@@ -1671,7 +1970,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1671
1970
  }
1672
1971
  }
1673
1972
  dataPoints.push({
1674
- attributes: [...attributes, {
1973
+ attributes: [...attributes2, {
1675
1974
  key: "key",
1676
1975
  value: {
1677
1976
  stringValue: freqKey
@@ -1702,99 +2001,26 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1702
2001
  break;
1703
2002
  }
1704
2003
  case "Summary": {
1705
- const dataPoints = [{
1706
- attributes: [...attributes, {
1707
- key: "quantile",
1708
- value: {
1709
- stringValue: "min"
1710
- }
1711
- }],
1712
- startTimeUnixNano: intervalStartTime,
1713
- timeUnixNano: nowTime,
1714
- asDouble: state.state.min
1715
- }];
1716
- for (const [quantile, value] of state.state.quantiles) {
1717
- dataPoints.push({
1718
- attributes: [...attributes, {
1719
- key: "quantile",
1720
- value: {
1721
- stringValue: quantile.toString()
1722
- }
1723
- }],
1724
- startTimeUnixNano: intervalStartTime,
1725
- timeUnixNano: nowTime,
1726
- asDouble: value ?? 0
1727
- });
1728
- }
1729
- dataPoints.push({
1730
- attributes: [...attributes, {
1731
- key: "quantile",
1732
- value: {
1733
- stringValue: "max"
1734
- }
1735
- }],
1736
- startTimeUnixNano: intervalStartTime,
1737
- timeUnixNano: nowTime,
1738
- asDouble: state.state.max
1739
- });
1740
- let reportCount = state.state.count;
1741
- let reportSum = state.state.sum;
1742
- if (isDelta) {
1743
- const previousState = previousSummaryState.get(metricKey);
1744
- if (previousState !== void 0) {
1745
- reportCount = state.state.count - previousState.count;
1746
- reportSum = state.state.sum - previousState.sum;
1747
- }
1748
- nextSummaryState.set(metricKey, {
1749
- count: state.state.count,
1750
- sum: state.state.sum
1751
- });
1752
- }
1753
- const countDataPoint = {
1754
- attributes,
1755
- startTimeUnixNano: intervalStartTime,
1756
- timeUnixNano: nowTime,
1757
- asInt: reportCount
1758
- };
1759
- const sumDataPoint = {
1760
- attributes,
1761
- startTimeUnixNano: intervalStartTime,
2004
+ const dataPoint = {
2005
+ attributes: attributes2,
2006
+ startTimeUnixNano: startTime,
1762
2007
  timeUnixNano: nowTime,
1763
- asDouble: reportSum
2008
+ count: state.state.count,
2009
+ sum: state.state.sum,
2010
+ quantileValues: state.state.quantiles.flatMap(([quantile, value]) => value === void 0 ? [] : [{
2011
+ quantile,
2012
+ value
2013
+ }])
1764
2014
  };
1765
- if (metricDataByName.has(`${state.id}_quantiles`)) {
1766
- metricDataByName.get(`${state.id}_quantiles`).sum.dataPoints.push(...dataPoints);
1767
- metricDataByName.get(`${state.id}_count`).sum.dataPoints.push(countDataPoint);
1768
- metricDataByName.get(`${state.id}_sum`).sum.dataPoints.push(sumDataPoint);
2015
+ if (metricDataByName.has(state.id)) {
2016
+ metricDataByName.get(state.id).summary.dataPoints.push(dataPoint);
1769
2017
  } else {
1770
2018
  addMetricData({
1771
- name: `${state.id}_quantiles`,
2019
+ name: state.id,
1772
2020
  description: state.description,
1773
2021
  unit,
1774
- sum: {
1775
- aggregationTemporality: aggregationTemporalityEnum,
1776
- isMonotonic: false,
1777
- dataPoints
1778
- }
1779
- });
1780
- addMetricData({
1781
- name: `${state.id}_count`,
1782
- description: state.description,
1783
- unit: "1",
1784
- sum: {
1785
- aggregationTemporality: aggregationTemporalityEnum,
1786
- isMonotonic: true,
1787
- dataPoints: [countDataPoint]
1788
- }
1789
- });
1790
- addMetricData({
1791
- name: `${state.id}_sum`,
1792
- description: state.description,
1793
- unit: "1",
1794
- sum: {
1795
- aggregationTemporality: aggregationTemporalityEnum,
1796
- isMonotonic: true,
1797
- dataPoints: [sumDataPoint]
2022
+ summary: {
2023
+ dataPoints: [dataPoint]
1798
2024
  }
1799
2025
  });
1800
2026
  }
@@ -1816,16 +2042,16 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1816
2042
  previousCounterState = nextCounterState;
1817
2043
  previousHistogramState = nextHistogramState;
1818
2044
  previousFrequencyState = nextFrequencyState;
1819
- previousSummaryState = nextSummaryState;
1820
2045
  previousExportTimeNanos = nowNanos;
1821
2046
  committedSnapshotSequence = currentSnapshotSequence;
1822
2047
  }) : void_;
1823
2048
  return [body, onSuccess];
1824
2049
  };
1825
- yield* make4({
2050
+ yield* make5({
1826
2051
  label: "OtlpMetrics",
1827
2052
  url: options.url,
1828
2053
  headers: options.headers,
2054
+ compression: options.compression,
1829
2055
  maxBatchSize: "disabled",
1830
2056
  exportEmpty: true,
1831
2057
  exportInterval: options.exportInterval ?? seconds(10),
@@ -1833,7 +2059,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1833
2059
  shutdownTimeout: options.shutdownTimeout ?? seconds(3)
1834
2060
  });
1835
2061
  });
1836
- var layer3 = (options) => effectDiscard(make7(options)).pipe(provideMerge(layerFlusher));
2062
+ var layer3 = (options) => effectDiscard(make8(options)).pipe(provideMerge(layerFlusher));
1837
2063
  var layerFromConfig2 = (options) => gen(function* () {
1838
2064
  const {
1839
2065
  disabled,
@@ -1848,12 +2074,16 @@ var layerFromConfig2 = (options) => gen(function* () {
1848
2074
  return layerFlusher;
1849
2075
  }
1850
2076
  const {
2077
+ baseCompression,
2078
+ compression,
1851
2079
  baseTimeout,
1852
2080
  metricsTimeout,
1853
2081
  exportTimeout,
1854
2082
  exportInterval,
1855
2083
  temporalityPreference
1856
2084
  } = yield* all({
2085
+ baseCompression: option(Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
2086
+ compression: option(Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_METRICS_COMPRESSION")),
1857
2087
  baseTimeout: option(Int("OTEL_EXPORTER_OTLP_TIMEOUT")),
1858
2088
  metricsTimeout: option(Int("OTEL_EXPORTER_OTLP_METRICS_TIMEOUT")),
1859
2089
  exportTimeout: option(Int("OTEL_METRIC_EXPORT_TIMEOUT")),
@@ -1865,18 +2095,22 @@ var layerFromConfig2 = (options) => gen(function* () {
1865
2095
  url: endpoint2.toString(),
1866
2096
  resource: options?.resource,
1867
2097
  headers: options?.headers ?? (yield* headers("METRICS")),
2098
+ compression: getOrElse(firstSomeOf([compression, baseCompression]), () => "none"),
1868
2099
  exportInterval: getOrUndefined(exportInterval),
1869
2100
  shutdownTimeout: getOrUndefined(shutdownTimeout),
1870
2101
  temporality: getOrUndefined(temporalityPreference)
1871
2102
  });
1872
2103
  }).pipe(orDie, unwrap);
1873
- var makeMetricKey = (id, attributes) => {
1874
- if (attributes === void 0 || Object.keys(attributes).length === 0) {
2104
+ var makeMetricKey = (id, attributes2) => {
2105
+ if (attributes2 === void 0 || Object.keys(attributes2).length === 0) {
1875
2106
  return id;
1876
2107
  }
1877
- const sortedEntries = Object.entries(attributes).sort((a, b) => a[0].localeCompare(b[0]));
2108
+ const sortedEntries = Object.entries(attributes2).sort((a, b) => a[0].localeCompare(b[0]));
1878
2109
  return `${id}:${JSON.stringify(sortedEntries)}`;
1879
2110
  };
2111
+ var ucumUnits = /* @__PURE__ */ new Map([["nanoseconds", "ns"], ["microseconds", "us"], ["milliseconds", "ms"], ["seconds", "s"], ["bytes", "By"]]);
2112
+ var toUcumUnit = (unit = "") => ucumUnits.get(unit) ?? unit;
2113
+ var bigintToInt64 = (value) => Number.isSafeInteger(Number(value)) ? Number(value) : value.toString();
1880
2114
  var EAggregationTemporality = {
1881
2115
  AGGREGATION_TEMPORALITY_UNSPECIFIED: 0,
1882
2116
  /** DELTA is an AggregationTemporality for a metric aggregator which reports
@@ -1936,23 +2170,25 @@ var EAggregationTemporality = {
1936
2170
  AGGREGATION_TEMPORALITY_CUMULATIVE: 2
1937
2171
  };
1938
2172
 
1939
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpTracer.js
2173
+ // ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/observability/OtlpTracer.js
1940
2174
  var OtlpTracer_exports = {};
1941
2175
  __export(OtlpTracer_exports, {
1942
2176
  layer: () => layer4,
1943
2177
  layerFromConfig: () => layerFromConfig3,
1944
- make: () => make8
2178
+ make: () => make9
1945
2179
  });
1946
- var make8 = /* @__PURE__ */ fnUntraced(function* (options) {
2180
+ var make9 = /* @__PURE__ */ fnUntraced(function* (options) {
1947
2181
  const otelResource = yield* fromConfig(options.resource);
1948
2182
  const serialization = yield* OtlpSerialization;
1949
2183
  const scope = {
1950
- name: serviceNameUnsafe(otelResource)
2184
+ name: "effect",
2185
+ version: getCurrentVersion()
1951
2186
  };
1952
- const exporter = yield* make4({
2187
+ const exporter = yield* make5({
1953
2188
  label: "OtlpTracer",
1954
2189
  url: options.url,
1955
2190
  headers: options.headers,
2191
+ compression: options.compression,
1956
2192
  exportInterval: options.exportInterval ?? seconds(5),
1957
2193
  maxBatchSize: options.maxBatchSize ?? 1e3,
1958
2194
  body(spans) {
@@ -1985,7 +2221,7 @@ var make8 = /* @__PURE__ */ fnUntraced(function* (options) {
1985
2221
  } : void 0
1986
2222
  });
1987
2223
  });
1988
- var layer4 = /* @__PURE__ */ flow(make8, /* @__PURE__ */ effect(Tracer), /* @__PURE__ */ provideMerge(layerFlusher));
2224
+ var layer4 = /* @__PURE__ */ flow(make9, /* @__PURE__ */ effect(Tracer), /* @__PURE__ */ provideMerge(layerFlusher));
1989
2225
  var layerFromConfig3 = (options) => gen(function* () {
1990
2226
  const {
1991
2227
  disabled,
@@ -2000,12 +2236,16 @@ var layerFromConfig3 = (options) => gen(function* () {
2000
2236
  return layerFlusher;
2001
2237
  }
2002
2238
  const {
2239
+ baseCompression,
2240
+ compression,
2003
2241
  baseTimeout,
2004
2242
  tracesTimeout,
2005
2243
  exportTimeout,
2006
2244
  scheduleDelay,
2007
2245
  maxBatchSize
2008
2246
  } = yield* all({
2247
+ baseCompression: option(Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
2248
+ compression: option(Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_TRACES_COMPRESSION")),
2009
2249
  baseTimeout: option(Int("OTEL_EXPORTER_OTLP_TIMEOUT")),
2010
2250
  tracesTimeout: option(Int("OTEL_EXPORTER_OTLP_TRACES_TIMEOUT")),
2011
2251
  exportTimeout: option(Int("OTEL_BSP_EXPORT_TIMEOUT")),
@@ -2017,6 +2257,7 @@ var layerFromConfig3 = (options) => gen(function* () {
2017
2257
  url: endpoint2.toString(),
2018
2258
  resource: options?.resource,
2019
2259
  headers: options?.headers ?? (yield* headers("TRACES")),
2260
+ compression: getOrElse(firstSomeOf([compression, baseCompression]), () => "none"),
2020
2261
  exportInterval: getOrUndefined(scheduleDelay),
2021
2262
  maxBatchSize: getOrUndefined(maxBatchSize),
2022
2263
  context: options?.context,
@@ -2051,10 +2292,10 @@ var SpanImpl = class {
2051
2292
  };
2052
2293
  }
2053
2294
  get traceId() {
2054
- return this._traceId ??= isSome(this.parent) ? this.parent.value.traceId : randomHex(32);
2295
+ return this._traceId ??= isSome(this.parent) ? this.parent.value.traceId : random(32);
2055
2296
  }
2056
2297
  get spanId() {
2057
- return this._spanId ??= randomHex(16);
2298
+ return this._spanId ??= random(16);
2058
2299
  }
2059
2300
  get attributes() {
2060
2301
  return this._attributes ??= /* @__PURE__ */ new Map();
@@ -2063,6 +2304,7 @@ var SpanImpl = class {
2063
2304
  return this._events ??= [];
2064
2305
  }
2065
2306
  end(endTime, exit) {
2307
+ if (this.status._tag === "Ended") return;
2066
2308
  this.status = {
2067
2309
  _tag: "Ended",
2068
2310
  startTime: this.status.startTime,
@@ -2072,104 +2314,101 @@ var SpanImpl = class {
2072
2314
  this.export(this);
2073
2315
  }
2074
2316
  attribute(key, value) {
2317
+ if (this.status._tag === "Ended") return;
2075
2318
  this.attributes.set(key, value);
2076
2319
  }
2077
- event(name, startTime, attributes) {
2078
- this.events.push([name, startTime, attributes]);
2320
+ event(name, startTime, attributes2) {
2321
+ if (this.status._tag === "Ended") return;
2322
+ this.events.push([name, startTime, attributes2]);
2079
2323
  }
2080
2324
  addLinks(links) {
2325
+ if (this.status._tag === "Ended") return;
2081
2326
  this.links.push(...links);
2082
2327
  }
2083
2328
  };
2084
2329
  var makeOtlpSpan = (self) => {
2085
- const status = self.status;
2086
- const attributes = self._attributes === void 0 ? [] : entriesToAttributes(self._attributes);
2330
+ const status2 = self.status;
2331
+ const attributes2 = self._attributes === void 0 ? [] : entriesToAttributes(self._attributes);
2087
2332
  const events = [];
2088
2333
  if (self._events !== void 0) {
2089
2334
  for (let i = 0; i < self._events.length; i++) {
2090
- const [name, startTime, attributes2] = self._events[i];
2335
+ const [name, startTime, attributes3] = self._events[i];
2091
2336
  events.push({
2092
2337
  name,
2093
2338
  timeUnixNano: String(startTime),
2094
- attributes: attributes2 ? entriesToAttributes(Object.entries(attributes2)) : [],
2339
+ attributes: attributes3 ? entriesToAttributes(Object.entries(attributes3)) : [],
2095
2340
  droppedAttributesCount: 0
2096
2341
  });
2097
2342
  }
2098
2343
  }
2099
2344
  let otelStatus;
2100
- if (status.exit._tag === "Success") {
2345
+ if (status2.exit._tag === "Success") {
2101
2346
  otelStatus = {
2102
- code: StatusCode.Ok
2347
+ code: StatusCode.Unset
2103
2348
  };
2104
- } else if (hasInterruptsOnly(status.exit.cause)) {
2349
+ } else if (hasInterruptsOnly(status2.exit.cause)) {
2105
2350
  otelStatus = {
2106
- code: StatusCode.Ok,
2107
- message: "Interrupted"
2351
+ code: StatusCode.Unset
2108
2352
  };
2109
- attributes.push({
2110
- key: "span.label",
2111
- value: {
2112
- stringValue: "\u26A0\uFE0E Interrupted"
2113
- }
2114
- }, {
2115
- key: "status.interrupted",
2353
+ attributes2.push({
2354
+ key: "effect.fiber.interrupted",
2116
2355
  value: {
2117
2356
  boolValue: true
2118
2357
  }
2119
2358
  });
2120
2359
  } else {
2121
- const errors = prettyErrors(status.exit.cause, {
2360
+ const errors = prettyErrors(status2.exit.cause, {
2122
2361
  includeCauseInStack: true
2123
2362
  });
2124
- otelStatus = {
2125
- code: StatusCode.Error
2363
+ otelStatus = errors.length > 0 ? {
2364
+ code: StatusCode.Error,
2365
+ message: errors[0].message
2366
+ } : {
2367
+ code: StatusCode.Unset
2126
2368
  };
2127
- if (errors.length > 0) {
2128
- otelStatus.message = errors[0].message;
2129
- for (const error of errors) {
2130
- events.push({
2131
- name: "exception",
2132
- timeUnixNano: String(status.endTime),
2133
- droppedAttributesCount: 0,
2134
- attributes: [{
2135
- "key": "exception.type",
2136
- "value": {
2137
- "stringValue": error.name
2138
- }
2139
- }, {
2140
- "key": "exception.message",
2141
- "value": {
2142
- "stringValue": error.message
2143
- }
2144
- }, {
2145
- "key": "exception.stacktrace",
2146
- "value": {
2147
- "stringValue": error.stack ?? "No stack trace available"
2148
- }
2149
- }]
2150
- });
2151
- }
2369
+ for (const error of errors) {
2370
+ events.push({
2371
+ name: "exception",
2372
+ timeUnixNano: String(status2.endTime),
2373
+ droppedAttributesCount: 0,
2374
+ attributes: [{
2375
+ "key": "exception.type",
2376
+ "value": {
2377
+ "stringValue": error.name
2378
+ }
2379
+ }, {
2380
+ "key": "exception.message",
2381
+ "value": {
2382
+ "stringValue": error.message
2383
+ }
2384
+ }, {
2385
+ "key": "exception.stacktrace",
2386
+ "value": {
2387
+ "stringValue": error.stack ?? "No stack trace available"
2388
+ }
2389
+ }]
2390
+ });
2152
2391
  }
2153
2392
  }
2154
2393
  const links = [];
2155
2394
  for (let i = 0; i < self.links.length; i++) {
2156
2395
  const link = self.links[i];
2157
2396
  links.push({
2158
- traceId: link.span.traceId,
2397
+ traceId: link.span.traceId.padStart(32, "0"),
2159
2398
  spanId: link.span.spanId,
2160
2399
  attributes: entriesToAttributes(Object.entries(link.attributes)),
2161
2400
  droppedAttributesCount: 0
2162
2401
  });
2163
2402
  }
2164
2403
  return {
2165
- traceId: self.traceId,
2404
+ traceId: self.traceId.padStart(32, "0"),
2166
2405
  spanId: self.spanId,
2167
2406
  parentSpanId: isSome(self.parent) ? self.parent.value.spanId : void 0,
2168
2407
  name: self.name,
2169
2408
  kind: SpanKind[self.kind],
2170
- startTimeUnixNano: String(status.startTime),
2171
- endTimeUnixNano: String(status.endTime),
2172
- attributes,
2409
+ startTimeUnixNano: String(status2.startTime),
2410
+ endTimeUnixNano: String(status2.endTime),
2411
+ attributes: attributes2,
2173
2412
  droppedAttributesCount: 0,
2174
2413
  events,
2175
2414
  droppedEventsCount: 0,
@@ -2193,18 +2432,20 @@ var SpanKind = {
2193
2432
  };
2194
2433
 
2195
2434
  // ../telemetry/src/layer.ts
2196
- var telemetryLayer = (config, lifetime = "process", logger = Logger_exports.withConsoleError(Logger_exports.formatJson)) => {
2435
+ var telemetryLayer = (config, lifetime = "process", logger = Logger_exports.withConsoleError(Logger_exports.formatJson), shutdownTimeouts = {}) => {
2197
2436
  const resource = {
2198
2437
  serviceName: config.service,
2199
2438
  serviceVersion: config.version,
2200
2439
  attributes: { "deployment.environment.name": config.environment }
2201
2440
  };
2202
- const signal = (target) => ({
2441
+ const signal = (target, name) => ({
2203
2442
  url: target.url,
2204
2443
  resource,
2205
2444
  ...target.headers === void 0 ? {} : { headers: Redacted_exports.value(target.headers) },
2206
- exportInterval: lifetime === "event" ? "1 hour" : "1 second",
2207
- shutdownTimeout: "3 seconds"
2445
+ // An event exports when its scope closes. With no interval the exporter runs no loop, so a
2446
+ // span or log recorded from another event never resumes a fiber of this one.
2447
+ exportInterval: lifetime === "event" ? Duration_exports.infinity : "1 second",
2448
+ shutdownTimeout: shutdownTimeouts[name] ?? "3 seconds"
2208
2449
  });
2209
2450
  const console = Logger_exports.layer([logger]);
2210
2451
  return Layer_exports.mergeAll(
@@ -2216,18 +2457,18 @@ var telemetryLayer = (config, lifetime = "process", logger = Logger_exports.with
2216
2457
  // not authority to suppress server diagnostics.
2217
2458
  spanAttributes(config.clock, true).pipe(
2218
2459
  Layer_exports.provideMerge(
2219
- OtlpTracer_exports.layer(signal(config.traces)).pipe(
2460
+ OtlpTracer_exports.layer(signal(config.traces, "traces")).pipe(
2220
2461
  Layer_exports.provide(OtlpSerialization_exports.layerJson)
2221
2462
  )
2222
2463
  )
2223
2464
  )
2224
2465
  ),
2225
2466
  config.logs === void 0 ? console : OtlpLogger_exports.layer({
2226
- ...signal(config.logs),
2467
+ ...signal(config.logs, "logs"),
2227
2468
  mergeWithExisting: true
2228
2469
  }).pipe(Layer_exports.provide(OtlpSerialization_exports.layerJson), Layer_exports.provideMerge(console)),
2229
2470
  config.metrics === void 0 ? Layer_exports.empty : OtlpMetrics_exports.layer({
2230
- ...signal(config.metrics),
2471
+ ...signal(config.metrics, "metrics"),
2231
2472
  exportInterval: "30 seconds",
2232
2473
  temporality: "delta"
2233
2474
  }).pipe(
@@ -2245,30 +2486,431 @@ var telemetryLayer = (config, lifetime = "process", logger = Logger_exports.with
2245
2486
  );
2246
2487
  };
2247
2488
 
2489
+ // ../telemetry/src/app-records.ts
2490
+ var appText = "Text from the app is not recorded";
2491
+ var unrecognized = "unrecognized";
2492
+ var operations = [
2493
+ "requirements",
2494
+ "inspect",
2495
+ "skills",
2496
+ "query",
2497
+ "mutate",
2498
+ "call",
2499
+ "account-check",
2500
+ "webhooks",
2501
+ "webhook-validate",
2502
+ "webhook-complete",
2503
+ "webhook-register",
2504
+ "webhook-unregister",
2505
+ "webhook-handle",
2506
+ "workflows",
2507
+ "workflow-validate",
2508
+ "workflow-run",
2509
+ "migrate"
2510
+ ];
2511
+ var httpMethods = [
2512
+ "GET",
2513
+ "HEAD",
2514
+ "POST",
2515
+ "PUT",
2516
+ "PATCH",
2517
+ "DELETE",
2518
+ "OPTIONS",
2519
+ "TRACE",
2520
+ "CONNECT"
2521
+ ];
2522
+ var appSpanNames = /* @__PURE__ */ new Set([
2523
+ "app.dispatch",
2524
+ ...operations.map((operation) => `app.${operation}`),
2525
+ "app.evaluate",
2526
+ "app.accounts.bind",
2527
+ "app.account.check",
2528
+ "app.catalog.read",
2529
+ "app.skills.load",
2530
+ "app.skills.routers",
2531
+ "app.tool.resolve",
2532
+ "app.tool.approval",
2533
+ "app.tool.elicitation",
2534
+ "app.elicitation.wait",
2535
+ "app.workflow.control",
2536
+ "app.operation.execute",
2537
+ "app.sql.migrate",
2538
+ "app.code",
2539
+ "app.cache.call",
2540
+ "app.cache.get",
2541
+ "app.cache.load",
2542
+ "app.cache.command",
2543
+ "app.cache.publish",
2544
+ "app.cache.flush",
2545
+ "app.cache.lease.renew",
2546
+ "app.cache.lease.wait",
2547
+ "app.cache.refresh",
2548
+ "provider.http.request",
2549
+ "provider.http.response.read",
2550
+ "provider.openapi.call",
2551
+ "provider.graphql.request",
2552
+ "provider.graphql.call",
2553
+ "provider.mcp.session",
2554
+ "provider.mcp.connect",
2555
+ "provider.mcp.close",
2556
+ "provider.mcp.request",
2557
+ "provider.mcp.call",
2558
+ "provider.mcp.discover",
2559
+ "provider.mcp.check",
2560
+ "provider.mcp.health",
2561
+ "provider.mcp.anonymous",
2562
+ "provider.mcp.elicitation",
2563
+ "sql.execute",
2564
+ ...httpMethods.map((method) => `http.client ${method}`)
2565
+ ]);
2566
+ var errorKinds = /* @__PURE__ */ new Set([
2567
+ "HostRequestInvalid",
2568
+ "HostAccountsInvalid",
2569
+ "HostDeclarationInvalid",
2570
+ "HostEvaluationFailed",
2571
+ "HostOperationNotFound",
2572
+ "HostOperationFailed",
2573
+ "HostKindMismatch",
2574
+ "HostToolNotFound",
2575
+ "HostInputInvalid",
2576
+ "HostOutputInvalid",
2577
+ "HostToolBlocked",
2578
+ "HostToolApprovalRequired",
2579
+ "HostToolPolicyFailed",
2580
+ "ElicitationFailed",
2581
+ "DatabaseLimitExceeded",
2582
+ "DatabaseFieldReserved",
2583
+ "SkillLoadFailed",
2584
+ "WorkflowFailure",
2585
+ "ProviderError",
2586
+ "OpenapiResponseError",
2587
+ "OpenapiError",
2588
+ "OpenapiCompileError",
2589
+ "GraphqlError",
2590
+ "McpError",
2591
+ "McpToolError",
2592
+ "McpCredentialsUnverified",
2593
+ "CacheError",
2594
+ "AppDatabaseError",
2595
+ "AppStorageError",
2596
+ "AppStorageUnavailable",
2597
+ "NetworkRefused",
2598
+ "FetchOptionUnsupported",
2599
+ "LogicalOperationFailed",
2600
+ "HttpClientError",
2601
+ "SchemaError",
2602
+ "TimeoutError",
2603
+ "UnknownError",
2604
+ "InterruptError",
2605
+ "Error",
2606
+ "TypeError",
2607
+ "RangeError",
2608
+ "ReferenceError",
2609
+ "SyntaxError",
2610
+ "EvalError",
2611
+ "URIError",
2612
+ "AggregateError",
2613
+ "AbortError",
2614
+ "string",
2615
+ "number",
2616
+ "bigint",
2617
+ "boolean",
2618
+ "symbol",
2619
+ "undefined",
2620
+ "object",
2621
+ "function"
2622
+ ]);
2623
+ var failureCodes = /* @__PURE__ */ new Set([
2624
+ // CacheError
2625
+ "unavailable",
2626
+ "storage",
2627
+ "invalid",
2628
+ "capacity",
2629
+ "timeout",
2630
+ // AppDatabaseError
2631
+ "schema",
2632
+ "schema_changed",
2633
+ "table",
2634
+ "index",
2635
+ "range",
2636
+ "value",
2637
+ "readonly",
2638
+ "cursor",
2639
+ "limit",
2640
+ "closed",
2641
+ "replay",
2642
+ // OpenapiError
2643
+ "invalid_definition",
2644
+ "invalid_input",
2645
+ "request",
2646
+ // McpError, McpCredentialsUnverified and ProviderError
2647
+ "unauthorized",
2648
+ "invalid_response",
2649
+ "forbidden",
2650
+ "rate_limited",
2651
+ "rejected",
2652
+ "anonymous_access",
2653
+ // NetworkRefused and FetchOptionUnsupported
2654
+ "private_address",
2655
+ "credential_host",
2656
+ "credential_app",
2657
+ "credential_expired",
2658
+ "redirect",
2659
+ "cache",
2660
+ "integrity"
2661
+ ]);
2662
+ var text2 = (value) => typeof value["stringValue"] === "string" ? value["stringValue"] : void 0;
2663
+ var integer = (value) => {
2664
+ const raw = value["intValue"];
2665
+ const number = typeof raw === "string" && /^-?\d{1,15}$/.test(raw) ? Number(raw) : raw;
2666
+ return typeof number === "number" && Number.isSafeInteger(number) ? number : void 0;
2667
+ };
2668
+ var oneOf = (...values) => (value) => {
2669
+ const found = text2(value);
2670
+ return found !== void 0 && values.includes(found) ? { stringValue: found } : void 0;
2671
+ };
2672
+ var classified = (known) => (value) => {
2673
+ const found = text2(value);
2674
+ return found === void 0 ? void 0 : { stringValue: known.has(found) ? found : unrecognized };
2675
+ };
2676
+ var errorType = (value) => {
2677
+ const found = text2(value);
2678
+ if (found === void 0) return void 0;
2679
+ return {
2680
+ stringValue: errorKinds.has(found) || /^[45]\d\d$/u.test(found) ? found : unrecognized
2681
+ };
2682
+ };
2683
+ var flag = (value) => typeof value["boolValue"] === "boolean" ? { boolValue: value["boolValue"] } : void 0;
2684
+ var count = (value) => {
2685
+ const found = integer(value);
2686
+ return found !== void 0 && found >= 0 ? { intValue: found } : void 0;
2687
+ };
2688
+ var status = (value) => {
2689
+ const found = integer(value);
2690
+ return found !== void 0 && found >= 100 && found <= 599 ? { intValue: found } : void 0;
2691
+ };
2692
+ var duration = (value) => {
2693
+ const found = typeof value["doubleValue"] === "number" ? value["doubleValue"] : integer(value);
2694
+ return found !== void 0 && Number.isFinite(found) && found >= 0 ? { doubleValue: found } : void 0;
2695
+ };
2696
+ var spanAttributes2 = {
2697
+ "executor.operation": oneOf(...operations, "mutation", "discover"),
2698
+ "executor.outcome": oneOf("failed"),
2699
+ "executor.clock.type": oneOf("system", "cloudflare-io"),
2700
+ "executor.trace.parent_sampled": flag,
2701
+ "executor.failure.source": oneOf("app", "storage", "service"),
2702
+ "executor.failure.code": classified(failureCodes),
2703
+ "error.type": errorType,
2704
+ "cache.operation": oneOf(
2705
+ "read",
2706
+ "acquire",
2707
+ "claim",
2708
+ "publish",
2709
+ "release",
2710
+ "renew",
2711
+ "write",
2712
+ "invalidate"
2713
+ ),
2714
+ "cache.result": oneOf("fresh", "stale", "miss", "local"),
2715
+ "cache.load.leased": flag,
2716
+ "cache.flush.index": count,
2717
+ "cache.flush.count": count,
2718
+ "cache.flush.entries": count,
2719
+ "cache.flush.bytes": count,
2720
+ "cache.leases": count,
2721
+ "mcp.transport": oneOf("http", "sse", "stdio"),
2722
+ "mcp.operation": oneOf("discover", "call", "check", "health"),
2723
+ "mcp.tool.is_error": flag,
2724
+ "rpc.system.name": oneOf("jsonrpc"),
2725
+ "rpc.method": oneOf("initialize", "tools/list", "tools/call", "ping"),
2726
+ "graphql.operation.type": oneOf("query", "mutation", "subscription"),
2727
+ "db.system.name": oneOf("sqlite"),
2728
+ "db.operation.name": oneOf("execute"),
2729
+ "http.request.method": oneOf(...httpMethods),
2730
+ "http.response.status_code": status,
2731
+ "url.scheme": oneOf("http", "https"),
2732
+ // Effect 4.1 marks an interrupted span with `effect.fiber.interrupted`; apps built on an
2733
+ // earlier Effect still send the label and `status.interrupted`.
2734
+ "effect.fiber.interrupted": flag,
2735
+ "span.label": oneOf("\u26A0\uFE0E Interrupted"),
2736
+ "status.interrupted": flag,
2737
+ "executor.milestone.reached": flag,
2738
+ "executor.owner": oneOf("executor", "app", "upstream", "person", "lease", "background"),
2739
+ "executor.app.code": oneOf(
2740
+ "factory",
2741
+ "router",
2742
+ "approval",
2743
+ "handler",
2744
+ "loader",
2745
+ "cache",
2746
+ "webhook",
2747
+ "check",
2748
+ "skills",
2749
+ "elicitation",
2750
+ "workflow",
2751
+ "step"
2752
+ ),
2753
+ "executor.workflow.operation": oneOf("start", "get", "list", "terminate"),
2754
+ "cache.method": oneOf("get", "revalidate", "read", "readMany", "write", "invalidate"),
2755
+ "executor.upstream.wait_ms": duration,
2756
+ "executor.elicitation.wait_ms": duration,
2757
+ "executor.authored_ms": duration,
2758
+ "executor.lease.wait_ms": duration,
2759
+ "executor.background_ms": duration,
2760
+ "executor.overhead_ms": duration
2761
+ };
2762
+ var appSpanAttributeKeys = new Set(Object.keys(spanAttributes2));
2763
+ var logMessages = /* @__PURE__ */ new Set([
2764
+ "The app's request failed unexpectedly",
2765
+ "App cache refresh failed",
2766
+ "MCP catalog invalidation failed",
2767
+ "Telemetry export failed"
2768
+ ]);
2769
+ var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2770
+ var spanId = (value) => typeof value === "string" && /^[a-f0-9]{16}$/.test(value) ? value : void 0;
2771
+ var nanos = (value) => typeof value === "string" && /^\d{1,20}$/.test(value) ? value : void 0;
2772
+ var between = (value, minimum, maximum) => typeof value === "number" && Number.isInteger(value) && value >= minimum && value <= maximum ? value : void 0;
2773
+ var attributes = (from) => (Array.isArray(from) ? from : []).flatMap((attribute) => {
2774
+ if (!isObject(attribute) || typeof attribute["key"] !== "string") return [];
2775
+ const key = attribute["key"];
2776
+ const keep = Object.hasOwn(spanAttributes2, key) ? spanAttributes2[key] : void 0;
2777
+ const value = attribute["value"];
2778
+ const kept = keep === void 0 || !isObject(value) ? void 0 : keep(value);
2779
+ return kept === void 0 ? [] : [{ key, value: kept }];
2780
+ });
2781
+ var exception = (event) => {
2782
+ const named = (Array.isArray(event["attributes"]) ? event["attributes"] : []).find(
2783
+ (attribute) => isObject(attribute) && attribute["key"] === "exception.type"
2784
+ );
2785
+ const type = isObject(named) && isObject(named["value"]) ? text2(named["value"]) : void 0;
2786
+ const recorded2 = type !== void 0 && errorKinds.has(type) ? type : unrecognized;
2787
+ const time = nanos(event["timeUnixNano"]);
2788
+ return {
2789
+ name: "exception",
2790
+ ...time === void 0 ? {} : { timeUnixNano: time },
2791
+ attributes: [
2792
+ { key: "exception.type", value: { stringValue: recorded2 } },
2793
+ { key: "exception.message", value: { stringValue: appText } },
2794
+ { key: "exception.stacktrace", value: { stringValue: `${recorded2}: ${appText}` } }
2795
+ ]
2796
+ };
2797
+ };
2798
+ var appSpan = (span) => {
2799
+ const start = nanos(span["startTimeUnixNano"]);
2800
+ const end = nanos(span["endTimeUnixNano"]);
2801
+ if (start === void 0 || end === void 0) return void 0;
2802
+ const parent = spanId(span["parentSpanId"]);
2803
+ const kind = between(span["kind"], 0, 5);
2804
+ const code = isObject(span["status"]) ? between(span["status"]["code"], 0, 2) : void 0;
2805
+ const name = typeof span["name"] === "string" && appSpanNames.has(span["name"]) ? span["name"] : "app.unrecognized";
2806
+ return {
2807
+ traceId: span.traceId,
2808
+ spanId: span.spanId,
2809
+ ...parent === void 0 ? {} : { parentSpanId: parent },
2810
+ name,
2811
+ ...kind === void 0 ? {} : { kind },
2812
+ startTimeUnixNano: start,
2813
+ endTimeUnixNano: end,
2814
+ attributes: attributes(span["attributes"]),
2815
+ events: (Array.isArray(span["events"]) ? span["events"] : []).flatMap(
2816
+ (event) => isObject(event) && event["name"] === "exception" ? [exception(event)] : []
2817
+ ),
2818
+ ...code === void 0 ? {} : { status: { code } }
2819
+ };
2820
+ };
2821
+ var appLog = (log) => {
2822
+ const time = nanos(log["timeUnixNano"]);
2823
+ const observed = nanos(log["observedTimeUnixNano"]);
2824
+ const severity = between(log["severityNumber"], 1, 24);
2825
+ const level = log["severityText"];
2826
+ const body = isObject(log["body"]) ? text2(log["body"]) : void 0;
2827
+ return {
2828
+ ...log.traceId === void 0 ? {} : { traceId: log.traceId },
2829
+ ...log.spanId === void 0 ? {} : { spanId: log.spanId },
2830
+ ...time === void 0 ? {} : { timeUnixNano: time },
2831
+ ...observed === void 0 ? {} : { observedTimeUnixNano: observed },
2832
+ ...severity === void 0 ? {} : { severityNumber: severity },
2833
+ ...typeof level === "string" && ["Trace", "Debug", "Info", "Warn", "Error", "Fatal"].includes(level) ? { severityText: level } : {},
2834
+ body: { stringValue: body !== void 0 && logMessages.has(body) ? body : appText }
2835
+ };
2836
+ };
2837
+
2248
2838
  // ../telemetry/src/relay.ts
2249
- var makeTelemetryForwarder = Effect_exports.gen(function* () {
2839
+ var forwarder = Effect_exports.gen(function* () {
2250
2840
  const fibers = yield* FiberSet_exports.make();
2251
- const pending = yield* Semaphore_exports.make(16);
2252
2841
  const sender = yield* Semaphore_exports.make(1);
2253
- const failed = (reason) => recordExportFailure("app").pipe(Effect_exports.annotateLogs({ "executor.telemetry.failure": reason }));
2254
- yield* Effect_exports.addFinalizer(
2255
- () => FiberSet_exports.awaitEmpty(fibers).pipe(
2256
- Effect_exports.timeoutOption("3 seconds"),
2257
- Effect_exports.flatMap((drained) => Option_exports.isNone(drained) ? failed("shutdown") : Effect_exports.void)
2842
+ const pending = [];
2843
+ let queued = 0;
2844
+ const failed = (reason) => recordExportFailure("app", reason);
2845
+ const take = () => {
2846
+ let size = 0;
2847
+ let count2 = 0;
2848
+ while (count2 < pending.length && (count2 === 0 || size + pending[count2].size <= exportBudget2))
2849
+ size += pending[count2++].size;
2850
+ queued -= size;
2851
+ return pending.splice(0, count2);
2852
+ };
2853
+ let closing = false;
2854
+ let deadlineWhileClosing = false;
2855
+ const sendAll = Effect_exports.suspend(() => {
2856
+ const forwards = take();
2857
+ return forwards.length === 0 ? Effect_exports.void : exportForwards(forwards, "executor-app").pipe(
2858
+ Effect_exports.catchTag(
2859
+ "TimeoutError",
2860
+ () => Effect_exports.sync(() => {
2861
+ if (closing) deadlineWhileClosing = true;
2862
+ }).pipe(Effect_exports.andThen(failed("timeout")))
2863
+ ),
2864
+ Effect_exports.catch(() => failed("relay")),
2865
+ Effect_exports.andThen(sendAll)
2866
+ );
2867
+ });
2868
+ const drain = Effect_exports.suspend(
2869
+ () => sender.withPermitsIfAvailable(1)(sendAll).pipe(
2870
+ Effect_exports.flatMap((sent) => Option_exports.isSome(sent) && pending.length > 0 ? drain : Effect_exports.void)
2258
2871
  )
2259
2872
  );
2260
- return (batch, traceId, build) => FiberSet_exports.run(
2261
- fibers,
2262
- sender.withPermits(1)(
2263
- forwardTelemetry(batch, traceId, build).pipe(Effect_exports.catch(() => failed("relay")))
2264
- ).pipe(
2265
- pending.withPermitsIfAvailable(1),
2873
+ const reportWait = yield* TelemetryWaitReport;
2874
+ yield* Effect_exports.addFinalizer(
2875
+ () => Effect_exports.sync(() => {
2876
+ closing = true;
2877
+ }).pipe(
2878
+ Effect_exports.andThen(FiberSet_exports.awaitEmpty(fibers)),
2879
+ Effect_exports.timeoutOption("3 seconds"),
2880
+ Effect_exports.tap(
2881
+ (drained) => Option_exports.isNone(drained) || deadlineWhileClosing ? reportWait("forwarder") : Effect_exports.void
2882
+ ),
2266
2883
  Effect_exports.flatMap(
2267
- (accepted) => Option_exports.isNone(accepted) ? failed("capacity") : Effect_exports.void
2884
+ (drained) => Option_exports.isNone(drained) || pending.length > 0 ? failed("shutdown") : Effect_exports.void
2268
2885
  )
2269
2886
  )
2270
- ).pipe(Effect_exports.asVoid);
2887
+ );
2888
+ return (batch, traceId, source) => Effect_exports.suspend(() => {
2889
+ const size = [...batch.traces, ...batch.logs].reduce((total, body) => total + body.length, 0);
2890
+ if (queued + size > queueBudget) return failed("capacity");
2891
+ pending.push({ batch, traceId, source, size });
2892
+ queued += size;
2893
+ return FiberSet_exports.run(fibers, drain).pipe(Effect_exports.asVoid);
2894
+ });
2271
2895
  });
2896
+ var TelemetryWaitReport = Context_exports.Reference(
2897
+ "@executor-js/telemetry/TelemetryWaitReport",
2898
+ { defaultValue: () => () => Effect_exports.void }
2899
+ );
2900
+ var TelemetryDrainScope = Context_exports.Reference(
2901
+ "@executor-js/telemetry/TelemetryDrainScope",
2902
+ { defaultValue: () => void 0 }
2903
+ );
2904
+ var makeTelemetryForwarder = Effect_exports.flatMap(
2905
+ TelemetryDrainScope,
2906
+ (scope) => scope === void 0 ? forwarder : (
2907
+ // A scope of its own: its drain runs before its queue is interrupted, even when the host's
2908
+ // scope closes its finalizers in parallel.
2909
+ Effect_exports.flatMap(Scope_exports.fork(scope, "sequential"), (own) => Scope_exports.provide(forwarder, own))
2910
+ )
2911
+ );
2912
+ var queueBudget = 8 * 1048576;
2913
+ var exportBudget2 = 4 * 1048576;
2272
2914
  var payloadBytes = 262144;
2273
2915
  var encoder = new TextEncoder();
2274
2916
  var Payload = Schema_exports.String.check(
@@ -2360,8 +3002,8 @@ var recordPacker = (prefix, suffix) => {
2360
3002
  }
2361
3003
  };
2362
3004
  };
2363
- var HexTrace = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{32}$/));
2364
- var HexSpan = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{16}$/));
3005
+ var HexTrace = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{32}$/u));
3006
+ var HexSpan = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{16}$/u));
2365
3007
  var Span = Schema_exports.StructWithRest(Schema_exports.Struct({ traceId: HexTrace, spanId: HexSpan }), [
2366
3008
  Schema_exports.Record(Schema_exports.String, Schema_exports.Json)
2367
3009
  ]);
@@ -2391,58 +3033,67 @@ var LogPayload = Schema_exports.fromJsonString(
2391
3033
  )
2392
3034
  })
2393
3035
  );
2394
- var forwardTelemetry = (batch, traceId, build, service = "executor-app") => Effect_exports.gen(function* () {
3036
+ var exportForwards = (forwards, service) => Effect_exports.gen(function* () {
2395
3037
  const config = yield* CurrentTelemetryConfig;
2396
3038
  if (config === void 0) return;
2397
- const resource = {
3039
+ const resource = ({ build, app }) => ({
2398
3040
  attributes: [
2399
3041
  { key: "service.name", value: { stringValue: service } },
2400
3042
  { key: "service.version", value: { stringValue: config.version } },
2401
3043
  { key: "deployment.environment.name", value: { stringValue: config.environment } },
2402
- ...build === void 0 ? [] : [{ key: "executor.build.id", value: { stringValue: build } }]
3044
+ ...build === void 0 ? [] : [{ key: "executor.build.id", value: { stringValue: build } }],
3045
+ ...app === void 0 ? [] : [{ key: "executor.app.id", value: { stringValue: app } }]
2403
3046
  ]
2404
- };
2405
- const client = yield* HttpClient_exports.HttpClient;
2406
- if (batch.dropped > 0) yield* recordExportFailure("app", "capacity", batch.dropped);
2407
- for (const signal of ["traces", "logs"]) {
3047
+ });
3048
+ const client = retryTelemetryExport(yield* HttpClient_exports.HttpClient);
3049
+ const dropped = forwards.reduce((total, { batch }) => total + batch.dropped, 0);
3050
+ if (dropped > 0) yield* recordExportFailure("app", "capacity", dropped);
3051
+ const send = (signal) => Effect_exports.gen(function* () {
2408
3052
  const target = config[signal];
2409
- if (target === void 0 || batch[signal].length === 0) continue;
2410
- const data = signal === "traces" ? yield* Effect_exports.forEach(
2411
- batch.traces,
2412
- (body) => Schema_exports.decodeUnknownEffect(TracePayload)(body)
2413
- ).pipe(
2414
- Effect_exports.map((payloads) => ({
2415
- resourceSpans: [
2416
- {
2417
- resource,
3053
+ const sending = forwards.filter(({ batch }) => batch[signal].length > 0);
3054
+ if (target === void 0 || sending.length === 0) return;
3055
+ const data = signal === "traces" ? {
3056
+ resourceSpans: yield* Effect_exports.forEach(
3057
+ sending,
3058
+ ({ batch, traceId, source }) => Effect_exports.forEach(
3059
+ batch.traces,
3060
+ (body) => Schema_exports.decodeUnknownEffect(TracePayload)(body)
3061
+ ).pipe(
3062
+ Effect_exports.map((payloads) => ({
3063
+ resource: resource(source),
2418
3064
  scopeSpans: [
2419
3065
  {
2420
3066
  scope: { name: service },
2421
- spans: payloads.flatMap((payload) => payload.resourceSpans).flatMap((r) => r.scopeSpans.flatMap((s) => s.spans)).filter((span) => traceId === void 0 || span.traceId === traceId)
3067
+ spans: payloads.flatMap((payload) => payload.resourceSpans).flatMap((r) => r.scopeSpans.flatMap((s) => s.spans)).filter((span) => traceId === void 0 || span.traceId === traceId).flatMap((span) => {
3068
+ if (service !== "executor-app") return [span];
3069
+ const kept = appSpan(span);
3070
+ return kept === void 0 ? [] : [kept];
3071
+ })
2422
3072
  }
2423
3073
  ]
2424
- }
2425
- ]
2426
- }))
2427
- ) : yield* Effect_exports.forEach(
2428
- batch.logs,
2429
- (body) => Schema_exports.decodeUnknownEffect(LogPayload)(body)
2430
- ).pipe(
2431
- Effect_exports.map((payloads) => ({
2432
- resourceLogs: [
2433
- {
2434
- resource,
3074
+ }))
3075
+ )
3076
+ )
3077
+ } : {
3078
+ resourceLogs: yield* Effect_exports.forEach(
3079
+ sending,
3080
+ ({ batch, traceId, source }) => Effect_exports.forEach(
3081
+ batch.logs,
3082
+ (body) => Schema_exports.decodeUnknownEffect(LogPayload)(body)
3083
+ ).pipe(
3084
+ Effect_exports.map((payloads) => ({
3085
+ resource: resource(source),
2435
3086
  scopeLogs: [
2436
3087
  {
2437
3088
  scope: { name: service },
2438
- logRecords: payloads.flatMap((payload) => payload.resourceLogs).flatMap((r) => r.scopeLogs.flatMap((s) => s.logRecords)).filter((log) => traceId === void 0 || log.traceId === traceId)
3089
+ logRecords: payloads.flatMap((payload) => payload.resourceLogs).flatMap((r) => r.scopeLogs.flatMap((s) => s.logRecords)).filter((log) => traceId === void 0 || log.traceId === traceId).map((log) => service === "executor-app" ? appLog(log) : log)
2439
3090
  }
2440
3091
  ]
2441
- }
2442
- ]
2443
- }))
2444
- );
2445
- yield* client.pipe(HttpClient_exports.filterStatusOk).execute(
3092
+ }))
3093
+ )
3094
+ )
3095
+ };
3096
+ yield* client.execute(
2446
3097
  HttpClientRequest_exports.post(target.url).pipe(
2447
3098
  HttpClientRequest_exports.setHeaders(
2448
3099
  target.headers === void 0 ? {} : Redacted_exports.value(target.headers)
@@ -2450,7 +3101,13 @@ var forwardTelemetry = (batch, traceId, build, service = "executor-app") => Effe
2450
3101
  HttpClientRequest_exports.bodyJsonUnsafe(data)
2451
3102
  )
2452
3103
  );
2453
- }
3104
+ });
3105
+ const sent = yield* Effect_exports.forEach(
3106
+ ["traces", "logs"],
3107
+ (signal) => Effect_exports.result(send(signal)),
3108
+ { concurrency: "unbounded" }
3109
+ );
3110
+ yield* Effect_exports.forEach(sent, (result) => Effect_exports.fromResult(result), { discard: true });
2454
3111
  }).pipe(
2455
3112
  Effect_exports.provide(telemetryHttpClient),
2456
3113
  Effect_exports.provideService(Tracer_exports.DisablePropagation, true),
@@ -2459,8 +3116,8 @@ var forwardTelemetry = (batch, traceId, build, service = "executor-app") => Effe
2459
3116
 
2460
3117
  // ../telemetry/src/trace-context.ts
2461
3118
  var TraceContext = Schema_exports.Struct({
2462
- traceId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{32}$)[a-f0-9]{32}$/)),
2463
- spanId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{16}$)[a-f0-9]{16}$/)),
3119
+ traceId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{32}$)[a-f0-9]{32}$/u)),
3120
+ spanId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{16}$)[a-f0-9]{16}$/u)),
2464
3121
  sampled: Schema_exports.Boolean
2465
3122
  });
2466
3123
  var currentTraceContext = Effect_exports.currentSpan.pipe(
@@ -2502,12 +3159,17 @@ var pendingSpan = (name, options) => Effect_exports.gen(function* () {
2502
3159
 
2503
3160
  export {
2504
3161
  CurrentTelemetryConfig,
3162
+ ownedBy,
3163
+ owned,
3164
+ measuredSpan,
3165
+ makeOwnershipAccounting,
2505
3166
  OtlpExporter_exports,
2506
3167
  telemetryLayer,
2507
3168
  captureTelemetry,
2508
3169
  withRemoteSpan,
2509
3170
  invocationFetch,
2510
3171
  collectTelemetry,
3172
+ TraceContext,
2511
3173
  externalTrace,
2512
3174
  traceLinks,
2513
3175
  pendingSpan