Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Protectai Llm guard Observability Instrumentation

From Leeroopedia
Knowledge Sources
Domains Observability, DevOps, Monitoring
Last Updated 2026-02-14 12:00 GMT

Overview

An instrumentation pattern that integrates OpenTelemetry tracing and metrics into a FastAPI application to provide distributed tracing, latency monitoring, and scanner validity counters.

Description

Observability instrumentation adds three capabilities to the LLM Guard API:

  • Distributed tracing: Automatic span creation for each HTTP request via FastAPIInstrumentor, with support for OTLP HTTP, console, and AWS X-Ray exporters.
  • Metrics collection: Scanner validity counters tracking pass/fail rates per scanner, exportable via Prometheus, OTLP HTTP, or console.
  • Health endpoints: /healthz and /readyz endpoints excluded from tracing to avoid noise.

Usage

Use this principle when deploying LLM Guard in production environments that require monitoring. Configure via the tracing and metrics sections of the YAML configuration file.

Theoretical Basis

# Pseudocode for observability setup
resource = Resource(service_name=app_name, service_version=version)
configure_tracer(resource, tracing_config)    # TracerProvider + exporter
configure_metrics(resource, metrics_config)   # MeterProvider + exporter
instrument_fastapi(app, excluded_urls=["healthz", "readyz", "metrics"])

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment