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

Introduce option for behavior of Peep.Plug for paths that don't match the metrics path #19

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

rkallos
Copy link
Owner

@rkallos rkallos commented Nov 5, 2024

This leads to a confusing behavior when Peep.Plug is used as part of a larger Plug router.

It's worth noting that other Elixir libraries that export Prometheus metrics seem to start a separate HTTP listener on a separate port, supporting only the metrics endpoint. This is something Peep may want to encourage in the future, and the behavior of Peep.Plug before the changes in this PR seem to be a perfect fit for that sort of Plug module.

This option supports two values:

- `halt`: This preserves the current behavior of Peep responding with 404. This
  option is useful when Peep.Plug is used to serve metrics on its own port,
  which is an encouraged option by other libraries that export Prometheus metrics.

- `continue`: This allows for subsequent Plugs in a router to be executed. This
  option is useful when Peep.Plug is part of a router for a Phoenix application,
  or a router that matches other paths after Peep.Plug.
@rkallos rkallos changed the title Do not respond 404 on mismatched metrics path Introduce option for behavior of Peep.Plug for paths that don't match the metrics path Nov 5, 2024
@yordis
Copy link
Contributor

yordis commented Nov 10, 2024

This should be good enough

This is something Peep may want to encourage in the future,

Encourage what precisely? Use an entire endpoint just for the metrics?

@rkallos
Copy link
Owner Author

rkallos commented Nov 20, 2024

Encourage what precisely? Use an entire endpoint just for the metrics?

Exactly right. An example I see often when the metrics scraping agent runs on the same machine as a service; the metrics endpoint listens on a separate port that only listens on localhost.

@rkallos rkallos merged commit 9e8d094 into main Nov 20, 2024
1 check passed
@rkallos rkallos deleted the fix/plug branch November 20, 2024 20:43
@yordis
Copy link
Contributor

yordis commented Nov 26, 2024

Hey @rkallos are you intending to release this any time soon?

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

Successfully merging this pull request may close these issues.

2 participants