Skip to content

simitt/apm-agent-nodejs

 
 

Repository files navigation

Elastic APM Node.js Agent (Experimental)

Build status Standard - JavaScript Style Guide

Warning: This project is currently in a pre-alpha stage and no support or documentation is currently provided. Use it at your own risk.

This is the official Node.js agent for Elastic APM. Read our announcement blog post for details.

If you are trying out APM and have feedback or problems, please post them on the Discuss forum.

Quick start

  1. To run Elastic APM for your own applications make sure you have the prerequisites in place first. For details see "APM Getting Started".

  2. Install the module:

    npm install elastic-apm --save
    
  3. To get started just require and start the Elastic APM agent at the very top of your app's startup script. The Elastic APM agent will be returned. The agent will now instrument your Node.js application and track unhandled exceptions automatically.

    // Add this to the VERY top of the first file loaded in your app
    var apm = require('elastic-apm').start({
      // Set required app name (allowed characters: a-z, A-Z, 0-9, -, _, and space)
      appName: '',
    
      // Use if APM Server requires a token
      secretToken: '',
    
      // Set custom APM Server URL (default: http://localhost:8200)
      serverUrl: ''
    })

    If you want to manually send an error to Elastic APM, use the captureError() function:

    apm.captureError(new Error('Ups, something broke'))

Testing

The test suite expects the databases PostgreSQL, MySQL, MongoDB and Redis to be present. The npm test command will try and start them all automatically before running the tests. This should work on OS X if the databases are all installed using Homebrew.

To run the linter without running any tests, run npm run lint. To automatically fix linting errors run npm run lint-fix.

License

BSD-2-Clause


Made with ♥️ and ☕️ by Elastic and our community.

About

Elastic APM Node.js Agent (Experimental)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.2%
  • Shell 0.8%