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

Extract plug #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Extract plug #30

wants to merge 1 commit into from

Conversation

chulkilee
Copy link

Instead of running separate cowboy process, I'd like to plug prometheus exporter plug directly to existing endpoint (e.g. to keep everything in one port...)

I could do that with this in Phoenix router.

  get "/metrics", TelemetryMetricsPrometheus.Router, [name: :prometheus_metrics]

However, I need to call example.com/metrics/metrics - since the router has metrics path init.

This PR is to extract minimal plug (e.g. not covering other routes, etc.), so that it can be added freely.

Also it adds @moduledoc to make it public.

@bryannaegele
Copy link
Collaborator

Hey @chulkilee.

This needs a lot more documentation, especially around how and when you'd use one method over another and examples of how this would be used in Phoenix. 😉

The purpose of this library was to provide an out-of-the-box ability to expose prometheus metrics on a different port which requires a separately running server. If a user doesn't want those features then this probably isn't the right package to download since it includes plug_cowbyoy. Instead, users should probably be guided to simply copy and paste the plug to their own codebase and only include the core prometheus dependency and follow setup instructions there.

@chulkilee
Copy link
Author

chulkilee commented Oct 1, 2020

Thanks a lot for the feedback!

You're absolutely correct that it needs more documentation. Before working more on that I'd like to make sure it's the right direction 😉

I agree that this is very simple plug - but it would require copy and paste for any users not wanting to run the separate port) and that's what this PR to solve. For example, Plug itself has many commonly needed but simple plugs such as Plug.BasicAuth for convenience.

Also this lib is anyway not auto-starting global app anyway - if we really want to make it out-of-box, we may just make it otp app starting by itself with global config (like logger) - but it's kind of middle of app and library since it requires adding it to supervisor manually.

The main question here is whether we require running separate process with separate port to use this package. I believe that should be an option, not only option. Probably it would be better to make plug as dependency, and plug_cowboy as optional dep, and raise error when it's needed but not added.

Base automatically changed from master to main February 7, 2021 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants