#22642·netbox

Add native OpenTelemetry instrumentation with OTLP export to a collector

Author: emersonfelipespCreated Jul 8, 2026Updated Sep 30, 2026
Labelstype: featurestatus: under reviewnetbox

NetBox version

v4.6.4

Feature type

Data model extension

Proposed functionality

Add optional, native OpenTelemetry (OTel) instrumentation to NetBox, allowing operators to export traces, metrics, and (optionally) logs via OTLP to an OpenTelemetry Collector endpoint.

Use case

NetBox increasingly sits at the center of network automation stacks: external tooling (Ansible, Nornir, Terraform, custom pipelines, plugins) drives it through the REST and GraphQL APIs, and NetBox itself fans out to PostgreSQL, Redis, RQ background workers, and outbound webhooks. Today, operators have no way to trace a request across those boundaries.

The existing observability options are:

  • METRICS_ENABLED (django-prometheus) exposes aggregate metrics only — no per-request tracing, no context propagation.
  • Sentry integration is error-reporting focused and vendor-specific (and its legacy config parameters are already deprecated as of v4.6, per netbox-community/netbox#21881).

Native OpenTelemetry support addresses several concrete needs:

  1. End-to-end distributed tracing. An automation pipeline that calls the NetBox API could see its traceparent propagated into NetBox's Django spans, down to individual PostgreSQL queries and Redis calls, and out through webhook HTTP requests to receivers — one correlated trace across the whole stack.
  2. Performance troubleshooting. Slow API responses on large deployments (bulk operations, heavy GraphQL queries, permission-constrained querysets) become diagnosable with span-level timing instead of guesswork from aggregate Prometheus histograms.
  3. Vendor neutrality. OTLP export to a collector lets operators fan telemetry out to whatever backend they already run (Grafana Tempo/Jaeger/Datadog/Elastic/etc.) without NetBox adopting any vendor SDK — a natural successor to the deprecated vendor-specific Sentry parameters.
  4. Background job visibility. RQ workers processing event rules, webhooks, custom scripts, and sync jobs are currently a blind spot; instrumenting the worker entry points makes async work observable and correlatable with the originating change.

The feature is strictly opt-in (OTEL_ENABLED = False by default), following the same pattern as the existing METRICS_ENABLED and SENTRY_ENABLED parameters, so deployments that don't opt in see zero overhead and zero new imports.

Database changes

None. This feature is purely operational instrumentation configured via configuration.py / standard OTEL_* environment variables. No new models, fields, or migrations are required, and no telemetry data is persisted by NetBox itself — all export is handled in-process by the OpenTelemetry SDK's batch processors sending to an external collector.

External dependencies

All new dependencies would be optional, following the exact pattern already used for Sentry: sentry-sdk is not listed in requirements.txt and settings.py conditionally imports it only when SENTRY_ENABLED is true, raising ImproperlyConfigured if the package is missing. OpenTelemetry support would do the same behind OTEL_ENABLED — installed by operators via local_requirements.txt (documented), not added to core requirements.

Proposed optional packages (all Apache-2.0, maintained under the CNCF open-telemetry org):

  • opentelemetry-sdk — core SDK (TracerProvider, Resource, BatchSpanProcessor)
  • opentelemetry-exporter-otlp — OTLP export over gRPC or HTTP/protobuf
  • opentelemetry-instrumentation-django — request/response spans for the WSGI/ASGI app
  • opentelemetry-instrumentation-psycopg — matches NetBox's psycopg[c,pool] (psycopg 3) driver
  • opentelemetry-instrumentation-redis — covers cache, RQ queue transport, and django-redis usage
  • opentelemetry-instrumentation-requests — outbound webhook/HTTP span injection and context propagation

Notes:

  • The OTel Collector itself is external infrastructure provided by the operator; NetBox only needs an OTLP endpoint.
  • There is no official contrib instrumentation for RQ, so worker-side tracing would use a small amount of manual instrumentation around the job execution path (initialized from the rqworker startup), with the Redis instrumentation covering the transport layer.
  • Version pinning would follow the OTel Python SDK's stable (1.x) release line; instrumentation packages are versioned in lockstep and support the Django/psycopg/redis versions NetBox currently pins.