> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc-studio-tools-doc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Latitude

> Integrate Agno with Latitude to send traces and gain insights into your agent's performance.

## Integrating Agno with Latitude

[Latitude](https://latitude.so) is an open-source observability and evaluation
platform for LLM applications. By instrumenting Agno with OpenInference and
exporting OpenTelemetry traces to Latitude, every agent run, tool call, and
model call becomes a span you can inspect, search, and evaluate — with token
usage, cost, latency, and full input/output captured automatically.

## Prerequisites

1. **Install Dependencies**

   Ensure you have the necessary packages installed:

   ```bash theme={null}
   uv pip install agno openai opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-agno
   ```

2. **Setup Latitude Account**

   * Sign up for an account at [Latitude](https://console.latitude.so/login) (or self-host).
   * Create a project and copy its slug.
   * Obtain an API key from the project's settings.

3. **Set Environment Variables**

   Configure your environment with the Latitude credentials:

   ```bash theme={null}
   export LATITUDE_API_KEY=<your-api-key>
   export LATITUDE_PROJECT=<your-project-slug>
   ```

## Sending Traces to Latitude

### Example: Using Latitude with OpenInference

This example demonstrates how to instrument your Agno agent with OpenInference
and send traces to Latitude's OpenTelemetry ingestion endpoint.

```python theme={null}
import os

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.yfinance import YFinanceTools
from openinference.instrumentation.agno import AgnoInstrumentor
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

# Point the OTLP exporter at Latitude's ingestion endpoint
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://ingest.latitude.so"
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = (
    f"Authorization=Bearer {os.getenv('LATITUDE_API_KEY')},"
    f"X-Latitude-Project={os.getenv('LATITUDE_PROJECT')}"
)

# Configure the tracer provider
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
trace_api.set_tracer_provider(tracer_provider=tracer_provider)

# Start instrumenting agno
AgnoInstrumentor().instrument()

# Create and configure the agent
agent = Agent(
    name="Stock Price Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[YFinanceTools()],
    instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
    debug_mode=True,
)

# Use the agent
agent.print_response("What is the current price of Tesla?")
```

After running the agent, open your project in the
[Latitude dashboard](https://console.latitude.so/login) to view the trace, with child
spans for each model and tool call.

<Frame caption="Agno traces in Latitude">
  <img src="https://mintcdn.com/phidatainc-studio-tools-doc/YKjk4lDceLWnD8SR/images/latitude-trace.png?fit=max&auto=format&n=YKjk4lDceLWnD8SR&q=85&s=cd05e40e5561872876c9ba5937a14424" alt="Latitude dashboard showing Agno traces and sessions with cost, token usage, duration, and tags" width="2322" height="1542" data-path="images/latitude-trace.png" />
</Frame>

## Notes

* **Environment Variables**: Ensure `LATITUDE_API_KEY` and `LATITUDE_PROJECT`
  are set, and that the project slug matches a project in the organization that
  owns the API key.
* **Endpoint**: The OTLP HTTP exporter appends `/v1/traces` to the base
  `OTEL_EXPORTER_OTLP_ENDPOINT`. If you self-host Latitude, point the endpoint
  at your own ingestion host instead of `https://ingest.latitude.so`.
* **Short-lived scripts**: When tracing one-off scripts, call
  `tracer_provider.shutdown()` (or use a `BatchSpanProcessor` and flush on
  exit) so the final batch of spans is exported before the process ends.

By following these steps, you can integrate Agno with Latitude, enabling
comprehensive observability and evaluation of your AI agents.
