Browse Source

Merge pull request #38 from jetmind/rename-metric-type-option

s/counter/count for metric type
pull/39/head
Brett Langdon 10 years ago
parent
commit
9ae68c7c53
2 changed files with 18 additions and 18 deletions
  1. +4
    -4
      lib/api/metric.js
  2. +14
    -14
      test/api/metric.js

+ 4
- 4
lib/api/metric.js View File

@ -12,7 +12,7 @@ var client = require("../client");
* optional, object which can contain the following keys * optional, object which can contain the following keys
* * host: the host source of the metric * * host: the host source of the metric
* * tags: array of "tag:value"'s to use for the metric * * tags: array of "tag:value"'s to use for the metric
* * metric_type|type: which metric type to use ("gauge" or "counter") [default: gauge]
* * metric_type|type: which metric type to use ("gauge" or "count") [default: gauge]
* callback: | * callback: |
* function(err, res) * function(err, res)
*example: | *example: |
@ -33,7 +33,7 @@ var client = require("../client");
* dogapi.metric.send("my.metric", [[now, 1000]], function(err, results){ * dogapi.metric.send("my.metric", [[now, 1000]], function(err, results){
* console.dir(results); * console.dir(results);
* }); * });
* dogapi.metric.send("my.counter", 5, {type: "counter"}, function(err, results){
* dogapi.metric.send("my.counter", 5, {type: "count"}, function(err, results){
* console.dir(results); * console.dir(results);
* }); * });
* ``` * ```
@ -68,7 +68,7 @@ function send(metric, points, extra, callback){
* * points: a single data point (e.g. `50`), an array of data points (e.g. `[50, 100]`) or an array of `[timestamp, value]` elements (e.g. `[[now, 50], [now, 100]]`) * * points: a single data point (e.g. `50`), an array of data points (e.g. `[50, 100]`) or an array of `[timestamp, value]` elements (e.g. `[[now, 50], [now, 100]]`)
* * tags: an array of "tag:value"'s * * tags: an array of "tag:value"'s
* * host: the source hostname to use for the metrics * * host: the source hostname to use for the metrics
* * metric_type|type: the type of metric to use ("gauge" or "counter") [default: gauge]
* * metric_type|type: the type of metric to use ("gauge" or "count") [default: gauge]
* callback: | * callback: |
* function(err, res) * function(err, res)
*example: | *example: |
@ -196,7 +196,7 @@ module.exports = {
" Options:", " Options:",
" --tags <tags> a comma separated list of \"tag:value\"'s", " --tags <tags> a comma separated list of \"tag:value\"'s",
" --host <host> the hostname that should be associated with this metric", " --host <host> the hostname that should be associated with this metric",
" --type <type> the type of metric \"gauge\" or \"counter\""
" --type <type> the type of metric \"gauge\" or \"count\""
] ]
}, },
handleCli: function(subcommand, args, callback){ handleCli: function(subcommand, args, callback){


+ 14
- 14
test/api/metric.js View File

@ -134,7 +134,7 @@ describe("api/metrics", function(){
it("should properly set metric type", function(){ it("should properly set metric type", function(){
// Make our api call // Make our api call
metric.send("metrics.send.counter", 5, {type: "counter"});
metric.send("metrics.send.counter", 5, {type: "count"});
// Assert we called `client.request` with the correct `points` // Assert we called `client.request` with the correct `points`
assert(stub_request.calledOnce); assert(stub_request.calledOnce);
@ -150,16 +150,16 @@ describe("api/metrics", function(){
assert.equal(series.length, 1); assert.equal(series.length, 1);
// Assert the first series is properly formatted // Assert the first series is properly formatted
// first_series = {metric: "", type: "counter", points: [], ...}
// first_series = {metric: "", type: "count", points: [], ...}
var first_series = series[0] var first_series = series[0]
assert.equal(first_series.metric, "metrics.send.counter"); assert.equal(first_series.metric, "metrics.send.counter");
assert(first_series.hasOwnProperty("type")); assert(first_series.hasOwnProperty("type"));
assert.equal(first_series.type, "counter");
assert.equal(first_series.type, "count");
}); });
it("should properly set convert metric_type to type", function(){ it("should properly set convert metric_type to type", function(){
// Make our api call // Make our api call
metric.send("metrics.send.counter", 5, {metric_type: "counter"});
metric.send("metrics.send.counter", 5, {metric_type: "count"});
// Assert we called `client.request` with the correct `points` // Assert we called `client.request` with the correct `points`
assert(stub_request.calledOnce); assert(stub_request.calledOnce);
@ -176,11 +176,11 @@ describe("api/metrics", function(){
assert.equal(series.length, 1); assert.equal(series.length, 1);
// Assert the first series is properly formatted // Assert the first series is properly formatted
// first_series = {metric: "", type: "counter", points: [], ...}
// first_series = {metric: "", type: "count", points: [], ...}
var first_series = series[0] var first_series = series[0]
assert.equal(first_series.metric, "metrics.send.counter"); assert.equal(first_series.metric, "metrics.send.counter");
assert(first_series.hasOwnProperty("type")); assert(first_series.hasOwnProperty("type"));
assert.equal(first_series.type, "counter");
assert.equal(first_series.type, "count");
}); });
}); });
@ -280,7 +280,7 @@ describe("api/metrics", function(){
{ {
metric: "metric.send.counter", metric: "metric.send.counter",
points: 5, points: 5,
type: "counter"
type: "count"
} }
]; ];
metric.send_all(metrics); metric.send_all(metrics);
@ -293,7 +293,7 @@ describe("api/metrics", function(){
assert.equal(call_args[1], "/series"); assert.equal(call_args[1], "/series");
// Properly formatted body // Properly formatted body
// { body: series: [ {metric: "metric.send.counter", host: undefined, tags: undefined, type: "counter"} ] }
// { body: series: [ {metric: "metric.send.counter", host: undefined, tags: undefined, type: "count"} ] }
// DEV: host/tags are optional and should be undefined for this case // DEV: host/tags are optional and should be undefined for this case
var data = call_args[2]; var data = call_args[2];
assert(data.hasOwnProperty("body")); assert(data.hasOwnProperty("body"));
@ -306,11 +306,11 @@ describe("api/metrics", function(){
assert.equal(series.length, 1); assert.equal(series.length, 1);
// Assert the first series is properly formatted // Assert the first series is properly formatted
// first_series = {metric: "", type: "counter", points: [], ...}
// first_series = {metric: "", type: "count", points: [], ...}
var first_series = series[0] var first_series = series[0]
assert.equal(first_series.metric, "metric.send.counter"); assert.equal(first_series.metric, "metric.send.counter");
assert(Array.isArray(first_series.points)); assert(Array.isArray(first_series.points));
assert.deepEqual(first_series.type, "counter");
assert.deepEqual(first_series.type, "count");
}); });
it("should properly send metric_type as type", function(){ it("should properly send metric_type as type", function(){
@ -319,7 +319,7 @@ describe("api/metrics", function(){
{ {
metric: "metric.send.counter", metric: "metric.send.counter",
points: 5, points: 5,
metric_type: "counter"
metric_type: "count"
} }
]; ];
metric.send_all(metrics); metric.send_all(metrics);
@ -332,7 +332,7 @@ describe("api/metrics", function(){
assert.equal(call_args[1], "/series"); assert.equal(call_args[1], "/series");
// Properly formatted body // Properly formatted body
// { body: series: [ {metric: "metric.send.counter", host: undefined, tags: undefined, type: "counter"} ] }
// { body: series: [ {metric: "metric.send.counter", host: undefined, tags: undefined, type: "count"} ] }
// DEV: host/tags are optional and should be undefined for this case // DEV: host/tags are optional and should be undefined for this case
var data = call_args[2]; var data = call_args[2];
assert(data.hasOwnProperty("body")); assert(data.hasOwnProperty("body"));
@ -345,11 +345,11 @@ describe("api/metrics", function(){
assert.equal(series.length, 1); assert.equal(series.length, 1);
// Assert the first series is properly formatted // Assert the first series is properly formatted
// first_series = {metric: "", type: "counter", points: [], ...}
// first_series = {metric: "", type: "count", points: [], ...}
var first_series = series[0] var first_series = series[0]
assert.equal(first_series.metric, "metric.send.counter"); assert.equal(first_series.metric, "metric.send.counter");
assert(Array.isArray(first_series.points)); assert(Array.isArray(first_series.points));
assert.deepEqual(first_series.type, "counter");
assert.deepEqual(first_series.type, "count");
}); });
}); });
}); });

Loading…
Cancel
Save