@fedify/fedify 1.10.5 → 1.10.7
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/{actor-CjkHF7Cj.cjs → actor-BGIAXtRd.cjs} +3112 -4674
- package/dist/{actor-Ch9BTg3N.js → actor-C-_2S5Mn.mjs} +8 -15
- package/dist/{actor-CQdxP8N-.js → actor-Cujbx4Zv.js} +1205 -2768
- package/dist/{actor-eeONG_sv.d.ts → actor-DXwwgFeR.d.ts} +3 -3
- package/dist/{actor-D190nbTD.d.cts → actor-DxvGbmjm.d.cts} +3 -3
- package/dist/{assert-MZs1qjMx.js → assert-DikXweDx.mjs} +5 -9
- package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
- package/dist/{assert_is_error-BPGph1Jx.js → assert_is_error-C50x8tnw.mjs} +5 -9
- package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-CJC9ThS-.mjs} +6 -11
- package/dist/{assert_throws-BOO88avQ.js → assert_throws-BIL7gChy.mjs} +6 -10
- package/dist/{authdocloader-fR-Fqcpa.js → authdocloader-1Sk2bqFx.mjs} +9 -14
- package/dist/{authdocloader-COFZT9Wh.js → authdocloader-D4Y6iyTF.js} +8 -15
- package/dist/{authdocloader-zc5ibOmU.cjs → authdocloader-DQfruCir.cjs} +14 -22
- package/dist/{builder-YD0q32nG.js → builder-CZbrDRl7.mjs} +31 -40
- package/dist/{client-B3mQJNO7.d.ts → client-D7t26_op.d.ts} +2 -2
- package/dist/{client-BgCucCG7.js → client-Dyb8MI3u.mjs} +11 -15
- package/dist/{client-n6L4GtQL.d.cts → client-yc0Z0P6Y.d.cts} +2 -2
- package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
- package/dist/compat/mod.cjs +5 -8
- package/dist/compat/mod.d.cts +78 -12
- package/dist/compat/mod.d.ts +78 -12
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-Cr5DIxq_.d.ts → context-C6n2yrj0.d.ts} +33 -26
- package/dist/{context-WJoO0SQs.d.cts → context-PfghnHYj.d.cts} +33 -26
- package/dist/{denokv-D0nfNQ1x.js → denokv-NJPMXyK0.mjs} +22 -11
- package/dist/{docloader-BucCRHZI.d.ts → docloader-D7k5A9JP.d.ts} +2 -7
- package/dist/{docloader-ChxNLZAA.d.cts → docloader-DbM94pGY.d.cts} +2 -7
- package/dist/{docloader-BETPdM09.js → docloader-Dtaju6oI.js} +18 -156
- package/dist/{docloader-irBWMSOZ.cjs → docloader-Q3DfzuUi.cjs} +116 -220
- package/dist/{esm-iGH0sRsE.js → esm-DOJg552-.mjs} +49 -85
- package/dist/federation/{builder.test.js → builder.test.mjs} +22 -41
- package/dist/federation/collection.test.d.mts +2 -0
- package/dist/federation/collection.test.mjs +21 -0
- package/dist/federation/handler.test.d.mts +2 -0
- package/dist/federation/{handler.test.js → handler.test.mjs} +29 -58
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +29 -59
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +10 -15
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -18
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +12 -26
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +182 -197
- package/dist/federation/mod.cjs +245 -21
- package/dist/federation/mod.d.cts +4 -13
- package/dist/federation/mod.d.ts +4 -13
- package/dist/federation/mod.js +240 -18
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +23 -38
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +9 -14
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +12 -19
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +24 -34
- package/dist/{http-PgdBoDIj.js → http-BRwSVBn1.mjs} +16 -32
- package/dist/{http-DS9z_HzB.d.ts → http-BYXQvoZQ.d.ts} +5 -9
- package/dist/{http-C_1RU1U_.d.cts → http-CMzg-A9P.d.cts} +5 -9
- package/dist/{http-CQAqR_vx.cjs → http-DCrun8ql.cjs} +51 -68
- package/dist/{http-CxiIW4rD.js → http-DRnRwr3i.js} +17 -33
- package/dist/{inbox-DcDIqTbR.js → inbox-pD1nbb_5.mjs} +17 -25
- package/dist/key-Cmbps6xt.cjs +4 -0
- package/dist/{key-dNFkodH5.cjs → key-DEYIxAFs.cjs} +42 -50
- package/dist/key-DMO0TgTa.mjs +5 -0
- package/dist/{key-I-ibyaZH.js → key-DdL5Oc59.mjs} +12 -18
- package/dist/{key-Cg0kO4dA.js → key-vIzWPiil.js} +19 -19
- package/dist/{keycache-hSs_XFSb.js → keycache-BVR9f06Y.mjs} +6 -10
- package/dist/{keys-CElJez9H.js → keys-Co-0pK8a.mjs} +6 -10
- package/dist/{kv-DipCBaw2.d.ts → kv-C6UC8M9S.d.ts} +1 -1
- package/dist/{kv-BqEOXcZv.d.cts → kv-ClC9WJh5.d.cts} +1 -1
- package/dist/{kv-QzKcOQgP.js → kv-OuT2IU64.mjs} +6 -10
- package/dist/{ld-b16r91YS.js → ld-BFaDk5gX.mjs} +17 -31
- package/dist/{lookup-CySNcNcC.js → lookup-CMYXdjVH.mjs} +8 -17
- package/dist/{lookup-Bfq9Jpm0.cjs → lookup-CZGJqSjm.cjs} +16 -23
- package/dist/{lookup-CiSAeWJl.js → lookup-jlmCTRsO.js} +5 -11
- package/dist/middleware-BWlZ-wms.cjs +4 -0
- package/dist/{middleware-C5emnCh-.js → middleware-BXD5WJbj.mjs} +276 -321
- package/dist/{middleware-Dxo56yae.cjs → middleware-BhMQrJXH.cjs} +494 -547
- package/dist/{middleware-Bs4xDuXR.js → middleware-CmA2E9Bu.js} +349 -393
- package/dist/middleware-H3Ce7yn3.mjs +5 -0
- package/dist/{mod-D5rfgGFE.d.cts → mod-BQ3lrlXU.d.cts} +3 -3
- package/dist/{mod-Dz5Y15Uy.d.cts → mod-C72agZIN.d.cts} +4 -4
- package/dist/{mod-CxMBb_dd.d.cts → mod-CDbqB60V.d.cts} +2 -2
- package/dist/{mod-DS4kJskR.d.ts → mod-Lj0W1nnG.d.ts} +3 -3
- package/dist/{mod-BZfdiPBo.d.ts → mod-_HNKaczF.d.ts} +4 -4
- package/dist/{mod-ChbckRnC.d.ts → mod-lHd-Zdd_.d.ts} +2 -2
- package/dist/mod.cjs +31 -33
- package/dist/mod.d.cts +15 -17
- package/dist/mod.d.ts +15 -17
- package/dist/mod.js +20 -23
- package/dist/{mq-B7R1Q-M5.d.cts → mq-CrItclRD.d.cts} +1 -1
- package/dist/{mq-CRGm1e_F.d.ts → mq-D_ZZRdby.d.ts} +1 -1
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +23 -45
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +14 -43
- package/dist/nodeinfo/mod.cjs +5 -9
- package/dist/nodeinfo/mod.d.cts +2 -5
- package/dist/nodeinfo/mod.d.ts +2 -5
- package/dist/nodeinfo/mod.js +4 -9
- package/dist/nodeinfo/semver.test.d.mts +2 -0
- package/dist/nodeinfo/{semver.test.js → semver.test.mjs} +28 -51
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +10 -21
- package/dist/otel/exporter.test.d.mts +2 -0
- package/dist/otel/{exporter.test.js → exporter.test.mjs} +122 -180
- package/dist/otel/mod.cjs +16 -22
- package/dist/otel/mod.d.cts +2 -2
- package/dist/otel/mod.d.ts +2 -2
- package/dist/otel/mod.js +9 -16
- package/dist/{otel-Chy5T2Xh.js → otel-0v4Zy01l.mjs} +5 -10
- package/dist/{owner-AcrG3Xz1.d.cts → owner-0yNTyGMb.d.cts} +4 -4
- package/dist/{owner-Bs-sPbHX.js → owner-CNdS8zxf.mjs} +11 -16
- package/dist/{owner-8NMhXwJd.d.ts → owner-CPEbNpnZ.d.ts} +4 -4
- package/dist/{proof-SgRikE_Y.js → proof-Co7YmDpv.mjs} +20 -32
- package/dist/{proof-flD2DeA-.js → proof-DHPbi_Mx.js} +34 -60
- package/dist/{proof-BvQS195q.cjs → proof-DcPdtve2.cjs} +115 -140
- package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
- package/dist/rolldown-runtime-C7fyD9f2.js +15 -0
- package/dist/runtime/authdocloader.test.d.mts +2 -0
- package/dist/runtime/{authdocloader.test.js → authdocloader.test.mjs} +16 -28
- package/dist/runtime/docloader.test.d.mts +2 -0
- package/dist/runtime/{docloader.test.js → docloader.test.mjs} +55 -77
- package/dist/runtime/key.test.d.mts +2 -0
- package/dist/runtime/{key.test.js → key.test.mjs} +27 -57
- package/dist/runtime/langstr.test.d.mts +2 -0
- package/dist/runtime/{langstr.test.js → langstr.test.mjs} +9 -19
- package/dist/runtime/link.test.d.mts +2 -0
- package/dist/runtime/{link.test.js → link.test.mjs} +7 -11
- package/dist/runtime/mod.cjs +7 -13
- package/dist/runtime/mod.d.cts +103 -6
- package/dist/runtime/mod.d.ts +103 -6
- package/dist/runtime/mod.js +6 -13
- package/dist/runtime/multibase/multibase.test.d.mts +2 -0
- package/dist/runtime/multibase/{multibase.test.js → multibase.test.mjs} +16 -33
- package/dist/runtime/url.test.d.mts +2 -0
- package/dist/runtime/{url.test.js → url.test.mjs} +10 -15
- package/dist/{semver-dArNLkR9.js → semver-CgD82xxg.mjs} +13 -28
- package/dist/{send-C0gFHa2i.js → send-BRCWNcMa.mjs} +7 -12
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +119 -203
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +13 -22
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +24 -39
- package/dist/sig/mod.cjs +7 -13
- package/dist/sig/mod.d.cts +3 -7
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +6 -13
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/{owner.test.js → owner.test.mjs} +23 -39
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +18 -31
- package/dist/{std__assert-X-_kMxKM.js → std__assert-2v7gYiZp.mjs} +13 -24
- package/dist/testing/docloader.test.d.mts +2 -0
- package/dist/testing/docloader.test.mjs +12 -0
- package/dist/testing/{mod.d.ts → mod.d.mts} +371 -541
- package/dist/testing/mod.mjs +5 -0
- package/dist/{testing-C1GIraJh.js → testing-BLIh1cXz.mjs} +27 -35
- package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
- package/dist/{transformers-CoBS-oFG.cjs → transformers-CLtJ5H8o.cjs} +20 -25
- package/dist/{types-BgUCCngg.cjs → types-B34v-m2N.cjs} +45 -64
- package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
- package/dist/{types-Bu-epI-z.js → types-CXZk86AG.js} +18 -36
- package/dist/vocab/actor.test.d.mts +2 -0
- package/dist/vocab/{actor.test.js → actor.test.mjs} +308 -550
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/lookup.test.d.mts +2 -0
- package/dist/vocab/{lookup.test.js → lookup.test.mjs} +34 -51
- package/dist/vocab/mod.cjs +256 -16
- package/dist/vocab/mod.d.cts +3 -5
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +249 -10
- package/dist/vocab/type.test.d.mts +2 -0
- package/dist/vocab/type.test.mjs +16 -0
- package/dist/vocab/vocab.test.d.mts +2 -0
- package/dist/vocab/{vocab.test.js → vocab.test.mjs} +178 -311
- package/dist/{vocab-BASuuzcJ.d.ts → vocab-DaT4UsJF.d.ts} +2 -2
- package/dist/{vocab-DPMmFPJ1.d.cts → vocab-DnlmNyXi.d.cts} +2 -2
- package/dist/{type-DUhon7qK.js → vocab-rT_94Pke.mjs} +1178 -2876
- package/dist/webfinger/handler.test.d.mts +2 -0
- package/dist/webfinger/{handler.test.js → handler.test.mjs} +23 -56
- package/dist/webfinger/lookup.test.d.mts +2 -0
- package/dist/webfinger/{lookup.test.js → lookup.test.mjs} +13 -27
- package/dist/webfinger/mod.cjs +5 -9
- package/dist/webfinger/mod.d.cts +1 -3
- package/dist/webfinger/mod.d.ts +1 -3
- package/dist/webfinger/mod.js +4 -9
- package/dist/x/cfworkers.cjs +25 -14
- package/dist/x/cfworkers.d.cts +33 -6
- package/dist/x/cfworkers.d.ts +33 -6
- package/dist/x/cfworkers.js +22 -12
- package/dist/x/cfworkers.test.d.mts +2 -0
- package/dist/x/{cfworkers.test.js → cfworkers.test.mjs} +28 -26
- package/dist/x/hono.cjs +25 -14
- package/dist/x/hono.d.cts +1 -11
- package/dist/x/hono.d.ts +1 -11
- package/dist/x/hono.js +22 -12
- package/dist/x/sveltekit.cjs +23 -12
- package/dist/x/sveltekit.d.cts +1 -11
- package/dist/x/sveltekit.d.ts +1 -11
- package/dist/x/sveltekit.js +20 -10
- package/package.json +2 -2
- package/dist/chunk-DqRYRqnO.cjs +0 -34
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -86
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/compat-nxUqe4Z-.js +0 -4
- package/dist/federation/builder.test.d.ts +0 -3
- package/dist/federation/collection.test.d.ts +0 -3
- package/dist/federation/collection.test.js +0 -35
- package/dist/federation/handler.test.d.ts +0 -3
- package/dist/federation/idempotency.test.d.ts +0 -3
- package/dist/federation/inbox.test.d.ts +0 -3
- package/dist/federation/keycache.test.d.ts +0 -3
- package/dist/federation/kv.test.d.ts +0 -3
- package/dist/federation/middleware.test.d.ts +0 -3
- package/dist/federation/mq.test.d.ts +0 -3
- package/dist/federation/retry.test.d.ts +0 -3
- package/dist/federation/router.test.d.ts +0 -3
- package/dist/federation/send.test.d.ts +0 -3
- package/dist/federation-C15gGOh1.cjs +0 -266
- package/dist/federation-K-xsO03l.js +0 -248
- package/dist/key-Bnod5wJl.js +0 -10
- package/dist/key-C6swTX71.js +0 -10
- package/dist/key-_Uq8gkmM.cjs +0 -10
- package/dist/middleware-BWsOtDIF.cjs +0 -17
- package/dist/middleware-Bm4bJzjg.js +0 -26
- package/dist/middleware-BvODpE_U.js +0 -17
- package/dist/mod-C2tOeRkN.d.cts +0 -1
- package/dist/mod-CD7gfdq3.d.ts +0 -104
- package/dist/mod-CnULG6Aa.d.ts +0 -82
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-JUhOKMHj.d.cts +0 -102
- package/dist/mod-OQfb33eH.d.cts +0 -80
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/semver.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-Co9lJrWl.cjs +0 -4
- package/dist/nodeinfo-DfycQ8Wf.js +0 -4
- package/dist/otel/exporter.test.d.ts +0 -3
- package/dist/runtime/authdocloader.test.d.ts +0 -3
- package/dist/runtime/docloader.test.d.ts +0 -3
- package/dist/runtime/key.test.d.ts +0 -3
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/link.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime-C58AJWSv.cjs +0 -4
- package/dist/runtime-DPYEDf-o.js +0 -4
- package/dist/sig/http.test.d.ts +0 -3
- package/dist/sig/key.test.d.ts +0 -3
- package/dist/sig/ld.test.d.ts +0 -3
- package/dist/sig/owner.test.d.ts +0 -3
- package/dist/sig/proof.test.d.ts +0 -3
- package/dist/sig-ByHXzqUi.cjs +0 -4
- package/dist/sig-Cj3tk-ig.js +0 -4
- package/dist/testing/docloader.test.d.ts +0 -3
- package/dist/testing/docloader.test.js +0 -24
- package/dist/testing/mod.js +0 -10
- package/dist/vocab/actor.test.d.ts +0 -3
- package/dist/vocab/lookup.test.d.ts +0 -3
- package/dist/vocab/type.test.d.ts +0 -3
- package/dist/vocab/type.test.js +0 -25
- package/dist/vocab/vocab.test.d.ts +0 -3
- package/dist/vocab-5i6DEIi6.cjs +0 -294
- package/dist/vocab-CBavAdew.js +0 -258
- package/dist/webfinger/handler.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.d.ts +0 -3
- package/dist/webfinger-BjOEdFPs.cjs +0 -4
- package/dist/webfinger-De_bU0iE.js +0 -4
- package/dist/x/cfworkers.test.d.ts +0 -3
- /package/dist/{mod-1pDWKvUL.d.ts → compat/transformers.test.d.mts} +0 -0
- /package/dist/{mod-g0xFzAP9.d.ts → federation/builder.test.d.mts} +0 -0
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "../
|
|
7
|
-
import {
|
|
8
|
-
import "../
|
|
9
|
-
import "../assert_instance_of-DHz7EHNU.js";
|
|
10
|
-
import { MemoryKvStore } from "../kv-QzKcOQgP.js";
|
|
11
|
-
import "../lookup-CySNcNcC.js";
|
|
12
|
-
import { test } from "../testing-C1GIraJh.js";
|
|
13
|
-
import "../std__assert-X-_kMxKM.js";
|
|
14
|
-
import "../assert_rejects-DiIiJbZn.js";
|
|
15
|
-
import "../assert_is_error-BPGph1Jx.js";
|
|
16
|
-
import "../assert_not_equals-f3m3epl3.js";
|
|
17
|
-
import { assertThrows } from "../assert_throws-BOO88avQ.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as test } from "../testing-BLIh1cXz.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
+
import "../std__assert-2v7gYiZp.mjs";
|
|
7
|
+
import { t as assertThrows } from "../assert_throws-BIL7gChy.mjs";
|
|
8
|
+
import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";
|
|
18
9
|
import { getLogger } from "@logtape/logtape";
|
|
19
10
|
import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
|
|
20
11
|
import { ExportResultCode } from "@opentelemetry/core";
|
|
21
|
-
|
|
22
12
|
//#region src/otel/exporter.ts
|
|
23
13
|
/**
|
|
24
14
|
* A SpanExporter that persists ActivityPub activity traces to a
|
|
@@ -107,8 +97,7 @@ var FedifySpanExporter = class {
|
|
|
107
97
|
const records = this.#extractRecords(span);
|
|
108
98
|
for (const record of records) storeOperations.push(this.#storeRecord(record));
|
|
109
99
|
}
|
|
110
|
-
const
|
|
111
|
-
const rejected = results.filter((r) => r.status === "rejected");
|
|
100
|
+
const rejected = (await Promise.allSettled(storeOperations)).filter((r) => r.status === "rejected");
|
|
112
101
|
if (rejected.length > 0) throw new AggregateError(rejected.map((r) => r.reason), "Failed to store one or more trace activity records.");
|
|
113
102
|
}
|
|
114
103
|
#extractRecords(span) {
|
|
@@ -209,12 +198,11 @@ var FedifySpanExporter = class {
|
|
|
209
198
|
}
|
|
210
199
|
async #setWithCasRetry(key, transform, options) {
|
|
211
200
|
if (this.#kv.cas != null) for (let attempt = 0; attempt < 3; attempt++) {
|
|
212
|
-
const existing
|
|
213
|
-
const newValue
|
|
214
|
-
if (await this.#kv.cas(key, existing
|
|
201
|
+
const existing = await this.#kv.get(key);
|
|
202
|
+
const newValue = transform(existing);
|
|
203
|
+
if (await this.#kv.cas(key, existing, newValue, options)) return;
|
|
215
204
|
}
|
|
216
|
-
const
|
|
217
|
-
const newValue = transform(existing);
|
|
205
|
+
const newValue = transform(await this.#kv.get(key));
|
|
218
206
|
await this.#kv.set(key, newValue, options);
|
|
219
207
|
}
|
|
220
208
|
async #updateTraceSummary(record, options) {
|
|
@@ -259,8 +247,7 @@ var FedifySpanExporter = class {
|
|
|
259
247
|
return records;
|
|
260
248
|
} else {
|
|
261
249
|
const key = [...this.#keyPrefix, traceId];
|
|
262
|
-
|
|
263
|
-
return records ?? [];
|
|
250
|
+
return await this.#kv.get(key) ?? [];
|
|
264
251
|
}
|
|
265
252
|
}
|
|
266
253
|
/**
|
|
@@ -287,15 +274,12 @@ var FedifySpanExporter = class {
|
|
|
287
274
|
*/
|
|
288
275
|
async shutdown() {}
|
|
289
276
|
};
|
|
290
|
-
|
|
291
277
|
//#endregion
|
|
292
278
|
//#region src/otel/exporter.test.ts
|
|
293
279
|
function createMockSpan(options) {
|
|
294
|
-
const traceId = options.traceId ?? "0123456789abcdef0123456789abcdef";
|
|
295
|
-
const spanId = options.spanId ?? "0123456789abcdef";
|
|
296
280
|
const spanContext = {
|
|
297
|
-
traceId,
|
|
298
|
-
spanId,
|
|
281
|
+
traceId: options.traceId ?? "0123456789abcdef0123456789abcdef",
|
|
282
|
+
spanId: options.spanId ?? "0123456789abcdef",
|
|
299
283
|
traceFlags: TraceFlags.SAMPLED
|
|
300
284
|
};
|
|
301
285
|
return {
|
|
@@ -358,23 +342,18 @@ test("FedifySpanExporter", async (t) => {
|
|
|
358
342
|
assertThrows(() => new FedifySpanExporter(kv), Error, "KvStore must support either list() or cas()");
|
|
359
343
|
});
|
|
360
344
|
await t.step("constructor accepts KvStore with list()", () => {
|
|
361
|
-
|
|
362
|
-
const exporter = new FedifySpanExporter(kv);
|
|
363
|
-
assertEquals(exporter instanceof FedifySpanExporter, true);
|
|
345
|
+
assertEquals(new FedifySpanExporter(new MemoryKvStore()) instanceof FedifySpanExporter, true);
|
|
364
346
|
});
|
|
365
347
|
await t.step("constructor accepts KvStore with cas() only", () => {
|
|
366
|
-
|
|
348
|
+
assertEquals(new FedifySpanExporter({
|
|
367
349
|
get: () => Promise.resolve(void 0),
|
|
368
350
|
set: () => Promise.resolve(),
|
|
369
351
|
delete: () => Promise.resolve(),
|
|
370
352
|
cas: () => Promise.resolve(true)
|
|
371
|
-
};
|
|
372
|
-
const exporter = new FedifySpanExporter(kv);
|
|
373
|
-
assertEquals(exporter instanceof FedifySpanExporter, true);
|
|
353
|
+
}) instanceof FedifySpanExporter, true);
|
|
374
354
|
});
|
|
375
355
|
await t.step("export() stores inbound activity from span event", async () => {
|
|
376
|
-
const
|
|
377
|
-
const exporter = new FedifySpanExporter(kv);
|
|
356
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
378
357
|
const traceId = "trace123";
|
|
379
358
|
const spanId = "span456";
|
|
380
359
|
const activity = {
|
|
@@ -415,8 +394,7 @@ test("FedifySpanExporter", async (t) => {
|
|
|
415
394
|
assertEquals(activities[0].verified, true);
|
|
416
395
|
});
|
|
417
396
|
await t.step("export() stores outbound activity from span event", async () => {
|
|
418
|
-
const
|
|
419
|
-
const exporter = new FedifySpanExporter(kv);
|
|
397
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
420
398
|
const traceId = "trace789";
|
|
421
399
|
const spanId = "span012";
|
|
422
400
|
const inboxUrl = "https://example.com/users/alice/inbox";
|
|
@@ -427,13 +405,12 @@ test("FedifySpanExporter", async (t) => {
|
|
|
427
405
|
actor: "https://myserver.com/users/bob",
|
|
428
406
|
object: "https://example.com/users/alice"
|
|
429
407
|
};
|
|
430
|
-
const activityJson = JSON.stringify(activity);
|
|
431
408
|
const span = createMockSpan({
|
|
432
409
|
traceId,
|
|
433
410
|
spanId,
|
|
434
411
|
name: "activitypub.send_activity",
|
|
435
412
|
events: [createActivitySentEvent({
|
|
436
|
-
activityJson,
|
|
413
|
+
activityJson: JSON.stringify(activity),
|
|
437
414
|
inboxUrl,
|
|
438
415
|
activityId: activity.id
|
|
439
416
|
})]
|
|
@@ -454,8 +431,7 @@ test("FedifySpanExporter", async (t) => {
|
|
|
454
431
|
assertEquals(activities[0].inboxUrl, inboxUrl);
|
|
455
432
|
});
|
|
456
433
|
await t.step("export() ignores spans without activity events", async () => {
|
|
457
|
-
const
|
|
458
|
-
const exporter = new FedifySpanExporter(kv);
|
|
434
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
459
435
|
const span = createMockSpan({
|
|
460
436
|
traceId: "trace999",
|
|
461
437
|
spanId: "span999",
|
|
@@ -468,12 +444,10 @@ test("FedifySpanExporter", async (t) => {
|
|
|
468
444
|
resolve();
|
|
469
445
|
});
|
|
470
446
|
});
|
|
471
|
-
|
|
472
|
-
assertEquals(activities.length, 0);
|
|
447
|
+
assertEquals((await exporter.getActivitiesByTraceId("trace999")).length, 0);
|
|
473
448
|
});
|
|
474
449
|
await t.step("export() stores multiple activities from same trace", async () => {
|
|
475
|
-
const
|
|
476
|
-
const exporter = new FedifySpanExporter(kv);
|
|
450
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
477
451
|
const inboundActivity = JSON.stringify({
|
|
478
452
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
479
453
|
type: "Create",
|
|
@@ -515,8 +489,7 @@ test("FedifySpanExporter", async (t) => {
|
|
|
515
489
|
assertEquals(outbound?.parentSpanId, "span1");
|
|
516
490
|
});
|
|
517
491
|
await t.step("getRecentTraces() returns recent traces", async () => {
|
|
518
|
-
const
|
|
519
|
-
const exporter = new FedifySpanExporter(kv);
|
|
492
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
520
493
|
for (let i = 0; i < 5; i++) {
|
|
521
494
|
const activityJson = JSON.stringify({
|
|
522
495
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
@@ -533,12 +506,10 @@ test("FedifySpanExporter", async (t) => {
|
|
|
533
506
|
exporter.export([span], () => resolve());
|
|
534
507
|
});
|
|
535
508
|
}
|
|
536
|
-
|
|
537
|
-
assertEquals(traces.length, 3);
|
|
509
|
+
assertEquals((await exporter.getRecentTraces({ limit: 3 })).length, 3);
|
|
538
510
|
});
|
|
539
511
|
await t.step("getRecentTraces() returns all traces when limit not specified", async () => {
|
|
540
|
-
const
|
|
541
|
-
const exporter = new FedifySpanExporter(kv);
|
|
512
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
542
513
|
for (let i = 0; i < 3; i++) {
|
|
543
514
|
const activityJson = JSON.stringify({
|
|
544
515
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
@@ -555,22 +526,17 @@ test("FedifySpanExporter", async (t) => {
|
|
|
555
526
|
exporter.export([span], () => resolve());
|
|
556
527
|
});
|
|
557
528
|
}
|
|
558
|
-
|
|
559
|
-
assertEquals(traces.length >= 3, true);
|
|
529
|
+
assertEquals((await exporter.getRecentTraces()).length >= 3, true);
|
|
560
530
|
});
|
|
561
531
|
await t.step("forceFlush() returns resolved promise", async () => {
|
|
562
|
-
|
|
563
|
-
const exporter = new FedifySpanExporter(kv);
|
|
564
|
-
await exporter.forceFlush();
|
|
532
|
+
await new FedifySpanExporter(new MemoryKvStore()).forceFlush();
|
|
565
533
|
});
|
|
566
534
|
await t.step("shutdown() completes successfully", async () => {
|
|
567
|
-
|
|
568
|
-
const exporter = new FedifySpanExporter(kv);
|
|
569
|
-
await exporter.shutdown();
|
|
535
|
+
await new FedifySpanExporter(new MemoryKvStore()).shutdown();
|
|
570
536
|
});
|
|
571
537
|
await t.step("works with cas()-only KvStore", async () => {
|
|
572
538
|
const storedData = {};
|
|
573
|
-
const
|
|
539
|
+
const exporter = new FedifySpanExporter({
|
|
574
540
|
get: (key) => {
|
|
575
541
|
const k = JSON.stringify(key);
|
|
576
542
|
return Promise.resolve(storedData[k]);
|
|
@@ -594,18 +560,16 @@ test("FedifySpanExporter", async (t) => {
|
|
|
594
560
|
}
|
|
595
561
|
return Promise.resolve(false);
|
|
596
562
|
}
|
|
597
|
-
};
|
|
598
|
-
const exporter = new FedifySpanExporter(kv);
|
|
599
|
-
const activityJson = JSON.stringify({
|
|
600
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
601
|
-
type: "Like",
|
|
602
|
-
id: "https://example.com/activities/like"
|
|
603
563
|
});
|
|
604
564
|
const span = createMockSpan({
|
|
605
565
|
traceId: "cas-trace",
|
|
606
566
|
spanId: "cas-span",
|
|
607
567
|
name: "activitypub.inbox",
|
|
608
|
-
events: [createActivityReceivedEvent({ activityJson
|
|
568
|
+
events: [createActivityReceivedEvent({ activityJson: JSON.stringify({
|
|
569
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
570
|
+
type: "Like",
|
|
571
|
+
id: "https://example.com/activities/like"
|
|
572
|
+
}) })]
|
|
609
573
|
});
|
|
610
574
|
await new Promise((resolve) => {
|
|
611
575
|
exporter.export([span], (result) => {
|
|
@@ -618,36 +582,31 @@ test("FedifySpanExporter", async (t) => {
|
|
|
618
582
|
assertEquals(activities[0].activityType, "Like");
|
|
619
583
|
});
|
|
620
584
|
await t.step("TTL option is respected", async () => {
|
|
621
|
-
const
|
|
622
|
-
const exporter = new FedifySpanExporter(kv, { ttl: Temporal.Duration.from({ hours: 1 }) });
|
|
623
|
-
const activityJson = JSON.stringify({
|
|
624
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
625
|
-
type: "Create"
|
|
626
|
-
});
|
|
585
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore(), { ttl: Temporal.Duration.from({ hours: 1 }) });
|
|
627
586
|
const span = createMockSpan({
|
|
628
587
|
traceId: "ttl-trace",
|
|
629
588
|
spanId: "ttl-span",
|
|
630
589
|
name: "activitypub.inbox",
|
|
631
|
-
events: [createActivityReceivedEvent({ activityJson
|
|
590
|
+
events: [createActivityReceivedEvent({ activityJson: JSON.stringify({
|
|
591
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
592
|
+
type: "Create"
|
|
593
|
+
}) })]
|
|
632
594
|
});
|
|
633
595
|
await new Promise((resolve) => {
|
|
634
596
|
exporter.export([span], () => resolve());
|
|
635
597
|
});
|
|
636
|
-
|
|
637
|
-
assertEquals(activities.length, 1);
|
|
598
|
+
assertEquals((await exporter.getActivitiesByTraceId("ttl-trace")).length, 1);
|
|
638
599
|
});
|
|
639
600
|
await t.step("keyPrefix option customizes storage keys", async () => {
|
|
640
|
-
const
|
|
641
|
-
const exporter = new FedifySpanExporter(kv, { keyPrefix: ["custom", "prefix"] });
|
|
642
|
-
const activityJson = JSON.stringify({
|
|
643
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
644
|
-
type: "Announce"
|
|
645
|
-
});
|
|
601
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore(), { keyPrefix: ["custom", "prefix"] });
|
|
646
602
|
const span = createMockSpan({
|
|
647
603
|
traceId: "prefix-trace",
|
|
648
604
|
spanId: "prefix-span",
|
|
649
605
|
name: "activitypub.inbox",
|
|
650
|
-
events: [createActivityReceivedEvent({ activityJson
|
|
606
|
+
events: [createActivityReceivedEvent({ activityJson: JSON.stringify({
|
|
607
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
608
|
+
type: "Announce"
|
|
609
|
+
}) })]
|
|
651
610
|
});
|
|
652
611
|
await new Promise((resolve) => {
|
|
653
612
|
exporter.export([span], () => resolve());
|
|
@@ -661,39 +620,37 @@ test("FedifySpanExporter", async (t) => {
|
|
|
661
620
|
const webServerExporter = new FedifySpanExporter(sharedKv);
|
|
662
621
|
const workerExporter = new FedifySpanExporter(sharedKv);
|
|
663
622
|
const dashboardExporter = new FedifySpanExporter(sharedKv);
|
|
664
|
-
const inboundActivity = JSON.stringify({
|
|
665
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
666
|
-
type: "Follow",
|
|
667
|
-
id: "https://remote.example/activities/follow-1",
|
|
668
|
-
actor: "https://remote.example/users/alice",
|
|
669
|
-
object: "https://local.example/users/bob"
|
|
670
|
-
});
|
|
671
623
|
const inboxSpan = createMockSpan({
|
|
672
624
|
traceId: "distributed-trace-001",
|
|
673
625
|
spanId: "inbox-span",
|
|
674
626
|
name: "activitypub.inbox",
|
|
675
627
|
events: [createActivityReceivedEvent({
|
|
676
|
-
activityJson:
|
|
628
|
+
activityJson: JSON.stringify({
|
|
629
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
630
|
+
type: "Follow",
|
|
631
|
+
id: "https://remote.example/activities/follow-1",
|
|
632
|
+
actor: "https://remote.example/users/alice",
|
|
633
|
+
object: "https://local.example/users/bob"
|
|
634
|
+
}),
|
|
677
635
|
verified: true
|
|
678
636
|
})]
|
|
679
637
|
});
|
|
680
638
|
await new Promise((resolve) => {
|
|
681
639
|
webServerExporter.export([inboxSpan], () => resolve());
|
|
682
640
|
});
|
|
683
|
-
const outboundActivity = JSON.stringify({
|
|
684
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
685
|
-
type: "Accept",
|
|
686
|
-
id: "https://local.example/activities/accept-1",
|
|
687
|
-
actor: "https://local.example/users/bob",
|
|
688
|
-
object: "https://remote.example/activities/follow-1"
|
|
689
|
-
});
|
|
690
641
|
const sendSpan = createMockSpan({
|
|
691
642
|
traceId: "distributed-trace-001",
|
|
692
643
|
spanId: "send-span",
|
|
693
644
|
parentSpanId: "inbox-span",
|
|
694
645
|
name: "activitypub.send_activity",
|
|
695
646
|
events: [createActivitySentEvent({
|
|
696
|
-
activityJson:
|
|
647
|
+
activityJson: JSON.stringify({
|
|
648
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
649
|
+
type: "Accept",
|
|
650
|
+
id: "https://local.example/activities/accept-1",
|
|
651
|
+
actor: "https://local.example/users/bob",
|
|
652
|
+
object: "https://remote.example/activities/follow-1"
|
|
653
|
+
}),
|
|
697
654
|
inboxUrl: "https://remote.example/users/alice/inbox",
|
|
698
655
|
activityId: "https://local.example/activities/accept-1"
|
|
699
656
|
})]
|
|
@@ -712,8 +669,7 @@ test("FedifySpanExporter", async (t) => {
|
|
|
712
669
|
assertEquals(accept?.direction, "outbound");
|
|
713
670
|
assertEquals(accept?.inboxUrl, "https://remote.example/users/alice/inbox");
|
|
714
671
|
assertEquals(accept?.parentSpanId, "inbox-span");
|
|
715
|
-
const
|
|
716
|
-
const ourTrace = recentTraces.find((t$1) => t$1.traceId === "distributed-trace-001");
|
|
672
|
+
const ourTrace = (await dashboardExporter.getRecentTraces()).find((t) => t.traceId === "distributed-trace-001");
|
|
717
673
|
assertEquals(ourTrace != null, true);
|
|
718
674
|
assertEquals(ourTrace?.activityCount, 2);
|
|
719
675
|
assertEquals(ourTrace?.activityTypes.includes("Follow"), true);
|
|
@@ -747,34 +703,30 @@ test("FedifySpanExporter", async (t) => {
|
|
|
747
703
|
});
|
|
748
704
|
});
|
|
749
705
|
await Promise.all(exportPromises);
|
|
750
|
-
const
|
|
751
|
-
const activities = await dashboard.getActivitiesByTraceId(traceId);
|
|
706
|
+
const activities = await new FedifySpanExporter(sharedKv).getActivitiesByTraceId(traceId);
|
|
752
707
|
assertEquals(activities.length, 3);
|
|
753
|
-
|
|
754
|
-
assertEquals(inboxUrls, [
|
|
708
|
+
assertEquals(activities.map((a) => a.inboxUrl).sort(), [
|
|
755
709
|
"https://follower-0.example/inbox",
|
|
756
710
|
"https://follower-1.example/inbox",
|
|
757
711
|
"https://follower-2.example/inbox"
|
|
758
712
|
]);
|
|
759
713
|
});
|
|
760
714
|
await t.step("extracts actorId from activity with string actor", async () => {
|
|
761
|
-
const
|
|
762
|
-
const exporter = new FedifySpanExporter(kv);
|
|
763
|
-
const activityJson = JSON.stringify({
|
|
764
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
765
|
-
type: "Create",
|
|
766
|
-
id: "https://example.com/activities/123",
|
|
767
|
-
actor: "https://example.com/users/alice",
|
|
768
|
-
object: {
|
|
769
|
-
type: "Note",
|
|
770
|
-
content: "Hello!"
|
|
771
|
-
}
|
|
772
|
-
});
|
|
715
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
773
716
|
const span = createMockSpan({
|
|
774
717
|
traceId: "actor-string-trace",
|
|
775
718
|
spanId: "span1",
|
|
776
719
|
name: "activitypub.inbox",
|
|
777
|
-
events: [createActivityReceivedEvent({ activityJson
|
|
720
|
+
events: [createActivityReceivedEvent({ activityJson: JSON.stringify({
|
|
721
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
722
|
+
type: "Create",
|
|
723
|
+
id: "https://example.com/activities/123",
|
|
724
|
+
actor: "https://example.com/users/alice",
|
|
725
|
+
object: {
|
|
726
|
+
type: "Note",
|
|
727
|
+
content: "Hello!"
|
|
728
|
+
}
|
|
729
|
+
}) })]
|
|
778
730
|
});
|
|
779
731
|
await new Promise((resolve) => {
|
|
780
732
|
exporter.export([span], () => resolve());
|
|
@@ -784,27 +736,25 @@ test("FedifySpanExporter", async (t) => {
|
|
|
784
736
|
assertEquals(activities[0].actorId, "https://example.com/users/alice");
|
|
785
737
|
});
|
|
786
738
|
await t.step("extracts actorId from activity with object actor", async () => {
|
|
787
|
-
const
|
|
788
|
-
const exporter = new FedifySpanExporter(kv);
|
|
789
|
-
const activityJson = JSON.stringify({
|
|
790
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
791
|
-
type: "Create",
|
|
792
|
-
id: "https://example.com/activities/456",
|
|
793
|
-
actor: {
|
|
794
|
-
type: "Person",
|
|
795
|
-
id: "https://example.com/users/bob",
|
|
796
|
-
name: "Bob"
|
|
797
|
-
},
|
|
798
|
-
object: {
|
|
799
|
-
type: "Note",
|
|
800
|
-
content: "Hello!"
|
|
801
|
-
}
|
|
802
|
-
});
|
|
739
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
803
740
|
const span = createMockSpan({
|
|
804
741
|
traceId: "actor-object-trace",
|
|
805
742
|
spanId: "span1",
|
|
806
743
|
name: "activitypub.inbox",
|
|
807
|
-
events: [createActivityReceivedEvent({ activityJson
|
|
744
|
+
events: [createActivityReceivedEvent({ activityJson: JSON.stringify({
|
|
745
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
746
|
+
type: "Create",
|
|
747
|
+
id: "https://example.com/activities/456",
|
|
748
|
+
actor: {
|
|
749
|
+
type: "Person",
|
|
750
|
+
id: "https://example.com/users/bob",
|
|
751
|
+
name: "Bob"
|
|
752
|
+
},
|
|
753
|
+
object: {
|
|
754
|
+
type: "Note",
|
|
755
|
+
content: "Hello!"
|
|
756
|
+
}
|
|
757
|
+
}) })]
|
|
808
758
|
});
|
|
809
759
|
await new Promise((resolve) => {
|
|
810
760
|
exporter.export([span], () => resolve());
|
|
@@ -814,21 +764,19 @@ test("FedifySpanExporter", async (t) => {
|
|
|
814
764
|
assertEquals(activities[0].actorId, "https://example.com/users/bob");
|
|
815
765
|
});
|
|
816
766
|
await t.step("extracts actorId from outbound activity", async () => {
|
|
817
|
-
const
|
|
818
|
-
const exporter = new FedifySpanExporter(kv);
|
|
819
|
-
const activityJson = JSON.stringify({
|
|
820
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
821
|
-
type: "Follow",
|
|
822
|
-
id: "https://myserver.com/activities/789",
|
|
823
|
-
actor: "https://myserver.com/users/charlie",
|
|
824
|
-
object: "https://example.com/users/alice"
|
|
825
|
-
});
|
|
767
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
826
768
|
const span = createMockSpan({
|
|
827
769
|
traceId: "outbound-actor-trace",
|
|
828
770
|
spanId: "span1",
|
|
829
771
|
name: "activitypub.send_activity",
|
|
830
772
|
events: [createActivitySentEvent({
|
|
831
|
-
activityJson
|
|
773
|
+
activityJson: JSON.stringify({
|
|
774
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
775
|
+
type: "Follow",
|
|
776
|
+
id: "https://myserver.com/activities/789",
|
|
777
|
+
actor: "https://myserver.com/users/charlie",
|
|
778
|
+
object: "https://example.com/users/alice"
|
|
779
|
+
}),
|
|
832
780
|
inboxUrl: "https://example.com/users/alice/inbox"
|
|
833
781
|
})]
|
|
834
782
|
});
|
|
@@ -840,20 +788,18 @@ test("FedifySpanExporter", async (t) => {
|
|
|
840
788
|
assertEquals(activities[0].actorId, "https://myserver.com/users/charlie");
|
|
841
789
|
});
|
|
842
790
|
await t.step("extracts signature verification details for inbound activity", async () => {
|
|
843
|
-
const
|
|
844
|
-
const exporter = new FedifySpanExporter(kv);
|
|
845
|
-
const activityJson = JSON.stringify({
|
|
846
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
847
|
-
type: "Create",
|
|
848
|
-
id: "https://example.com/activities/sig-test",
|
|
849
|
-
actor: "https://example.com/users/alice"
|
|
850
|
-
});
|
|
791
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
851
792
|
const span = createMockSpan({
|
|
852
793
|
traceId: "sig-details-trace",
|
|
853
794
|
spanId: "span1",
|
|
854
795
|
name: "activitypub.inbox",
|
|
855
796
|
events: [createActivityReceivedEvent({
|
|
856
|
-
activityJson
|
|
797
|
+
activityJson: JSON.stringify({
|
|
798
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
799
|
+
type: "Create",
|
|
800
|
+
id: "https://example.com/activities/sig-test",
|
|
801
|
+
actor: "https://example.com/users/alice"
|
|
802
|
+
}),
|
|
857
803
|
verified: true,
|
|
858
804
|
httpSigVerified: true,
|
|
859
805
|
httpSigKeyId: "https://example.com/users/alice#main-key",
|
|
@@ -872,20 +818,18 @@ test("FedifySpanExporter", async (t) => {
|
|
|
872
818
|
assertEquals(activities[0].signatureDetails?.ldSignaturesVerified, false);
|
|
873
819
|
});
|
|
874
820
|
await t.step("signature details with LD signatures verified", async () => {
|
|
875
|
-
const
|
|
876
|
-
const exporter = new FedifySpanExporter(kv);
|
|
877
|
-
const activityJson = JSON.stringify({
|
|
878
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
879
|
-
type: "Delete",
|
|
880
|
-
id: "https://example.com/activities/ld-sig-test",
|
|
881
|
-
actor: "https://example.com/users/alice"
|
|
882
|
-
});
|
|
821
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
883
822
|
const span = createMockSpan({
|
|
884
823
|
traceId: "ld-sig-trace",
|
|
885
824
|
spanId: "span1",
|
|
886
825
|
name: "activitypub.inbox",
|
|
887
826
|
events: [createActivityReceivedEvent({
|
|
888
|
-
activityJson
|
|
827
|
+
activityJson: JSON.stringify({
|
|
828
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
829
|
+
type: "Delete",
|
|
830
|
+
id: "https://example.com/activities/ld-sig-test",
|
|
831
|
+
actor: "https://example.com/users/alice"
|
|
832
|
+
}),
|
|
889
833
|
verified: true,
|
|
890
834
|
httpSigVerified: false,
|
|
891
835
|
ldSigVerified: true
|
|
@@ -900,19 +844,17 @@ test("FedifySpanExporter", async (t) => {
|
|
|
900
844
|
assertEquals(activities[0].signatureDetails?.ldSignaturesVerified, true);
|
|
901
845
|
});
|
|
902
846
|
await t.step("handles activity without actor field", async () => {
|
|
903
|
-
const
|
|
904
|
-
const exporter = new FedifySpanExporter(kv);
|
|
905
|
-
const activityJson = JSON.stringify({
|
|
906
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
907
|
-
type: "Delete",
|
|
908
|
-
id: "https://example.com/activities/no-actor",
|
|
909
|
-
object: "https://example.com/posts/123"
|
|
910
|
-
});
|
|
847
|
+
const exporter = new FedifySpanExporter(new MemoryKvStore());
|
|
911
848
|
const span = createMockSpan({
|
|
912
849
|
traceId: "no-actor-trace",
|
|
913
850
|
spanId: "span1",
|
|
914
851
|
name: "activitypub.inbox",
|
|
915
|
-
events: [createActivityReceivedEvent({ activityJson
|
|
852
|
+
events: [createActivityReceivedEvent({ activityJson: JSON.stringify({
|
|
853
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
854
|
+
type: "Delete",
|
|
855
|
+
id: "https://example.com/activities/no-actor",
|
|
856
|
+
object: "https://example.com/posts/123"
|
|
857
|
+
}) })]
|
|
916
858
|
});
|
|
917
859
|
await new Promise((resolve) => {
|
|
918
860
|
exporter.export([span], () => resolve());
|
|
@@ -922,5 +864,5 @@ test("FedifySpanExporter", async (t) => {
|
|
|
922
864
|
assertEquals(activities[0].actorId, void 0);
|
|
923
865
|
});
|
|
924
866
|
});
|
|
925
|
-
|
|
926
|
-
|
|
867
|
+
//#endregion
|
|
868
|
+
export {};
|
package/dist/otel/mod.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const __opentelemetry_core = require_chunk.__toESM(require("@opentelemetry/core"));
|
|
8
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
require("../docloader-Q3DfzuUi.cjs");
|
|
5
|
+
let _logtape_logtape = require("@logtape/logtape");
|
|
6
|
+
let _opentelemetry_core = require("@opentelemetry/core");
|
|
9
7
|
//#region src/otel/exporter.ts
|
|
10
8
|
/**
|
|
11
9
|
* A SpanExporter that persists ActivityPub activity traces to a
|
|
@@ -79,13 +77,13 @@ var FedifySpanExporter = class {
|
|
|
79
77
|
* @param resultCallback Callback to invoke with the export result.
|
|
80
78
|
*/
|
|
81
79
|
export(spans, resultCallback) {
|
|
82
|
-
this.#exportAsync(spans).then(() => resultCallback({ code:
|
|
83
|
-
(0,
|
|
80
|
+
this.#exportAsync(spans).then(() => resultCallback({ code: _opentelemetry_core.ExportResultCode.SUCCESS })).catch((error) => {
|
|
81
|
+
(0, _logtape_logtape.getLogger)([
|
|
84
82
|
"fedify",
|
|
85
83
|
"otel",
|
|
86
84
|
"exporter"
|
|
87
85
|
]).error("Failed to export spans to KvStore: {error}", { error });
|
|
88
|
-
resultCallback({ code:
|
|
86
|
+
resultCallback({ code: _opentelemetry_core.ExportResultCode.FAILED });
|
|
89
87
|
});
|
|
90
88
|
}
|
|
91
89
|
async #exportAsync(spans) {
|
|
@@ -94,8 +92,7 @@ var FedifySpanExporter = class {
|
|
|
94
92
|
const records = this.#extractRecords(span);
|
|
95
93
|
for (const record of records) storeOperations.push(this.#storeRecord(record));
|
|
96
94
|
}
|
|
97
|
-
const
|
|
98
|
-
const rejected = results.filter((r) => r.status === "rejected");
|
|
95
|
+
const rejected = (await Promise.allSettled(storeOperations)).filter((r) => r.status === "rejected");
|
|
99
96
|
if (rejected.length > 0) throw new AggregateError(rejected.map((r) => r.reason), "Failed to store one or more trace activity records.");
|
|
100
97
|
}
|
|
101
98
|
#extractRecords(span) {
|
|
@@ -196,12 +193,11 @@ var FedifySpanExporter = class {
|
|
|
196
193
|
}
|
|
197
194
|
async #setWithCasRetry(key, transform, options) {
|
|
198
195
|
if (this.#kv.cas != null) for (let attempt = 0; attempt < 3; attempt++) {
|
|
199
|
-
const existing
|
|
200
|
-
const newValue
|
|
201
|
-
if (await this.#kv.cas(key, existing
|
|
196
|
+
const existing = await this.#kv.get(key);
|
|
197
|
+
const newValue = transform(existing);
|
|
198
|
+
if (await this.#kv.cas(key, existing, newValue, options)) return;
|
|
202
199
|
}
|
|
203
|
-
const
|
|
204
|
-
const newValue = transform(existing);
|
|
200
|
+
const newValue = transform(await this.#kv.get(key));
|
|
205
201
|
await this.#kv.set(key, newValue, options);
|
|
206
202
|
}
|
|
207
203
|
async #updateTraceSummary(record, options) {
|
|
@@ -246,8 +242,7 @@ var FedifySpanExporter = class {
|
|
|
246
242
|
return records;
|
|
247
243
|
} else {
|
|
248
244
|
const key = [...this.#keyPrefix, traceId];
|
|
249
|
-
|
|
250
|
-
return records ?? [];
|
|
245
|
+
return await this.#kv.get(key) ?? [];
|
|
251
246
|
}
|
|
252
247
|
}
|
|
253
248
|
/**
|
|
@@ -274,6 +269,5 @@ var FedifySpanExporter = class {
|
|
|
274
269
|
*/
|
|
275
270
|
async shutdown() {}
|
|
276
271
|
};
|
|
277
|
-
|
|
278
272
|
//#endregion
|
|
279
|
-
exports.FedifySpanExporter = FedifySpanExporter;
|
|
273
|
+
exports.FedifySpanExporter = FedifySpanExporter;
|
package/dist/otel/mod.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as KvStore, t as KvKey } from "../kv-ClC9WJh5.cjs";
|
|
2
2
|
import { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-base";
|
|
3
3
|
import { ExportResultCode } from "@opentelemetry/core";
|
|
4
4
|
|
|
@@ -228,4 +228,4 @@ declare class FedifySpanExporter implements SpanExporter {
|
|
|
228
228
|
shutdown(): Promise<void>;
|
|
229
229
|
}
|
|
230
230
|
//#endregion
|
|
231
|
-
export { ActivityDirection, FedifySpanExporter, FedifySpanExporterOptions, GetRecentTracesOptions, SignatureVerificationDetails, TraceActivityRecord, TraceSummary };
|
|
231
|
+
export { type ActivityDirection, FedifySpanExporter, type FedifySpanExporterOptions, type GetRecentTracesOptions, type SignatureVerificationDetails, type TraceActivityRecord, type TraceSummary };
|
package/dist/otel/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import {
|
|
3
|
+
import { n as KvStore, t as KvKey } from "../kv-C6UC8M9S.js";
|
|
4
4
|
import { ExportResultCode } from "@opentelemetry/core";
|
|
5
5
|
import { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-base";
|
|
6
6
|
|
|
@@ -230,4 +230,4 @@ declare class FedifySpanExporter implements SpanExporter {
|
|
|
230
230
|
shutdown(): Promise<void>;
|
|
231
231
|
}
|
|
232
232
|
//#endregion
|
|
233
|
-
export { ActivityDirection, FedifySpanExporter, FedifySpanExporterOptions, GetRecentTracesOptions, SignatureVerificationDetails, TraceActivityRecord, TraceSummary };
|
|
233
|
+
export { type ActivityDirection, FedifySpanExporter, type FedifySpanExporterOptions, type GetRecentTracesOptions, type SignatureVerificationDetails, type TraceActivityRecord, type TraceSummary };
|