New Relic: "Application Code (in /theme)" I have several Drupal sites with which I'm using New Relic to help monitor and debug performance issues. 

I've been finding that when viewing the "Web Transactions" section under "Monitoring", that a large percentage of time is spent in "/theme". When I click in to view a trace, then view the Trace details, I often find that the majority of the time is listed in a rows named "Application Code (in /theme)". 

The help link beside "Application Code (in /theme)" takes me to New Relic's PHP Custom Metrics Collection page. The documentation is clear enough, but what I don't understand is how to make this useful in Drupal. I'm guessing this is difficult for me because of Drupal's hook system, and (again guessing) that the "Application Code" that New Relic is referring to in this case are calls to theme() functions.

Is there something that I can do to get more useful information out of New Relic? First thing that comes to mind is "killing a kitten" and hacking core's theme() function to insert a New Relic Custom Metric, but I'd prefer not to do that (nor do I know for certain it will help!).
New Relic offers Drupal monitoring as part of their paid Standard plan to collect metrics for Modules, Hooks, and Views.  


  The collection of Drupal-specific metrics can be
  controlled by the ini setting newrelic.framework.drupal.modules. It is
  enabled by default (in versions 3.0 and higher), and can be disabled
  with:
  
  newrelic.framework.drupal.modules = 0 Though this setting uses the
  word "modules", it controls the collection of all Drupal metrics:
  modules, views, and hooks.
  
  The PHP agent collects metrics for the following:
  
  Modules: Versions 2.5+. These metrics indicate time spent within each
  Drupal module. In versions 3.5+, time is calculated from the hook
  dispatch functions module_invoke and module_invoke_all. In previous
  versions, time was calculated from functions from a file with the
  ".module" extension where the file name and function prefix were a
  match. 
  Hooks: Versions 3.5+. These metrics indicate time spent within
  each Drupal hook. Time is calculated from the hook dispatch functions
  module_invoke and module_invoke_all. 
  Views: Versions 3.5+. These
  metrics indicate time spent within a view's view::execute method.


You are correct that New Relic: “Application Code (in /theme)” refers to the execution of the theme() function.  Given the throughput you referenced, this seems to be a minor issue, though there is definitely room for optimization if you're seeing ~7000ms response time.  I typically see around 400-500ms with similar throughput.