cloudwatch-metrics
Advanced tools
Comparing version 1.0.0 to 1.1.0
16
index.js
@@ -171,2 +171,18 @@ /** | ||
/** | ||
* Samples a metric so that we send the metric to Cloudwatch at the given | ||
* sampleRate. | ||
* @param {Integer|Long} value Data point to submit | ||
* @param {String} namespace Name of the metric | ||
* @param {Array} additionalDimensions Array of additional CloudWatch metric dimensions. See | ||
* http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Dimension.html for details. | ||
* @param {Float} sampleRate The rate at which to sample the metric at. | ||
* The sample rate must be between 0.0 an 1.0. As an example, if you provide | ||
* a sampleRate of 0.1, then we will send the metric to Cloudwatch 10% of the | ||
* time. | ||
*/ | ||
Metric.prototype.sample = function(value, metricName, additionalDimensions, sampleRate) { | ||
if (Math.random() < sampleRate) this.put(value, metricName, additionalDimensions); | ||
}; | ||
/** | ||
* _sendMetrics is called on a specified interval (defaults to 5 seconds but | ||
@@ -173,0 +189,0 @@ * can be overridden but providing a `sendInterval` option when creating a |
{ | ||
"name": "cloudwatch-metrics", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A simple wrapper for simplifying using Cloudwatch metrics", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "jasmine" | ||
}, | ||
@@ -29,6 +29,5 @@ "repository": { | ||
"devDependencies": { | ||
"aws-sdk-mock": "^1.5.0", | ||
"chai": "^3.5.0", | ||
"mocha": "^3.0.2" | ||
"jasmine": "^2.5.2", | ||
"rewire": "^2.5.2" | ||
} | ||
} |
@@ -13,3 +13,8 @@ ## cloudwatch-metrics | ||
### Initialization | ||
We should always initialize our environment first: | ||
By default, the library will log metrics to the `us-east-1` region and read | ||
AWS credentials from the AWS SDK's [default environment variables](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Environment_Variables). | ||
If you want to change these values, you can call `initialize`: | ||
```js | ||
@@ -57,3 +62,3 @@ var cloudwatchMetrics = require('cloudwatch-metrics'); | ||
```js | ||
myMetric.put(value, metric, additionalDimensions, done); | ||
myMetric.put(value, metric, additionalDimensions); | ||
``` | ||
@@ -94,2 +99,3 @@ | ||
## Release History | ||
1.1.0 Add `metric.sample()` | ||
1.0.0 Initial release. |
17430
2
9
357
99