elixir-plug / plug_cowboy

Plug adapter for the Cowboy web server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Telemetry event for `early_error`

binaryseed opened this issue · comments

There are a category of requests that cowboy itself will respond to before it invokes the Plug.Cowboy.Handler, and thus they aren't detectable by any telemetry instrumentation currently in plug or plug_cowboy...

The early_error cowboy callback is implemented, and a subset of requests are logged:

def early_error(_stream_id, reason, partial_req, resp, _opts) do
case reason do
{:connection_error, :limit_reached, specific_reason} ->
Logger.error("""
Cowboy returned 431 because it was unable to parse the request headers.

It would be nice to emit a telemetry event for these requests so that they aren't lost. They consume real resources, but are currently invisible to any monitoring solution based on the exiting Plug events.

Thoughts @josevalim?

What do you have in mind? A single event for early error?

Yes, we won’t get things like duration, but will be able to get minimal visibility into throughout with a single event.

Sounds good to me!

PR here: #34