From 339238280ce92c6a02a9ae4380987daa74e0f233 Mon Sep 17 00:00:00 2001 From: Alex Holovach Date: Tue, 7 Oct 2025 10:24:49 -0500 Subject: [PATCH] update readme --- packages/otel-upstash-queues/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/otel-upstash-queues/README.md b/packages/otel-upstash-queues/README.md index 7ef213f..b6952bf 100644 --- a/packages/otel-upstash-queues/README.md +++ b/packages/otel-upstash-queues/README.md @@ -20,6 +20,8 @@ pnpm add @kubiks/otel-upstash-queues ## Quick Start +### Publishing Messages + ```ts import { Client } from "@upstash/qstash"; import { instrumentUpstash } from "@kubiks/otel-upstash-queues"; @@ -37,6 +39,28 @@ await client.publishJSON({ `instrumentUpstash` wraps the QStash client instance you already use — no configuration changes needed. Every SDK call creates a client span with useful attributes. +### Consuming Messages + +```ts +// app/api/process/route.ts +import { verifySignatureAppRouter } from "@upstash/qstash/nextjs"; +import { instrumentConsumer } from "@kubiks/otel-upstash-queues"; + +async function handler(request: Request) { + const data = await request.json(); + + // Process your message + await processImage(data.imageId); + + return Response.json({ success: true }); +} + +// Instrument first, then verify signature +export const POST = verifySignatureAppRouter(instrumentConsumer(handler)); +``` + +`instrumentConsumer` wraps your message handler to trace message consumption, creating a SERVER span for each message received and processed. + ### With Body Capture Optionally capture request/response bodies for debugging: