elixir-plug / plug_cowboy

Plug adapter for the Cowboy web server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to set the metrics_callback function from the config

mohamedalikhechine opened this issue · comments

According to the Cowboy documentation, a metrics_callback function can be passed to the options when starting a new Endpoint as follows:
https://ninenines.eu/docs/en/cowboy/2.4/manual/cowboy_http2/

config :my_app, MyApp.Endpoint,
  http: [port: 4000, 
         metrics_callback:  &metrics_callback/1,
         stream_handlers: [:cowboy_metrics_h, :cowboy_stream_h]]

but I get this error when I try to start it:

** (Mix) Could not start application free_license_server: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: MyApp.Endpoint
    ** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, MyApp.Endpoint.HTTP}
        ** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
            ** (EXIT) :badarg

One fix was to to add :metrics_callback to the list of protocol_options

@protocol_options [:compress, :stream_handlers, :metrics_callback]
in the Plug.Cowboy module.

I hope that this issue makes sense.

You can pass it under the :protocol_options here: https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html