home
diamond Go Premium
Data Engineering Path  ·  Data & AI

LLM Observability, Tracing, and Monitoring

+---------------------------------------------------------------------------------+
|                       DISTRIBUTED TRACE OF A RAG REQUEST                        |
+---------------------------------------------------------------------------------+
|  [User Request] --------------------------------------------------> (Total 1.4s) |
|     ├── [Vector Search: ChromaDB] -------> (120ms)                              |
|     ├── [Prompt Assembly & Guardrail] ---> (15ms)                               |
|     └── [LLM Call: GPT-4o] --------------> (1265ms, 482 Prompt, 85 Comp Tokens) |
+---------------------------------------------------------------------------------+

Why Standard APM Tools (Datadog, New Relic) Are Not Enough

Standard application monitoring only tracks CPU, memory, and HTTP status codes. It is completely blind to:

  • Prompt and response payloads.
  • Individual token generation latencies (Time to First Token vs. inter-token latency).
  • RAG retrieval relevance scores.
  • Model hallucination rates and safety guardrail triggers.

Integrating Open-Source Tracing with OpenTelemetry / Langfuse

import os
from langfuse.openai import OpenAI

# Langfuse automatically intercepts and traces OpenAI calls with zero boilerplate
client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),
    # Reads LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST from env
)

def query_rag_assistant(user_id: str, prompt: str):
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": prompt}],
        metadata={"user_id": user_id, "environment": "production"},
        tags=["rag", "data_engineering"]
    )
    return response.choices[0].message.content

Golden Metrics for LLMOps

  1. TTFT (Time To First Token): Latency before the first token reaches the user. Target: $< 800 ext{ms}$.
  2. Token Generation Speed: Output tokens per second. Target: $> 30 ext{ tokens/sec}$.
  3. Cache Hit Rate: Percentage of queries answered by semantic cache without model inference. Target: $> 35\%$.
  4. Cost Per 1,000 Inferences: Continuous financial tracking of API spend.
Find this content helpful? ☕ Buy me a coffee

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.