@fedify/fedify 2.5.0-dev.2687 → 2.5.0-dev.2710

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/dist/federation/mod.cjs +1 -1
  2. package/dist/federation/mod.js +1 -1
  3. package/dist/{federation-pFFwPyoZ.cjs → federation-JvzYDx0P.cjs} +3 -3
  4. package/dist/{http-CXX-QPzs.cjs → http-BG5cDmTS.cjs} +1 -1
  5. package/dist/{http-T7h9GBAN.js → http-MUf125Jc.js} +1 -1
  6. package/dist/{kv-cache-C6XX_fwz.cjs → kv-cache-A2po7h0_.cjs} +1 -1
  7. package/dist/{kv-cache-EFcb1kkU.js → kv-cache-CbWc1BZA.js} +1 -1
  8. package/dist/{middleware-Bj91r7r2.js → middleware-DzzdJ7Wz.js} +3 -3
  9. package/dist/mod.cjs +4 -4
  10. package/dist/mod.js +4 -4
  11. package/dist/{portable-collection-Do5QA2oy.js → portable-collection-CAer9RWN.js} +1 -1
  12. package/dist/{portable-collection-BOl9oKrt.cjs → portable-collection-d8w7TCn9.cjs} +1 -1
  13. package/dist/sig/mod.cjs +2 -2
  14. package/dist/sig/mod.js +2 -2
  15. package/dist/utils/mod.cjs +1 -1
  16. package/dist/utils/mod.js +1 -1
  17. package/package.json +22 -9
  18. package/skills/fedify/SKILL.md +10 -0
  19. package/dist/accept-CPVqki78.mjs +0 -145
  20. package/dist/activity-listener-CELFAodc.mjs +0 -44
  21. package/dist/assert-D1Eafmd_.mjs +0 -23
  22. package/dist/assert_equals-Z6IcEbWU.mjs +0 -987
  23. package/dist/assert_exists-cffSpJ7X.mjs +0 -28
  24. package/dist/assert_false-CPdRnc3E.mjs +0 -23
  25. package/dist/assert_greater_or_equal-BlafOF4-.mjs +0 -31
  26. package/dist/assert_instance_of-mrXWWNY-.mjs +0 -37
  27. package/dist/assert_not_equals-CpPK2t89.mjs +0 -30
  28. package/dist/assert_rejects-CTptdYck.mjs +0 -39
  29. package/dist/assert_strict_equals-CYvBmkpC.mjs +0 -42
  30. package/dist/assert_throws-BYITOvPO.mjs +0 -74
  31. package/dist/assertion_error-B-cx0fFA.mjs +0 -31
  32. package/dist/audience-CHQ-FlLD.mjs +0 -95
  33. package/dist/builder-D1FP_5nQ.mjs +0 -911
  34. package/dist/circuit-breaker-XJ53md4S.mjs +0 -544
  35. package/dist/circuit-breaker-test-utils-DW6YC_Pe.mjs +0 -14
  36. package/dist/client-5SIFzW3q.mjs +0 -441
  37. package/dist/codec-C6rTrpIp.mjs +0 -147
  38. package/dist/collection-CnnP1UAv.mjs +0 -44
  39. package/dist/compat/outgoing-jsonld.test.d.mts +0 -2
  40. package/dist/compat/outgoing-jsonld.test.mjs +0 -257
  41. package/dist/compat/public-audience.test.d.mts +0 -2
  42. package/dist/compat/public-audience.test.mjs +0 -187
  43. package/dist/compat/secured-document.test.d.mts +0 -2
  44. package/dist/compat/secured-document.test.mjs +0 -58
  45. package/dist/compat/transformers.test.d.mts +0 -2
  46. package/dist/compat/transformers.test.mjs +0 -62
  47. package/dist/compound-proof-DSHhnOEW.mjs +0 -1019
  48. package/dist/context-LgGFFSz7.mjs +0 -146
  49. package/dist/deno-C50ikGBU.mjs +0 -8
  50. package/dist/dist-_geWsuaI.mjs +0 -189
  51. package/dist/docloader-BY-SEID0.mjs +0 -136
  52. package/dist/esm-BHXXx4Wx.mjs +0 -1233
  53. package/dist/exporter-DVG68ozH.mjs +0 -263
  54. package/dist/federation/audience.test.d.mts +0 -2
  55. package/dist/federation/audience.test.mjs +0 -130
  56. package/dist/federation/builder.test.d.mts +0 -2
  57. package/dist/federation/builder.test.mjs +0 -396
  58. package/dist/federation/circuit-breaker.test.d.mts +0 -2
  59. package/dist/federation/circuit-breaker.test.mjs +0 -1277
  60. package/dist/federation/collection.test.d.mts +0 -2
  61. package/dist/federation/collection.test.mjs +0 -21
  62. package/dist/federation/compound-fanout.test.d.mts +0 -2
  63. package/dist/federation/compound-fanout.test.mjs +0 -231
  64. package/dist/federation/handler-compound-proof.test.d.mts +0 -2
  65. package/dist/federation/handler-compound-proof.test.mjs +0 -384
  66. package/dist/federation/handler.test.d.mts +0 -2
  67. package/dist/federation/handler.test.mjs +0 -5445
  68. package/dist/federation/hashlink-media.test.d.mts +0 -2
  69. package/dist/federation/hashlink-media.test.mjs +0 -422
  70. package/dist/federation/idempotency.test.d.mts +0 -2
  71. package/dist/federation/idempotency.test.mjs +0 -207
  72. package/dist/federation/inbox-actorless.test.d.mts +0 -2
  73. package/dist/federation/inbox-actorless.test.mjs +0 -522
  74. package/dist/federation/inbox-authentication.test.d.mts +0 -2
  75. package/dist/federation/inbox-authentication.test.mjs +0 -220
  76. package/dist/federation/inbox-report.test.d.mts +0 -2
  77. package/dist/federation/inbox-report.test.mjs +0 -719
  78. package/dist/federation/inbox-view.test.d.mts +0 -2
  79. package/dist/federation/inbox-view.test.mjs +0 -369
  80. package/dist/federation/inbox.test.d.mts +0 -2
  81. package/dist/federation/inbox.test.mjs +0 -139
  82. package/dist/federation/keycache.test.d.mts +0 -2
  83. package/dist/federation/keycache.test.mjs +0 -337
  84. package/dist/federation/kv.test.d.mts +0 -2
  85. package/dist/federation/kv.test.mjs +0 -88
  86. package/dist/federation/metrics.test.d.mts +0 -2
  87. package/dist/federation/metrics.test.mjs +0 -634
  88. package/dist/federation/middleware.test.d.mts +0 -2
  89. package/dist/federation/middleware.test.mjs +0 -9314
  90. package/dist/federation/mq.test.d.mts +0 -2
  91. package/dist/federation/mq.test.mjs +0 -591
  92. package/dist/federation/negotiation.test.d.mts +0 -2
  93. package/dist/federation/negotiation.test.mjs +0 -18
  94. package/dist/federation/outbound-body.test.d.mts +0 -2
  95. package/dist/federation/outbound-body.test.mjs +0 -149
  96. package/dist/federation/outbound-capture.test.d.mts +0 -2
  97. package/dist/federation/outbound-capture.test.mjs +0 -394
  98. package/dist/federation/outbound-dispatch.test.d.mts +0 -2
  99. package/dist/federation/outbound-dispatch.test.mjs +0 -368
  100. package/dist/federation/outbound-document.test.d.mts +0 -2
  101. package/dist/federation/outbound-document.test.mjs +0 -171
  102. package/dist/federation/outbound-provenance.test.d.mts +0 -2
  103. package/dist/federation/outbound-provenance.test.mjs +0 -543
  104. package/dist/federation/outbound-report.test.d.mts +0 -2
  105. package/dist/federation/outbound-report.test.mjs +0 -5475
  106. package/dist/federation/outbound-workers.test.d.mts +0 -2
  107. package/dist/federation/outbound-workers.test.mjs +0 -64
  108. package/dist/federation/outbound-workflow.test.d.mts +0 -2
  109. package/dist/federation/outbound-workflow.test.mjs +0 -154
  110. package/dist/federation/outgoing-proof.test.d.mts +0 -2
  111. package/dist/federation/outgoing-proof.test.mjs +0 -933
  112. package/dist/federation/portable-actor.test.d.mts +0 -2
  113. package/dist/federation/portable-actor.test.mjs +0 -496
  114. package/dist/federation/portable-chain.test.d.mts +0 -2
  115. package/dist/federation/portable-chain.test.mjs +0 -370
  116. package/dist/federation/portable-collection.test.d.mts +0 -2
  117. package/dist/federation/portable-collection.test.mjs +0 -832
  118. package/dist/federation/portable-delivery.test.d.mts +0 -2
  119. package/dist/federation/portable-delivery.test.mjs +0 -845
  120. package/dist/federation/portable-gateway-keys.test.d.mts +0 -2
  121. package/dist/federation/portable-gateway-keys.test.mjs +0 -692
  122. package/dist/federation/portable-inbox.test.d.mts +0 -2
  123. package/dist/federation/portable-inbox.test.mjs +0 -1960
  124. package/dist/federation/portable-parse-uri.test.d.mts +0 -2
  125. package/dist/federation/portable-parse-uri.test.mjs +0 -348
  126. package/dist/federation/portable-route-activity.test.d.mts +0 -2
  127. package/dist/federation/portable-route-activity.test.mjs +0 -259
  128. package/dist/federation/portable.test.d.mts +0 -2
  129. package/dist/federation/portable.test.mjs +0 -1072
  130. package/dist/federation/retry.test.d.mts +0 -2
  131. package/dist/federation/retry.test.mjs +0 -42
  132. package/dist/federation/router.test.d.mts +0 -2
  133. package/dist/federation/router.test.mjs +0 -123
  134. package/dist/federation/send.test.d.mts +0 -2
  135. package/dist/federation/send.test.mjs +0 -1421
  136. package/dist/federation/tasks/codec.test.d.mts +0 -2
  137. package/dist/federation/tasks/codec.test.mjs +0 -302
  138. package/dist/federation/tasks/enqueue.test.d.mts +0 -2
  139. package/dist/federation/tasks/enqueue.test.mjs +0 -1095
  140. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  141. package/dist/federation/tasks/tasks.test.mjs +0 -1229
  142. package/dist/federation/temporal.test.d.mts +0 -2
  143. package/dist/federation/temporal.test.mjs +0 -71
  144. package/dist/federation/webfinger.test.d.mts +0 -2
  145. package/dist/federation/webfinger.test.mjs +0 -944
  146. package/dist/http-BXbQQZDM.mjs +0 -1449
  147. package/dist/inbox-authentication-CgonVRkg.mjs +0 -198
  148. package/dist/inbox-cS97XzOD.mjs +0 -399
  149. package/dist/inbox-view-D-d0Ar6o.mjs +0 -385
  150. package/dist/key-owner-evidence-APB6NpSk.mjs +0 -108
  151. package/dist/keycache-N2opu4-3.mjs +0 -221
  152. package/dist/keys-DIJNHW-Y.mjs +0 -120
  153. package/dist/kv-DBRWVx3Q.mjs +0 -104
  154. package/dist/kv-DCHkaJ9-.mjs +0 -92
  155. package/dist/kv-cache-fgbLHGVL.mjs +0 -121
  156. package/dist/ld-BpkhkDGj.mjs +0 -1752
  157. package/dist/map-local-context-conflict-DOYEEJ3u.mjs +0 -204
  158. package/dist/map-local-create-note-B0SeXJms.mjs +0 -214
  159. package/dist/metrics-Uqf8GomB.mjs +0 -818
  160. package/dist/middleware-DcXzz-YK.mjs +0 -9971
  161. package/dist/middleware-DgwZkvJR.mjs +0 -5
  162. package/dist/mq-eF96QxUT.mjs +0 -288
  163. package/dist/negotiation-BAKO9nih.mjs +0 -96
  164. package/dist/nodeinfo/client.test.d.mts +0 -2
  165. package/dist/nodeinfo/client.test.mjs +0 -1364
  166. package/dist/nodeinfo/handler.test.d.mts +0 -2
  167. package/dist/nodeinfo/handler.test.mjs +0 -94
  168. package/dist/nodeinfo/types.test.d.mts +0 -2
  169. package/dist/nodeinfo/types.test.mjs +0 -192
  170. package/dist/otel/exporter.test.d.mts +0 -2
  171. package/dist/otel/exporter.test.mjs +0 -887
  172. package/dist/outbound-body-CckPA5gc.mjs +0 -83
  173. package/dist/outbound-capture-DVgnRzlf.mjs +0 -184
  174. package/dist/outbound-document-BMgwLXTY.mjs +0 -179
  175. package/dist/outgoing-jsonld-4IJqPYos.mjs +0 -205
  176. package/dist/owner-BVenIFg1.mjs +0 -267
  177. package/dist/portable-collection-DIk9gpjL.mjs +0 -418
  178. package/dist/portable-key-C7pVaHNR.mjs +0 -549
  179. package/dist/portable-key-id-Ca30-hOa.mjs +0 -248
  180. package/dist/proof-BlfZ95--.mjs +0 -1420
  181. package/dist/public-audience--klBIOk1.mjs +0 -197
  182. package/dist/retry-zX5xw5e0.mjs +0 -34
  183. package/dist/router-u5O5KCQr.mjs +0 -156
  184. package/dist/secured-document-CxzZZ9nL.mjs +0 -35
  185. package/dist/send-DEGHPGFk.mjs +0 -710
  186. package/dist/sig/accept.test.d.mts +0 -2
  187. package/dist/sig/accept.test.mjs +0 -416
  188. package/dist/sig/compound-proof-discovery.test.d.mts +0 -2
  189. package/dist/sig/compound-proof-discovery.test.mjs +0 -331
  190. package/dist/sig/compound-proof-producer.test.d.mts +0 -2
  191. package/dist/sig/compound-proof-producer.test.mjs +0 -107
  192. package/dist/sig/compound-proof-verification.test.d.mts +0 -2
  193. package/dist/sig/compound-proof-verification.test.mjs +0 -1017
  194. package/dist/sig/compound-proof.test.d.mts +0 -2
  195. package/dist/sig/compound-proof.test.mjs +0 -411
  196. package/dist/sig/http.test.d.mts +0 -2
  197. package/dist/sig/http.test.mjs +0 -3328
  198. package/dist/sig/key-owner-evidence.test.d.mts +0 -2
  199. package/dist/sig/key-owner-evidence.test.mjs +0 -100
  200. package/dist/sig/key.test.d.mts +0 -2
  201. package/dist/sig/key.test.mjs +0 -1250
  202. package/dist/sig/ld.test.d.mts +0 -2
  203. package/dist/sig/ld.test.mjs +0 -1044
  204. package/dist/sig/mitra-receive-interop.test.d.mts +0 -2
  205. package/dist/sig/mitra-receive-interop.test.mjs +0 -260
  206. package/dist/sig/mitra-send-interop.test.d.mts +0 -2
  207. package/dist/sig/mitra-send-interop.test.mjs +0 -461
  208. package/dist/sig/owner.test.d.mts +0 -2
  209. package/dist/sig/owner.test.mjs +0 -202
  210. package/dist/sig/portable-collection.test.d.mts +0 -2
  211. package/dist/sig/portable-collection.test.mjs +0 -697
  212. package/dist/sig/portable-interop.test.d.mts +0 -2
  213. package/dist/sig/portable-interop.test.mjs +0 -156
  214. package/dist/sig/portable-key-id.test.d.mts +0 -2
  215. package/dist/sig/portable-key-id.test.mjs +0 -67
  216. package/dist/sig/portable-key.test.d.mts +0 -2
  217. package/dist/sig/portable-key.test.mjs +0 -1438
  218. package/dist/sig/proof.test.d.mts +0 -2
  219. package/dist/sig/proof.test.mjs +0 -2638
  220. package/dist/sig/tootik-request-interop.test.d.mts +0 -2
  221. package/dist/sig/tootik-request-interop.test.mjs +0 -190
  222. package/dist/sig/tootik-send-interop.test.d.mts +0 -2
  223. package/dist/sig/tootik-send-interop.test.mjs +0 -331
  224. package/dist/sig/verification.test.d.mts +0 -2
  225. package/dist/sig/verification.test.mjs +0 -310
  226. package/dist/std__assert-DvMDRPes.mjs +0 -8
  227. package/dist/tasks-BCUmQbbz.mjs +0 -77
  228. package/dist/temporal-B4oQ8HpW.mjs +0 -95
  229. package/dist/testing/context.test.d.mts +0 -2
  230. package/dist/testing/context.test.mjs +0 -19
  231. package/dist/testing/kv.test.d.mts +0 -2
  232. package/dist/testing/kv.test.mjs +0 -101
  233. package/dist/testing/mod.d.mts +0 -6099
  234. package/dist/testing/mod.mjs +0 -9
  235. package/dist/testing-vrnD5Uaa.mjs +0 -8
  236. package/dist/types-DE_LV1JB.mjs +0 -46
  237. package/dist/utils/docloader.test.d.mts +0 -2
  238. package/dist/utils/docloader.test.mjs +0 -1076
  239. package/dist/utils/kv-cache.test.d.mts +0 -2
  240. package/dist/utils/kv-cache.test.mjs +0 -261
  241. package/dist/verification-C3954hQh.mjs +0 -5
  242. package/dist/verification-Dpfcw8ml.mjs +0 -105
  243. package/dist/vocab/cjs.test.d.mts +0 -2
  244. package/dist/vocab/cjs.test.mjs +0 -27
