Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django explicit support #1088

Open
Chadys opened this issue Jan 27, 2025 · 2 comments
Open

Django explicit support #1088

Chadys opened this issue Jan 27, 2025 · 2 comments

Comments

@Chadys
Copy link

Chadys commented Jan 27, 2025

Hello, I was thinking it would be great to add explicit support for Django. Besides updating the documentation, it would be useful to provide a view so it can be added easily in the urlconf of a django app.

django-prometheus does it like this using generate_latest, but from looking at the already provided exposition endpoints, I was thinking of using the _bake_output utility instead.

I'm volunteering to make a PR for it.
What do you think?

@csmarchbanks
Copy link
Member

There could be opportunity for this similar to what is done for twisted. Specifically, only optional dependency on django code and in a separate directory.

That said, is there a problem you are encountering with django-prometheus? Perhaps we just link out to other projects to make it easier to discover how to use Prometheus with various frameworks? Starlette also comes to mind.

@Chadys
Copy link
Author

Chadys commented Jan 28, 2025

Yes I was thinking of following the same code architecture as the twisted support, to avoid any conflict.

To give you my context:

  • I am not using django-prometheus currently (so I have no problem with it ^^): django-prometheus gives you lots of already configured metrics out of the box and that's its main use, whereas I was only trying to add one specific custom metrics to my existing django-app so prometheus-client seemed more than enough
  • I found it hard to understand how to add a prometheus endpoint to my existing django app with no specific guidance in the prometheus-client documentation
  • Hence I ended up looking at how django-prometheus was doing it, and also how it was done for other web-frameworks here (like twisted)

django-prometheus is kinda huge and does a lot of things, so linking it as an example on how to integrate with prometheus-client is a bit involved I think. A simple view calling _bake_output and some dedicated documentation would be very appreciated of those coming from django I think :)
Maybe in time the provided view might even be used by django-prometheus directly instead of having to provide their own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants