Skip to content

Add configurable Phoenix HTTP metric tags#284

Open
pepicrft wants to merge 1 commit intoakoutmos:masterfrom
pepicrft:codex/configurable-phoenix-http-tags
Open

Add configurable Phoenix HTTP metric tags#284
pepicrft wants to merge 1 commit intoakoutmos:masterfrom
pepicrft:codex/configurable-phoenix-http-tags

Conversation

@pepicrft
Copy link
Copy Markdown

@pepicrft pepicrft commented Apr 1, 2026

Summary

  • add an optional http_metrics_tags configuration to PromEx.Plugins.Phoenix
  • allow callers to replace exact status with grouped status_class
  • keep the default HTTP metric tag set unchanged for existing users
  • add focused unit coverage for reduced tag sets, status_class, and invalid tag validation

Why

The current Phoenix plugin always emits the full HTTP label set:

  • status
  • method
  • path
  • controller
  • action
  • host

That is a sensible default, but some deployments need to trade label richness for lower cardinality without copying the plugin downstream.

This change makes the HTTP tags configurable while preserving the current default behavior. It also adds status_class as an opt-in replacement for exact status, which is useful when users want to keep route-level visibility but reduce the series explosion caused by per-code status labels.

Example configuration:

{PromEx.Plugins.Phoenix,
 router: MyAppWeb.Router,
 endpoint: MyAppWeb.Endpoint,
 http_metrics_tags: [:status_class, :method, :path]}

Validation

  • mise exec elixir@1.18.2-otp-27 erlang@27.2.1 -- mix test test/prom_ex/plugins/phoenix_test.exs test/prom_ex/plugins/phoenix_multi_router_test.exs

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.

1 participant