Skip to content
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

Implement elapsed_text display for request/response #48

Closed
wants to merge 1 commit into from
Closed

Implement elapsed_text display for request/response #48

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 10, 2021

Adds the elapsed_text field to the breeze_response model.

Should address the feature request in #33.

@ghost ghost marked this pull request as ready for review July 10, 2021 20:01
@@ -27,6 +27,7 @@ class Breeze::Requests::ShowPage < Breeze::BreezeLayout
mount Breeze::DescriptionListRow, "Action", req.action
req.breeze_response.try do |resp|
mount Breeze::DescriptionListRow, "Response Status", "#{resp.status} #{Wordsmith::Inflector.humanize(HTTP::Status.from_value?(resp.status))}"
mount Breeze::DescriptionListRow, "Response Elapsed Time", resp.elapsed_text
Copy link
Author

@ghost ghost Jul 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any test where I could check if this display is correct / present

@@ -65,18 +65,21 @@ module Breeze::ActionHelpers
)
Lucky::Log.dexter.debug { {debug_at: Breeze::Requests::Show.url(req.id)} }
Fiber.current.breeze_request = req
Fiber.current.breeze_request_start = Time.monotonic
Copy link
Author

@ghost ghost Jul 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured this was easier than storing the start in the db.

@matthewmcgarvey matthewmcgarvey linked an issue Jul 10, 2021 that may be closed by this pull request
@jwoertink
Copy link
Member

Hey @Liberatys thanks for contributing to this! So, there's a few things we need to think out first before considering this. The first thing is how migrations are added in afterwards. (See #47). The next thing is that the current action timing actually happens in the LogHandler https://github.com/luckyframework/lucky/blob/56396b4055b9050ce7815f94b71129e9a5773e5c/src/lucky/log_handler.cr#L27-L29 which tracks the entire middleware stack https://github.com/luckyframework/lucky_cli/blob/master/src/web_app_skeleton/src/app_server.cr.ecr#L8

I didn't do a great job of explaining what needed to be done, so sorry for that. Looking at your PR, I think it might be ok, but I'd like to consider if there's anything we may have to add in to Lucky itself in order to track this timing better. I will do some digging and then come back with some notes on the PR and we can go from there.

Thanks!

@jwoertink
Copy link
Member

Just letting you know I haven't forgotten about this. Just had to wrap up some other stuff. That first issue I mentioned about the migrations is moot...

Ok, so for storing the timing, we're going to have to hook in to Lucky for this. I think it might be a hybrid solution of what you have here with the database storage, and hooking in to the LogHandler. My guess is we can use Pulsar to publish the duration, and then have Breeze subscribe to that event and store it in the DB, then it's just a matter of displaying that. I also want to try and setup some sort of benchmark to test that adding the pulsar in to the loghandler doesn't affect application performance any. I'll probably work on that part, then come back to this and we can update to use that new stuff.

@jwoertink
Copy link
Member

Ok, this took longer than I wanted, but this PR is now possible to do. It'll require a bit of rework though. luckyframework/lucky#1601

Basically, this just needs to subscribe to Lucky::Events::RequestCompleteEvent and receive the duration. That will give us the accurate time that was spent on the request.

@ghost ghost closed this by deleting the head repository Nov 27, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show timing on requests
1 participant