CodeStream not only gives you a big-picture view of how the services built from your code are performing, but also provides insight into how the code itself is performing.
Anomaly detection
CodeStream automatically flags performance problems in your code, allowing you to proactively address performance issues as they arise.
CodeStream identifies performance issues by starting with transactions and looking for anomalies in either error rate or average duration. If you’re using New Relic’s change tracking to send deployment information, anomalies are calculated by comparing the performance since your last release against the preceding three weeks. Otherwise, we use the last seven days. For any transactions identified as having performance issues, CodeStream then drills down into the segments (e.g., database queries, external calls, individual methods, etc.) that make up the transaction to see if any of them are performing poorly. This allows you to hone in on the source of the problem.
CodeStream also lets you know about performance issues via desktop notifications in either VS Code or JetBrains IDEs.
In-editor performance data
Without having to seek it out, performance data is displayed contextually in the editor so that it can inform the work at hand. Say you’re working on a bug fix, and happen to notice that the area of the code you’re working in has an elevated error rate. Maybe you address that issue as part of your bug fix so that it doesn’t escalate into a bigger problem.
CodeStream shows the average duration and error rate, for the last 30 minutes, in a CodeLens above each method instrumented by the New Relic APM agents. Metrics are calculated for the service currently selected in the CodeStream pane. Expand a different service and the metrics update accordingly.
Click the CodeLens to see charts visualizing each of the metrics. If the repository is associated with multiple New Relic-monitored services, you can easily switch between them. This changes the service upon which the code-level metrics displayed in both the charts and the editor are based, and also change the service selection in the CodeStream pane.
Along with a chart of the error rate you’ll also see a list of the actual errors happening in the same timeframe, including the number of occurrences for each. If the error rate is spiking, and you see one particular error is causing the problem, you can click on it to view the stack trace and start collaborating on resolution.
Requirements
To see in-editor performance data, your service must meet the requirements listed below, and the service should have collected data in the last 30 minutes. The New Relic agent attempts to automatically collect data for functions on classes that are tied to HTTP requests. In many cases, and with many frameworks that use an MVC framework, these are often methods on a Controller class.
Because all requests by the New Relic agent are not collected all the time, it’s possible that low-traffic methods won't see any data. If data is missing for a specific method that you wish to see results for, you can use custom instrumentation to fill any gaps. See guidance for Java, .NET, PHP, Python, Ruby, Go and Node.js.
- Distributed tracing must be enabled. Distributed tracing is on by default in recent versions of all agents, so you only need to worry about this if you've disabled distributed tracing.
- Go: Requires Go agent version 3.24.0 or higher. If you're using VS Code, you must also have the Go for VS Code extension installed with the language server enabled.
- Java: Requires Java agent version 7.11.0 or higher. Code-level metrics are only available for projects implemented with a supported Java framework. If you're using VS Code, you must also have the Language Support for Java by Red Hat extension installed. Note that Kotlin support is only available in IntelliJ.
- .NET: Requires .NET agent version 10.2.0 or higher. If you're using Visual Studio, make sure that you have CodeLenses enabled in by going to Tools > Options > Text Editor > All Languages > CodeLens and making sure that both "Enable CodeLens" and "Show CodeStream Code-Level Metrics" are checked. If you're using VS Code, you must have the C# extension installed.
- Node.js: Requires Node.js agent version 10.5.0 or higher.
- PHP: Requires PHP agent version 10.6.0 or higher.
- Python: Requires Python agent version 7.10.0.175 or higher. Code-level metrics are only available for projects implemented with a supported Python framework and for PHP version 7.0 or higher. If you're using VS Code, you must also have the Python extension installed with the language server enabled.
- Ruby: Requires Ruby agent version 8.10.0 or higher. Code-level metrics are only available for Rails applications and Ruby methods with manual traces (learn more about Ruby methods and CodeStream). If you're using VS Code, you must also have either the Ruby or Ruby Solargraph extension installed with the language server enabled.
You can turn CodeLenses off by going to the CodeStream section of your IDE's settings and unchecking the CodeStream: Show Golden Signals In Editor setting.