Monitor Node.js Applications

APM for Node.js lets you monitor the performance of your Node.js applications.
apmdevops106
APM for Node.js lets you monitor the performance of your Node.js applications.
As an application owner, follow these high-level steps:
  1. Use the normal APM procedures for monitoring performance:
  2. Read and use this additional information that is specific to APM for Node.js:
The Node.js agent attributes are the common attributes that all agents and Infrastructure Agent extensions use.
View the Node.js Application Metrics
You can view metrics for your Node.js application. The Metric Browser tab lets you browse the BlamePoint metrics that a Node.js Probe Agent reports. For example, you can view metrics for frontend frameworks such as Express and LoopBack and backend frameworks such as MongoDB, MySQL, and Redis.
Follow these steps:
  1. In Team Center, click an item of interest such as an individual metric from the details panel.
    WebView opens and the metric appears for the monitored Node.js process.
    Example:
    nodejs-probes | <
    Agent
    > | Frontends | Apps | <
    Probe_Name
    > |
    The agent shows Frontend metrics in multiple levels for each:
    1 - Application
    2 - URL in an application
    3 - Backend system that the URL requested
  2. Investigate the BlamePoint metrics.
  3. Navigate to the
    nodejs-probes | <Agent>
    node.
    A node that is named for the frontend or backend framework (for example, Express) appears at the next level.
    Frontend and Backends Frameworks
    The route of the node application is a combination of a URI, an HTTP request method (GET, POST, and so on).
  4. Navigate the nodes to investigate the BlamePoint metrics.
  5. Click a metric and view performance information. Analyze events and other data by clicking the tabs in the right pane. For example, click the Errors tab to detect application errors.
View the Health of the Node.js Runtime
The Node.js Probe Agent monitors applications dynamically when a program is running or being executed. The Node.js runtime metrics help you monitor the health of the Node.js process.
Follow these steps:
  1. In Team Center, in the Metric Browser navigate to the Node.js Runtime node:
  2. nodejs-probes | <Agent> | Node.js Runtime | Metrics
    Here are the runtime health metrics:
    CPU System Percent
    CPU time that is spent inside the kernel on behalf of the process. This metric is expressed as a percentage of wall clock time. This value can exceed 100 percent on multi-core systems. CPU time is the elapsed wall clock time when the CPU is executing instructions on behalf of the process. Such as when the process or its corresponding kernel thread is actually running.
    CPU User Percent
    User CPU time. CPU time is directly attributable to the execution of the user-space process. This time is expressed as a percentage of wall clock time. Can exceed 100 percent on multi-core systems.
    Event Loop Average Tick Time (ms)
    The average time that is taken in milliseconds by event loop ticks in last interval. For a high-performing application, the Average Tick Time value is inversely proportional to the transaction load.
    Event Loop Ticks Per Interval
    The total number of event loop ticks in last interval. For a high-performing application, the Ticks Per Interval value is directly proportional to the transaction load.
    GC Heap Used
    The part of the V8 heap that remains in use after a minor or major garbage collector cycle, expressed in bytes. The V8 heap stores JavaScript objects and values, excluding integers in the range of -2,147,483,648 to 2,147,483,647. The exact range depends on the processor architecture.
    HTTP Connection Count
    The number of new HTTP connections in the last interval.
    HTTP Connections / sec
    The number of new HTTP connections per second.
    Heap Total
    The total size of the V8 heap, expressed in bytes.
    Used
    The part of the V8 heap that is in use, expressed in bytes.
    CPU Total Percent
    Sum of user and system time, expressed as a percentage of wall clock time. This value can exceed 100 percent on multi-core systems.
  3. Click a metric and view performance information. Analyze events and other data by clicking the tabs in the right pane. For example, click the Errors tab to detect application errors.
View Express Metrics in Team Center
When your Node.js application uses the Express framework, Team Center displays the Express.js node in the Map View. The node name is < RouteName > ( < HTTPMethodName >).
You can view the Express BlamePoint metrics under the Express.js tab.
Understand Node.js Transaction Traces
Node.js transactions are asynchronous. Asynchronous operations execute in two ways:
Sequentially
–Asynchronous events that occur in series are displayed as sequential components on same level and identified as the same lane. Asynchronous events that have a parent-child relationship are displayed on as called components on the next level. One child event in any given time continues in the same lane.
Parallel
–If the Node.js Probe Agent detects two or more parallel asynchronous operations, the agent creates a separate lane for each parallel operation sequence (transaction fragment).
Different events are important for tracing asynchronous operations:
  • Operation Start
    –This event is measured from the start of invoking an asynchronous API call and marks the transaction component start time.
  • Operation Done
    --This event is measured from the beginning of the operation result callback and marks the transaction component end time. This event also tracks if the next asynchronous operation start is in a series with a previous operation or in parallel.
The following example shows a sequential trace:
Asynchronous events that happen in a series are the result callback of the first operation, starts next asynchronous operation. These events are displayed as sequential components on same level and identified as the same lane. This diagram shows a sequential trace.
a sequential trace
Asynchronous events have a parent-child relationship when an asynchronous operation invokes another operation to complete. Asynchronous events are displayed as called components on a next level. When one such child event occurs in any given time, the trace continues in same lane.
If the Node.js probe detects two or more parallel asynchronous operations running, it creates a separate lane for each parallel operation sequence:
  • The main transaction has only one lane.
  • Each additional lane added to the transaction results in a new transaction fragment. The transaction fragments have a special first blame component named 'Fragment' that identifies it with the main transaction component that created it. Transaction fragments have the same correlation ID as the main transaction.
The following example shows asynchronous requests in a parallel trace. The separate lanes show transaction fragments:
parallel trace.png
Follow these steps:
  1. View transaction traces by running a Transaction Trace session in WebView.
    When the transaction trace session starts, the transactions that match the filter criteria display in Trace View. The transaction components appear in a graphical stack that is composed of execution lanes. As the Node.js Probe Agent detects asynchronous operation events, the stack tracks the state in an individual lane for each transaction.
  2. In the data viewer, examine the components in the graphical stack from top to bottom and evaluate the application performance.
  3. Examine the Component Details. For example, an Express framework includes these details:
    Type: Express
    Name: POST
    Path:
    Express/rest/account/_session/logout/POST
    Class: route
    Express Route: /rest/account/session/logout
    HTTP Method: POST
    Method: dispatch
Understand APM for Node.js Errors
APM for Node.js captures error objects that are part of callback arguments in the Node.js probes. APM for Node.js does not capture exceptions. For snapshot errors, APM for Node.js errors use the following convention:
Node.Error
. The following parameters in the error snapshot are relevant to Node.js:
Application Name
The name of the application/Probe Agent.
Class
The Node.js module/function name that caused the error snapshot as specified in the PBD.
Error Message
This parameter provides information about what caused the error.
Exception
This parameter provides information about what caused the error (this parameter is the same as the Error Message).
Resource Name
The resource name that is specified in the tracer directives for that class in the PBD.
Server Name
The host name where the Node.js application is running.
Server Port
The port on which the Node.js application is running.
Thread Name
This parameter provides the pid of the Node.js application process.
Trace Type
The value is ErrorSnapshot for errors or StallSnapshot for stalls.
URL
The URL that caused the error.
Note:
Errors are only supported for MySQL and HTTP probes.
As shown in the following example, this error appears in the Stack View:
Error Message: Frontends|Aps\nodetixchange-3000|URLs|Default: Node.Error: Http 403: Forbidden
Node-ErrorSnapshot.png