{"id":13526311,"url":"https://github.com/dnlup/doc","last_synced_at":"2025-10-17T20:57:44.075Z","repository":{"id":36986328,"uuid":"251345315","full_name":"dnlup/doc","owner":"dnlup","description":"Get usage and health data about your Node.js process.","archived":false,"fork":false,"pushed_at":"2025-02-18T08:08:19.000Z","size":2128,"stargazers_count":19,"open_issues_count":16,"forks_count":0,"subscribers_count":2,"default_branch":"next","last_synced_at":"2025-03-09T01:10:05.721Z","etag":null,"topics":["cpu","eventloop","garbage-collector","memory","metrics","nodejs","process"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnlup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["dnlup"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":[]}},"created_at":"2020-03-30T15:21:14.000Z","updated_at":"2025-02-18T08:08:22.000Z","dependencies_parsed_at":"2023-09-22T22:52:55.120Z","dependency_job_id":"33560c9a-f3e1-4c4b-aec1-60b5f44767ee","html_url":"https://github.com/dnlup/doc","commit_stats":{"total_commits":440,"total_committers":4,"mean_commits":110.0,"dds":0.4818181818181818,"last_synced_commit":"0690bd590d3555b8222157e208951bebd87d8fdf"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fdoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fdoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fdoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fdoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnlup","download_url":"https://codeload.github.com/dnlup/doc/tar.gz/refs/heads/next","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858929,"owners_count":20359260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpu","eventloop","garbage-collector","memory","metrics","nodejs","process"],"created_at":"2024-08-01T06:01:27.852Z","updated_at":"2025-10-17T20:57:43.919Z","avatar_url":"https://github.com/dnlup.png","language":"JavaScript","funding_links":["https://github.com/sponsors/dnlup"],"categories":["JavaScript"],"sub_categories":[],"readme":"# doc\n\n[![npm version](https://badge.fury.io/js/%40dnlup%2Fdoc.svg)](https://badge.fury.io/js/%40dnlup%2Fdoc)\n![Tests](https://github.com/dnlup/doc/workflows/Tests/badge.svg)\n![Benchmarks](https://github.com/dnlup/doc/workflows/Benchmarks/badge.svg)\n[![codecov](https://codecov.io/gh/dnlup/doc/branch/next/graph/badge.svg?token=2I4S01J2X3)](https://codecov.io/gh/dnlup/doc)\n[![Known Vulnerabilities](https://snyk.io/test/github/dnlup/doc/badge.svg?targetFile=package.json)](https://snyk.io/test/github/dnlup/doc?targetFile=package.json)\n\n\u003e Get usage and health data about your Node.js process.\n\n`doc` is a small module that helps you collect health metrics about your Node.js process.\nIt does that by using only the API available on Node itself (no native dependencies).\nIt doesn't have any ties with an APM platform, so you are free to use anything you want for that purpose.\nIts API lets you access both computed and raw values, where possible.\n\n\u003c!-- toc --\u003e\n\n- [Installation](#installation)\n        * [latest stable version](#latest-stable-version)\n        * [latest development version](#latest-development-version)\n- [Usage](#usage)\n        * [Importing with CommonJS](#importing-with-commonjs)\n        * [Importing with ESM](#importing-with-esm)\n        * [Note](#note)\n      - [Enable/disable metrics collection](#enabledisable-metrics-collection)\n      - [Garbage collection](#garbage-collection)\n      - [Active handles](#active-handles)\n  * [Examples](#examples)\n- [API](#api)\n  * [`doc([options])`](#docoptions)\n  * [Class: `doc.Sampler`](#class-docsampler)\n    + [new `doc.Sampler([options])`](#new-docsampleroptions)\n    + [Event: '`sample`'](#event-sample)\n    + [`sampler.start()`](#samplerstart)\n    + [`sampler.stop()`](#samplerstop)\n    + [`sampler.cpu`](#samplercpu)\n    + [`sampler.resourceUsage`](#samplerresourceusage)\n    + [`sampler.eventLoopDelay`](#samplereventloopdelay)\n    + [`sampler.eventLoopUtilization`](#samplereventlooputilization)\n    + [`sampler.gc`](#samplergc)\n    + [`sampler.activeHandles`](#sampleractivehandles)\n    + [`sampler.memory`](#samplermemory)\n  * [Class: `CpuMetric`](#class-cpumetric)\n    + [`cpuMetric.usage`](#cpumetricusage)\n    + [`cpuMetric.raw`](#cpumetricraw)\n  * [Class: `ResourceUsageMetric`](#class-resourceusagemetric)\n    + [`resourceUsage.cpu`](#resourceusagecpu)\n    + [`resourceUsage.raw`](#resourceusageraw)\n  * [Class: `EventLoopDelayMetric`](#class-eventloopdelaymetric)\n    + [`eventLoopDelay.computed`](#eventloopdelaycomputed)\n    + [`eventLoopDelay.raw`](#eventloopdelayraw)\n    + [`eventLoopDelay.compute(raw)`](#eventloopdelaycomputeraw)\n  * [Class: `EventLoopUtilizationMetric`](#class-eventlooputilizationmetric)\n    + [`eventLoopUtilization.idle`](#eventlooputilizationidle)\n    + [`eventLoopUtilization.active`](#eventlooputilizationactive)\n    + [`eventLoopUtilization.utilization`](#eventlooputilizationutilization)\n    + [`eventLoopUtilization.raw`](#eventlooputilizationraw)\n  * [Class: `GCMetric`](#class-gcmetric)\n    + [`new GCMetric(options)`](#new-gcmetricoptions)\n  * [`gcMetric.pause`](#gcmetricpause)\n    + [`gcMetric.major`](#gcmetricmajor)\n    + [`gcMetric.minor`](#gcmetricminor)\n    + [`gcMetric.incremental`](#gcmetricincremental)\n    + [`gcMetric.weakCb`](#gcmetricweakcb)\n  * [Class: `GCEntry`](#class-gcentry)\n    + [`new GCEntry()`](#new-gcentry)\n    + [`gcEntry.totalDuration`](#gcentrytotalduration)\n    + [`gcEntry.totalCount`](#gcentrytotalcount)\n    + [`gcEntry.mean`](#gcentrymean)\n    + [`gcEntry.max`](#gcentrymax)\n    + [`gcEntry.min`](#gcentrymin)\n    + [`gcEntry.stdDeviation`](#gcentrystddeviation)\n    + [`gcEntry.getPercentile(percentile)`](#gcentrygetpercentilepercentile)\n  * [Class: `GCAggregatedEntry`](#class-gcaggregatedentry)\n    + [`new GCAggregatedEntry()`](#new-gcaggregatedentry)\n    + [`gcAggregatedEntry.flags`](#gcaggregatedentryflags)\n    + [`gcAggregatedEntry.flags.no`](#gcaggregatedentryflagsno)\n    + [`gcAggregatedEntry.flags.constructRetained`](#gcaggregatedentryflagsconstructretained)\n    + [`gcAggregatedEntry.flags.forced`](#gcaggregatedentryflagsforced)\n    + [`gcAggregatedEntry.flags.synchronousPhantomProcessing`](#gcaggregatedentryflagssynchronousphantomprocessing)\n    + [`gcAggregatedEntry.flags.allAvailableGarbage`](#gcaggregatedentryflagsallavailablegarbage)\n    + [`gcAggregatedEntry.flags.allExternalMemory`](#gcaggregatedentryflagsallexternalmemory)\n    + [`gcAggregatedEntry.flags.scheduleIdle`](#gcaggregatedentryflagsscheduleidle)\n  * [`doc.errors`](#docerrors)\n  * [Diagnostics Channel support](#diagnostics-channel-support)\n- [License](#license)\n\n\u003c!-- tocstop --\u003e\n\n## Installation\n\n###### latest stable version\n\n```bash\n$ npm i @dnlup/doc\n```\n\n###### latest development version\n\n```bash\n$ npm i @dnlup/doc@next\n```\n\n## Usage\n\nYou can import the module by using either CommonJS or ESM.\n\nBy default `doc` returns a [`Sampler`](#class-docsampler) instance that collects metrics about cpu, memory usage, event loop delay and event loop utilization.\n\n###### Importing with CommonJS\n\n```js\nconst doc = require('@dnlup/doc')\n\nconst sampler = doc() // Use the default options\n\nsampler.on('sample', () =\u003e {\n  doStuffWithCpuUsage(sampler.cpu.usage)\n  doStuffWithMemoryUsage(sampler.memory)\n  doStuffWithEventLoopDelay(sampler.eventLoopDelay.computed)\n  doStuffWithEventLoopUtilization(sampler.eventLoopUtilization.utilization) // Available only on Node versions that support it\n})\n```\n\n###### Importing with ESM\n\n```js\nimport doc from '@dnlup/doc'\n\nconst sampler = doc()\n\nsampler.on('sample', () =\u003e {\n  doStuffWithCpuUsage(sampler.cpu.usage)\n  doStuffWithMemoryUsage(sampler.memory)\n  doStuffWithEventLoopDelay(sampler.eventLoopDelay.computed)\n  doStuffWithEventLoopUtilization(sampler.eventLoopUtilization.utilization) // Available only on Node versions that support it\n})\n```\n\n###### Note\n\nA `Sampler` holds a snapshot of the metrics taken at the specified sample interval.\nThis behavior makes the instance stateful. On every tick, a new snapshot will overwrite the previous one.\n\n##### Enable/disable metrics collection\n\nYou can disable the metrics that you don't need.\n\n```js\nconst doc = require('@dnlup/doc')\n\n// Collect only the event loop delay\nconst sampler = doc({ collect: { cpu: false, memory: false } })\n\nsampler.on('sample', () =\u003e {\n  // `sampler.cpu` will be `undefined`\n  // `sampler.memory` will be `undefined`\n  doStuffWithEventLoopDelay(sampler.eventLoopDelay.computed)\n  doStuffWithEventLoopUtilization(sampler.eventLoopUtilization.utilization) // Available only on Node versions that support it\n})\n```\n\nYou can enable more metrics if you need them.\n\n##### Garbage collection\n\n```js\nconst doc = require('@dnlup/doc')\n\nconst sampler = doc({ collect: { gc: true } })\nsampler.on('sample', () =\u003e {\n  doStuffWithCpuUsage(sampler.cpu.usage)\n  doStuffWithMemoryUsage(sampler.memory)\n  doStuffWithEventLoopDelay(sampler.eventLoopDelay.computed)\n  doStuffWithEventLoopUtilization(sampler.eventLoopUtilization.utilization) // Available only on Node versions that support it\n  doStuffWithGarbageCollectionDuration(sampler.gc.pause)\n})\n```\n\n##### Active handles\n\n```js\nconst doc = require('@dnlup/doc')\n\nconst sampler = doc({ collect: { activeHandles: true } })\n\nsampler.on('sample', () =\u003e {\n  doStuffWithCpuUsage(sampler.cpu.usage)\n  doStuffWithMemoryUsage(sampler.memory)\n  doStuffWithEventLoopDelay(sampler.eventLoopDelay.computed)\n  doStuffWithEventLoopUtilization(sampler.eventLoopUtilization.utilization) // Available only on Node versions that support it\n  doStuffWithActiveHandles(sampler.activeHandles)\n})\n```\n\n### Examples\n\nYou can find more examples in the [`examples`](./examples) folder.\n\n## API\n\n### `doc([options])`\n\nIt creates a metrics [`Sampler`](#class-docsampler) instance with the given options.\n\n* `options` `\u003cObject\u003e`: same as the `Sampler` [`options`](#new-docsampleroptions).\n* Returns: [`\u003cSampler\u003e`](#class-docsampler)\n\n### Class: `doc.Sampler`\n\n* Extends [`EventEmitter`](https://nodejs.org/dist/latest-v18.x/docs/api/events.html#events_class_eventemitter).\n\nMetrics sampler.\n\nIt collects the selected metrics at a regular interval. A `Sampler` instance is stateful so, on each tick,\nonly the values of the last sample are available. Each time the sampler emits the [`sample`](#event-sample) event, it will overwrite the previous one.\n\n#### new `doc.Sampler([options])`\n\n* `options` `\u003cObject\u003e`\n  * `sampleInterval` `\u003cnumber\u003e`: sample interval (ms) to get a sample. On each `sampleInterval` ms a [`sample`](#event-sample) event is emitted. **Default:** `1000` Under the hood the package uses [`monitorEventLoopDelay`](https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_perf_hooks_monitoreventloopdelay_options) to track the event loop delay.\n  * `autoStart` `\u003cboolean\u003e`: start automatically to collect metrics. **Default:** `true`.\n  * `unref` `\u003cboolean\u003e`: [unref](https://nodejs.org/dist/latest-v18.x/docs/api/timers.html#timers_timeout_unref) the timer used to schedule the sampling interval. **Default:** `true`.\n  * `gcOptions` `\u003cObject\u003e`: Garbage collection options\n    * `aggregate` `\u003cboolean\u003e`: Track and aggregate statistics about each garbage collection operation (see https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_performanceentry_kind). **Default:** `false`\n    * `flags` `\u003cboolean\u003e`: , Track statistics about the flags of each (aggregated) garbage collection operation (see https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_performanceentry_flags). `aggregate` has to be `true` to enable this option. **Default:** `true` on Node version `12.17.0` and newer.\n  * `eventLoopDelayOptions` `\u003cObject\u003e`: Options to setup [`monitorEventLoopDelay`](https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_perf_hooks_monitoreventloopdelay_options). **Default:** `{ resolution: 10 }`\n  * `collect` `\u003cObject\u003e`: enable/disable the collection of specific metrics.\n    * `cpu` `\u003cboolean\u003e`: enable cpu metric. **Default:** `true`.\n    * `resourceUsage` `\u003cboolean\u003e`: enable [resourceUsage](https://nodejs.org/docs/latest-v18.x/api/process.html#process_process_resourceusage) metric. **Default:** `false`.\n    * `eventLoopDelay` `\u003cboolean\u003e`: enable eventLoopDelay metric. **Default:** `true`.\n    * `eventLoopUtilization` `\u003cboolean\u003e`: enable [eventLoopUtilization](https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2) metric. **Default:** `true` on Node version `12.19.0` and newer.\n    * `memory` `\u003cboolean\u003e`: enable memory metric. **Default:** `true`.\n    * `gc` `\u003cboolean\u003e`: enable garbage collection metric. **Default:** `false`.\n    * `activeHandles` `\u003cboolean\u003e`: enable active handles collection metric. **Default:** `false`.\n\nIf `options.collect.resourceUsage` is set to `true`, `options.collect.cpu` will be set to false because the cpu metric is already available in the [`resource usage metric`](#samplerresourceusage).\n\n#### Event: '`sample`'\n\nEmitted every `sampleInterval`, it signals that new data the sampler has collected new data. \n\n#### `sampler.start()`\n\nStart collecting metrics.\n\n#### `sampler.stop()`\n\nStop collecting metrics.\n\n#### `sampler.cpu`\n\n* [`\u003cCpuMetric\u003e`](#class-cpumetric)\n\nResource usage metric instance.\n\n#### `sampler.resourceUsage`\n\n* [`\u003cResourceUsageMetric\u003e`](#class-resourceusagemetric)\n\nResource usage metric instance.\n\n#### `sampler.eventLoopDelay`\n\n* [`\u003cEventLoopDelayMetric\u003e`](#class-eventloopdelaymetric)\n\nEvent loop delay metric instance.\n\n#### `sampler.eventLoopUtilization`\n\n* [`\u003cEventLoopUtilizationMetric\u003e`](#class-eventlooputilizationmetric)\n\nEvent loop utilization metric instance.\n\n#### `sampler.gc`\n\n* [`\u003cGCMetric\u003e`](#class-gcmetric)\n\nGarbage collector metric instance.\n\n#### `sampler.activeHandles`\n\n* `\u003cnumber\u003e`\n\nNumber of active handles returned by `process._getActiveHandles()`.\n\n#### `sampler.memory`\n\n* `\u003cobject\u003e`\n\nObject returned by [`process.memoryUsage()`](https://nodejs.org/dist/latest-v18.x/docs/api/process.html#process_process_memoryusage).\n\n### Class: `CpuMetric`\n\nIt exposes both computed and raw values of the cpu usage.\n\n#### `cpuMetric.usage`\n\n* `\u003cnumber\u003e`\n\nCpu usage in percentage.\n\n#### `cpuMetric.raw`\n\n* `\u003cobject\u003e`\n\nRaw value returned by [`process.cpuUsage()`](https://nodejs.org/dist/latest-v18.x/docs/api/process.html#process_process_cpuusage_previousvalue).\n\n### Class: `ResourceUsageMetric`\n\nIt exposes both computed and raw values of the process resource usage.\n\n#### `resourceUsage.cpu`\n\n* `\u003cnumber\u003e`\n\nCpu usage in percentage.\n\n#### `resourceUsage.raw`\n\n* `\u003cobject\u003e`\n\nRaw value returned by [`process.resourceUsage()`](https://nodejs.org/docs/latest-v18.x/api/process.html#process_process_resourceusage).\n\n### Class: `EventLoopDelayMetric`\n\nIt exposes both computed and raw values about the event loop delay.\n\n#### `eventLoopDelay.computed`\n\n* `\u003cnumber\u003e`\n\nEvent loop delay in milliseconds. It computes this value using the `mean` of the [`Histogram`](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#perf_hooks_class_histogram) instance.\n\n#### `eventLoopDelay.raw`\n\n* `\u003cHistogram\u003e`\n\nExposes the [`Histogram`](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#perf_hooks_class_histogram) instance.\n\n#### `eventLoopDelay.compute(raw)`\n\n* `raw` `\u003cnumber\u003e` The raw value obtained using the [`Histogram`](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#perf_hooks_class_histogram) API.\n* Returns `\u003cnumber\u003e` The computed delay value.\n\n### Class: `EventLoopUtilizationMetric`\n\nIt exposes statistics about the event loop utilization.\n\n#### `eventLoopUtilization.idle`\n\n* `\u003cnumber\u003e`\n\nThe `idle` value in the object returned by [`performance.eventLoopUtilization()`](https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2) during the `sampleInterval` window.\n\n#### `eventLoopUtilization.active`\n\n* `\u003cnumber\u003e`\n\nThe `active` value in the object returned by [`performance.eventLoopUtilization()`](https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2) during the `sampleInterval` window.\n#### `eventLoopUtilization.utilization`\n\n* `\u003cnumber\u003e`\n\nThe `utilization` value in the object returned by [`performance.eventLoopUtilization()`](https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2) during the `sampleInterval` window.\n\n#### `eventLoopUtilization.raw`\n\n* `\u003cobject\u003e`\n\nRaw value returned by [`performance.eventLoopUtilization()`](https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html#perf_hooks_performance_eventlooputilization_utilization1_utilization2) during the `sampleInterval` window.\n\n### Class: `GCMetric`\n\nIt exposes the garbage collector activity statistics in the specified `sampleInterval` using hdr histograms.\n\n#### `new GCMetric(options)`\n\n* `options` `\u003cobject\u003e`: Configuration options\n  * `aggregate` `\u003cboolean\u003e`: See `gcOptions.aggregate` in the [Sampler options](#new-docsampleroptions).\n  * `flags` `\u003cboolean\u003e`: See `gcOptions.flags` in the [Sampler options](#new-docsampleroptions).\n\n### `gcMetric.pause`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\nIt tracks the global activity of the garbage collector.\n\n#### `gcMetric.major`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry) | [`\u003cGCAggregatedEntry\u003e`](#class-gcaggregatedentry)\n\nThe activity of the operation of type `major`. It's present only if `GCMetric` has been created with the option `aggregate` equal to `true`.\n\nSee [`performanceEntry.kind`](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#perf_hooks_performanceentry_kind).\n\n#### `gcMetric.minor`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry) | [`\u003cGCAggregatedEntry\u003e`](#class-gcaggregatedentry)\n\nThe activity of the operation of type `minor`. It's present only if `GCMetric` has been created with the option `aggregate` equal to `true`.\n\nSee [`performanceEntry.kind`](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#perf_hooks_performanceentry_kind).\n\n#### `gcMetric.incremental`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry) | [`\u003cGCAggregatedEntry\u003e`](#class-gcaggregatedentry)\n\nThe activity of the operation of type `incremental`. It's present only if `GCMetric` has been created with the option `aggregate` equal to `true`.\n\nSee [`performanceEntry.kind`](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#perf_hooks_performanceentry_kind).\n\n#### `gcMetric.weakCb`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry) | [`\u003cGCAggregatedEntry\u003e`](#class-gcaggregatedentry)\n\nThe activity of the operation of type `weakCb`. It's present only if `GCMetric` has been created with the option `aggregate` equal to `true`.\n\nSee [`performanceEntry.kind`](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#perf_hooks_performanceentry_kind).\n\n### Class: `GCEntry`\n\nIt contains garbage collection data, represented with an [histogram](https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#class-recordablehistogram-extends-histogram). All timing values are expressed in nanoseconds.\n\n#### `new GCEntry()`\n\nThe initialization doesn't require options. It is created internally by a [`GCMetric`](#class-gcmetric).\n\n#### `gcEntry.totalDuration`\n\n* `\u003cnumber\u003e`\n\nIt is the total time of the entry in nanoseconds.\n\n#### `gcEntry.totalCount`\n\n* `\u003cnumber\u003e`\n\nIt is the total number of operations counted.\n\n#### `gcEntry.mean`\n\n* `\u003cnumber\u003e`\n\nIt is the mean value of the entry in nanoseconds.\n#### `gcEntry.max`\n\n* `\u003cnumber\u003e`\n\nIt is the maximum value of the entry in nanoseconds.\n#### `gcEntry.min`\n\n* `\u003cnumber\u003e`\n\nIt is the minimum value of the entry in nanoseconds.\n\n#### `gcEntry.stdDeviation`\n\n* `\u003cnumber\u003e`\n\nIt is the standard deviation of the entry in nanoseconds.\n\n#### `gcEntry.getPercentile(percentile)`\n\n* `percentile` `\u003cnumber\u003e`: Get a percentile from the histogram.\n* Returns `\u003cnumber\u003e` The percentile\n\n### Class: `GCAggregatedEntry`\n\nIt extends [`GCEntry`](#class-gcentry) and contains garbage collection data plus the flags associated with it (see https://nodejs.org/dist/latest-v18.x/docs/api/perf_hooks.html#performanceentryflags).\n\n#### `new GCAggregatedEntry()`\n\nThe initialization doesn't require options. It is created internally by a [`GCMetric`](#class-gcmetric).\n\n#### `gcAggregatedEntry.flags`\n\n* `\u003cobject\u003e`\n\nThis object contains the various histograms of each flag.\n#### `gcAggregatedEntry.flags.no`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\n#### `gcAggregatedEntry.flags.constructRetained`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\n\n#### `gcAggregatedEntry.flags.forced`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\n\n#### `gcAggregatedEntry.flags.synchronousPhantomProcessing`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\n\n#### `gcAggregatedEntry.flags.allAvailableGarbage`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\n\n#### `gcAggregatedEntry.flags.allExternalMemory`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\n#### `gcAggregatedEntry.flags.scheduleIdle`\n\n* [`\u003cGCEntry\u003e`](#class-gcentry)\n\n\n### `doc.errors`\n\nIn the `errors` object are exported all the custom errors used by the module.\n\n| Error | Error Code | Description |\n|-------|------------|-------------|\n| `InvalidArgumentError` | `DOC_ERR_INVALID_ARG` | An invalid option or argument was used |\n| `NotSupportedError` | `DOC_ERR_NOT_SUPPORTED` | A metric is not supported on the Node.js version used |\n\n### Diagnostics Channel support\n\nNode [diagnostics channel](https://nodejs.org/dist/latest-v20.x/docs/api/diagnostics_channel.html) are supported.\n\n```js\nconst diagnosticsChannel = require('diagnostics_channel')\nconst doc = require('@dnlup/doc)\n\ndiagnosticsChannel.subscribe(doc.constants.DOC_CHANNEL, s =\u003e {\n  console.log('A new instance', s)\n})\n\ndiagnosticsChannel.subscribe(doc.constants.DOC_SAMPLES_CHANNEL, s =\u003e {\n  console.log('A new sample', s)\n})\n\ndoc()\n```\n\n## License\n\n[ISC](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlup%2Fdoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnlup%2Fdoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlup%2Fdoc/lists"}