
Show HN: Get Rails performance metrics into Chrome Dev Tools - itsderek23
https://github.com/scoutapp/ruby_server_timing
======
umaar
Here's a gif I made showcasing Server Timing with Node.js + Chrome DevTools:
[https://umaar.com/dev-tips/136-server-timing/](https://umaar.com/dev-
tips/136-server-timing/)

------
andrewingram
I was excited when I first heard about Server Timing, until I realised it was
limited to a single duration value. Being able to model an actual timeline
would make it significantly more useful.

~~~
gingerlime
The screenshot shows a breakdown of timing by component (Middleware, router,
view, etc). Or perhaps I don't quite understand what you mean by "model an
actual timeline"?

As a side note, we've been using miniprofiler[0] for a long while now, and it
has some limitations, but can be very useful some times.

[0] [https://github.com/MiniProfiler/rack-mini-
profiler](https://github.com/MiniProfiler/rack-mini-profiler)

~~~
kaycebasques
I think I get what OP is saying. The screenshot [1] shows you the aggregate
time of each arbitrary component, but it's not mapped out along a time series,
like you see in the Network panel's Waterfall or in a Performance recording.

I'll see if there's anything we can do on our side (I'm the DevTools tech
writer), but I think it's an API limitation. We might be able to use some
arbitrary convention in the timing values that let's us plot along a time
series...

[1]
[https://camo.githubusercontent.com/bc62621acd195d11d0247c0cc...](https://camo.githubusercontent.com/bc62621acd195d11d0247c0cc8087f48604ba064/68747470733a2f2f73332d75732d776573742d312e616d617a6f6e6177732e636f6d2f73636f75742d626c6f672f727562795f7365727665725f74696d696e672e706e673f78)

~~~
itsderek23
> but I think it's an API limitation

Author here - I believe that's the case. There isn't a way to specific start &
end time: [https://w3c.github.io/server-timing/#dom-
performanceserverti...](https://w3c.github.io/server-timing/#dom-
performanceservertiming)

That said, the spec also mentions:

> To minimize the HTTP overhead the provided names and descriptions should be
> kept as short as possible - e.g. use abbreviations and omit optional values
> where possible.

I could see significant issues if we tried to send data in timeline fashion
(such as creating a metric for each database record call in an N+1 scenario).

One idea: pass down an URI (ie -
[https://scoutapp.com/r/ID](https://scoutapp.com/r/ID)) that when clicked,
provides full trace information.

------
mooreds
This gem seems like a good way to get a full app view while remaining in the
browser. The only thing I might add would be to have an example turning on
these metrics on a per request basis (via a parameter) so that you could check
performance for users other than admin users.

Aside: I've used scout on a production application and it is similar in
quality to new relic but far simpler to understand.

------
cagmz
Hi Derek! You've helped me with my employer's Scout configuration in Slack :)

Is there an automated way of getting the average of a performance metric (eg
Time spent in AR) over N requests?

~~~
itsderek23
> Hi Derek! You've helped me with my employer's Scout configuration in Slack
> :)

Small world!

> Is there an automated way of getting the average of a performance metric (eg
> Time spent in AR) over N requests?

I'm assuming you mean w/Chrome dev tools + server timing?

Not that I'm aware of...DevTools is an area I'd like to explore more though.

------
amatix
Seems to be using the `Server-Timing` header — are there docs somewhere on
what this expects & what features it supports? Are other browsers likely to
follow it?

~~~
mitchellh
This is the W3C spec for it: [https://www.w3.org/TR/server-
timing/](https://www.w3.org/TR/server-timing/)

------
thirdsun
There's also RailsPanel which I found quite useful when I was still using
Chrome:
[https://chrome.google.com/webstore/detail/railspanel/gjpfobp...](https://chrome.google.com/webstore/detail/railspanel/gjpfobpafnhjhbajcjgccbbdofdckggg)

------
jacobevelyn
Neat! Seems similar to this project which I've been keeping an eye on:
[https://github.com/geoffreylitt/ladybug](https://github.com/geoffreylitt/ladybug)

------
iampims
Similar library for go: [https://github.com/mitchellh/go-server-
timing](https://github.com/mitchellh/go-server-timing)

------
hultner
Neat!

Anyone know of a similar tool for Python3/flask (or wsgi probably)?

------
Thaxll
What's the point of using that vs proper tracing?

~~~
itsderek23
Author here.

The server timing metrics here are actually extracted from an APM tracing tool
(Scout).

Tracing services generally do not give immediate feedback on the timing
breakdown of a web request. At worst, the metrics are heavily aggregated. At
best, you'll need to wait a couple of minutes for a trace.

The Server Timing API (which is how this works) give immediate performance
information, shortening the feedback loop and allowing you to do a quick gut-
check on a slow request before jumping to your tracing tool.

