Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dnlup/doc

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dnlup/doc - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0-0

lib/config.js

41

CHANGELOG.md

@@ -5,2 +5,43 @@ # Changelog

## [3.0.0-0](https://github.com/dnlup/doc/compare/v2.0.2...v3.0.0-0) (2020-10-05)
### ⚠ BREAKING CHANGES
* **config:** message errors and instances are changed.
* the exported class is named Sampler and not Doc anymore
* **types:** types are not accessible using `Doc.` notation.
`DocInstance` has been renamed to `Doc` and declared as a class.
* **gc:** the metric is not exposed to the event handler anymore,
but it is attached directly to the Doc instance.
* **eventLoopDelay:** the eventLoopDelay metric is not exposed anymore to the
event handler, but it is attached to the Doc instance.
* **cpu:** the cpu metric is not exposed anymore to the
event handler, but it is attached to the Doc instance. The event name is
changed from `data` to `sample`.
### Features
* **cpu:** attach cpu state to doc instance ([2f66fae](https://github.com/dnlup/doc/commit/2f66fae9dd5ad2644fb50492c3bcc366d57f5d0e))
* **eventLoopDelay:** attach object to doc instance ([5d90062](https://github.com/dnlup/doc/commit/5d90062867d46e2115ebcf0e4bedb9eed91f043b))
* **eventLoopDelay:** expose compute method ([2f44d63](https://github.com/dnlup/doc/commit/2f44d6324c43d552f07b0587d5d8c19ee86e6fa9))
* **gc:** attach metric to doc instance ([f628872](https://github.com/dnlup/doc/commit/f628872a6b4b0d48d6a25e99f4435d00afacccb3))
* **sampler:** add event loop utilization metric ([43243db](https://github.com/dnlup/doc/commit/43243db33b6ee6b1c24da2f51489d3a5f072602f))
* attach remaining metrics and add start options ([01cd4d0](https://github.com/dnlup/doc/commit/01cd4d0247bd64717d13f9cf456bed068dbd3f3a))
* improve gc metric ([0a4d52b](https://github.com/dnlup/doc/commit/0a4d52b4d522b18747494c8d51aed2c7eebb9e5b))
### Bug Fixes
* **config:** drop ajv-cli and build step ([b143d15](https://github.com/dnlup/doc/commit/b143d153b1df55d4e32770696491b2e7b5c31205))
* **eventLoopDelay:** use Symbol for sample method ([1515760](https://github.com/dnlup/doc/commit/1515760720198bc440b6677131308ac91df4b819))
* **gc:** use symbols for GCAggregatedEntry methods ([a28359f](https://github.com/dnlup/doc/commit/a28359f99e555b3fd7812190342ac133935ed4ec))
* **lib:** fix wrong name used for options symbol ([65675d6](https://github.com/dnlup/doc/commit/65675d68cb8efe36327de3bc6ca20e8aed7ca768))
* **sampler:** exit if timer is initialized on `start` ([b2f406a](https://github.com/dnlup/doc/commit/b2f406a7f0294ae735db368d6c7271972e016367))
* **types:** use camel case for enum and use jsdoc ([4cd976d](https://github.com/dnlup/doc/commit/4cd976d58dbe309cade247b497dae67eee4253fa))
* rename Doc to Sampler and move it to lib ([53b0ca0](https://github.com/dnlup/doc/commit/53b0ca04e44fe808c848cd32ad62abc1f3213c6f))
* **types:** remove Doc namespace ([489d2bd](https://github.com/dnlup/doc/commit/489d2bd6b20aeebed83b81806cfb19823149c548))
### [2.0.2](https://github.com/dnlup/doc/compare/v2.0.1...v2.0.2) (2020-10-04)

@@ -7,0 +48,0 @@

@@ -28,2 +28,3 @@ import { EventEmitter } from 'events' // eslint-disable-line no-unused-vars

eventLoopDelay?: boolean,
eventLoopUtilization?: boolean,
memory?: boolean,

@@ -65,2 +66,13 @@ gc?: boolean,

declare interface EventLoopUtilizationMetric {
/**
* Raw metric value
*/
raw: {
idle: number,
active: number,
utilization: number
}
}
declare enum GCFlag {

@@ -128,2 +140,3 @@ /** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_NO */

eventLoopDelay?: EventLoopDelayMetric
eventLoopUtilization?: EventLoopUtilizationMetric
gc?: GCMetric

@@ -147,2 +160,3 @@ memory?: MemoryMetric

EventLoopDelayMetric,
EventLoopUtilizationMetric,
GCMetric,

@@ -149,0 +163,0 @@ GCAggregatedEntry,

1

lib/cpu.js

@@ -9,3 +9,2 @@ 'use strict'

} = require('./symbols')
const kCpuLastSample = Symbol('kCpuLastSample')

@@ -12,0 +11,0 @@

@@ -13,5 +13,9 @@ 'use strict'

const DEFAULTS = {
resolution: 10
}
class EventLoopDelayMetric {
constructor (opts) {
this[kOptions] = opts || {}
this[kOptions] = Object.assign({}, DEFAULTS, opts)
if (monitorEventLoopDelay) {

@@ -18,0 +22,0 @@ this[kRawMetric] = monitorEventLoopDelay(this[kOptions])

@@ -5,2 +5,3 @@ 'use strict'

const EventLoopDelayMetric = require('./eventLoopDelay')
const EventLoopUtilizationMetric = require('./eventLoopUtilization')
const CpuMetric = require('./cpu')

@@ -15,2 +16,3 @@ const GCMetric = require('./gc')

kEventLoopDelay,
kEventLoopUtilization,
kCpu,

@@ -39,2 +41,6 @@ kGC,

if (this[kOptions].collect.eventLoopUtilization) {
this[kEventLoopUtilization] = new EventLoopUtilizationMetric()
}
if (this[kOptions].collect.cpu) {

@@ -76,2 +82,6 @@ this[kCpu] = new CpuMetric()

get eventLoopUtilization () {
return this[kEventLoopUtilization]
}
get gc () {

@@ -103,2 +113,6 @@ return this[kGC]

if (this[kOptions].collect.eventLoopUtilization) {
this[kEventLoopUtilization][kSample]()
}
if (this[kOptions].collect.activeHandles) {

@@ -124,2 +138,6 @@ this[kActiveHandles] = process._getActiveHandles().length

if (this[kOptions].collect.eventLoopUtilization) {
this[kEventLoopUtilization][kReset]()
}
if (this[kOptions].collect.cpu) {

@@ -126,0 +144,0 @@ this[kCpu][kReset]()

'use strict'
// TODO: rename symbols to reflect the fact that they apply most to the Sampler
// and follow Node.js naming convention.
module.exports = {

@@ -11,2 +9,3 @@ kOptions: Symbol('kOptions'),

kEventLoopDelay: Symbol('kEventLoopDelay'),
kEventLoopUtilization: Symbol('kEventLoopUtilization'),
kCpu: Symbol('kCpu'),

@@ -13,0 +12,0 @@ kGC: Symbol('kGC'),

{
"name": "@dnlup/doc",
"version": "2.0.2",
"version": "3.0.0-0",
"description": "Get usage and health data about your Node.js process",

@@ -8,7 +8,5 @@ "main": "index.js",

"scripts": {
"build": "ajv compile --remove-additional=true --coerce-types --use-defaults -s lib/config/schema.js -o lib/config/validate.js",
"lint": "npm run lint:js && npm run lint:ts",
"lint:js": "eslint .",
"lint:ts": "eslint *.ts",
"pretest": "npm run build",
"test": "npm run lint && npm run test:js && npm run test:ts",

@@ -71,2 +69,3 @@ "test:js": "tap",

"ajv-cli": "^3.3.0",
"atomic-sleep": "^1.0.0",
"autocannon": "^6.4.0",

@@ -73,0 +72,0 @@ "concurrently": "^5.3.0",

@@ -31,2 +31,3 @@ # doc

+ [`sampler.eventLoopDelay`](#samplereventloopdelay)
+ [`sampler.eventLoopUtilization`](#samplereventlooputilization)
+ [`sampler.gc`](#samplergc)

@@ -42,2 +43,4 @@ + [`sampler.activeHandles`](#sampleractivehandles)

+ [`eventLoopDelay.compute(raw)`](#eventloopdelaycomputeraw)
* [Class: `EventLoopUtilizationMetric`](#class-eventlooputilizationmetric)
+ [`eventLoopUtilization.raw`](#eventlooputilizationraw)
* [Class: `GCMetric`](#class-gcmetric)

@@ -74,3 +77,3 @@ + [`gcMetric.major`](#gcmetricmajor)

By default `doc` returns a [`Sampler`](#class-docsampler) instance that collects metrics about cpu, memory usage and event loop delay.
By default `doc` returns a [`Sampler`](#class-docsampler) instance that collects metrics about cpu, memory usage, event loop delay and event loop utilization (only on Node versions that [support it](https://nodejs.org/docs/latest-v14.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2)).

@@ -86,2 +89,3 @@ ```js

doStuffWithEventLoopDelay(sampler.eventLoopDelay.computed)
doStuffWithEventLoopUtilization(sampler.eventLoopUtilization.raw) // Available only on Node versions that support it
})

@@ -170,2 +174,3 @@ ```

* `eventLoopDelay` `<boolean>`: enable eventLoopDelay metric. **Default:** `true`.
* `eventLoopUtilization` `<boolean>`: enable [eventLoopUtilization](https://nodejs.org/docs/latest-v14.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2) metric. **Default:** `true` on Node versions that support it.
* `memory` `<boolean>`: enable memory metric. **Default:** `true`.

@@ -199,2 +204,8 @@ * `gc` `<boolean>`: enable garbage collection metric. **Default:** `false`.

#### `sampler.eventLoopUtilization`
* [`<EventLoopUtilizationMetric>`](#class-eventlooputilizationmetric)
Event loop utilization metric instance.
#### `sampler.gc`

@@ -257,2 +268,12 @@

### Class: `EventLoopUtilizationMetric`
Exposes raw values about the event loop utilization.
#### `eventLoopUtilization.raw`
* `<object>`
Raw value returned by [`performance.eventLoopUtilization()`](https://nodejs.org/docs/latest-v14.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2) during the `sampleInterval` window.
### Class: `GCMetric`

@@ -259,0 +280,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc