@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.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.
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!