Monitorex.EventHandler
(monitorex v0.3.0)
Copy Markdown
Handles telemetry events from Tesla, Finch, and Phoenix, transforming them
into Monitorex.Event structs.
Each handler function follows the Telemetry handler callback signature:
(event_name, measurements, metadata, config).
Summary
Functions
Handles a Finch telemetry event ([:finch, :request, :stop]).
Handles a Phoenix telemetry event ([:phoenix, :router_dispatch, :stop]).
Handles a Tesla telemetry event ([:tesla, :request, :stop]).
Functions
@spec handle_finch_event( event_name :: [atom()], measurements :: map(), metadata :: map(), config :: keyword() ) :: Monitorex.Event.t() | nil
Handles a Finch telemetry event ([:finch, :request, :stop]).
Parses the metadata and measurements into a Monitorex.Event struct with
source :finch and direction :outbound.
Telemetry metadata shape
%{
url: %URI{} | String.t(),
method: :get | "GET" | …,
status: 200,
pid: pid,
monotonic_time: integer
}The url field may be a URI.t() struct or a string; both are handled.
The method field may be an atom or string; both are normalised.
@spec handle_phoenix_event( event_name :: [atom()], measurements :: map(), metadata :: map(), config :: keyword() ) :: Monitorex.Event.t() | nil
Handles a Phoenix telemetry event ([:phoenix, :router_dispatch, :stop]).
Parses the metadata and measurements into a Monitorex.Event struct with
source :phoenix and direction :inbound.
The consumer is extracted via ConsumerIdentifier.identify/1.
If the application config key :inbound_path_prefixes is set to a list of
path prefixes, only requests whose path starts with one of the prefixes
produce an event. Returns nil (i.e. the event is filtered) when no
prefix matches.
Telemetry metadata shape
%{
conn: %Plug.Conn{}
}
@spec handle_tesla_event( event_name :: [atom()], measurements :: map(), metadata :: map(), config :: keyword() ) :: Monitorex.Event.t() | nil
Handles a Tesla telemetry event ([:tesla, :request, :stop]).
Parses the metadata and measurements into a Monitorex.Event struct with
source :tesla and direction :outbound.
The URL is normalised via UrlNormalizer.normalize/1 and sensitive query
parameters are redacted via URLRedactor.redact/1.
Telemetry metadata shape
%{
url: %URI{},
method: :get | :post | …,
status: 200,
pid: pid,
monotonic_time: integer
}The dedup_key is set to {pid, monotonic_time} for deduplication.