nodesource/ah-collector

Name: ah-collector

Owner: NodeSource

Description: Super light wrapper around async-hooks to collect information about resources created during async operations.

Created: 2017-01-18 22:16:05.0

Updated: 2017-02-01 21:18:11.0

Pushed: 2017-02-09 19:23:49.0

Homepage: https://nodesource.github.io/ah-collector

Size: 1205

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

ah-collector

Super light wrapper around async-hooks to collect information about resources created during async operations.

t ActivityCollector = require('ah-collector')

tion captureStack(hook, { uid, type, triggerId }, resource) {
 Predicate to decide if a stack should be captured or not.
 Capture only inits of the TIMERWRAP but everything of the Timeout.
turn type === 'Timeout' || (type === 'TIMERWRAP' && hook === 'init')


t collector = new ActivityCollector({
start: process.hrtime()
captureStack
nable()

imeout(ontimeout, 100)

tion ontimeout() {
llector
.processStacks()
.dump()

Requirements

Needs async hooks feature, therefore build from this PR for now.

EPS document

Documentation in progress

Installation
npm install ah-collector
API
ActivityCollector

Creates an instance of an ActivityCollector

Parameters

Returns ActivityCollector instance of ActivityCollector

activityCollector.enable

Enables the collection of async hooks. Needs to be called as otherwise nothing will be collected.

Returns ActivityCollector activityCollector

activityCollector.disable

Disables the collection of async hooks. Nothing will be collected until activityCollector.enable() is called.

Returns ActivityCollector activityCollector

activityCollector.clear

Clears all currently collected activity.

Returns ActivityCollector activityCollector

activityCollector.activitiesOfTypes

Returns an Array of all activities collected so far that are of the specified type(s).

Parameters

Returns Array activities matching the specified type(s)

activityCollector.activities

A getter that returns a map of all activities collected so far.

Returns Map activities

activityCollector.activitiesArray

A getter that returns an Array of all activities collected so far.

Returns Array activities

activityCollector.processStacks

Processes all stacks that were captured for specific activities This is done in line, i.e. the actual stacks of the activity objects are modified.

Returns ActivityCollector activityCollector

activityCollector.dump

Dumps all so far collected activities to the console. This is useful for diagnostic purposes.

If no arguments are provided, all activities are dumped.

Parameters

Returns ActivityCollector activityCollector

activityCollector.dumpTypes

Dumps all types in the order they were collected including id and trigger id.

Example: FSREQWRAP:id:triggerId

ActivityCollector#UNKNOWN_TYPE

Static getter that denotes the type given to activities whose type is unkown since we missed their init event.

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.