Skip to content

Commit 77ab7ba

Browse files
committed
added rendering results for ssr duration
1 parent 1d8f8a1 commit 77ab7ba

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app/helpers/vue_ssr_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def render_single(component_name, data_hash)
1313
}
1414

1515
response = ::HTTParty.post(ssr_server_url, body: body.to_json, headers: {"Content-Type" => 'application/json'})
16+
duration = response.parsed_response.dig("results","content","duration")
17+
::Rails.logger.info "SSR render took duration #{duration}ms"
1618

1719
return ::JSON.parse(response.body).dig("results","content","html")
1820
end
@@ -32,6 +34,15 @@ def render_many(component_name, payloads=[])
3234

3335
response = ::HTTParty.post(ssr_server_url, body: body_h.to_json, headers: {"Content-Type" => 'application/json'})
3436

37+
durations = response.parsed_response["results"].values.map{|res| res["duration"] }
38+
duration_sum = durations.sum
39+
40+
durations.each do |duration|
41+
::Rails.logger.info "SSR render took duration #{duration}ms"
42+
end
43+
44+
::Rails.logger.info "Total: SSR render took duration #{duration_sum}ms"
45+
3546
return ::JSON.parse(response.body)["results"].map{|k,v| v["html"]}
3647
end
3748

0 commit comments

Comments
 (0)