OpenTelemetry Metrics Integration
The NVIDIA NeMo Guardrails library follows OpenTelemetry best practices. The library uses only the API, and the host application configures the SDK. The following sections explain how to install and configure the OpenTelemetry SDK for metrics export from the NeMo Guardrails IORails engine.
Installation
Choose one of the following options for installing the library, the OpenTelemetry SDK, and an exporter.
-
For development with the OpenTelemetry SDK (console exporter only):
-
For production with the OpenTelemetry Protocol (OTLP) exporter:
-
For Prometheus scraping:
prometheus-clientis required because the example usesstart_http_serverto expose the scrape endpoint.
Enabling Metrics in the Configuration
Set metrics.enabled: true in your guardrails configuration.
This is independent of tracing.enabled.
When metrics.enabled is true and opentelemetry-api is installed, the IORails engine emits metrics through the active MeterProvider.
When opentelemetry-api is not installed, the IORails engine emits a UserWarning at construction time and runs without metrics.
Configuration Examples
Console Output (Development)
Use the console exporter to verify emissions locally before pointing at a real backend.
OTLP Exporter (Production)
Push metrics over OTLP/gRPC to an OpenTelemetry Collector or any backend that accepts OTLP.
Prometheus Exporter
Use the Prometheus exporter to expose metrics on an HTTP endpoint that Prometheus scrapes directly.
After Prometheus has scraped the endpoint, periods in OpenTelemetry metric names are replaced with underscores, for example guardrails.requests becomes guardrails_requests_total and gen_ai.client.token.usage becomes gen_ai_client_token_usage_bucket.
Refer to the Prometheus exposition format for details on how dots, units, and counter suffixes are translated.
OpenTelemetry Ecosystem Compatibility
You can export IORails metrics to any backend that accepts OpenTelemetry metric data, including:
- OTLP-compatible backends, such as New Relic, Datadog, Honeycomb, Grafana Cloud, AWS CloudWatch (with the ADOT collector), and Google Cloud Monitoring.
- Prometheus and any system that ingests Prometheus exposition format (Grafana Mimir, Cortex, Thanos, VictoriaMetrics).
- OpenTelemetry Collector as a fan-out point to receive metrics once and export them to many backends.
Refer to the OpenTelemetry Registry for the complete list.
Combining Metrics with Tracing
Configure each signal independently.
Metrics and traces correlate naturally when both are exported under the same service.name resource: trace exemplars on histograms link directly to their request spans.
For full tracing setup, refer to OpenTelemetry.