Monitorex.ConsumerIdentifier (monitorex v0.3.0)

Copy Markdown

Extracts a consumer label from an inbound Plug.Conn for per-consumer dashboard breakdowns.

Priority order

  1. Custom functionconsumer_fn in Application config (arity 1, receives conn)
  2. Basic-auth username — decoded from authorization header, password discarded
  3. API key header — value of x-api-key truncated to 8 characters
  4. nil — unknown / anonymous consumer

Summary

Functions

Identifies the consumer from a Plug.Conn.

Functions

identify(conn)

@spec identify(conn :: Plug.Conn.t()) :: String.t() | nil

Identifies the consumer from a Plug.Conn.

Returns nil when no consumer can be determined.