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

Forward-friendly exporter plug #37

Open
chulkilee opened this issue Jan 17, 2020 · 2 comments
Open

Forward-friendly exporter plug #37

chulkilee opened this issue Jan 17, 2020 · 2 comments

Comments

@chulkilee
Copy link

chulkilee commented Jan 17, 2020

The current exporter plug is serving metrics on given path (/metrics by default), or passing the conn. This is for plug pipeline... and it doesn't work for phoenix router!

  # phoenix example
  # in endpoint

  plug My.PrometheusExporter.

This works... but it sounds strange. For example, to change the path, I need to set it at application config of the exporter module, not when using it.

One option is to add plug option :path.. but that is wrong approach, since plug can be composable!

Instead of we make this as "app" like plug having lots of configs... we can just have very simple exporter plug use forward mechanism. (Plug - forward/2 / Phoenix - forward/4).

  # phoenix example

  pipeline :default do
    plug :accepts, ["json"]
  end

  scope "/" do
    pipe_through :default
    forward "/metrics", My.PrometheusExporter
  end

In this case, path for metrics is configured at router, not on application config of the exporter module. Also the exporter plug runs only on that path (not for all requests as in pipeline)

@deadtrickster
Copy link
Owner

I like that! what needs to be done?

@svileng
Copy link

svileng commented Apr 27, 2020

Here's how the bamboo library does it, they have an EmailPreviewPlug plug that serves a page for viewing sent emails:

https://github.com/thoughtbot/bamboo/blob/master/lib/bamboo/plug/sent_email_viewer/email_preview_plug.ex

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

3 participants