New Relic CodeStream allows developers to see how the code they're responsible for is performing in production by bringing observability into the IDE and making it part of their daily routine.
To bring observability into your IDE, connect CodeStream to New Relic with a user key.
Once you have your user API key, click Connect to New Relic in the Observability section of CodeStream, then paste your user API key and click Connect to New Relic. If you signed up for CodeStream using your New Relic user API key then you'll already be connected.
To use the observability features in CodeStream, note that you must have a New Relic user type of core user or full platform user.
The telemetry data available in CodeStream is contextual, meaning that it's all related to the code you have open in your IDE. To do this, CodeStream needs to know what entities in New Relic are built by the repositories you have open, and there are a number of ways to make these associations.
There are instances where CodeStream will prompt you to make an association if one doesn't exist. For example, if you try to view an error from New Relic in CodeStream, and the entity the error belongs to isn't associated with a repository, CodeStream will ask you to identify the appropriate repository. The Observability section of the the CodeStream pane will also prompt you to make an association for the currently selected repository in your IDE.
In some cases your repository may need to be associated with multiple entities. For example, you might have different entities that represent different environments (like production, or staging) and they may all be associated with the same repository. To associate the current repository with an additional entity, click on Add another service.
Making these associations on the fly when prompted is a great way to get started, but we recommend one of the following methods because they require less ongoing manual effort and eliminate the possibility of end-user mistakes, such as misconfigured remote URLs.
With any of these methods you can specify the remote URL in either the SSH or HTTPS format:
It's possible to add the same GitHub repository more than once, if you're using different protocols to do so. The UI warns you about this, but won't prevent you from doing so.
firstname.lastname@example.org:tuna/repo are the same repo, with different protocols.
The Observability section of CodeStream gives developers a view into how their code is performing by allowing them to see golden metrics and errors for each service associated with the repository currently selected in the IDE. Each service has its own node in the tree, and when expanded it shows the service's golden metrics, service level objectives, errors assigned to you, and the five most recent errors. You can also see the bigger picture by digging into the services that are called by or call your service, and see the golden metrics for each of them.
If the currently selected repository isn't associated with a service on New Relic you'll be prompted to make the association, or instrument the project.
When hovering over a service name in the tree, click on the broadcast icon to see code-level metrics in the editor for that service or click on the globe to open the service's summary page on New Relic. Click on any error to view the details, inclding the stack trace, and start collaborating on resolution.
If your project isn't monitored by New Relic, you can set up monitoring by clicking on the gear icon in the heading of the Observability section and then selecting Instrument my App. CodeStream has setup wizards available for Node.js JS, Java, and .NET projects.
Code-level metrics give you detailed insight into how your code is performing at the method level. For each method automatically instrumented by the New Relic APM agents you'll see golden signals displayed via a line of text inserted above each method. This line of text is called a CodeLens. Response time, throughput, and error rate are shown for the last 30 minutes.
To see metrics, 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 trafficked methods will not see any data. If data is missing for a specific method that you wish to see results for, custom instrumentation can be used to fill any gaps. See guidance for Java, .NET, PHP, Python, Ruby, Go and Node.js. Also note that for Node.js, code-level metrics are not captured for anonymous functions.
Your code reviews can now also be more data driven by leveraging golden metrics during the review process. Code-level metrics are displayed in the diffs for both pull requests and feedback requests, allowing you to make sure that performance issues get addressed as part of the changes.
Click the CodeLens to see charts visualizing each of the golden metrics. If the repository is associated with multiple New Relic-monitored entities, you can easily switch between them. This will change the entity upon which the code-level metrics displayed in the editor are based.
Click the entity name at the top of the charts to see more detailed service-level data on New Relic.
You can also change the entity for which you'd like to see code-level metrics via the Observability section. Hover over the name of a service and click on the broadcast icon to see code-level metrics for that service.
- 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're disabled distributed tracing.
- Java: Requires Java agent version 7.10.0 or higher. For version 7.11.0 or higher, code-level metrics are enabled by default. For version 7.10.0, code-level metrics must be manually enabled in the Java agent configuration. 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 9.9.0 or higher. For version 10.2.0 or higher, code-level metrics are enabled by default. For versions 9.9.0 through 10.1.0, code-level metrics must be manually enabled in the .NET agent configuration. 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.
- Python: Requires Python agent version 220.127.116.11 or higher. Code-level metrics are only available for projects implemented with a supported Python framework. 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.8.0 or higher. For version 8.10.0 or higher, code-level metrics are enabled by default. For versions 8.8.0 and 8.9.0, code-level metrics must be manually enabled in the Ruby agent configuration. 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.
- Go: Requires Go agent version 3.19.2 or higher. Code-level metrics must also be enabled in the Go agent configuration. If you're using VS Code, you must also have the Go for VS Code extension installed with the language server enabled.
- PHP: Requires PHP agent version 10.4.0 or higher. Code-level metrics must also be enabled in the PHP agent configuration.
- Node.js: Requires Node.js agent version 9.7.5 or higher. Code-level metrics must also be enabled in the Node.js agent configuration.
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.
CodeStream will show you recent errors happening in the code you have open in your IDE, but you can see a more comprehensive list of APM errors via the errors inbox on New Relic. When you're ready to dig into the root cause of a specific error with a stack trace, click Open in IDE to go directly to the code in your IDE.
A typical collaboration session could include developers commenting on code in their IDEs, a DevOps engineer assigning errors in errors inbox, and a development manager following along in Slack. By meeting people in the tools they're already using, CodeStream shortens the amount of time between error discovery and error resolution.
Watch this short YouTube video (approx. 2:27 minutes) to see this in action.
Whether you clicked on an error in the Observability section or clicked Open in IDE from the errors inbox on New Relic, CodeStream presents all of the error's details, including the stack trace.
Navigate the stack trace to investigate the issue.
Click any frame in the stack trace to jump straight to the corresponding file and line number in your IDE. Note that frames of the stack trace that represent code that isn't part of your repository (e.g., an external library) aren't clickable.
As you navigate the stack trace, if you come across code that seems like the source of your problem, select it and click the comment icon to start a discussion. CodeStream automatically mentions the most recent person to touch that code, making it easy for you to bring the right people into the discussion.
Select code in your editor to add a comment.
- Once you've identified the problem you can assign the error, either to an existing teammate on CodeStream or to a person suggested based on the repository's Git commit history.
- You can update the error status from unresolved to resolved or ignored.
- Use the
...More actions menu to share the discussion on Slack or Microsoft Teams.
When viewing and error in CodeStream you may see this warning if there's no git reference, either a build SHA or release tag, associated with the error. CodeStream uses the git reference to match the specific stack trace error with the version of the code running in the environment that triggered the error.
While you don't need a git reference configured to investigate the error, bear in mind that you may not be looking at the version of the code that caused it.
The git reference not configured warning message reads: Associate a build SHA or release tag with your errors so that CodeStream can help make sure you're looking at the right version of the code.
You can use an environment variable to let the New Relic APM agent know the commit sha associated with each build of your project. You can also use the release tag associated with the running version of your software.
For New Relic APM, the commit sha and/or release tag (
tags.releaseTag) are added as attributes on
TransactionError events. You can use APM environment variables to set these attributes.
We recommend setting one or both of these variables as part of your build pipeline.
NEW_RELIC_METADATA_COMMIT- The commit sha. You can include the whole thing or only the first seven characters (e.g.,
NEW_RELIC_METADATA_RELEASE_TAG- A release tag (such as
release-209). This has the advantage of being human readable.
For more on how to set these variables, here are specific configuration details for each language:
If you do have git references configured, CodeStream will let you know if the version of the code you're on locally doesn't contain the reference associated with the error. In this case, you may want to check out the version of the code that does contain that reference so that you can more effectively investigate and resolve the error.
The git reference not found warning message reads: Your version of the code doesn't match the environment that triggered the error. Fetch the following reference to better investigate the error.
CodeStream will also let you know if the error doesn't have a stack trace associated with it. This happens with older errors when the stack trace has aged out on New Relic.