Skip to content

Real-Time Telemetry (SSE)

4. Real-Time Telemetry & Server-Sent Events (SSE)

Section titled “4. Real-Time Telemetry & Server-Sent Events (SSE)”

The SSE endpoint streams stages as they execute inside the Rust runtime:

GET /v1/stream/did:web:identity.foundation HTTP/1.1
Host: did.is
Accept: text/event-stream

Stream event lifecycle:

  1. event: stage: Emitted on completion of each trace stage (startedUs, durationUs, status: PASS|FAIL).
  2. event: result: Emitted once with the full EnrichedResolution payload.
  3. event: error: Emitted if resolution halts prematurely (carries RFC 9457 problem JSON).
  4. event: done: Emits {} and closes the stream.

import { DidisClient } from "@didis/client";
const didis = new DidisClient();
async function streamDemo() {
const iterator = didis.stream("did:web:identity.foundation", { noCache: true });
for await (const event of iterator) {
if (event.event === "stage") {
const { stage, status, durationUs } = event.data;
console.log(`⏱️ [${status}] ${stage} (${durationUs} µs)`);
} else if (event.event === "result") {
console.log(`\n🎉 Resolution Complete: ${event.data.verdict.headline}`);
} else if (event.event === "error") {
console.error(`❌ Stream Failed: ${event.data.title}`);
}
}
}
streamDemo();

from didis import DidisClient
with DidisClient() as client:
for event_type, payload in client.stream("did:web:identity.foundation", no_cache=True):
if event_type == "stage":
print(f"⏱️ [{payload['status']}] {payload['stage']} ({payload['durationUs']} µs)")
elif event_type == "result":
print(f"\n🎉 Resolution Complete: {payload['verdict']['headline']}")
elif event_type == "error":
print(f"❌ Error: {payload['title']}")