CodeStream is your IDE’s window into New Relic, letting you see how your code is performing without leaving your editor.
Imagine you’re in your IDE, looking at a function. With CodeStream, you can right-click that function and see its performance metrics from New Relic directly alongside your code. This means you can pinpoint slow code, identify errors, and understand the impact of your changes in real-time, as you’re writing it.
Here’s a quick look at it in action. Let’s say you’re debugging a slow API endpoint.
// src/api/userController.js
export async function getUser(req, res) {
const userId = req.params.userId;
try {
const user = await db.users.findUnique({ where: { id: userId } }); // <-- Potential bottleneck
if (!user) {
return res.status(404).json({ message: 'User not found' });
}
// ... more logic ...
res.json(user);
} catch (error) {
logger.error('Error fetching user:', error);
res.status(500).json({ message: 'Internal server error' });
}
}
In your IDE, you’d highlight the db.users.findUnique line. CodeStream would then query New Relic’s APM data for that specific transaction and service.
You might see something like this pop up in a CodeStream panel:
- Average Duration: 150ms
- 95th Percentile Duration: 400ms
- Error Rate: 0.1%
- Transactions per Minute: 1200
This immediately tells you that db.users.findUnique is a significant contributor to the latency of the getUser endpoint, especially under load. You can then drill down further, perhaps seeing the database query itself and its execution time.
CodeStream connects to your New Relic account. You configure it by providing your New Relic API key and account ID. Once connected, it indexes your codebase and links it to the telemetry data in New Relic. When you’re in your IDE, it uses this indexing to match the code you’re viewing with the corresponding traces and metrics in New Relic.
The core problem CodeStream solves is the context switch. Developers often have to jump between their IDE, APM tools, error tracking systems, and other observability platforms to diagnose issues. This fragmented workflow slows down development and debugging. CodeStream collapses this by bringing the observability data into the IDE, right next to the code that generated it.
It works by:
- Code Indexing: CodeStream scans your codebase to create an index of functions, classes, and methods.
- Trace Linking: When New Relic APM instruments your application, it generates traces that include metadata about the code execution. CodeStream uses this metadata, along with its code index, to link specific code spans within a trace back to their source files and line numbers.
- Contextual Queries: When you interact with code in your IDE (e.g., hover, right-click), CodeStream uses the identified code element to query New Relic’s API for relevant performance data, error information, and even logs associated with that code path.
- UI Integration: The retrieved data is displayed in a dedicated panel or hover tooltip within your IDE, providing immediate context.
You control CodeStream through its configuration settings within your IDE (e.g., VS Code, JetBrains IDEs). Key settings include:
- New Relic API Key: Used for authentication to access your New Relic data.
- New Relic Account ID: Specifies which New Relic account to query.
- Service Mapping: You often need to tell CodeStream which service in New Relic corresponds to your current codebase. This might involve matching service names or environment variables. For example, you might configure a
newrelic.serviceName: "my-java-app"in acodestream.jsonfile or via IDE settings. - Environment: Specify the environment (e.g.,
production,staging) to filter New Relic data appropriately.
The most powerful aspect of CodeStream is its ability to surface distributed tracing information directly within your code. When a request traverses multiple services, CodeStream can show you the entire trace, highlighting which service and which specific line of code within your service contributed most to the overall latency or error, all without leaving your IDE. You can see the duration of individual spans, the dependencies between them, and the stack trace associated with any errors.
Once you’ve used CodeStream to identify and fix performance bottlenecks in your code, the next logical step is to proactively ensure that new code you introduce doesn’t create similar problems. This leads to exploring features like CodeStream’s code review integration and its ability to link code changes directly to deployment events in New Relic.