DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Improving Java Application Reliability with Dynatrace AI Engine
  • Enabling Single-Sign-On in SaaS Application
  • Reimagining Innovation: How Citizen Application Development is Reshaping the Modern Enterprise

Trending

  • Designing API-First EMR Architectures in .NET: Enabling Modular Growth in Compliance-Driven Systems
  • From Indicators to Insights: Automating IOC Enrichment Using Python and Threat Feeds
  • DevOps and Platform Engineering Readiness Checklist: Everything Needed for a Scalable, Secure, High-Velocity Delivery Platform
  • How to Format Articles for DZone

Tips on Using the New Relic APM Thread Profiler

Get to know New Relic's APM Thread profiler, which helps determine where your code spends its time.

By 
Phil Weber user avatar
Phil Weber
·
Nov. 14, 16 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
5.4K Views

Join the DZone community and get the full member experience.

Join For Free

in order to add as little overhead as possible, new relic’s language agents are selective about the code they instrument. as a result, new relic may occasionally report that a particular transaction consumed a significant amount of time, but doesn’t provide details about exactly where the code spent its time. in such cases, new relic’s thread profiler feature may be helpful.

a sample scenario

let’s consider a scenario in which the thread profiler can help.

image title


in this scenario, you notice that your application is performing poorly. you look at the application’s overview dashboard and see that two transactions, /owners (get) and /vets (get) , are much slower than the rest. to help figure out why these transactions are so slow, you select a transaction trace in which /owners (get) took 7.5 seconds to complete.

image title


the transaction trace tells you that 92% of the time (almost 7 seconds) was spent in ownerslist.jsp . you want to know what the code could possibly be doing that would take so long, so you select the trace details tab.

image title


the trace detail shows the amount of time spent in each segment of the transaction, with the most time-consuming segments highlighted in yellow or red. you locate ownerslist.jsp and, sure enough, it’s colored red because it consumed more than 92% of the total time.

you drill down further, hoping to see what code ownerslist.jsp is calling, but you hit a dead end.

image title


all the transaction trace can tell you is that ownerslist.jsp executed some “application code.” not very helpful.

hovering your cursor over the question mark icon, you learn that new relic can’t provide more detail about this transaction because the code in question is not instrumented by the language agent. (for information about why this might happen, see the sections application code in traces and partial traces in the new relic documentation on transaction trace details .)

this sounds like a job for the thread profiler!

image title


while new relic’s language agents work by injecting instrumentation into your code, the thread profiler relies on sampling: it periodically takes a snapshot of your application’s call stack. this allows it to see even uninstrumented code that is invisible to the language agent.

to use the thread profiler, you select the application instance you wish to profile, the length of time the profiler should watch it, and click the start profiler button. when the thread profiling session is finished, you may view the results by selecting its time stamp or application instance name.

image title


hint: you can remove “noise” from the thread profile result by selecting filter outliers and clicking the refresh tree button. this hides methods that occur very infrequently, helping to focus your attention on the methods that are more likely to affect your application’s performance.

image title


the result page shows you how frequently each method appears in the collected call-stack samples.

remember, your goal here is to figure out what ownerslist.jsp is doing that’s taking so much time, so you expand the results tree and search for “ownerslist.” there it is!

the thread profile reveals that ownerslist.jsp is calling a component named com.github.dandelion.datatables , which is not instrumented by the new relic language agent.

now that you’ve found the culprit, you have a couple of options:

  1. you can debug the dandelion datatables component (or contact its author) to figure out why it’s performing poorly.
  2. you can implement custom instrumentation to tell the new relic language agent to instrument dandelion datatables from now on.

in this sample scenario, new relic’s thread profiler gave you x-ray vision into your code, allowing you to see inside a black-box transaction and figure out where the code was spending its time. that capability can come in handy in many real-world situations, too!

application

Published at DZone with permission of Phil Weber. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Improving Java Application Reliability with Dynatrace AI Engine
  • Enabling Single-Sign-On in SaaS Application
  • Reimagining Innovation: How Citizen Application Development is Reshaping the Modern Enterprise

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook