> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Telemetry

> Monitor agent performance and usage

Telemetry tracks agent metrics for monitoring and optimization.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Telemetry"
        A[🤖 Agent] --> M[📊 Metrics]
        M --> T[⏱️ Timing]
        M --> U[📈 Usage]
        M --> C[💰 Costs]
    end
    
    classDef agent fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef metric fill:#10B981,stroke:#7C90A0,color:#fff
    
    class A agent
    class M,T,U,C metric
```

## Quick Start

<Steps>
  <Step title="Monitor Agent with Verbose Output">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::Agent;

    // Enable verbose output for telemetry
    let agent = Agent::new()
        .name("Assistant")
        .instructions("You are a helpful assistant")
        .verbose(true)  // Shows detailed output including timing
        .build()?;

    let response = agent.chat("Hello").await?;
    // Verbose mode shows token usage and timing information
    ```
  </Step>

  <Step title="Custom Metrics Tracking">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::Agent;
    use std::time::Instant;

    let agent = Agent::new()
        .name("Assistant")
        .build()?;

    // Wrap with your own telemetry
    let start = Instant::now();
    let response = agent.chat("Hello").await?;
    let latency = start.elapsed();

    // Send to your metrics system
    metrics::record_latency("agent_chat", latency);
    metrics::increment_counter("agent_requests");
    ```
  </Step>
</Steps>

***

## Metrics Available

| Metric              | Description            |
| ------------------- | ---------------------- |
| `total_tokens`      | Total tokens used      |
| `prompt_tokens`     | Input tokens           |
| `completion_tokens` | Output tokens          |
| `latency`           | Response time          |
| `tool_calls`        | Number of tool calls   |
| `api_calls`         | Number of LLM requests |

***

## Best Practices

<AccordionGroup>
  <Accordion title="Monitor in production">
    Track costs and latency to optimize performance.
  </Accordion>

  <Accordion title="Set up alerts">
    Alert on high token usage or slow responses.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Tracing" icon="chart-line" href="/docs/rust/tracing">
    Distributed tracing
  </Card>

  <Card title="Evaluation" icon="chart-bar" href="/docs/rust/evaluation">
    Quality metrics
  </Card>
</CardGroup>
