1

I include cowboy_metrics_h into stream_handlers in my cowboy application.

How I can put data in user_data?
Where I should do it?

1 Answer 1

2

In documentation says:

The set_options command can be used to add additional metadata in the user_data metric. This can be used for example to add the handler module which was selected by the router. The option to be set is metrics_user_data. It takes a map which will be merged in the existing user_data map.

Example usage set_options:

set_options(<<"metrics_user_data">>, Req, State) ->
  cowboy_req:cast({set_options, #{metrics_user_data => #{handler => ?MODULE}}}, Req),
  {ok, cowboy_req:reply(200, #{}, <<"Hello world!">>, Req), State}.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.