Monitor Claude Code usage and costs with Sentry
Add the claude-code-sentry-monitor plugin to track token usage, session costs, and tool activity across every Claude Code session, without touching your project code.
Before you start
SDKs & packages
- Claude Code installed and configured
- Node.js 18+ installed
Accounts & access
- Sentry account with a Node.js project created
Knowledge
- Basic familiarity with Claude Code slash commands
1 Create a Sentry project
In Sentry, create a new project for your Claude Code monitoring data. Go to Settings → Projects and click Create Project. Select Node.js as the platform, give it a name like claude-code, and copy the DSN from the project settings. You'll need it in step 4.
2 Add the plugin marketplace
Claude Code supports third-party plugin marketplaces. Add the marketplace that hosts the Sentry monitor plugin by running this slash command inside Claude Code.
/plugin marketplace add sergical/claude-code-sentry-monitor 3 Install the plugin and reload
With the marketplace added, install the plugin and reload to activate it. The reload step is required, as hooks won't fire until Claude Code picks up the new plugin.
/plugin install claude-code-sentry-monitor
/reload-plugins 4 Run the setup wizard
Tell Claude to set up Sentry monitoring. It will run the plugin's setup skill, prompt you for the DSN you copied in step 1, and write the config to ~/.config/claude-code/sentry-monitor.json automatically.
set up Sentry monitoring 5 Explore traces in Sentry
Head to AI Agents Insights in Sentry. Each Claude Code session appears as an invoke_agent root span. Expand a session to see each conversation turn as a gen_ai.request child span, including input and output token counts for that turn, which map directly to your API costs. Tool calls (read, bash, grep, and others) are nested inside each turn as execute_tool spans with durations and metadata. To check total token usage and cost across sessions, use the Trace Explorer and filter by service.name:claude-code.
That's it.
Token usage, costs, and tool calls. All in one place.
See exactly how many tokens each Claude Code session consumed, what it cost, and which tools it used, so you can understand your usage, control spend, and tune your workflow.
- Installed the claude-code-sentry-monitor plugin into Claude Code
- Connected Claude Code sessions to Sentry AI Observability
- Tracked token usage and estimated API costs per Claude Code session
- Tracked tool calls per session as structured spans
- Explored per-session traces in the Sentry AI Agents dashboard
- Explored per-conversation-turn spans showing input/output tokens and which tools Claude used to answer each message
Pro tips
- 💡 Adjust
tracesSampleRatein~/.config/claude-code/sentry-monitor.jsonto reduce volume during heavy sessions. - 💡 Add a
tagsfield with"developer": "yourname"to filter traces and costs by team member in the Sentry dashboard. - 💡 The config lives at
~/.config/claude-code/sentry-monitor.jsonand can be edited at any time without reinstalling the plugin. - 💡 To monitor token usage and costs across your whole team, have each developer install the plugin and set a shared Sentry project DSN. All sessions roll up into one dashboard.
Common pitfalls
- ⚠️ Forgetting
/reload-pluginsafter install. Hooks won't fire until Claude Code reloads the plugin. - ⚠️ Using a browser or Python Sentry DSN instead of a Node.js project. The plugin uses
@sentry/nodeand requires a server-side DSN. - ⚠️ The plugin is user-level, not project-level. One install covers all your Claude Code projects automatically.
Frequently asked questions
What's next?
Fix it, don't observe it.
Get started with the only application monitoring platform that empowers developers to fix application problems without compromising on velocity.