Skip to content

Commit d16cece

Browse files
authored
Merge pull request #564 from dahlia/debugger
`@fedify/debugger`: Embedded ActivityPub debug dashboard
2 parents 38d1c66 + f54f003 commit d16cece

29 files changed

Lines changed: 3894 additions & 325 deletions

CHANGES.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ To be released.
139139
code, the inbox URL, and the response body, making it easier to
140140
programmatically handle delivery errors. [[#548], [#559]]
141141

142+
- Added `traceId` and `spanId` to LogTape context in federation middleware
143+
so that log records emitted during request handling and queue processing
144+
include the OpenTelemetry trace and span IDs in their properties. This
145+
enables the `@fedify/debugger` dashboard to display per-trace logs.
146+
[[#561], [#564]]
147+
142148
[#280]: https://github.com/fedify-dev/fedify/issues/280
143149
[#366]: https://github.com/fedify-dev/fedify/issues/366
144150
[#376]: https://github.com/fedify-dev/fedify/issues/376
@@ -163,6 +169,8 @@ To be released.
163169
[#548]: https://github.com/fedify-dev/fedify/issues/548
164170
[#559]: https://github.com/fedify-dev/fedify/pull/559
165171
[#560]: https://github.com/fedify-dev/fedify/issues/560
172+
[#561]: https://github.com/fedify-dev/fedify/issues/561
173+
[#564]: https://github.com/fedify-dev/fedify/pull/564
166174

167175
### @fedify/cli
168176

@@ -231,6 +239,38 @@ To be released.
231239
[#529]: https://github.com/fedify-dev/fedify/pull/529
232240
[#531]: https://github.com/fedify-dev/fedify/pull/531
233241

242+
### @fedify/debugger
243+
244+
- Created the *@fedify/debugger* package, an embedded real-time ActivityPub
245+
debug dashboard for Fedify. It wraps an existing `Federation` object as
246+
a proxy, intercepting requests to a configurable path prefix (default
247+
`/__debug__`) and serving an SSR-based web UI. [[#561], [#564]]
248+
249+
- Added `createFederationDebugger()` function that returns a
250+
`Federation` proxy with a built-in debug dashboard. When called
251+
without an `exporter` option, it automatically sets up OpenTelemetry
252+
tracing (creating `MemoryKvStore`, `FedifySpanExporter`,
253+
`BasicTracerProvider`) and registers it as the global tracer
254+
provider—no manual OTel configuration needed.
255+
- Traces list page showing trace IDs, activity types, activity counts,
256+
and timestamps, with auto-polling for real-time updates.
257+
- Trace detail page showing activity direction, type, actor, signature
258+
verification details, inbox URL, and expandable activity JSON.
259+
- JSON API endpoint at `/__debug__/api/traces` for programmatic access.
260+
- Added per-trace log collection using LogTape. The returned federation
261+
object now includes a `sink` property (a LogTape `Sink` function)
262+
that captures log records grouped by trace ID. In the simplified
263+
overload (without `exporter`), LogTape is auto-configured.
264+
- Trace detail page now shows a “Logs” section with log level, timestamp,
265+
logger category, and message for each log record in the trace.
266+
- JSON API endpoint at `/__debug__/api/logs/:traceId` for retrieving
267+
log records for a specific trace.
268+
- Added optional `auth` configuration for protecting the debug dashboard
269+
with authentication. Supports three modes: password-only,
270+
username + password, and request-based (e.g., IP filtering).
271+
Each mode supports both static credentials and callback functions.
272+
Uses cookie-based sessions with HMAC-signed tokens.
273+
234274
### @fedify/relay
235275

236276
- Created ActivityPub relay integration as the *@fedify/relay* package.

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ The repository is organized as a monorepo with the following packages:
335335
- *packages/amqp/*: AMQP/RabbitMQ driver (@fedify/amqp) for Fedify.
336336
- *packages/cfworkers/*: Cloudflare Workers integration (@fedify/cfworkers) for
337337
Fedify.
338+
- *packages/debugger/*: Embedded ActivityPub debug dashboard (@fedify/debugger)
339+
for Fedify.
338340
- *packages/denokv/*: Deno KV integration (@fedify/denokv) for Fedify.
339341
- *packages/elysia/*: Elysia integration (@fedify/elysia) for Fedify.
340342
- *packages/express/*: Express integration (@fedify/express) for Fedify.

deno.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"./packages/amqp",
44
"./packages/cfworkers",
55
"./packages/cli",
6+
"./packages/debugger",
67
"./packages/denokv",
78
"./packages/express",
89
"./packages/fastify",
@@ -35,8 +36,10 @@
3536
"@logtape/logtape": "jsr:@logtape/logtape@^2.0.0",
3637
"@nestjs/common": "npm:@nestjs/common@^11.0.1",
3738
"@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
38-
"@opentelemetry/core": "npm:@opentelemetry/core@^2.0.0",
39-
"@opentelemetry/sdk-trace-base": "npm:@opentelemetry/sdk-trace-base@^2.0.0",
39+
"@opentelemetry/context-async-hooks": "npm:@opentelemetry/context-async-hooks@^2.5.0",
40+
"@opentelemetry/core": "npm:@opentelemetry/core@^2.5.0",
41+
"@opentelemetry/sdk-trace-base": "npm:@opentelemetry/sdk-trace-base@^2.5.0",
42+
"@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.39.0",
4043
"@std/assert": "jsr:@std/assert@^1.0.13",
4144
"@std/async": "jsr:@std/async@^1.0.13",
4245
"@std/encoding": "jsr:@std/encoding@^1.0.10",
@@ -49,6 +52,7 @@
4952
"byte-encodings": "npm:byte-encodings@^1.0.11",
5053
"es-toolkit": "npm:es-toolkit@^1.43.0",
5154
"h3": "npm:h3@^1.15.0",
55+
"hono": "jsr:@hono/hono@^4.8.3",
5256
"ioredis": "npm:ioredis@^5.8.2",
5357
"json-preserve-indent": "npm:json-preserve-indent@^1.1.3",
5458
"postgres": "npm:postgres@^3.4.7",

deno.lock

Lines changed: 68 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/.vitepress/config.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const MANUAL = {
7777
{ text: "Integration", link: "/manual/integration.md" },
7878
{ text: "Relay", link: "/manual/relay.md" },
7979
{ text: "Testing", link: "/manual/test.md" },
80+
{ text: "Debugging", link: "/manual/debug.md" },
8081
{ text: "Linting", link: "/manual/lint.md" },
8182
{ text: "Logging", link: "/manual/log.md" },
8283
{ text: "OpenTelemetry", link: "/manual/opentelemetry.md" },
@@ -92,6 +93,7 @@ const REFERENCES = {
9293
{ text: "@fedify/fedify", link: "https://jsr.io/@fedify/fedify/doc" },
9394
{ text: "@fedify/amqp", link: "https://jsr.io/@fedify/amqp/doc" },
9495
{ text: "@fedify/cfworkers", link: "https://jsr.io/@fedify/cfworkers/doc" },
96+
{ text: "@fedify/debugger", link: "https://jsr.io/@fedify/debugger/doc" },
9597
{ text: "@fedify/denokv", link: "https://jsr.io/@fedify/denokv/doc" },
9698
{ text: "@fedify/express", link: "https://jsr.io/@fedify/express/doc" },
9799
{ text: "@fedify/fastify", link: "https://jsr.io/@fedify/fastify/doc" },

0 commit comments

Comments
 (0)