Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
elastic-apm-node
Advanced tools
The elastic-apm-node package is an official Elastic APM (Application Performance Monitoring) agent for Node.js applications. It allows you to monitor the performance of your Node.js applications by collecting metrics, tracing requests, and capturing errors. This helps in identifying performance bottlenecks and understanding the behavior of your application in production.
Transaction Tracing
This feature allows you to trace transactions in your application. You can start and end transactions to measure the time taken for specific operations.
const apm = require('elastic-apm-node').start({
serviceName: 'my-service',
serverUrl: 'http://localhost:8200'
});
// Start a transaction
const transaction = apm.startTransaction('myTransaction');
// Do some work
setTimeout(() => {
// End the transaction
transaction.end();
}, 1000);
Error Capturing
This feature allows you to capture and report errors that occur in your application. The captured errors are sent to the APM server for analysis.
const apm = require('elastic-apm-node').start({
serviceName: 'my-service',
serverUrl: 'http://localhost:8200'
});
try {
throw new Error('Something went wrong');
} catch (error) {
apm.captureError(error);
}
Custom Spans
This feature allows you to create custom spans within a transaction to measure the time taken for specific blocks of code. This helps in identifying performance bottlenecks within a transaction.
const apm = require('elastic-apm-node').start({
serviceName: 'my-service',
serverUrl: 'http://localhost:8200'
});
const transaction = apm.startTransaction('myTransaction');
const span = transaction.startSpan('myCustomSpan');
// Do some work
setTimeout(() => {
span.end();
transaction.end();
}, 1000);
The newrelic package is an APM agent for Node.js applications provided by New Relic. It offers similar functionalities such as transaction tracing, error capturing, and custom instrumentation. New Relic provides a comprehensive monitoring solution with a rich set of features and integrations.
The appdynamics package is an APM agent for Node.js applications provided by AppDynamics. It offers features like transaction tracing, error capturing, and custom metrics. AppDynamics is known for its advanced analytics and machine learning capabilities to provide deep insights into application performance.
This is the official Node.js application performance monitoring (APM) agent for the Elastic Observability solution. It is a Node.js package that runs with your Node.js application to automatically capture errors, tracing data, and performance metrics. APM data is sent to your Elastic Observability deployment -- hosted in Elastic's cloud or in your own on-premises deployment -- where you can monitor your application, create alerts, and quick identify root causes of service issues.
If you have any feedback or questions, please post them on the Discuss forum.
npm install --save elastic-apm-node
First, you will need an Elastic Stack deployment. This is a deployment of APM
Server (which receives APM data from the APM agent running in your application),
Elasticsearch (the database that stores all APM data), and Kibana (the
application that provides the interface to visualize and analyze the data). If
you do not already have an Elastic deployment to use, follow this APM Quick
Start guide
to create a free trial on Elastic's cloud. From this deployment you will need
the APM serverUrl
and secretToken
(or a configured apiKey
) to use
for configuring the APM agent.
Next, the best and easiest way to see how to install and start the APM agent is to follow one of the "Get started" guides for the web framework or technology that you are using:
Typically, the quick start steps are:
Install the APM agent package as a dependency:
npm install --save elastic-apm-node
Configure and start the APM agent. For the APM agent's automatic instrumentation of popular modules to work, it must be started before your application imports its other dependencies. For example, if you use CommonJS, then put this at the very top of your main application file:
require('elastic-apm-node').start({
serverUrl: '<serverUrl from your Elastic Stack deployment>',
secretToken: '<secretToken from your Elastic Stack deployment>'
serviceName: '...', // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#service-name
environment: '...', // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#environment
});
There are other ways to start the APM agent: for example, to support starting the APM agent without having to change application code; or to avoid certain surprises when using TypeScript or other transpilers like Babel or esbuild. See Starting the agent for a reference of all ways to start the agent and for details on gotchas with transpilers and bundlers (like Webpack and esbuild).
If your application is using ES modules, please see ECMAScript module support for the current experimental support.
The full Node.js APM agent documentation is here. Some important links:
apm.start(...)
, environment variables, or other mechanisms).The following git branches are active:
Contributions are very welcome. You can get in touch with us through our Discuss forum. If you have found an issue, you can open an issue at https://github.com/elastic/apm-agent-nodejs/issues.
If you are considering contributing code to the APM agent, please read our contribution guide.
Please see TESTING.md for instructions on how to run the test suite.
Made with ♥️ by Elastic and our community.
FAQs
The official Elastic APM agent for Node.js
The npm package elastic-apm-node receives a total of 338,837 weekly downloads. As such, elastic-apm-node popularity was classified as popular.
We found that elastic-apm-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.