# measured-core

> A Node library for measuring and reporting application-level metrics.

Latest version **2.0.0** (published 2020-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install measured-core
pnpm add measured-core
yarn add measured-core
bun add measured-core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-07-10 |
| First published | 2018-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 5.12 |
| Dependencies | 2 |
| Unpacked size | 48.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 515 |
| Maintainers | csabapalfi, fieldju |

## Links

- npm: https://www.npmjs.com/package/measured-core
- Repository: https://github.com/yaorg/node-measured
- Homepage: https://yaorg.github.io/node-measured/
- npm.io page: https://npm.io/package/measured-core

## Dependencies (2)

- [optional-js](https://npm.io/package/optional-js.md) ^2.0.0
- [binary-search](https://npm.io/package/binary-search.md) ^1.3.3

## Recent versions

- 2.0.0 (latest) — 2020-07-10
- 1.0.2 (measured-legacy) — 2018-06-02
- 1.51.1 — 2019-09-05
- 1.51.0 — 2019-08-28
- 1.50.0 — 2019-08-02
- 1.49.0 — 2019-06-06
- 1.48.0 — 2019-05-26
- 1.47.0 — 2019-05-24
- 1.46.0 — 2019-05-24
- 1.45.0 — 2019-05-24
- 1.44.0 — 2019-05-24
- 1.43.0 — 2019-05-24
- 1.42.0 — 2019-05-23
- 1.41.0 — 2019-03-20
- 1.40.2 — 2019-02-02
- … 49 more at https://npm.io/package/measured-core/versions

## README

# Measured Core

The core measured library that has the Metric interfaces and implementations.

[![npm](https://img.shields.io/npm/v/measured-core.svg)](https://www.npmjs.com/package/measured-core) 

## Install

```
npm install measured-core
```

## What is in this package

### Metric Implemenations

The core library has the following metrics classes:

#### [Gauge](https://yaorg.github.io/node-measured/packages/measured-core/Gauge.html)
Values that can be read instantly via a supplied call back.

#### [SettableGauge](https://yaorg.github.io/node-measured/packages/measured-core/SettableGauge.html)
Just like a Gauge but its value is set directly rather than supplied by a callback.

#### [CachedGauge](https://yaorg.github.io/node-measured/packages/measured-core/CachedGauge.html)
Like a mix of the regular and settable Gauge it takes a call back that returns a promise that will resolve the cached value and an interval that it should call the callback on to update its cached value.

#### [Counter](https://yaorg.github.io/node-measured/packages/measured-core/Counter.html)
Counters are things that increment or decrement.

#### [Timer](https://yaorg.github.io/node-measured/packages/measured-core/Timer.html)
Timers are a combination of Meters and Histograms. They measure the rate as well as distribution of scalar events.

#### [Histogram](https://yaorg.github.io/node-measured/packages/measured-core/Histogram.html)
Keeps a reservoir of statistically relevant values to explore their distribution.

#### [Meter](https://yaorg.github.io/node-measured/packages/measured-core/Meter.html)
Things that are measured as events / interval.

### Registry

The core library comes with a basic registry class 

#### [Collection](https://yaorg.github.io/node-measured/packages/measured-core/Collection.html)

that is not aware of dimensions / tags and leaves reporting up to you.

#### See the [measured-reporting](../measured-reporting/) module for more advanced and featured registries.

### Other

See The [measured-core](https://yaorg.github.io/node-measured/packages/measured-core/module-measured-core.html) modules for the full list of exports for require('measured-core').

## Usage

**Step 1:** Add measurements to your code. For example, lets track the
requests/sec of a http server:

```js
var http  = require('http');
var stats = require('measured').createCollection();

http.createServer(function(req, res) {
  stats.meter('requestsPerSecond').mark();
  res.end('Thanks');
}).listen(3000);
```

**Step 2:** Show the collected measurements (more advanced examples follow later):

```js
setInterval(function() {
  console.log(stats.toJSON());
}, 1000);
```

This will output something like this every second:

```
{ requestsPerSecond:
   { mean: 1710.2180279856818,
     count: 10511,
     'currentRate': 1941.4893498239829,
     '1MinuteRate': 168.08263156623656,
     '5MinuteRate': 34.74630977619571,
     '15MinuteRate': 11.646507524106095 } }
```

**Step 3:** Aggregate the data into your backend of choice.
Here are a few time series data aggregators.
- [Graphite](http://graphite.wikidot.com/)
    - A free and open source, self hosted and managed solution for time series data.
- [SignalFx](https://signalfx.com/)
    - An enterprise SASS offering for time series data.
- [Datadog](https://www.datadoghq.com/)
    - An enterprise SASS offering for time series data.

---
_Source: https://npm.io/package/measured-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
