-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Telemetry via cowboy stream_handler #39
[WIP] Telemetry via cowboy stream_handler #39
Conversation
8e3e7b1
to
e2a012e
Compare
src/cowboy_telemetry_h.erl
Outdated
SystemTime = erlang:system_time(), | ||
StartTime = erlang:monotonic_time(), | ||
telemetry:execute( | ||
[cowboy, stream_handler, start], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stream_handler
is still a bit of an implementation detail, and it's not true that all stream handler events are emitted, so I'm thinking that [cowboy, request, start|stop|exception]
would be ideal...
682695e
to
a0ce0e0
Compare
This is absolutely beautiful. I have added just one comment, which is about either using |
2a3acf0
to
977d1d8
Compare
❤️ thanks! Updated to use I think a new package would be a good home for this - how should we go about getting that started? |
src/cowboy_telemetry_h.erl
Outdated
#{duration => EndTime - StartTime}, | ||
#{stream_id => StreamID, response => Response} | ||
); | ||
{'EXIT', _, Reason} when Reason /= normal -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason /= normal
means no exception nor stop events will be emitted. I am not sure that's the way we want to go. Another other ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually noticing that other handlers (like cowboy_metrics_h
) respond to the Commands
rather than the Info
.. And I've found that an error_response
tuple is part of the commands returned alongside an exit - it's shaped just like the response
tuple.
Commands
:
- request process completes:
[{response, _, _, _}]
- request process fails:
[{error_response, _, _, _}, _log_command, {internal_error, {EXIT, pid, reason}}]
Now I'm thinking of reworking this so that the exception
event is all based on Commands
. It seems better to respond based on the commands cowboy gives rather than trying to pre-parse the info.
I'll push up a change for that soon...
You have been invited to beam-telemetry so you can create the repo there. :) |
I think responding based on There's a nested Commands that start with The upside of this is that the |
Nice! We should probably get someone who actually understands Cowboy to review this too. :) |
OK! I got this ported into it's own repo! https://github.com/beam-telemetry/cowboy_telemetry I just setup a basic Github Action for test, but nothing relating to publishing this as a package on Hex yet. I'm sure there's more to do getting it setup for release, but I'm closing this issue in favor of moving discussion to it's own repo & Issues |
Once it gets published we can re-work this to reference the new package |
WIP. This PR demonstrates how we might leverage a cowboy
stream_handler
to provide instrumentation that isn't susceptible to the problems thatplug_adapter
instrumentation encounteredThis needs more work and an evaluation before consideration for merging