|
| 1 | +# StackImpact Node.js Agent |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +StackImpact is a performance profiler for production applications. It gives developers continuous and historical view of application performance with line-of-code precision, which includes CPU, memory allocation and blocking call hot spots as well as execution bottlenecks, errors and runtime metrics. Learn more at [stackimpact.com](https://stackimpact.com/). |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +#### Features |
| 11 | + |
| 12 | +* Continuous hot spot profiling for CPU, memory allocations, blocking calls |
| 13 | +* Continuous bottleneck tracing for HTTP handlers and other libraries |
| 14 | +* Exception monitoring |
| 15 | +* Health monitoring including CPU, memory, garbage collection and other runtime metrics |
| 16 | +* Anomaly alerts on most important metrics |
| 17 | +* Multiple account users for team collaboration |
| 18 | + |
| 19 | +Learn more on the [features](https://stackimpact.com/features/) page (with screenshots). |
| 20 | + |
| 21 | + |
| 22 | +#### Documentation |
| 23 | + |
| 24 | +See full [documentation](https://stackimpact.com/docs/) for reference. |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +## Supported environment |
| 29 | + |
| 30 | +* Linux, OS X or Windows. Node.js v4.0.0 or higher. |
| 31 | +* **CPU profiler is disabled by default for Node.js v7.0.0 and higher due to memory leak in underlying V8’s CPU profiler. To enable, add `cpuProfilerDisabled: false` to startup options.** |
| 32 | +* Allocation profiler supports Node.js v6.0.0 and higher. **The allocation profiler is disabled by default, since V8’s heap sampling is still experimental and is seen to result in segmentation faults. To enable, add `allocationProfilerDisabled: false` to startup options.** |
| 33 | +* Async profiler supports Node.js v8.1.0 and higher. |
| 34 | + |
| 35 | + |
| 36 | +## Getting started |
| 37 | + |
| 38 | + |
| 39 | +#### Create StackImpact account |
| 40 | + |
| 41 | +[Sign up](https://dashboard.stackimpact.com/#/signup) for a free account (also with GitHub login). |
| 42 | + |
| 43 | + |
| 44 | +#### Installing the agent |
| 45 | + |
| 46 | +Install the Node.js agent by running |
| 47 | + |
| 48 | +``` |
| 49 | +npm install stackimpact |
| 50 | +``` |
| 51 | + |
| 52 | +And import the package in your application |
| 53 | + |
| 54 | +```javascript |
| 55 | +const stackimpact = require('stackimpact'); |
| 56 | +``` |
| 57 | + |
| 58 | + |
| 59 | +#### Configuring the agent |
| 60 | + |
| 61 | +Start the agent in the main thread by specifying the agent key and application name. The agent key can be found in your account's Configuration section. |
| 62 | + |
| 63 | +```javascript |
| 64 | +let agent = stackimpact.start({ |
| 65 | + agentKey: 'agent key here', |
| 66 | + appName = 'MyNodejsApp' |
| 67 | +}); |
| 68 | +``` |
| 69 | + |
| 70 | +All initialization options: |
| 71 | + |
| 72 | +* `agentKey` (Required) The API key for communication with the StackImpact servers. |
| 73 | +* `appName` (Required) A name to identify and group application data. Typically, a single codebase, deployable unit or executable module corresponds to one application. |
| 74 | +* `appVersion` (Optional) Sets application version, which can be used to associate profiling information with the source code release. |
| 75 | +* `appEnvironment` (Optional) Used to differentiate applications in different environments. |
| 76 | +* `hostName` (Optional) By default, host name will be the OS hostname. |
| 77 | +* `debug` (Optional) Enables debug logging. |
| 78 | +* `cpuProfilerDisabled`, `allocationProfilerDisabled`, `asyncProfilerDisabled`, `errorProfilerDisabled` (Optional) Disables respective profiler when `true`. |
| 79 | +* `includeAgentFrames` (Optional) Set to `true` to not exclude agent stack frames from profiles. |
| 80 | + |
| 81 | + |
| 82 | +#### Shutting down the agent |
| 83 | + |
| 84 | +Use `agent.destroy()` to stop the agent if necessary, e.g. to allow application to exit. |
| 85 | + |
| 86 | + |
| 87 | +#### Analyzing performance data in the Dashboard |
| 88 | + |
| 89 | +Once your application is restarted, you can start observing continuous CPU, memory, I/O, and other hot spot profiles, execution bottlenecks as well as process metrics in the [Dashboard](https://dashboard.stackimpact.com/). |
| 90 | + |
| 91 | + |
| 92 | +#### Troubleshooting |
| 93 | + |
| 94 | +To enable debug logging, add `debug: true` to startup options. If the debug log doesn't give you any hints on how to fix a problem, please report it to our support team in your account's Support section. |
| 95 | + |
| 96 | + |
| 97 | +## Overhead |
| 98 | + |
| 99 | +The agent overhead is measured to be less than 1% for applications under high load. |
0 commit comments