@raindrop-ai/claude-agent-sdk package automatically instruments the
Claude Agent SDK to capture events and traces from wrapped query calls.
Add eventMetadata() (with a userId) to the specific queries you want tracked in Raindrop.
Features:
- No OpenTelemetry setup required
- Automatic tool call tracing
- Automatic conversation tracking using Claude Agent SDK’s
session_id - Subagent span hierarchies for Task tool invocations
- Wrap once, then optionally pass
eventMetadata()to eachquery()call you want Raindrop to track
Installation
Quick Start
eventMetadata() are tracked with events and traces. Calls without it run normally and are not tracked in Raindrop.
Configuration
Client Options
Projects
Route events to a specific project by passing its slug asprojectId:
X-Raindrop-Project-Id header on every outbound event. Omit it (or pass "default") to use your org’s default Production project, which is the existing behavior. Single-project orgs need nothing new.
Self Diagnostics (Optional)
Self Diagnostics lets your agent proactively report its own issues — capability gaps, missing context, persistent tool failures — back to your team. It’s most valuable when an agent’s self-reflection provides signal you can’t easily get otherwise. The tool is delivered as an in-process MCP server, so it works alongside any other MCP servers you configure. The tool name defaults to__raindrop_report, and can be overridden with selfDiagnostics.toolName.
The SDK automatically prompt-engineers the tool description from your signals definitions; selfDiagnostics.guidance is optional extra guidance.
eventId:
Per-Query Context
UseeventMetadata() as the second argument when you want a query tracked. userId is required:
convoId, eventName, properties, or eventId per query.
Defaults:
- If
eventMetadata()is omitted, the query runs normally but no events or traces are captured by Raindrop eventNamedefaults to"agent_query"convoIdis auto-captured from Claude’ssession_idif not providedeventIdis auto-generated if not provided
Identifying Users
Useusers.identify to associate traits with a user:
Signals (Feedback)
Track user feedback on AI responses using the sameeventId:
Signal Types
Manual Event Updates
Update events after they’re created (useeventId from eventMetadata):
The event is automatically finalized when the query stream completes. Use
finish() only when you need to force immediate shipping before the stream ends.Tool catalog capture (ai.prompt.tools)
Override only. The wrapper never sees the model requests the Claude Agent SDK makes: it observes the message stream, whose system/init message lists tool names without schemas. A name-only catalog is indistinguishable from an unknown one downstream, so nothing is inferred and ai.prompt.tools is absent unless you provide it with wrap(sdk, { tools }). Any recognized declaration shape works (Anthropic input_schema, OpenAI function, plain { name, description, parameters }); tools: [] records an empty catalog. See Tool catalog capture for the attribute format, the absent / [] semantics and the override shapes accepted.
Flush & Shutdown
Always flush before your process exits to ensure all data is sent:Debugging
Enable debug logging to troubleshoot issues:- Every event sent to Raindrop
- Every trace batch shipped
- Span parent/child relationships (with
debugSpans)
Troubleshooting
Events not appearing in dashboard
- Ensure tracked queries include
eventMetadata() - Check your write key - Ensure
RAINDROP_WRITE_KEYis set correctly - Flush before exit - Call
await raindrop.flush()before your process ends - Enable debug logging - Set
events: { debug: true }to see what’s being sent
Traces missing or incomplete
- Enable trace debugging - Set
traces: { debug: true, debugSpans: true } - Check for errors - Look for
[raindrop-ai/claude-agent-sdk]prefixed logs
Wrapper not capturing tool calls
Ensure the wrappedquery is the one you call. Tools are traced via SDK hooks; if you call the unwrapped SDK directly, no tracing occurs.
Application Git identity
SetappGit on createRaindropClaudeAgentSDK to provide commitSha, commitDirty, and optional
branch, or pass false to opt out. Because the SDK may observe a remote workspace, it never uses
the observer or edited checkout by default; local discovery requires a sourceDirectory that
explicitly identifies the application-under-test. See the TypeScript Git reference.
That’s it! You’re ready to explore your events and traces in the Raindrop dashboard. Ping us on Slack or email us if you get stuck!