Skip to content

Commit

Permalink
feat: emit an event when a page is rendered thru Steam (great for sta…
Browse files Browse the repository at this point in the history
…ts for instance)
  • Loading branch information
did committed Nov 15, 2024
1 parent ba10b57 commit 08b029b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/locomotive/steam/middlewares/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ def call(env)
app.call(env).tap do |response|
done_in_ms = ((Time.now - now) * 10000).truncate / 10.0
log "Completed #{code_to_human(response.first)} in #{done_in_ms}ms\n\n".green

ActiveSupport::Notifications.instrument('steam.http.render', {
site_id: env['steam.site']&._id,
domain: env['SERVER_NAME'],
path: env['PATH_INFO'],
status: response.first,
time_in_ms: done_in_ms
})
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
require_relative '../lib/locomotive/steam'
require_relative 'support'

ActiveSupport.to_time_preserves_timezone = true

Locomotive::Steam.configure do |config|
config.mode = :test
end
Expand Down

0 comments on commit 08b029b

Please sign in to comment.