зеркало из https://github.com/microsoft/statsd.git
Merge pull request #292 from etsy/mgmt_console_patch
cleanup whitespace and small tweaks
This commit is contained in:
Коммит
d16d744e64
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete_stats - delete all matching statistics
|
* delete_stats - delete all matching statistics
|
||||||
*
|
*
|
||||||
* Side effect notes: this function works by altering stats_type in place,
|
* Side effect notes: this function works by altering stats_type in place,
|
||||||
* and calls stream.write(str) to display user feedback.
|
* and calls stream.write(str) to display user feedback.
|
||||||
*
|
*
|
||||||
* @param stats_type array of all statistics of this type (eg~ timers) to delete from
|
* @param stats_type array of all statistics of this type (eg~ timers) to delete from
|
||||||
* @param cmdline array of all requested deletions, which can be fully qualified,
|
* @param cmdline array of all requested deletions, which can be fully qualified,
|
||||||
* or end in a .* to delete a folder, like stats.temp.*
|
* or end in a .* to delete a folder, like stats.temp.*
|
||||||
|
@ -14,15 +14,15 @@ exports.delete_stats = function(stats_type, cmdline, stream) {
|
||||||
|
|
||||||
//for each metric requested on the command line
|
//for each metric requested on the command line
|
||||||
for (var index in cmdline) {
|
for (var index in cmdline) {
|
||||||
|
|
||||||
//get a list of deletable metrics that match the request
|
//get a list of deletable metrics that match the request
|
||||||
deletable = existing_stats(stats_type, cmdline[index]);
|
deletable = existing_stats(stats_type, cmdline[index]);
|
||||||
|
|
||||||
//warn if no matches
|
//warn if no matches
|
||||||
if (deletable.length == 0) {
|
if (deletable.length === 0) {
|
||||||
stream.write("metric " + cmdline[index] + " not found\n");
|
stream.write("metric " + cmdline[index] + " not found\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete all requested metrics
|
//delete all requested metrics
|
||||||
for (var del_idx in deletable) {
|
for (var del_idx in deletable) {
|
||||||
delete stats_type[deletable[del_idx]];
|
delete stats_type[deletable[del_idx]];
|
||||||
|
@ -30,20 +30,20 @@ exports.delete_stats = function(stats_type, cmdline, stream) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream.write("END\n\n");
|
stream.write("END\n\n");
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* existing_stats - find fully qualified matches for the requested stats bucket
|
* existing_stats - find fully qualified matches for the requested stats bucket
|
||||||
*
|
*
|
||||||
* @param stats_type array of all statistics of this type (eg~ timers) to match
|
* @param stats_type array of all statistics of this type (eg~ timers) to match
|
||||||
* @param bucket string to search on, which can be fully qualified,
|
* @param bucket string to search on, which can be fully qualified,
|
||||||
* or end in a .* to search for a folder, like stats.temp.*
|
* or end in a .* to search for a folder, like stats.temp.*
|
||||||
*
|
*
|
||||||
* @return array of fully qualified stats that match the specified bucket. if
|
* @return array of fully qualified stats that match the specified bucket. if
|
||||||
* no matches, an empty array is a valid response
|
* no matches, an empty array is a valid response
|
||||||
*/
|
*/
|
||||||
function existing_stats(stats_type, bucket){
|
function existing_stats(stats_type, bucket){
|
||||||
matches = []
|
matches = [];
|
||||||
|
|
||||||
//typical case: one-off, fully qualified
|
//typical case: one-off, fully qualified
|
||||||
if (bucket in stats_type) {
|
if (bucket in stats_type) {
|
||||||
|
@ -53,7 +53,7 @@ function existing_stats(stats_type, bucket){
|
||||||
//special case: match a whole 'folder' (and subfolders) of stats
|
//special case: match a whole 'folder' (and subfolders) of stats
|
||||||
if (bucket.slice(-2) == ".*") {
|
if (bucket.slice(-2) == ".*") {
|
||||||
var folder = bucket.slice(0,-1);
|
var folder = bucket.slice(0,-1);
|
||||||
|
|
||||||
for (var name in stats_type) {
|
for (var name in stats_type) {
|
||||||
//check if stat is in bucket, ie~ name starts with folder
|
//check if stat is in bucket, ie~ name starts with folder
|
||||||
if (name.substring(0, folder.length) == folder) {
|
if (name.substring(0, folder.length) == folder) {
|
||||||
|
@ -61,7 +61,7 @@ function existing_stats(stats_type, bucket){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче