Metrics for progressive rendering

george's Avatar

george

19 May, 2010 09:59 PM via web

Hi,

I have a Rails plugin which enables progressive rendering for Rails.

As one might expect, it needs to move all the view rendering out of the action, and into the call to response.body.each. However, NewRelic won't include this time in transaction traces, average response times, apdex metrics, etc. This is a big problem for us, as much of the time is spent in our views.

I was wondering if you could offer any ideas on how to best solve this. Are custom metrics powerful enough?

If so, how do I:

  • associate a custom metric with a controller/action?
  • ensure view rendering times get incorporated into response times and apdex?

If not, any suggestions on how best to hook into and/or patch the agent? I'm open to any degree of unholy hacks if that's what it takes.

Thanks,
George.

  1. Support Staff 2 Posted by Justin George on 19 May, 2010 10:36 PM

    Justin George's Avatar

    Hi George,

    I'm taking a look at your plugin now, we may be able to do something for you.

    It'll probably take the shape of some custom instrumentation for you to include in your plugin, and enable conditionally on New Relic's enable / disabled / missing status.

    J

  2. Support Staff 3 Posted by Justin George on 19 May, 2010 10:44 PM

    Justin George's Avatar

    So looking through it all, I would say there's not a whole lot we could do. We don't really know which request it is at that point, and the instrumentation for our rack stuff would also have returned at that point, otherwise I'd tell you to use that.

    We can capture it globally, but that's not particularly helpful for your case, I think.

    Any thoughts?

    Justin

  3. 4 Posted by george on 20 May, 2010 12:07 AM

    george's Avatar

    Hi Justin,

    Thanks for the fast response!

    We certainly do need to capture it per-action. We can pass information from #call to #each by storing the environment hash in a middleware and stashing info in there.

    I guess we'll need a way to accumulate the times collected during #call and #each. Any tips on doing this? In particular appending a second call trace to TransactionSample looks a little troublesome. If you have any info on the data structure that gets sent between the agent and NewRelic, particularly what it must conform to, that would be extremely helpful.

    Many thanks,
    George

  4. Support Staff 5 Posted by Justin George on 20 May, 2010 12:24 AM

    Justin George's Avatar

    Hi George,

    I'm pretty sure that with our current agent architecture, it's not gonna be doable easily. Once a transaction is closed, it's pretty fixed. You can reopen it and play with the numbers, but it's at your own risk, so to speak. I would just store a reference to the transaction and increment it's total time, and add a new segment to it that includes the time in the rendering block.

    Take a look at the template rendering instrumentation in lib/new_relic/agent/instrumentation/ - most of that stuff will give you an idea, but you're going to have to dive pretty deep to get it to work. I'll be glad to help you if you have any questions.

    J

  5. 6 Posted by george on 21 May, 2010 03:30 AM

    george's Avatar

    Thanks Justin.

    I'll probably have a go at this on the weekend. Would there be any interest in merging any such functionality into the gem?

    George

  6. Support Staff 7 Posted by Justin George on 24 May, 2010 06:06 PM

    Justin George's Avatar

    Hi again George,

    We have a gem rpm_contrib that would be perfect to merge your instrumentation into.

    Or, if you prefer to keep it self contained, I can work with you on how to make an addition to your plugin that loads if-and-only-if RPM is installed.

    Either way is good for us

    Thanks,

    Justin

  7. 8 Posted by george on 24 May, 2010 06:12 PM

    george's Avatar

    Excellent, thanks Justin!

    Unfortunately I haven't got around to doing much on this yet as I've been sick for most of the last week. Will keep you posted.

    George

  8. Bill Kayser resolved this discussion on 25 May, 2010 10:56 PM.

Comments are currently closed for this discussion. You can start a new one.