You have reached the beginning of time!

Tracing of Node.js for Better Visibility and Performance with N|Solid

Tracing is a critical feature in N|Solid that allows developers to analyze application performance by visualizing the relationships between different processes through spans and traces. Without proper tracing, debugging performance issues becomes significantly more challenging, as developers lack visibility into how requests flow through an application. Tracing helps pinpoint bottlenecks, optimize request execution, and improve overall application efficiency.

In this post, we’ll explore how tracing works in N|Solid, including recent updates that improve visibility and filtering capabilities.

The Basics of Tracing in N|Solid

When an application generates a trace, it creates multiple spans, each representing an individual operation within that trace. These spans form a hierarchy, starting from a root span, which serves as the first executed span in the trace.

Tracing in Node.js graph

Root Spans and Hierarchy

Previously, the application name appeared as the root of a trace, but this has changed. Now, the root is the span name that was generated. A trace can contain multiple spans, but there will always be a root span, identifiable by having a Parent ID of 000000000. This root span serves as the starting point for all child spans.

Root spans in tracing Node.js

Each child span references its parent span via a Parent ID, creating a hierarchical structure that maps the entire request path. This allows for detailed insights into how each operation contributes to the overall request execution.

Handling Orphaned Spans

One key challenge in tracing is dealing with orphaned spans—spans that do not have a recorded parent. This happens when the parent process is not running with N|Solid, leading to missing relationships in the trace visualization.

Example of an Orphaned Span

Imagine three applications:

  • Test API (not running with N|Solid)
  • Accounts API (running with N|Solid)
  • Server API (running with N|Solid)

If Test API makes requests to both Accounts API and Server API, but it is not monitored by N|Solid, then its spans will not appear in the trace. Instead, spans from Accounts API and Server API will appear as orphaned nodes—lacking a parent ID, as you can see in the following image:

Orphaned span in tracing Node.js

In such cases, N|Solid will display a warning like:

"Invalid parent span ID=8d486ba62855cdda” as is shown in the following image:

Screen Shot 2025-02-12 at 3.51.54 PM

This indicates that the parent span is missing from the database, preventing the system from properly linking it to its children.

New Features and Improvements

Enhanced Filtering

A new set of filters has been introduced in the tracing section, allowing users to refine traces, these filters include:

Tracing in node.js improvements

These filters help in isolating specific traces, making debugging and performance analysis more efficient.

Visualizing Span Durations

In the updated visualization, spans are represented as bars, with their length corresponding to their duration within the total trace time range. This provides a clearer understanding of execution time distribution.

Span duration in tracing

Expanded Span Details

Previously, clicking on a node only highlighted its corresponding line. Now, clicking on a span not only highlights it but also opens a detailed view, providing:

  • The exact time the span was generated
  • The request URL
  • The duration of the operation
  • The parent-child relationship

See the full list in the image below:

Span details in tracing

This improvement gives developers more in-depth trace insights at a glance.

Conclusion

Tracing in N|Solid has undergone significant improvements, particularly in how root spans are identified and how orphaned spans are handled. The addition of enhanced filtering and expanded visualization makes it easier than ever to diagnose performance issues and optimize application efficiency.

If you’re using N|Solid for tracing, these updates will help streamline your debugging process and provide deeper visibility into your application’s behavior. Stay tuned for more updates as we continue to improve the tracing experience!

The NodeSource platform offers a high-definition view of the performance, security and behavior of Node.js applications and functions.

Start for Free