@lunora/runtime 1.0.0-alpha.34 → 1.0.0-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1647 -1001
- package/dist/index.d.ts +1647 -1001
- package/dist/index.mjs +6 -3
- package/dist/packem_shared/HEALTH_PATH-e5J_NHBx.mjs +150 -0
- package/dist/packem_shared/{analyticsEngineSink-DE48mQA9.mjs → analyticsEngineSink-DgL64WVC.mjs} +1 -1
- package/dist/packem_shared/argsFromQuery-BqPiQTPc.mjs +114 -0
- package/dist/packem_shared/{composeWorker-DAwO9LLs.mjs → composeWorker-UwHY2r8O.mjs} +282 -69
- package/dist/packem_shared/createKvCursorStore-g8aA6B4L.mjs +165 -0
- package/dist/packem_shared/emitLogEvent-BlGMnKZK.mjs +1 -0
- package/dist/packem_shared/method-guard-Qzw99aCj.mjs +3 -0
- package/dist/packem_shared/observability--NOFYBFc.mjs +47 -0
- package/dist/packem_shared/{otlp-DOLuy1Aj.mjs → otlp-DKZJCkdD.mjs} +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/emitLogEvent-pEdtqAK8.mjs +0 -20
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const DEFAULT_TRACE_HEAD_RATE = 1;
|
|
2
|
+
const traceIdToUnitInterval = (traceId) => {
|
|
3
|
+
const int = Number.parseInt(traceId.slice(0, 8), 16);
|
|
4
|
+
return Number.isFinite(int) ? int / 4294967296 : 0;
|
|
5
|
+
};
|
|
6
|
+
const isTraceHeadSampled = (traceId, headRate = DEFAULT_TRACE_HEAD_RATE) => {
|
|
7
|
+
if (headRate >= 1) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (headRate <= 0) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return traceIdToUnitInterval(traceId) < headRate;
|
|
14
|
+
};
|
|
15
|
+
const resolveTraceSampling = (config, traceId) => {
|
|
16
|
+
return {
|
|
17
|
+
isTraced: isTraceHeadSampled(traceId, config?.headRate ?? DEFAULT_TRACE_HEAD_RATE),
|
|
18
|
+
keepErrors: config?.alwaysSampleErrors ?? true
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const shouldExportTrace = (decision, traceHasError) => {
|
|
22
|
+
return decision.isTraced || decision.keepErrors && traceHasError;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const emitRpcEvent = (sink, event, context, sampling) => {
|
|
26
|
+
if (!sink?.onRpc) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (sampling !== void 0 && event.traceId !== void 0 && !shouldExportTrace(resolveTraceSampling(sampling, event.traceId), !event.ok)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
sink.onRpc(event, context);
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const emitLogEvent = (sink, event, context) => {
|
|
38
|
+
if (!sink?.onLog) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
sink.onLog(event, context);
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { emitRpcEvent as a, emitLogEvent as e, resolveTraceSampling as r };
|
|
@@ -24,7 +24,7 @@ const otlpRandomHex = (bytes) => {
|
|
|
24
24
|
}
|
|
25
25
|
return hex;
|
|
26
26
|
};
|
|
27
|
-
const buildTraceparent = (traceId, spanId) => `00-${traceId}-${spanId}
|
|
27
|
+
const buildTraceparent = (traceId, spanId, sampled = true) => `00-${traceId}-${spanId}-${sampled ? "01" : "00"}`;
|
|
28
28
|
const encodeAttribute = (key, value) => {
|
|
29
29
|
if (typeof value === "boolean") {
|
|
30
30
|
return { key, value: { boolValue: value } };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/runtime",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.35",
|
|
4
4
|
"description": "Lunora Worker runtime: the RPC router, shard resolver, and query coordinator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/bindings": "1.0.0-alpha.
|
|
50
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
49
|
+
"@lunora/bindings": "1.0.0-alpha.10",
|
|
50
|
+
"@lunora/errors": "1.0.0-alpha.7"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": "^22.15.0 || >=24.11.0"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const emitRpcEvent = (sink, event, context) => {
|
|
2
|
-
if (!sink?.onRpc) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
try {
|
|
6
|
-
sink.onRpc(event, context);
|
|
7
|
-
} catch {
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const emitLogEvent = (sink, event, context) => {
|
|
11
|
-
if (!sink?.onLog) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
try {
|
|
15
|
-
sink.onLog(event, context);
|
|
16
|
-
} catch {
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { emitLogEvent, emitRpcEvent };
|