1.2.15 • Published 1 year ago

node-health-agent v1.2.15

Weekly downloads
163
License
MIT
Repository
github
Last release
1 year ago

GitHub release GitHub license CI pipeline Code coverage Opened issues Opened PR DeepScan grade Node version

Node agent for Node health project.

Purpose

Agent to trigger events in your instances (even on production). It comes with a list of built-in events and allows to trigger custom actions.

Compatibility

/!\ This module use async/await syntax and the inspector module, this is why you must have node 8.0+.

Supported and tested : >= 8.0

VersionSupportedTested
18.xyesyes
16.xyesyes
14.xyesyes

In order to have all features we recommend to use at least Node.js version 10 or higher.

Installation

$ npm install node-health-agent --save

Usage

Basic

const agent = require('node-health-agent')({
  appName: 'testAPI',
  serverUrl: 'ws://localhost:3001',
  inspector: {
    storage: {
      type: "s3",
      bucket: process.env.CONFIG_S3_BUCKET,
      dir: 'inspector'
    }
  }
})

Add a custom event

agent.addEvent('myEvent', (event) => {
  console.log(event)
})

Add a custom event and send data to server

agent.addEvent('myEvent', (event, ws) => {
  const data = ... // get data in any way
  event.data = data
  ws.send(JSON.stringify(event))
})

Trigger event manually

agent._events.cpu_profiling_start({}, agent.ws, agent.inspector)
// ...
// a few moment later
const profile = await agent._events.cpu_profiling_stop({}, agent.ws, agent.inspector)

List of built-in events

Eventdescription
cpu_profiling_startStart a CPU profiling
cpu_profiling_stopStop a CPU profiling
extract_env_varExtract environment variables
extract_package_fileExtract package.json file content
extract_dependenciesExtract the full dependencies tree
memory_dumpTake a memory snapshot
memory_sampling_startStart a memory sampling
memory_sampling_stopStop memory sampling
code_coverage_startStart to collect code coverage data
code_coverage_stopStop code coevrage and send data
diagnosis_reportRun Node.js diagnosis report
memory_cpu_usageExport CPU and memory info

Debug

Node-health's agent use debug module in order not to pollute your logs. If you want to see all agent output just use DEBUG environment variable:

DEBUG=node-health-agent* node myApp.js

Test

$ npm test

Coverage report can be found in coverage/.

1.2.15

1 year ago

1.2.14

2 years ago

1.2.12

2 years ago

1.2.13

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.8

2 years ago

1.2.9

2 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.18.0

4 years ago

0.16.0

4 years ago

0.17.0

4 years ago

0.15.0

4 years ago

0.14.0

4 years ago

0.12.0

4 years ago

0.13.0

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.1.0

4 years ago