@@ -1,818 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-C50ikGBU.mjs";
5
- import { metrics } from "@opentelemetry/api";
6
- import { FetchError } from "@fedify/vocab-runtime";
7
- //#region src/federation/metrics.ts
8
- var FederationMetrics = class {
9
- deliverySent;
10
- deliveryPermanentFailure;
11
- signatureVerificationFailure;
12
- signatureVerificationDuration;
13
- signatureKeyFetchDuration;
14
- deliveryDuration;
15
- inboxProcessingDuration;
16
- httpServerRequestCount;
17
- httpServerRequestDuration;
18
- queueTaskEnqueued;
19
- queueTaskStarted;
20
- queueTaskCompleted;
21
- queueTaskFailed;
22
- queueTaskDuration;
23
- queueTaskInFlight;
24
- queueDepth;
25
- fanoutRecipients;
26
- inboxActivity;
27
- outboxActivity;
28
- circuitBreakerStateChange;
29
- keyLookup;
30
- keyLookupDuration;
31
- documentFetch;
32
- documentFetchDuration;
33
- documentCache;
34
- webFingerHandle;
35
- webFingerHandleDuration;
36
- collectionRequest;
37
- collectionDispatchDuration;
38
- collectionPageItems;
39
- collectionTotalItems;
40
- constructor(meterProvider) {
41
- const meter = meterProvider.getMeter(name, version);
42
- this.deliverySent = meter.createCounter("activitypub.delivery.sent", {
43
- description: "ActivityPub delivery attempts.",
44
- unit: "{attempt}"
45
- });
46
- this.deliveryPermanentFailure = meter.createCounter("activitypub.delivery.permanent_failure", {
47
- description: "ActivityPub deliveries abandoned as permanent failures.",
48
- unit: "{failure}"
49
- });
50
- this.signatureVerificationFailure = meter.createCounter("activitypub.signature.verification_failure", {
51
- description: "ActivityPub signature verification failures.",
52
- unit: "{failure}"
53
- });
54
- this.signatureVerificationDuration = meter.createHistogram("activitypub.signature.verification.duration", {
55
- description: "Duration of ActivityPub signature verification, including local key lookup and remote key fetches.",
56
- unit: "ms",
57
- advice: { explicitBucketBoundaries: [
58
- .1,
59
- .25,
60
- .5,
61
- 1,
62
- 2.5,
63
- 5,
64
- 10,
65
- 25,
66
- 50,
67
- 100,
68
- 250,
69
- 500,
70
- 1e3
71
- ] }
72
- });
73
- this.signatureKeyFetchDuration = meter.createHistogram("activitypub.signature.key_fetch.duration", {
74
- description: "Duration of public key lookup performed during ActivityPub signature verification.",
75
- unit: "ms"
76
- });
77
- this.deliveryDuration = meter.createHistogram("activitypub.delivery.duration", {
78
- description: "Duration of ActivityPub delivery attempts.",
79
- unit: "ms"
80
- });
81
- this.inboxProcessingDuration = meter.createHistogram("activitypub.inbox.processing_duration", {
82
- description: "Duration of ActivityPub inbox listener processing.",
83
- unit: "ms"
84
- });
85
- this.httpServerRequestCount = meter.createCounter("fedify.http.server.request.count", {
86
- description: "HTTP requests handled by Federation.fetch().",
87
- unit: "{request}"
88
- });
89
- this.httpServerRequestDuration = meter.createHistogram("fedify.http.server.request.duration", {
90
- description: "Duration of HTTP requests handled by Federation.fetch().",
91
- unit: "ms",
92
- advice: { explicitBucketBoundaries: [
93
- 5,
94
- 10,
95
- 25,
96
- 50,
97
- 75,
98
- 100,
99
- 250,
100
- 500,
101
- 750,
102
- 1e3,
103
- 2500,
104
- 5e3,
105
- 7500,
106
- 1e4
107
- ] }
108
- });
109
- this.queueTaskEnqueued = meter.createCounter("fedify.queue.task.enqueued", {
110
- description: "Tasks Fedify enqueued for inbox, outbox, or fanout work.",
111
- unit: "{task}"
112
- });
113
- this.queueTaskStarted = meter.createCounter("fedify.queue.task.started", {
114
- description: "Tasks Fedify began processing as a queue worker.",
115
- unit: "{task}"
116
- });
117
- this.queueTaskCompleted = meter.createCounter("fedify.queue.task.completed", {
118
- description: "Queue tasks Fedify finished processing without throwing.",
119
- unit: "{task}"
120
- });
121
- this.queueTaskFailed = meter.createCounter("fedify.queue.task.failed", {
122
- description: "Queue tasks Fedify abandoned because processing threw.",
123
- unit: "{task}"
124
- });
125
- this.queueTaskDuration = meter.createHistogram("fedify.queue.task.duration", {
126
- description: "Duration of queue task processing in Fedify workers.",
127
- unit: "ms",
128
- advice: { explicitBucketBoundaries: [
129
- 5,
130
- 10,
131
- 25,
132
- 50,
133
- 75,
134
- 100,
135
- 250,
136
- 500,
137
- 750,
138
- 1e3,
139
- 2500,
140
- 5e3,
141
- 7500,
142
- 1e4
143
- ] }
144
- });
145
- this.queueTaskInFlight = meter.createUpDownCounter("fedify.queue.task.in_flight", {
146
- description: "Queue tasks currently being processed in this Fedify process.",
147
- unit: "{task}"
148
- });
149
- this.queueDepth = meter.createObservableGauge("fedify.queue.depth", {
150
- description: "Messages waiting in configured Fedify queues, as reported by the queue backend.",
151
- unit: "{message}"
152
- });
153
- this.fanoutRecipients = meter.createHistogram("activitypub.fanout.recipients", {
154
- description: "Number of recipient inboxes produced by an ActivityPub fanout task.",
155
- unit: "{recipient}"
156
- });
157
- this.inboxActivity = meter.createCounter("activitypub.inbox.activity", {
158
- description: "ActivityPub activities observed at the inbox lifecycle level: queued, processed, retried, rejected, or abandoned.",
159
- unit: "{activity}"
160
- });
161
- this.outboxActivity = meter.createCounter("activitypub.outbox.activity", {
162
- description: "ActivityPub activities observed at the outbox lifecycle level: queued, retried, or abandoned. Per-recipient delivery counters live on `activitypub.delivery.*`.",
163
- unit: "{activity}"
164
- });
165
- this.circuitBreakerStateChange = meter.createCounter("activitypub.circuit_breaker.state_change", {
166
- description: "Outbound ActivityPub delivery circuit breaker changes.",
167
- unit: "{change}"
168
- });
169
- this.keyLookup = meter.createCounter("activitypub.key.lookup", {
170
- description: "Public-key lookup attempts performed by Fedify, including cache hits, local resolutions, and remote fetches.",
171
- unit: "{lookup}"
172
- });
173
- this.keyLookupDuration = meter.createHistogram("activitypub.key.lookup.duration", {
174
- description: "Duration of public-key lookups performed by Fedify, including cache hits, local resolutions, and any remote fetch.",
175
- unit: "ms",
176
- advice: { explicitBucketBoundaries: [
177
- 5,
178
- 10,
179
- 25,
180
- 50,
181
- 75,
182
- 100,
183
- 250,
184
- 500,
185
- 750,
186
- 1e3,
187
- 2500,
188
- 5e3,
189
- 7500,
190
- 1e4
191
- ] }
192
- });
193
- this.documentFetch = meter.createCounter("activitypub.document.fetch", {
194
- description: "Remote JSON-LD document loader invocations made by Fedify-wrapped loaders.",
195
- unit: "{fetch}"
196
- });
197
- this.documentFetchDuration = meter.createHistogram("activitypub.document.fetch.duration", {
198
- description: "Duration of remote JSON-LD document loader invocations made by Fedify-wrapped loaders.",
199
- unit: "ms",
200
- advice: { explicitBucketBoundaries: [
201
- 5,
202
- 10,
203
- 25,
204
- 50,
205
- 75,
206
- 100,
207
- 250,
208
- 500,
209
- 750,
210
- 1e3,
211
- 2500,
212
- 5e3,
213
- 7500,
214
- 1e4
215
- ] }
216
- });
217
- this.documentCache = meter.createCounter("activitypub.document.cache", {
218
- description: "KV-backed document loader cache lookups, with `hit` or `miss` classification.",
219
- unit: "{lookup}"
220
- });
221
- this.webFingerHandle = meter.createCounter("webfinger.handle", {
222
- description: "Incoming WebFinger requests handled by Fedify, classified by terminal outcome.",
223
- unit: "{request}"
224
- });
225
- this.webFingerHandleDuration = meter.createHistogram("webfinger.handle.duration", {
226
- description: "Duration of incoming WebFinger request handling in Fedify.",
227
- unit: "ms",
228
- advice: { explicitBucketBoundaries: [
229
- 5,
230
- 10,
231
- 25,
232
- 50,
233
- 75,
234
- 100,
235
- 250,
236
- 500,
237
- 750,
238
- 1e3,
239
- 2500,
240
- 5e3,
241
- 7500,
242
- 1e4
243
- ] }
244
- });
245
- this.collectionRequest = meter.createCounter("activitypub.collection.request", {
246
- description: "ActivityPub collection and collection-page requests handled by Fedify.",
247
- unit: "{request}"
248
- });
249
- this.collectionDispatchDuration = meter.createHistogram("activitypub.collection.dispatch.duration", {
250
- description: "Duration of ActivityPub collection dispatcher callbacks.",
251
- unit: "ms",
252
- advice: { explicitBucketBoundaries: [
253
- 5,
254
- 10,
255
- 25,
256
- 50,
257
- 75,
258
- 100,
259
- 250,
260
- 500,
261
- 750,
262
- 1e3,
263
- 2500,
264
- 5e3,
265
- 7500,
266
- 1e4
267
- ] }
268
- });
269
- this.collectionPageItems = meter.createHistogram("activitypub.collection.page.items", {
270
- description: "Number of items Fedify materialized for an ActivityPub collection response.",
271
- unit: "{item}"
272
- });
273
- this.collectionTotalItems = meter.createHistogram("activitypub.collection.total_items", {
274
- description: "Total item count reported by ActivityPub collection counters.",
275
- unit: "{item}"
276
- });
277
- }
278
- recordDelivery(inbox, durationMs, success, activityType) {
279
- const deliveryAttributes = {
280
- "activitypub.remote.host": getRemoteHost(inbox),
281
- "activitypub.delivery.success": success
282
- };
283
- if (activityType != null) deliveryAttributes["activitypub.activity.type"] = activityType;
284
- this.deliverySent.add(1, deliveryAttributes);
285
- this.deliveryDuration.record(durationMs, deliveryAttributes);
286
- }
287
- recordPermanentFailure(inbox, statusCode) {
288
- this.deliveryPermanentFailure.add(1, {
289
- "activitypub.remote.host": getRemoteHost(inbox),
290
- "http.response.status_code": statusCode
291
- });
292
- }
293
- recordSignatureVerificationFailure(reason, remoteHost) {
294
- const attributes = { "activitypub.verification.failure_reason": reason };
295
- if (remoteHost != null) attributes["activitypub.remote.host"] = remoteHost;
296
- this.signatureVerificationFailure.add(1, attributes);
297
- }
298
- recordSignatureVerificationDuration(durationMs, kind, result, extra = {}) {
299
- const attributes = {
300
- "activitypub.signature.kind": kind,
301
- "activitypub.signature.result": result
302
- };
303
- if (extra.algorithm != null) attributes["http_signatures.algorithm"] = extra.algorithm;
304
- if (extra.failureReason != null) attributes["http_signatures.failure_reason"] = extra.failureReason;
305
- if (extra.verificationFailureReason != null) attributes["activitypub.verification.failure_reason"] = extra.verificationFailureReason;
306
- if (extra.ldType != null) attributes["ld_signatures.type"] = extra.ldType;
307
- if (extra.cryptosuite != null) attributes["object_integrity_proofs.cryptosuite"] = extra.cryptosuite;
308
- this.signatureVerificationDuration.record(durationMs, attributes);
309
- }
310
- recordSignatureKeyFetchDuration(durationMs, kind, result) {
311
- this.signatureKeyFetchDuration.record(durationMs, {
312
- "activitypub.signature.kind": kind,
313
- "activitypub.signature.key_fetch.result": result
314
- });
315
- }
316
- recordInboxProcessingDuration(activityType, durationMs) {
317
- this.inboxProcessingDuration.record(durationMs, { "activitypub.activity.type": activityType });
318
- }
319
- recordHttpServerRequest(method, endpoint, durationMs, options = {}) {
320
- const attributes = {
321
- "http.request.method": normalizeHttpMethod(method),
322
- "fedify.endpoint": endpoint
323
- };
324
- if (options.statusCode != null) attributes["http.response.status_code"] = options.statusCode;
325
- if (options.routeTemplate != null) attributes["fedify.route.template"] = options.routeTemplate;
326
- this.httpServerRequestCount.add(1, attributes);
327
- this.httpServerRequestDuration.record(durationMs, attributes);
328
- }
329
- recordQueueTaskEnqueued(common, attempt, count = 1) {
330
- const attributes = buildQueueTaskAttributes(common);
331
- attributes["fedify.queue.task.attempt"] = attempt;
332
- this.queueTaskEnqueued.add(count, attributes);
333
- }
334
- recordQueueTaskStarted(common) {
335
- this.queueTaskStarted.add(1, buildQueueTaskAttributes(common));
336
- }
337
- incrementQueueTaskInFlight(common) {
338
- this.queueTaskInFlight.add(1, buildQueueTaskInFlightAttributes(common));
339
- }
340
- decrementQueueTaskInFlight(common) {
341
- this.queueTaskInFlight.add(-1, buildQueueTaskInFlightAttributes(common));
342
- }
343
- recordQueueTaskOutcome(common, result, durationMs, failureReason) {
344
- const attributes = buildQueueTaskAttributes(common);
345
- attributes["fedify.queue.task.result"] = result;
346
- if (failureReason != null && result === "failed") attributes["fedify.task.failure_reason"] = failureReason;
347
- if (result === "completed") this.queueTaskCompleted.add(1, attributes);
348
- else if (result === "failed") this.queueTaskFailed.add(1, attributes);
349
- this.queueTaskDuration.record(durationMs, attributes);
350
- }
351
- recordFanoutRecipients(recipientCount, activityType) {
352
- const attributes = {};
353
- if (activityType != null) attributes["activitypub.activity.type"] = activityType;
354
- this.fanoutRecipients.record(recipientCount, attributes);
355
- }
356
- recordInboxActivity(result, activityType) {
357
- this.inboxActivity.add(1, buildActivityLifecycleAttributes(result, activityType));
358
- }
359
- recordOutboxActivity(result, activityType) {
360
- this.outboxActivity.add(1, buildActivityLifecycleAttributes(result, activityType));
361
- }
362
- recordCircuitBreakerStateChange(remoteHost, state) {
363
- this.circuitBreakerStateChange.add(1, {
364
- "activitypub.remote.host": remoteHost,
365
- "activitypub.circuit_breaker.state": state
366
- });
367
- }
368
- recordKeyLookup(attrs) {
369
- const attributes = {
370
- "activitypub.lookup.kind": "public_key",
371
- "activitypub.lookup.result": attrs.result,
372
- "activitypub.cache.enabled": attrs.cacheEnabled
373
- };
374
- if (attrs.remoteUrl != null) attributes["activitypub.remote.host"] = getRemoteHost(attrs.remoteUrl);
375
- if (attrs.statusCode != null) attributes["http.response.status_code"] = attrs.statusCode;
376
- this.keyLookup.add(1, attributes);
377
- this.keyLookupDuration.record(attrs.durationMs, attributes);
378
- }
379
- recordDocumentFetch(attrs) {
380
- const attributes = {
381
- "activitypub.lookup.kind": attrs.kind,
382
- "activitypub.lookup.result": attrs.result
383
- };
384
- if (attrs.remoteUrl != null) attributes["activitypub.remote.host"] = getRemoteHost(attrs.remoteUrl);
385
- if (attrs.cacheEnabled != null) attributes["activitypub.cache.enabled"] = attrs.cacheEnabled;
386
- if (attrs.statusCode != null) attributes["http.response.status_code"] = attrs.statusCode;
387
- this.documentFetch.add(1, attributes);
388
- this.documentFetchDuration.record(attrs.durationMs, attributes);
389
- }
390
- recordDocumentCache(attrs) {
391
- const attributes = {
392
- "activitypub.lookup.kind": attrs.kind,
393
- "activitypub.lookup.result": attrs.result
394
- };
395
- if (attrs.remoteUrl != null) attributes["activitypub.remote.host"] = getRemoteHost(attrs.remoteUrl);
396
- this.documentCache.add(1, attributes);
397
- }
398
- recordWebFingerHandle(attrs) {
399
- const attributes = { "webfinger.handle.result": attrs.result };
400
- if (attrs.scheme != null) attributes["webfinger.resource.scheme"] = attrs.scheme;
401
- if (attrs.statusCode != null) attributes["http.response.status_code"] = attrs.statusCode;
402
- this.webFingerHandle.add(1, attributes);
403
- this.webFingerHandleDuration.record(attrs.durationMs, attributes);
404
- }
405
- recordCollectionRequest(attrs) {
406
- this.collectionRequest.add(1, buildCollectionAttributes(attrs));
407
- }
408
- recordCollectionDispatchDuration(durationMs, attrs) {
409
- this.collectionDispatchDuration.record(durationMs, buildCollectionAttributes(attrs));
410
- }
411
- recordCollectionPageItems(itemCount, attrs) {
412
- this.collectionPageItems.record(itemCount, buildCollectionAttributes(attrs));
413
- }
414
- recordCollectionTotalItems(totalItems, attrs) {
415
- this.collectionTotalItems.record(totalItems, buildCollectionAttributes(attrs));
416
- }
417
- };
418
- function buildCollectionAttributes(attrs) {
419
- const attributes = {
420
- "activitypub.collection.kind": attrs.kind,
421
- "activitypub.collection.page": attrs.page,
422
- "activitypub.collection.result": attrs.result,
423
- "fedify.collection.dispatcher": attrs.dispatcher
424
- };
425
- if (attrs.statusCode != null) attributes["http.response.status_code"] = attrs.statusCode;
426
- return attributes;
427
- }
428
- function buildActivityLifecycleAttributes(result, activityType) {
429
- const attributes = { "activitypub.processing.result": result };
430
- if (activityType != null) attributes["activitypub.activity.type"] = activityType;
431
- return attributes;
432
- }
433
- function buildQueueTaskAttributes(common) {
434
- const attributes = { "fedify.queue.role": common.role };
435
- const backend = getQueueBackend(common.queue);
436
- if (backend != null) attributes["fedify.queue.backend"] = backend;
437
- const nativeRetrial = common.queue?.nativeRetrial;
438
- if (typeof nativeRetrial === "boolean") attributes["fedify.queue.native_retrial"] = nativeRetrial;
439
- if (common.activityType != null) attributes["activitypub.activity.type"] = common.activityType;
440
- if (common.taskName != null) attributes["fedify.task.name"] = common.taskName;
441
- return attributes;
442
- }
443
- function buildQueueTaskInFlightAttributes(common) {
444
- return buildQueueTaskAttributes({
445
- role: common.role,
446
- queue: common.queue
447
- });
448
- }
449
- /**
450
- * Returns the constructor name of the given message queue, when it is a
451
- * meaningful identifier. Used as a best-effort `fedify.queue.backend`
452
- * attribute on queue task metrics; returns `undefined` for plain object
453
- * literals (whose constructor is `Object`) so the attribute does not appear
454
- * with a non-informative value.
455
- * @since 2.3.0
456
- */
457
- function getQueueBackend(queue) {
458
- const name = queue?.constructor?.name;
459
- if (name == null || name === "" || name === "Object") return void 0;
460
- return name;
461
- }
462
- /**
463
- * Registers a callback for observing queue backend depth.
464
- * @since 2.3.0
465
- */
466
- function registerQueueDepthGauge(meterProvider, entries, options = {}) {
467
- const uniqueQueues = /* @__PURE__ */ new Map();
468
- for (const { role, queue } of entries) {
469
- if (queue?.getDepth == null) continue;
470
- const roles = uniqueQueues.get(queue);
471
- if (roles == null) uniqueQueues.set(queue, [role]);
472
- else if (!roles.includes(role)) roles.push(role);
473
- }
474
- if (uniqueQueues.size < 1) return;
475
- const queueEntries = Array.from(uniqueQueues.entries());
476
- getFederationMetrics(meterProvider).queueDepth.addCallback(async (observableResult) => {
477
- await Promise.all(queueEntries.map(async ([queue, roles]) => {
478
- let depth;
479
- try {
480
- depth = await queue.getDepth();
481
- } catch {
482
- return;
483
- }
484
- if (depth == null) return;
485
- const attributes = buildQueueDepthAttributes(queue, roles, options);
486
- observableResult.observe(depth.queued, {
487
- ...attributes,
488
- "fedify.queue.depth.state": "queued"
489
- });
490
- if (depth.ready != null) observableResult.observe(depth.ready, {
491
- ...attributes,
492
- "fedify.queue.depth.state": "ready"
493
- });
494
- if (depth.delayed != null) observableResult.observe(depth.delayed, {
495
- ...attributes,
496
- "fedify.queue.depth.state": "delayed"
497
- });
498
- }));
499
- });
500
- }
501
- function buildQueueDepthAttributes(queue, roles, options) {
502
- const sortedRoles = roles.toSorted();
503
- const role = sortedRoles.length === 1 ? sortedRoles[0] : "shared";
504
- const attributes = { "fedify.queue.role": role };
505
- if (options.sourceId != null) attributes["fedify.federation.instance_id"] = options.sourceId;
506
- if (role === "shared") attributes["fedify.queue.roles"] = sortedRoles.join(",");
507
- const backend = getQueueBackend(queue);
508
- if (backend != null) attributes["fedify.queue.backend"] = backend;
509
- const nativeRetrial = queue.nativeRetrial;
510
- if (typeof nativeRetrial === "boolean") attributes["fedify.queue.native_retrial"] = nativeRetrial;
511
- return attributes;
512
- }
513
- /**
514
- * Records `fedify.queue.task.enqueued` for an outgoing outbox enqueue and,
515
- * for the initial attempt, also records
516
- * `activitypub.outbox.activity{queued}`.
517
- *
518
- * Both `Context.sendActivity()` and `OutboxContext.forwardActivity()` enqueue
519
- * outbox messages with the same metric attributes (role, queue, activity
520
- * type, attempt), so they share this helper rather than each defining a local
521
- * closure. Retry enqueues (attempt > 0) intentionally do not record a
522
- * second `activitypub.outbox.activity{queued}`; retries are reported as
523
- * `result=retried` from the retry-scheduling site, which has the failure
524
- * context.
525
- * @since 2.3.0
526
- */
527
- function recordOutboxEnqueue(meterProvider, outboxQueue, message) {
528
- const metrics = getFederationMetrics(meterProvider);
529
- metrics.recordQueueTaskEnqueued({
530
- role: "outbox",
531
- queue: outboxQueue,
532
- activityType: message.activityType
533
- }, message.attempt);
534
- if (message.attempt === 0) metrics.recordOutboxActivity("queued", message.activityType);
535
- }
536
- /**
537
- * Records `activitypub.fanout.recipients` with the number of recipient
538
- * inboxes a single fanout produced. The histogram is unitless count
539
- * (one measurement per fanout enqueue). Recipient URLs are deliberately
540
- * not recorded; only the activity type, when known.
541
- * @since 2.3.0
542
- */
543
- function recordFanoutRecipients(meterProvider, recipientCount, activityType) {
544
- getFederationMetrics(meterProvider).recordFanoutRecipients(recipientCount, activityType);
545
- }
546
- /**
547
- * Records one `activitypub.inbox.activity` measurement. The
548
- * `activitypub.processing.result` attribute is always present;
549
- * `activitypub.activity.type` is recorded only when Fedify already knows
550
- * the activity type.
551
- * @since 2.3.0
552
- */
553
- function recordInboxActivity(meterProvider, result, activityType) {
554
- getFederationMetrics(meterProvider).recordInboxActivity(result, activityType);
555
- }
556
- /**
557
- * Records one `activitypub.outbox.activity` measurement. The
558
- * `activitypub.processing.result` attribute is always present;
559
- * `activitypub.activity.type` is recorded only when Fedify already knows
560
- * the activity type (it is always known for outbox lifecycle events).
561
- * @since 2.3.0
562
- */
563
- function recordOutboxActivity(meterProvider, result, activityType) {
564
- getFederationMetrics(meterProvider).recordOutboxActivity(result, activityType);
565
- }
566
- /**
567
- * Records one outbound delivery circuit breaker state transition.
568
- * @since 2.3.0
569
- */
570
- function recordCircuitBreakerStateChange(meterProvider, remoteHost, state) {
571
- getFederationMetrics(meterProvider).recordCircuitBreakerStateChange(remoteHost, state);
572
- }
573
- /**
574
- * Records one measurement on `activitypub.key.lookup` (counter) and
575
- * `activitypub.key.lookup.duration` (histogram) for a public-key lookup.
576
- *
577
- * `activitypub.lookup.kind` is always recorded as `public_key`; the result
578
- * classification, remote host, HTTP status code (when an HTTP response was
579
- * received), and `activitypub.cache.enabled` are recorded as attributes on
580
- * both measurements. Full key URLs and key IDs are deliberately omitted to
581
- * keep cardinality bounded.
582
- * @since 2.3.0
583
- */
584
- function recordKeyLookup(meterProvider, attrs) {
585
- getFederationMetrics(meterProvider).recordKeyLookup(attrs);
586
- }
587
- /**
588
- * Records one measurement each on `activitypub.document.fetch` (counter)
589
- * and `activitypub.document.fetch.duration` (histogram) for one remote
590
- * JSON-LD document loader invocation, with bounded
591
- * `activitypub.lookup.kind` and `activitypub.lookup.result` attributes
592
- * plus the optional remote-host, cache-enabled, and HTTP status-code
593
- * attributes. Counter and histogram are always recorded together so
594
- * aggregate rate and latency views stay in sync.
595
- * @since 2.3.0
596
- */
597
- function recordDocumentFetch(meterProvider, attrs) {
598
- getFederationMetrics(meterProvider).recordDocumentFetch(attrs);
599
- }
600
- /**
601
- * Records one `activitypub.document.cache` measurement, classifying the
602
- * lookup as `hit` (the cache returned an entry) or `miss` (the cache was
603
- * consulted and returned nothing, prompting a delegate fetch).
604
- * @since 2.3.0
605
- */
606
- function recordDocumentCache(meterProvider, attrs) {
607
- getFederationMetrics(meterProvider).recordDocumentCache(attrs);
608
- }
609
- /**
610
- * Records one measurement on `webfinger.handle` (counter) and
611
- * `webfinger.handle.duration` (histogram) for an incoming WebFinger
612
- * request handled by Fedify. Counter and histogram are always recorded
613
- * together, with `webfinger.handle.result` set to one of `resolved`,
614
- * `invalid`, `not_found`, `tombstoned`, or `error`. The queried
615
- * resource string is deliberately excluded; it remains on the
616
- * `webfinger.handle` span for trace-level investigation.
617
- * @since 2.3.0
618
- */
619
- function recordWebFingerHandle(meterProvider, attrs) {
620
- getFederationMetrics(meterProvider).recordWebFingerHandle(attrs);
621
- }
622
- /**
623
- * Records one `activitypub.collection.request` measurement for a
624
- * collection or collection-page request handled by Fedify.
625
- * @since 2.3.0
626
- */
627
- function recordCollectionRequest(meterProvider, attrs) {
628
- getFederationMetrics(meterProvider).recordCollectionRequest(attrs);
629
- }
630
- /**
631
- * Records one `activitypub.collection.dispatch.duration` measurement for a
632
- * collection dispatcher callback invocation.
633
- * @since 2.3.0
634
- */
635
- function recordCollectionDispatchDuration(meterProvider, durationMs, attrs) {
636
- getFederationMetrics(meterProvider).recordCollectionDispatchDuration(durationMs, attrs);
637
- }
638
- /**
639
- * Records one `activitypub.collection.page.items` measurement when Fedify
640
- * has materialized collection items in memory.
641
- * @since 2.3.0
642
- */
643
- function recordCollectionPageItems(meterProvider, itemCount, attrs) {
644
- getFederationMetrics(meterProvider).recordCollectionPageItems(itemCount, attrs);
645
- }
646
- /**
647
- * Records one `activitypub.collection.total_items` measurement when a
648
- * collection counter has already reported a total item count.
649
- * @since 2.3.0
650
- */
651
- function recordCollectionTotalItems(meterProvider, totalItems, attrs) {
652
- getFederationMetrics(meterProvider).recordCollectionTotalItems(totalItems, attrs);
653
- }
654
- /**
655
- * Classifies a thrown value from a key or document fetch into the bounded
656
- * {@link LookupResult} taxonomy and, when an HTTP response was received,
657
- * surfaces its status code.
658
- *
659
- * - `FetchError` with a `Response` whose status is `404` or `410`:
660
- * `result=not_found` and the response status code.
661
- * - `FetchError` with any other `Response`: `result=error` and the
662
- * response status code.
663
- * - `FetchError` without a `Response`: `result=network_error`.
664
- * - An `AbortError` (typically from a cancelled fetch): `result=network_error`.
665
- * - A bare `TypeError` (the shape native `fetch()` raises on DNS, connect,
666
- * and TLS failures before any response is observed):
667
- * `result=network_error`.
668
- * - Any other value: `result=error`.
669
- * @since 2.3.0
670
- */
671
- function classifyFetchError(error) {
672
- if (error instanceof FetchError) {
673
- if (error.response != null) {
674
- const status = error.response.status;
675
- return {
676
- result: status === 404 || status === 410 ? "not_found" : "error",
677
- statusCode: status
678
- };
679
- }
680
- return { result: "network_error" };
681
- }
682
- if (isAbortError(error)) return { result: "network_error" };
683
- if (error instanceof TypeError) return { result: "network_error" };
684
- return { result: "error" };
685
- }
686
- /**
687
- * Wraps a {@link DocumentLoader} so each invocation records one
688
- * measurement on `activitypub.document.fetch` (counter) and one on
689
- * `activitypub.document.fetch.duration` (histogram), classifying the
690
- * outcome via {@link classifyFetchError} when the wrapped loader throws
691
- * and as `fetched` on success. The wrapper rethrows whatever the
692
- * wrapped loader throws so caller behavior is unchanged.
693
- *
694
- * The wrapper records the host of the requested URL, including any
695
- * non-default port, on `activitypub.remote.host` when the URL parses; full
696
- * URLs, paths, and query strings are deliberately excluded to keep
697
- * cardinality bounded.
698
- * HTTP status codes are recorded only when the failure carries a
699
- * `Response` (currently, when the wrapped loader throws a
700
- * {@link FetchError} with a non-`null` `response`).
701
- * @since 2.3.0
702
- */
703
- function instrumentDocumentLoader(loader, options) {
704
- const meterProvider = options.meterProvider;
705
- if (meterProvider == null) return loader;
706
- return async (url, opts) => {
707
- const start = performance.now();
708
- let remoteUrl;
709
- try {
710
- remoteUrl = new URL(url);
711
- } catch {
712
- remoteUrl = void 0;
713
- }
714
- try {
715
- const result = await loader(url, opts);
716
- recordDocumentFetch(meterProvider, {
717
- durationMs: getDurationMs(start),
718
- kind: options.kind,
719
- result: "fetched",
720
- remoteUrl,
721
- cacheEnabled: options.cacheEnabled
722
- });
723
- return result;
724
- } catch (error) {
725
- const classified = classifyFetchError(error);
726
- recordDocumentFetch(meterProvider, {
727
- durationMs: getDurationMs(start),
728
- kind: options.kind,
729
- result: classified.result,
730
- remoteUrl,
731
- cacheEnabled: options.cacheEnabled,
732
- statusCode: classified.statusCode
733
- });
734
- throw error;
735
- }
736
- };
737
- }
738
- /**
739
- * Times an awaited public key fetch and records exactly one
740
- * `activitypub.signature.key_fetch.duration` measurement, classifying the
741
- * outcome as `hit`, `fetched`, or `error` based on the `cached` flag and
742
- * whether the returned key is non-null. Errors thrown by the fetch are
743
- * reported as `error` and rethrown, so verifier behavior is unchanged.
744
- *
745
- * Shared by the three signature verifiers (HTTP, Linked Data, Object
746
- * Integrity Proofs); the only per-call variation is the
747
- * `activitypub.signature.kind` attribute value.
748
- * @since 2.3.0
749
- */
750
- async function measureSignatureKeyFetch(meterProvider, kind, fetch) {
751
- const start = performance.now();
752
- try {
753
- const result = await fetch();
754
- getFederationMetrics(meterProvider).recordSignatureKeyFetchDuration(getDurationMs(start), kind, result.key != null ? result.cached ? "hit" : "fetched" : "error");
755
- return result;
756
- } catch (error) {
757
- getFederationMetrics(meterProvider).recordSignatureKeyFetchDuration(getDurationMs(start), kind, "error");
758
- throw error;
759
- }
760
- }
761
- /**
762
- * Whether the given thrown value is an `AbortError`.
763
- *
764
- * `processQueuedTask` distinguishes aborted tasks (recorded as
765
- * `fedify.queue.task.result=aborted`) from other failures so that backend
766
- * shutdown signals do not inflate the `fedify.queue.task.failed` counter.
767
- * @since 2.3.0
768
- */
769
- function isAbortError(error) {
770
- if (error == null || typeof error !== "object") return false;
771
- const name = error.name;
772
- return typeof name === "string" && name === "AbortError";
773
- }
774
- const KNOWN_HTTP_METHODS = /* @__PURE__ */ new Set([
775
- "CONNECT",
776
- "DELETE",
777
- "GET",
778
- "HEAD",
779
- "OPTIONS",
780
- "PATCH",
781
- "POST",
782
- "PUT",
783
- "QUERY",
784
- "TRACE"
785
- ]);
786
- function normalizeHttpMethod(method) {
787
- const upper = method.toUpperCase();
788
- return KNOWN_HTTP_METHODS.has(upper) ? upper : "_OTHER";
789
- }
790
- const federationMetrics = /* @__PURE__ */ new WeakMap();
791
- /**
792
- * Gets the cached Fedify metric instruments for a meter provider.
793
- * @since 2.3.0
794
- */
795
- function getFederationMetrics(meterProvider = metrics.getMeterProvider()) {
796
- let instruments = federationMetrics.get(meterProvider);
797
- if (instruments == null) {
798
- instruments = new FederationMetrics(meterProvider);
799
- federationMetrics.set(meterProvider, instruments);
800
- }
801
- return instruments;
802
- }
803
- /**
804
- * Gets the bounded remote host attribute value for a URL.
805
- * @since 2.3.0
806
- */
807
- function getRemoteHost(url) {
808
- return url.host;
809
- }
810
- /**
811
- * Gets an elapsed duration in milliseconds from a `performance.now()` value.
812
- * @since 2.3.0
813
- */
814
- function getDurationMs(start) {
815
- return Math.max(0, performance.now() - start);
816
- }
817
- //#endregion
818
- export { recordKeyLookup as _, instrumentDocumentLoader as a, recordWebFingerHandle as b, recordCircuitBreakerStateChange as c, recordCollectionRequest as d, recordCollectionTotalItems as f, recordInboxActivity as g, recordFanoutRecipients as h, getRemoteHost as i, recordCollectionDispatchDuration as l, recordDocumentFetch as m, getDurationMs as n, isAbortError as o, recordDocumentCache as p, getFederationMetrics as r, measureSignatureKeyFetch as s, classifyFetchError as t, recordCollectionPageItems as u, recordOutboxActivity as v, registerQueueDepthGauge as x, recordOutboxEnqueue as y };