{"_id":"felix-metrics","_rev":"11-0d7ca0ae901fed88956ad47564bf53f1","name":"felix-metrics","description":"This is an alternative port of Coda Hale's metrics library.","dist-tags":{"latest":"0.0.9"},"versions":{"0.0.6":{"author":{"name":"Felix Geisendörfer","email":"felix@debuggable.com","url":"http://debuggable.com/"},"name":"felix-metrics","description":"This is an alternative port of Coda Hale's metrics library.","version":"0.0.6","homepage":"https://github.com/felixge/node-better-metrics","repository":{"url":"git://github.com/felixge/node-better-metrics.git"},"main":"./index","scripts":{"test":"make test"},"engines":{"node":"*"},"dependencies":{},"devDependencies":{"urun":"0.0.4","utest":"0.0.3","sinon":"git://github.com/felixge/Sinon.JS.git#stub-prototype-properties"},"_npmUser":{"name":"felixge","email":"felix@debuggable.com"},"_id":"felix-metrics@0.0.6","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"9691c26a10626f00bd5484637843bc74425228cf","tarball":"https://registry.npmjs.org/felix-metrics/-/felix-metrics-0.0.6.tgz","integrity":"sha512-saRXqME5Wti+30GhA6yghtRcifqByIZsiabwlNwPBuGAY06q7A/C1cc4kkSUZdBiRjLVWDHXnvfkLuIazaT0ug==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD9wqpsZvsj8arPi58pHpwQ7urmwSG4lpC7gzBasVDudQIhANvo8vcUJaoQcorWzHstpDspDIT/v1RTMWpVG+AXN65V"}]},"maintainers":[{"name":"felixge","email":"felix@debuggable.com"}]},"0.0.7":{"author":{"name":"Felix Geisendörfer","email":"felix@debuggable.com","url":"http://debuggable.com/"},"name":"felix-metrics","description":"This is an alternative port of Coda Hale's metrics library.","version":"0.0.7","homepage":"https://github.com/felixge/node-better-metrics","repository":{"url":"git://github.com/felixge/node-better-metrics.git"},"main":"./index","scripts":{"test":"make test"},"engines":{"node":"*"},"dependencies":{},"devDependencies":{"urun":"0.0.4","utest":"0.0.3","sinon":"git://github.com/felixge/Sinon.JS.git#stub-prototype-properties"},"_npmUser":{"name":"felixge","email":"felix@debuggable.com"},"_id":"felix-metrics@0.0.7","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"93807921be8a26a50d75ea6a19e03ad89ddff433","tarball":"https://registry.npmjs.org/felix-metrics/-/felix-metrics-0.0.7.tgz","integrity":"sha512-FKtxEwqGjPmOswoca+tzJLcnJBNjxODcUgnDaH0bUWCegkwyu1vcx0dOSvjbmpnkhw8taN1rBwzOuL9nkpU6gw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwna4VvMMFvqQqUZCKUFf5Tsi6ZSG3dU4b6vXZBuuzsgIhAOwxnkR8yYqj0qUgRMvIN0gj9t5k/z3v4Uh/dMr8J75c"}]},"maintainers":[{"name":"felixge","email":"felix@debuggable.com"}]},"0.0.8":{"author":{"name":"Felix Geisendörfer","email":"felix@debuggable.com","url":"http://debuggable.com/"},"name":"felix-metrics","description":"This is an alternative port of Coda Hale's metrics library.","version":"0.0.8","homepage":"https://github.com/felixge/node-better-metrics","repository":{"url":"git://github.com/felixge/node-better-metrics.git"},"main":"./index","scripts":{"test":"make test"},"engines":{"node":"*"},"dependencies":{},"devDependencies":{"urun":"0.0.4","utest":"0.0.3","sinon":"git://github.com/felixge/Sinon.JS.git#stub-prototype-properties"},"_npmUser":{"name":"felixge","email":"felix@debuggable.com"},"_id":"felix-metrics@0.0.8","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"f0ed7519f56e8923078a278ea2603e2fe1f4584f","tarball":"https://registry.npmjs.org/felix-metrics/-/felix-metrics-0.0.8.tgz","integrity":"sha512-wvg39wmkFpGSH4ZWhQkUDuD2jKJpsvF5SYRFCPWrMczosETfCz7WyVuPf4ceyrCd7WJK6VShQX+LVG34Da2hXw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCCCESokLyybStRNgVRMiaDTT9EQDg8G8r2F4u8iINusgIhAImJAEg+flPkt1KcjYBcdXWSbcIT8Iu9I1sZb/u6OOLa"}]},"maintainers":[{"name":"felixge","email":"felix@debuggable.com"}]},"0.0.9":{"author":{"name":"Felix Geisendörfer","email":"felix@debuggable.com","url":"http://debuggable.com/"},"name":"felix-metrics","description":"This is an alternative port of Coda Hale's metrics library.","version":"0.0.9","homepage":"https://github.com/felixge/node-felix-metrics","repository":{"url":"git://github.com/felixge/node-felix-metrics.git"},"main":"./index","scripts":{"test":"make test"},"engines":{"node":"*"},"dependencies":{},"devDependencies":{"urun":"0.0.4","utest":"0.0.3","sinon":"git://github.com/felixge/Sinon.JS.git#stub-prototype-properties"},"_npmUser":{"name":"felixge","email":"felix@debuggable.com"},"_id":"felix-metrics@0.0.9","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"cf0ebbc802e262de207d99d398d736c7075bd250","tarball":"https://registry.npmjs.org/felix-metrics/-/felix-metrics-0.0.9.tgz","integrity":"sha512-2RkFoKWktHpOMcrAdt8dNIoPU5dj6HZzXLUvUreOW66VQS+XmAPaPClwdi4eEXDdQLmy5lIZVw73jG/Y/XnfDA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBtIg6PZgTFSoPy8uxe/mGOjgqGpgii41Q9LqUqjcCNeAiBWA2mG7/oQFeN44u+AyYoMvC2gROsULW+C/vghPAGrYQ=="}]},"maintainers":[{"name":"felixge","email":"felix@debuggable.com"}]}},"readme":"# felix-metrics\n\n[![Build Status](https://secure.travis-ci.org/felixge/node-felix-metrics.png)](http://travis-ci.org/felixge/node-felix-metrics)\n\nThis is an alternative port of Coda Hale's [metrics library][codametrics].\n\nI created this despite the existing [metrics port][existingmetrics] for node.js\nbecause I wanted to fully understand the underlaying Math and algorithms.\n\n[codametrics]:  https://github.com/codahale/metrics\n[existingmetrics]: https://github.com/mikejihbe/metrics\n\n## Install\n\nThis is not ready for you yet\n\n## Usage\n\n**Step 1:** Add metrics to your code. For example, lets track the requests/sec\nof a http server:\n\n```js\nvar metrics    = require('felix-metrics');\nvar collection = new metrics.Collection('http');\nvar http       = require('http');\n\nvar rps = collection.meter('requestsPerSecond');\nhttp.createServer(function(req, res) {\n  meter.mark();\n  res.end('Thanks');\n}).listen(3000);\n```\n\n**Step 2:** Show the collected metrics (more advanced examples follow later):\n\n```js\nsetInterval(function() {\n  console.log(collection.toJSON());\n}, 1000);\n```\n\nThis will output something like this every second:\n\n```\n{ requestsPerSecond:\n   { mean: 1710.2180279856818,\n     count: 10511,\n     '1MinuteRate': 168.08263156623656,\n     '5MinuteRate': 34.74630977619571,\n     '15MinuteRate': 11.646507524106095 } }\n```\n\n**Step 3:** Aggregate the data into your backend of choice. I recommend\n[graphite][].\n\n[graphite]: http://graphite.wikidot.com/\n\n## Metrics\n\nThe following metrics are available (both standalone and on the Collection API):\n\n### Gauge\n\nValues that can be read instantly. Example:\n\n```js\nvar gauge = new metrics.Gauge({read: function() {\n  return process.memoryUsage().rss;\n});\n```\n\nThere is currently no callback support for Gauges because otherwise it would be\nvery difficult to report the metrics inside a collection within a regular\ninterval.\n\n**Options:**\n\n* `read` A function that returns the current value of the Gauge.\n\n**Methods:**\n\nNone.\n\n### Counter\n\nThings that increment or decrement. Example:\n\n```js\nvar activeUploads = new metrics.Counter();\nhttp.createServer(function(req, res) {\n  activeUploads.inc();\n  req.on('end', function() {\n    activeUploads.dec();\n  });\n});\n```\n\n**Options:**\n\n* `count` An initial count for the counter. Defaults to `0`.\n\n**Methods:**\n\n* `inc(n)` Increment the counter by `n`. Defaults to `1`.\n* `dec(n)` Decrement the counter by `n`. Defaults to `1`.\n\n### Meter\n\nThings that are measured as events / interval. Example:\n\n```js\nvar meter = new metrics.Meter();\nhttp.createServer(function(req, res) {\n  meter.mark();\n});\n```\n\n**Options:**\n\n* `rateUnit` The rate unit. Defaults to `1000` (1 sec).\n* `tickInterval` The interval in which the averages are updated. Defaults to\n  `5000` (5 sec).\n\n**Methods:**\n\n* `mark(n)` Register `n` events as having just occured. Defaults to `1.\n\n### Histogram\n\nThings that are measured as distributions of scalars. Example:\n\n```js\nvar histogram = new metrics.Histogram();\nhttp.createServer(function(req, res) {\n  if (req.headers['content-length']) {\n    histogram.update(parseInt(req.headers['content-length'], 10));\n  }\n});\n```\n\n**Options:**\n\n* `sample` The sample resevoir to use. Defaults to an `ExponentiallyDecayingSample`.\n\n**Methods:**\n\n* `update(value, timestamp)` Pushes `value` into the sample. `timestamp`\n  defaults to `Date.now()`.\n\n### Timers\n\nTimers are a combination of Meters and Histograms. They measure the rate as\nwell as distribution of scalar events. Since they are frequently used for\ntracking how long certain things take, they expose an API for that:\n\n```js\nvar timer = new metrics.Timer();\nhttp.createServer(function(req, res) {\n  var stopwatch = timer.start();\n  req.on('end', function() {\n    stopwatch.end();\n  });\n});\n```\n\nBut you can also use them as generic histograms that also track the rate of\nevents:\n\n```js\nvar timer = new metrics.Timer();\nhttp.createServer(function(req, res) {\n  if (req.headers['content-length']) {\n    timer.update(parseInt(req.headers['content-length'], 10));\n  }\n});\n```\n\n**Options:**\n\n* `meter` The internal meter to use. Defaults to a new `Meter`.\n* `histogram` The internal histogram to use. Defaults to a new `Histogram`.\n\n**Methods:**\n\n* `start()` Returns a `Stopwatch`.\n* `update(value)` Updates the internal histogram with `value` and marks one\n  event on the internal meter.\n\n## Todo\n\n* Implement a graphite reporter and feature it in the usage section.\n\n## License\n\nThis module is licensed under the MIT license.\n","maintainers":[{"name":"felixge","email":"felix@debuggable.com"}],"time":{"modified":"2022-06-18T00:08:30.918Z","created":"2011-11-17T15:46:49.774Z","0.0.6":"2011-11-17T15:46:51.269Z","0.0.7":"2011-11-18T13:33:35.879Z","0.0.8":"2011-11-18T13:43:36.237Z","0.0.9":"2011-11-23T16:31:12.774Z"},"author":{"name":"Felix Geisendörfer","email":"felix@debuggable.com","url":"http://debuggable.com/"},"repository":{"url":"git://github.com/felixge/node-felix-metrics.git"}}