CertSafari
    Anthropic Claude Certified Architect – Professional (CCAR-P)· Lessons

    Domain 4 · Lesson 25/38

    Organisation-wide monitoring: API traces, usage and cost reports, audit events

    Monitor system performance using logging and observability tools

    12 min read
    2.67% of exam
    9 sources
    Published 19 Oct 2026
    Docs as of 14 Oct 2026

    What you will be able to do

    • Add a Claude API OpenTelemetry destination and nest its spans under your application's traces
    • Read a Managed Agents session's usage and list cost
    • Query the Usage & Cost Admin API at a granularity and polling rate that fit the monitoring need
    • Name what the Claude Code analytics dashboard and compliance activities record, and route Claude Code log events to a SIEM

    1.Tracing Messages API requests and Managed Agents sessions

    Claude Code and the Agent SDK export OpenTelemetry metrics, log events and traces from the process that runs them. That covers one client at a time. Watching a whole organisation takes four further streams, each answering a different question: spans emitted by the Claude API itself, the usage and cost of individual Managed Agents sessions, organisation-wide usage and cost reports, and adoption and audit records. This page covers each in turn. A Managed Agents session is a run of an agent on the Claude Platform, with its own threads, tools and usage totals, which you can inspect in the Claude Console.

    Client-side telemetry stops at your process boundary. The Claude API can emit its own spans, one for each model request and each tool use it runs on Messages API requests and Managed Agents sessions, without any code change. You receive them by adding a destination: an OTLP/HTTP endpoint that accepts protobuf over HTTPS on port 443, plus the headers that authenticate to it. Only organisation admins can add or change destinations. A destination covers All workspaces, Selected ones, or All except a list. Its content mode is either Metadata only or Full content. That is the same opt-in idea as in Claude Code, which redacts prompt, response and tool content by default and records it only when you switch it on.

    Creating a metadata-only destination for every workspace through the Admin APIpython
    client = anthropic.Anthropic()
    
    destination = client.beta.organization.telemetry_destinations.create(
        endpoint_url="https://gateway.example.com/otlp",
        headers={"authorization": "Bearer YOUR_OBSERVABILITY_API_KEY"},
        traces={"content_mode": "metadata_only"},
        workspaces={"type": "all"},
    )
    
    print(destination.id)

    Leave /v1/traces off the endpoint URL, because the API appends it. After saving, run Test from the destination's menu and look for an anthropic.test span. Real spans arrive under service.name = claude-platform. If you run your own Collector, note that its OTLP/HTTP receiver listens on port 4318 by default. Either reconfigure it for HTTPS on 443 or put a reverse proxy in front.

    On their own, API spans start their own traces. To nest them under your application's spans, call the SDK from inside one of your own spans. The SDK writes a W3C traceparent header, and your sampler controls its sampled flag. When the flag is off, the API emits no spans for that request. The same propagation continues into MCP servers connected through the MCP connector, which receive a traceparent in params._meta and can attach their own spans.

    Delivery is at least once and best effort. Expect duplicate spans and deduplicate on trace ID plus span ID. A lost span is never resent. The Console's Delivery column shows Healthy, Failing, No data or Disabled. The API disables a destination that answers with a 3xx redirect, resolves to a non-public IP, or fails every delivery for 24 hours.

    Checkpoint 1 of 6· Fill the gap

    An admin is adding a destination so the Claude API sends spans to their observability platform's OTLP/HTTP gateway. Which endpoint URL goes in the blank?

    client = anthropic.Anthropic()
    
    destination = client.beta.organization.telemetry_destinations.create(
        endpoint_url=" ? ",
        headers={"authorization": "Bearer YOUR_OBSERVABILITY_API_KEY"},
        traces={"content_mode": "metadata_only"},
        workspaces={"type": "all"},
    )
    
    print(destination.id)

    Checkpoint 2 of 6· Check yourself

    An organisation has a destination covering all workspaces. Their application calls the SDK inside its own spans, and its sampler keeps only 10% of traces. What happens to the API spans for the other 90% of Messages API requests?

    Sources12

    2.Usage and cost of a Managed Agents session

    A single Managed Agents session reports its own consumption. The session object's usage field holds cumulative token counts, cache reads and writes, server tool requests, active_seconds and list_cost. A session can run several threads, for example one per agent in a multiagent session, and the Console's session viewer shows one timeline lane per thread, a transcript, and a Tools tab with failure counts and median duration. active_seconds is the time during which at least one thread was running, with overlapping threads counted once. The session's running-time cost is priced on that duration. Each thread also reports its own list_cost, but per-thread costs are rounded independently and leave out the running-time cost, so the session figure is the authoritative one.

    A session.usage event carries the same cumulative snapshot on the session stream, so you don't have to poll. It is emitted on idle transitions rather than on a timer: immediately before the session goes idle, and when a thread pauses at a session budget. During a long run you therefore see no new totals until one of those moments. That is why a spend cap built from watching usage and stopping the session yourself fails, since the stop arrives after the money is spent. A session budget is a dollar cap on list cost. The platform prices consumption continuously and pauses each thread before its next model request once the cap is reached, so enforcement doesn't depend on your code noticing in time.

    Checkpoint 3 of 6· Check yourself

    Your team runs long Managed Agents sessions and must make sure none of them goes past a fixed dollar amount at list price. Which approach should you build?

    Sources2

    3.Usage & Cost Admin API: organisation-wide trends

    The Usage & Cost Admin API answers organisation-wide questions: tokens by model, workspace, API key or service tier over time, and spend by day. You call it with an Admin API key. The response is a series of time buckets, and bucket_width sets their granularity. Each width has its own default and maximum limit, which is the number of buckets returned per request. The cost endpoint offers only daily buckets.

    bucket_width options for the messages usage report
    bucket_widthDefault limitMaximum limitFits
    1m60 buckets1440 bucketsIncident watch and minute-level spikes
    1h24 buckets168 bucketsA week at hourly resolution
    1d7 buckets31 bucketsMonthly trends and chargebacks

    bucket_width sets granularity, not refresh rate. Usage and cost data typically shows up within 5 minutes of a request completing. So for incident monitoring, use 1m buckets, raise limit past the default 60 when you need a longer window, and poll about once a minute. Short bursts of faster requests are fine for paging through results. For a dashboard that many people refresh, cache the responses instead of calling the API on every page load.

    Checkpoint 4 of 6· Check yourself

    Finance wants a report of last month's token use broken down by model and workspace across the whole organisation, with spend per day. Where should this data come from?

    Checkpoint 5 of 6· Exam question

    During an active incident, an on-call engineer needs a near real-time view of organization-wide token consumption spikes, checking for anomalies roughly once a minute. Which Usage API configuration fits this monitoring need within the documented granularity limits?

    Sources345

    4.Adoption analytics, audit events and SIEM routing

    Spend data shows what Claude Code costs. Adoption data shows whether people use it. The Claude Code analytics dashboard reports usage metrics: lines of code accepted, suggestion accept rate, and daily active users and sessions. Teams and Enterprise plans add contribution metrics from a GitHub integration, such as merged PRs that contain Claude Code lines, plus a leaderboard and CSV export. On API organisations the dashboard lives in the Claude Console and adds spend tracking and team insights.

    Administrative actions are a different stream again. The compliance activities endpoint lets you query actions such as workspaces being created or archived, members being added or removed, RBAC custom roles being created or assigned, spend limits being changed, and the zero data retention override being toggled. It also logs reads: viewing the Claude Code usage report or the messages usage report is itself an activity.

    Claude Code's per-user activity reaches a retention store such as a SIEM through the logs exporter. Managed settings are the policy settings an admin deploys and enforces across all Claude Code users, so they are the right place for this configuration. When managed settings set an endpoint or credential, Claude Code removes any per-signal endpoints a developer set, so a developer can't send logs to a different collector. Three switches matter here. CLAUDE_CODE_ENABLE_TELEMETRY=1 turns telemetry collection on, and nothing is exported without it. OTEL_LOGS_EXPORTER=otlp sends log events to an OTLP endpoint, where none would disable them. OTEL_LOG_TOOL_DETAILS=1 is an opt-in that is off by default: it makes tool events carry the Bash commands and MCP server and tool names that ran, where otherwise those arguments are not logged.

    Routing Claude Code log events, with tool details, to a SIEM's OTLP logs endpointjson
    {
      "env": {
        "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
        "OTEL_LOGS_EXPORTER": "otlp",
        "OTEL_LOG_TOOL_DETAILS": "1",
        "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL": "http/protobuf",
        "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT": "https://siem.example.com:4318/v1/logs",
        "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer your-siem-token"
      }
    }

    Checkpoint 6 of 6· Fill the gap

    Security wants its SIEM to keep a per-user record of the Bash commands and MCP tools each developer's Claude Code ran. Only log events are exported to the SIEM. Which variable belongs in the blank?

    {
      "env": {
        "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
        "OTEL_LOGS_EXPORTER": "otlp",
        " ? ": "1",
        "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL": "http/protobuf",
        "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT": "https://siem.example.com:4318/v1/logs",
        "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer your-siem-token"
      }
    }

    Sources6789

    Sources

    (9)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “the Claude API can emit a span for each model request and each tool use that it runs.”
      ↩︎ Tracing Messages API requests and Managed Agents sessions
      “If the sampled flag in the header is off, the API doesn't emit the request's span or the spans under it.”
      ↩︎ Tracing Messages API requests and Managed Agents sessions
      “At least once: A destination can receive the same span more than once.”
      ↩︎ Tracing Messages API requests and Managed Agents sessions
      “If the sampled flag in the header is off, the API doesn't emit the request's span or the spans under it.”
      ↩︎ Exam trap 2
    2. 2.
      “Use the session viewer in the Claude Console to inspect what an agent did in a session, without writing any code.”
      ↩︎ Tracing Messages API requests and Managed Agents sessions
      “The session's cumulative consumption priced at public list rates, as a whole number of cents in a string, with a currency code.”
      ↩︎ Usage and cost of a Managed Agents session
      “To enforce a spend limit, set a session budget rather than polling usage and stopping the session yourself.”
      ↩︎ Usage and cost of a Managed Agents session
      “The event is emitted on idle transitions rather than on a timer:”
      ↩︎ Usage and cost of a Managed Agents session
      “The session object includes a usage field with the session's cumulative usage: token counts, server tool use, active time, and the tracked list cost.”
      ↩︎ Checkpoint
    3. 4.
      “The API supports polling once per minute for sustained use.”
      ↩︎ Usage & Cost Admin API: organisation-wide trends
      “Usage and cost data typically appears within 5 minutes of API request completion”
      ↩︎ Exam trap 1
    4. 5.
      “1d (1 day): Only option available, max 31 buckets per request”
      ↩︎ Usage & Cost Admin API: organisation-wide trends
    5. 6.
      “Usage metrics: lines of code accepted, suggestion accept rate, daily active users and sessions”
      ↩︎ Adoption analytics, audit events and SIEM routing
    6. 8.
      “Developers can’t point one signal at a different collector”
      ↩︎ Adoption analytics, audit events and SIEM routing
      “Enables telemetry collection (required)”
      ↩︎ Adoption analytics, audit events and SIEM routing
    7. 9.
      “Deploy and enforce settings across all Claude Code users to match internal policies”
      ↩︎ Adoption analytics, audit events and SIEM routing

    Spotted a mistake, or was something unclear? Tell us.