Omit the django-prometheus middleware if METRICS_ENABLED is false #9610

Closed
opened 2025-12-29 21:19:43 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (May 7, 2024).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

NetBox supports the export of Prometheus metrics via django-prometheus if configured to do so. Metrics export is disabled by default, however the middleware is still active. This issue proposes enabling the middleware only when METRICS_ENABLED is true.

Justification

We may be able to optimize performance and shrink our bug surface a bit by disabling this middleware when metrics are not in use.

Originally created by @jeremystretch on GitHub (May 7, 2024). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes NetBox supports the export of Prometheus metrics via [django-prometheus](https://github.com/korfuri/django-prometheus) if [configured to do so](https://docs.netbox.dev/en/stable/configuration/miscellaneous/#metrics_enabled). Metrics export is disabled by default, however the middleware is still active. This issue proposes enabling the middleware only when `METRICS_ENABLED` is true. ### Justification We may be able to optimize performance and shrink our bug surface a bit by disabling this middleware when metrics are not in use.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 21:19:43 +01:00
adam closed this issue 2025-12-29 21:19:43 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9610