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. For Visual Studio, a New Relic icon is displayed in the editor gutter in lieu of a CodeLens. 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.
Coverage
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.
Run the following NRQL query to identify where you might see CodeLenses with code-level metrics for one of your services. Just replace the example entity.guid
value with the one for the given service. In the query results, look at the code.*
attributes to see if any of them represent your code, and not framework code.
SELECT * FROM SpanWHERE entity.guid = 'YOUR_ENTITY_GUID' AND code.function IS NOT NULLSINCE 30 minutes ago LIMIT MAX
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.
- 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. If your codebase include anonymous functions you'll need to either use change tracking to send deployment information to New Relic, or you'll need to send your build SHA via an environment variable in your build pipeline.
- PHP: Requires PHP agent version 10.6.0 or higher. If you're using VS Code, you must also have the PHP Intelephense extension installed.
- 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 the Ruby LSP extension installed.
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.