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