npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-health-agent

v1.2.15

Published

[![GitHub release](https://img.shields.io/npm/v/node-health-agent.svg)](https://github.com/wallet77/node-health-agent/releases/) [![GitHub license](https://img.shields.io/github/license/wallet77/node-health-agent)](https://github.com/wallet77/node-health-

Downloads

18

Readme

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

| Version | Supported | Tested | |:-------------:|:-------------:|:--------------:| | 18.x | yes | yes | | 16.x | yes | yes | | 14.x | yes | yes |

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

| Event | description | |:----------------------------:|:------------------------------------------:| | cpu_profiling_start | Start a CPU profiling | | cpu_profiling_stop | Stop a CPU profiling | | extract_env_var | Extract environment variables | | extract_package_file | Extract package.json file content | | extract_dependencies | Extract the full dependencies tree | | memory_dump | Take a memory snapshot | | memory_sampling_start | Start a memory sampling | | memory_sampling_stop | Stop memory sampling | | code_coverage_start | Start to collect code coverage data | | code_coverage_stop | Stop code coevrage and send data | | diagnosis_report | Run Node.js diagnosis report | | memory_cpu_usage | Export 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/.