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 3.0.0-2 to 3.0.0

types/cpuMetric.d.ts

45

CHANGELOG.md

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

## [3.0.0](https://github.com/dnlup/doc/compare/v2.0.2...v3.0.0) (2020-10-23)
### ⚠ 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))
* **sampler:** add resourceUsage metric ([f83c1e8](https://github.com/dnlup/doc/commit/f83c1e885c0be448c1debeb68c4a46deac8b9a86))
* **types:** add resourceUsage types ([4e1e01c](https://github.com/dnlup/doc/commit/4e1e01ced353d9de0f70a5e58c862e84f38113c1))
* **types:** use NodeJS types where possible ([b7148f1](https://github.com/dnlup/doc/commit/b7148f1b8f573baa8792603efddfc89f383b8e07))
* 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:** add default property to module.exports ([6ceac40](https://github.com/dnlup/doc/commit/6ceac40c8d21e029ae4cf595ea2acbb2a55f01ac))
* **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 +52,0 @@

136

index.d.ts
import { EventEmitter } from 'events'
import { CPUMetric } from './types/cpuMetric'
import { EventLoopDelayMetric } from './types/eventLoopDelayMetric'
import { ResourceUsageMetric } from './types/resourceUsageMetric'
import { EventLoopUtilizationMetric } from './types/eventLoopUtilizationMetric'
import { GCMetric } from './types/gcMetric'

@@ -36,111 +41,5 @@ declare interface SamplerOptions {

declare interface CPUMetric {
/**
* Usage percentage
*/
usage: number,
/**
* Raw value returned by `process.cpuUsage()`
*/
raw: NodeJS.CpuUsage
}
export interface MemoryMetric extends NodeJS.MemoryUsage {}
declare interface ResourceUsageMetric {
/**
* Cpu usage percentage
*/
cpu: number,
/**
* Raw vaule returned by `process.resourceUsage()`
*/
raw: {
fsRead: number;
fsWrite: number;
involuntaryContextSwitches: number;
ipcReceived: number;
ipcSent: number;
majorPageFault: number;
maxRSS: number;
minorPageFault: number;
sharedMemorySize: number;
signalsCount: number;
swappedOut: number;
systemCPUTime: number;
unsharedDataSize: number;
unsharedStackSize: number;
userCPUTime: number;
voluntaryContextSwitches: number;
}
}
/**
* On Node 12 and above this is a Histogram instance from 'perf_hooks'.
*/
declare interface EventLoopDelayHistogram {
min: number,
max: number,
mean: number,
stddev: number,
percentiles: Map<number, number>,
exceeds: number,
}
declare interface EventLoopDelayMetric {
/**
* computed delay in milliseconds
*/
computed: number,
raw: number | EventLoopDelayHistogram
}
declare interface EventLoopUtilizationMetric {
/**
* Raw metric value
*/
raw: {
idle: number,
active: number,
utilization: number
}
}
declare enum GCFlag {
/** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_NO */
No = 'no',
/** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED */
ConstructRetained = 'constructRetained',
/** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_FORCED */
Forced = 'forced',
/** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING */
SynchronousPhantomProcessing = 'synchronousPhantomProcessing',
/** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE */
AllAvailableGarbage = 'allAvailableGarbage',
/** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY */
AllExternalMemory = 'allExternalMemory',
/** perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE */
ScheduleIdle = 'scheduleIdle'
}
declare interface GCOpStats {
count: number,
total: number,
average: number
}
declare interface GCAggregatedEntry extends GCOpStats {
flags?: Map<GCFlag, GCOpStats>
}
declare interface GCMetric {
/** perf_hooks.constants.NODE_PERFORMANCE_GC_MAJOR */
major: GCAggregatedEntry,
/** perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR */
minor: GCAggregatedEntry,
/** perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL */
incremental: GCAggregatedEntry,
/** perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB */
weakCb: GCAggregatedEntry
}
declare interface MemoryMetric extends NodeJS.MemoryUsage {}
declare class Sampler extends EventEmitter {
export class Sampler extends EventEmitter {
cpu?: CPUMetric

@@ -162,15 +61,8 @@ resourceUsage?: ResourceUsageMetric

export {
Sampler,
SamplerOptions,
createSampler,
CPUMetric,
ResourceUsageMetric,
EventLoopDelayMetric,
EventLoopUtilizationMetric,
GCMetric,
GCAggregatedEntry,
GCFlag,
GCOpStats,
MemoryMetric
}
export { createSampler }
export { CPUMetric } from './types/cpuMetric'
export { EventLoopDelayMetric } from './types/eventLoopDelayMetric'
export { ResourceUsageMetric } from './types/resourceUsageMetric'
export { EventLoopUtilizationMetric } from './types/eventLoopUtilizationMetric'
export { GCMetric } from './types/gcMetric'

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

module.exports = createSampler
module.exports.doc = createSampler
module.exports.default = createSampler
module.exports.Sampler = Sampler
{
"name": "@dnlup/doc",
"version": "3.0.0-2",
"version": "3.0.0",
"description": "Get usage and health data about your Node.js process",
"main": "index.js",
"type": "commonjs",
"types": "index.d.ts",

@@ -15,5 +16,5 @@ "scripts": {

"test:ts": "tsd",
"deoptigate:server": "PORT=3000 deoptigate benchmarks/doc.js",
"deoptigate:server:resourceUsage": "PORT=3000 deoptigate benchmarks/docResourceUsage.js",
"deoptigate:load": "autocannon -d 60 -c 100 -p 10 localhost:3000",
"trace:ic:server": "PORT=3000 deoptigate benchmarks/doc.js",
"trace:ic:resourceUsage": "PORT=3000 deoptigate benchmarks/docResourceUsage.js",
"trace:ic:load": "autocannon -d 60 -c 100 -p 10 localhost:3000",
"bench": "npm run bench:base && npm run bench:doc",

@@ -26,6 +27,6 @@ "bench:resourceUsage": "npm run bench:base && npm run bench:doc:resourceUsage",

"prerelease": "npm cit",
"release": "standard-version --sign",
"release": "HUSKY_SKIP_HOOKS=1 standard-version --sign",
"postrelease": "npm run push && npm publish",
"prenext": "npm cit",
"next": "standard-version --sign --prerelease --skip.changelog",
"next": "HUSKY_SKIP_HOOKS=1 standard-version --sign --prerelease --skip.changelog",
"postnext": "npm run push && npm publish --tag next",

@@ -40,2 +41,3 @@ "push": "git push origin --follow-tags `git rev-parse --abbrev-ref HEAD`"

"lib",
"types",
"index.js",

@@ -79,3 +81,3 @@ "index.d.ts"

"eslint": "^7.9.0",
"eslint-config-standard": "^14.1.1",
"eslint-config-standard": "^15.0.0",
"eslint-plugin-import": "^2.22.0",

@@ -85,2 +87,3 @@ "eslint-plugin-node": "^11.1.0",

"eslint-plugin-standard": "^4.0.1",
"husky": "^4.3.0",
"is-ci": "^2.0.0",

@@ -87,0 +90,0 @@ "markdown-toc": "^1.2.0",

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

* [`total`](#total)
- [Contributing](#contributing)
- [Credits](#credits)

@@ -394,4 +395,35 @@

## Contributing
You found a bug or want to discuss and implement a new feature? This project welcomes contributions.
The code follows the [standardjs](https://standardjs.com/) style guide.
Every contribution should pass the existing tests or implementing new ones if that's the case.
```bash
# Run tests locally
$ npm test
# Run js tests
$ npm test:js
# Run typescript types tests
$ npm test:ts
# Lint all the code
$ npm lint
# Lint only js files
$ npm lint:js
# Lint only typescript files
$ npm lint:ts
# Create the TOC in the README
$ npm run doc
```
## Credits
When writing this module, I took a lot of inspiration from the fantastic [Node Clinic Doctor](https://github.com/clinicjs/node-clinic-doctor) package.
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