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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • DGS GraphQL and Spring Boot
  • Auto-Instrumentation in Azure Application Insights With AKS
  • Deploying a Scala Play Application to Heroku: A Step-by-Step Guide
  • Why Mocking Sucks

Trending

  • Building Enterprise-Ready Landing Zones: Beyond the Initial Setup
  • Mastering Fluent Bit: Installing and Configuring Fluent Bit on Kubernetes (Part 3)
  • Streamlining Event Data in Event-Driven Ansible
  • AI Meets Vector Databases: Redefining Data Retrieval in the Age of Intelligence

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.1K 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, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • DGS GraphQL and Spring Boot
  • Auto-Instrumentation in Azure Application Insights With AKS
  • Deploying a Scala Play Application to Heroku: A Step-by-Step Guide
  • Why Mocking Sucks

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!