How does New Relic work?
Asked Answered
W

7

24

How can New Relic tap into my app with a simple install? How does it know all the methods, requests, etc?

It works for RoR, PHP, etc.

Can anyone explain the technology behind it? I'm interested in tapping into my Rails app, but I want to do so smoothly like New Relic.

Thanks

Walkway answered 15/7, 2011 at 10:27 Comment(1)
It can't be javascript because you need to know detailed info about a controller, model, etc.Walkway
F
13

First up, you will not manage to duplicate the functionality of NewRelic on your own. Ignoring the server-side, the rpm Gem is a pretty complex piece of software, doing a lot of stuff. Have a look at the source if you want to see how it hooks into the Rails system. The source is a worth a read, as it does some cool stuff in terms of threading and marshaling of the data before sending it back to their servers.

If you want a replacement because Newrelic is expensive (and rightly so, it's awesome at what it does), then have a look at the FreeRelic project on Github.

Fugate answered 15/7, 2011 at 10:45 Comment(4)
No, I don't want a replacement. I want to do something different, with specific controllers only. I only need to replicate the information being retrieved but not for the same goal. ThanksWalkway
@donald: As the source is available, what hinders you to take the stuff you need to deal with your requirements?Language
@hakre: The license for the newrelic_rpm gem precludes you from "modification, distribution, or exploitation of these files".Lacerate
@rkb: Well, the fork button could be probably seen as a written statement that it's available for editing ;) - but jokes aside, as with any licensing, ask your lawyer or legal team / department.Language
D
2

They are using ASPECT ORIENTED PROGRAMMING CONCEPTS AND Reflection heavily for Intercepting original method call and adding instrumentation around that.

Diecious answered 29/4, 2014 at 21:14 Comment(0)
N
2

In a general way, New Relic's gem inserts kinda middleware in your web framework, and collects data from your endpoint (think as a rails route) until it's response. After every "harvesting time" (defaults to 60 seconds), it sends a post request to NR services with this data. You can also tailor data you need with Custom Metrics, Custom Events. Is also possible to do queries with NRQL and build graphs with that (like you would do in Graphana). They have a customize service for Wordpress too, but is a bit messy in the start. Some options if you want to save some money is configure cloudwatch + datadog, but I would give a shot to their service if uptime is crucial for your app.

Nilotic answered 15/1, 2019 at 23:9 Comment(0)
W
1

For a rails solution you could simply implement a more verbose logging level (development/debug level) and interrogate the production.log file for specific events, timings etc

Whitefish answered 23/7, 2011 at 3:41 Comment(0)
F
1

For Java they are attaching a Java agent to JVM which intercepts method calls and monitor them. You can use AspectJ to replicate the same behaviour and log every method call to wherever you want, let's say create custom Cloudwatch metrics.

Ferial answered 19/6, 2016 at 11:46 Comment(0)
E
0

In case of Java it's bytecode ingestion. They "hacking" the key methods of your application server and add their code in it. Then they send relevant transaction info to their server, aggregating it and you can see the summary. It's really complicated process so I don't think one dev can implement it.

Elysium answered 18/2, 2014 at 9:4 Comment(0)
M
0
  • If you’re already familiar with New Relic’s application monitoring then you probably know about New Relic’s agents that run in-process on web apps collecting and reporting all sorts of details about whats happening in the app. RUM leverages the agents to dynamically inject JavaScript into pages as they are built. The injected JavaScript collects timing information in the browser and contains details that identify the specific app and web transaction processed on the backend as well as how time was spent in the app for each request. When a page completes loading in an end user’s browser, the information is sent back to New Relic asynchronously – so it doesn’t effect page load time.

    You can turn RUM on/off via your application settings in New Relic. As well, you can turn RUM on/off via the agent’s configuration file (newrelic.yml – a ‘browser_monitoring auto_instrument’ flag has been introduced).

    The agents have been enhanced to automatically inject JavaScript into the HTML pages so using RUM is as simple as checking the checkbox on the New Relic control panel. However, if you’d prefer more control, you can use New Relic’s Agent API to generate the JavaScript and thus control exactly when and where the header and footer scripts are included.

Molini answered 28/3, 2019 at 9:7 Comment(1)
RUM is Real User Monitoring.Commuter

© 2022 - 2024 — McMap. All rights reserved.