Skip to content

Commit da3b985

Browse files
committed
Update outbound telemetry debug example
The debug exporter example now records the outbound activity ID and inbox URL from the sent activity event attributes instead of parsing the removed activity JSON event attribute. Assisted-by: gpt-5.5
1 parent bb03d95 commit da3b985

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

docs/manual/opentelemetry.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,22 @@ ActivityPub activities for a debug dashboard:
408408
import type { SpanExporter, ReadableSpan } from "@opentelemetry/sdk-trace-base";
409409
import { ExportResultCode } from "@opentelemetry/core";
410410

411-
interface ActivityRecord {
412-
direction: "inbound" | "outbound";
411+
interface InboundActivityRecord {
412+
direction: "inbound";
413413
activity: unknown;
414414
timestamp: Date;
415415
verified?: boolean;
416416
}
417417

418+
interface OutboundActivityRecord {
419+
direction: "outbound";
420+
activityId?: string;
421+
inboxUrl?: string;
422+
timestamp: Date;
423+
}
424+
425+
type ActivityRecord = InboundActivityRecord | OutboundActivityRecord;
426+
418427
export class FedifyDebugExporter implements SpanExporter {
419428
private activities: ActivityRecord[] = [];
420429

@@ -443,11 +452,16 @@ export class FedifyDebugExporter implements SpanExporter {
443452
(e) => e.name === "activitypub.activity.sent"
444453
);
445454
if (event && event.attributes) {
455+
const activityId = event.attributes[
456+
"activitypub.activity.id"
457+
] as string | undefined;
458+
const inboxUrl = event.attributes[
459+
"activitypub.inbox.url"
460+
] as string | undefined;
446461
this.activities.push({
447462
direction: "outbound",
448-
activity: JSON.parse(
449-
event.attributes["activitypub.activity.json"] as string
450-
),
463+
activityId,
464+
inboxUrl,
451465
timestamp: new Date(span.startTime[0] * 1000),
452466
});
453467
}

0 commit comments

Comments
 (0)