Claude Code usage tracking by LangWatch  favicon

Claude Code usage tracking by LangWatch

Track Claude Code Usage with LangWatch: A Comprehensive Guide to LLM Observability

Introduction:

Discover how to effectively track Claude Code usage using LangWatch. This comprehensive guide details token accounting, cost analytics, and trace history for Claude Code, Cursor, Copilot, and other AI agents.

Added On:

2026-08-01

Monthly Visitors:

17.5K

Claude Code usage tracking by LangWatch  - AI Tool Screenshot and Interface Preview

Claude Code usage tracking by LangWatch Product Information

Track Claude Code Usage with LangWatch: A Comprehensive Guide to LLM Observability

In the rapidly evolving landscape of AI development, understanding how your autonomous agents consume resources is critical. Developers and engineering teams need precise tools to track Claude Code usage, monitor spending, and optimize performance. LangWatch emerges as the premier LLM engineering platform designed to provide full transparency into AI workflows, offering deep insights into every token spent and every command executed.

What is LangWatch and Claude Code Tracking?

LangWatch is a specialized LLM engineering platform built for teams that ship AI to production. It serves as a comprehensive observability suite that allows users to track Claude Code usage, as well as monitor other popular AI tools like Codex, OpenCode, GitHub Copilot, Cursor, and Pi.

When you track Claude Code usage through LangWatch, you are not just looking at a simple log; you are capturing a full trace history. This allows you to improve your development flow by understanding exactly how much you are spending in tokens and how your agent—specifically the Claude Code agent—is performing in real-world scenarios. By leveraging OpenTelemetry, LangWatch follows your activity across multiple machines, ensuring that your data survives local log cleanups and provides a persistent record of your AI-assisted coding sessions.

Key Features of LangWatch for Claude Code

To effectively track Claude Code usage, LangWatch offers a suite of advanced features that go beyond basic analytics. These tools are designed to provide a granular view of every interaction between the developer, the agent, and the LLM.

1. Advanced Token Accounting

Understanding token consumption is the first step in managing AI costs. LangWatch provides detailed token accounting that distinguishes between different types of usage:

  • Cache Hit Tracking: LangWatch separates cache reads and writes into distinct token classes on every span. It even tracks the 5-minute and 1-hour TTL (Time To Live) split on writes, ensuring you know exactly how much you are saving or spending on cached data.
  • Token Classes: In long agent sessions, cache reads often represent the bulk of the volume. LangWatch ensures these are not lumped into general input, providing a more accurate picture of your Claude Code usage.

2. Theoretical vs. Billed Cost Analytics

One of the most powerful features of the platform is its ability to provide exact cost numbers straight from API responses.

  • Bundled Costs: For users on Claude subscriptions (Pro, Max, or Team), there is no per-token invoice. LangWatch marks these as "Bundled" and calculates a theoretical total based on API list prices. This allows you to see what your usage would have cost on a standard API plan.
  • Cost Per Session: Users can plot analytics to see the cost per session and identify which tasks are the most resource-intensive.

3. Comprehensive Trace History and Tool Spans

Every action taken by your coding agent is captured as a span. This includes:

  • Bash Commands: Every command run in the terminal.
  • File Edits: Modifications made to your codebase.
  • Skill Invocations: Specific functions or skills called by the agent.
  • MCP Calls: Full input and output details for Model Context Protocol interactions.

4. LangWatch MCP: Self-Querying Agents

LangWatch provides an MCP server that exposes your trace history back to the agent itself. This means Claude Code can query its own history to:

  • Inspect previous runs from the past week.
  • Identify where tokens are being wasted.
  • Edit its own workflow to become more efficient over time.

5. Insights and Skill Improvement

By running Claude over your own trace history, you can analyze which prompts helped most and identify "friction patterns" where sessions went wrong. This analytical approach helps developers refine their instructions to get better results from their AI agents.

Use Cases for Tracking Claude Code

Engineering Workflow Optimization

By using LangWatch to track Claude Code usage, engineering leads can identify bottlenecks in the development process. For instance, if an agent is spending excessive time in a "wobble" or repeating Bash commands without success, the trace history will highlight these inefficiencies, allowing for immediate correction of the agent's instructions.

Budgeting and Resource Management

For organizations using multiple AI agents like Cursor or Copilot, LangWatch provides a single store for all token and cost data. This unified view is essential for teams needing to justify AI spend or project future costs as they scale their use of AI-assisted engineering.

Debugging Complex Agent Interactions

When an agent fails to enable a specific API (like the Google Ads API seen in the trace summary) or misses a design change request, LangWatch allows developers to dive into the span attributes. You can see the exact input, the model's reasoning effort, and the resulting output to diagnose the root cause of the error.

How to Use LangWatch to Track Claude Code

Setting up LangWatch to monitor your coding sessions is straightforward and requires minimal configuration.

Step-by-Step Setup

  1. Initialize Tracking: To start tracking right away, run the following command in your terminal:

    npx langwatch claude

  2. Automatic Configuration: This command configures Claude Code’s native OpenTelemetry export to point to LangWatch.
  3. Monitor Sessions: Once configured, every session will land as a trace in the LangWatch UI. You can view model turns, tool calls, and tokens by class immediately.
  4. Continuous Integration: Because the OpenTelemetry route follows you across machines, you can maintain a consistent history even if you switch development environments.

Frequently Asked Questions (FAQ)

How do I track my Claude Code usage effectively?

Simply run npx langwatch claude. This sets up the OpenTelemetry export. Your sessions will then appear as detailed traces in the LangWatch platform, showing everything from model turns to theoretical costs.

Does LangWatch work with other agents like Cursor or Pi?

Yes. Each agent, including Codex, OpenCode, Copilot, Cursor, and Pi, exports through the same OTLP endpoint. This ensures all your AI agent data is stored in one place with consistent treatment of tokens and costs.

What does the "Bundled" cost label mean in my dashboard?

If you are on a Claude subscription (such as Pro or Team), you don't pay per token. LangWatch uses the "Bundled" label to indicate these sessions and computes a theoretical cost based on standard API prices so you can gauge the value and volume of your usage.

Are cached tokens accurately counted?

Yes. LangWatch treats cache reads and cache writes as separate token classes. This is vital for Claude Code usage tracking because, in long sessions, cached tokens often represent the majority of the volume. Accurate tracking prevents your total cost calculations from being misleading.

What happens if I accidentally include a secret key in a session?

LangWatch prioritizes security. API secrets and PII (Personally Identifiable Information) are automatically redacted and are never stored on the LangWatch side. For enterprises requiring even tighter control, self-hosted setups and specific enterprise policies are available.

Is LangWatch free to use?

LangWatch is free for individual use, making it an accessible tool for independent developers looking to optimize their AI workflows. Teams and enterprises can explore further options for advanced governance and evaluation features.

Loading related products...