Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hot-shots

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hot-shots - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

CHANGES.md~

12

CHANGES.md

@@ -8,4 +8,10 @@ CHANGELOG

## 3.1.0 (2015-5-3)
* @ash2k Support a client-wide error handler used in case no callback is provided and to handle various exceptions.
## 3.0.1 (2015-4-28)
* @bdeitte Add 'use strict' to files and make changes needed for this.
## 3.0.0 (2015-4-27)
* @ash2k Method to create child clients
* @ash2k Method to create child clients. (This is not a backwards-incompatible change but is rather large.)
* @ash2k Shrink npm package a bit more

@@ -41,4 +47,4 @@

## 2.0.0 (2015-10-22)
* @jjofseattle Add options.maxBufferSize and optinons.bufferFlushInterval
* @bdeitte Change options.global_tags to options.globalTags for conistency
* @jjofseattle Add options.maxBufferSize and options.bufferFlushInterval
* @bdeitte Change options.global_tags to options.globalTags for consistency

@@ -45,0 +51,0 @@ ## 1.0.2 (2015-09-25)

@@ -0,1 +1,3 @@

"use strict";
var dgram = require('dgram'),

@@ -16,2 +18,3 @@ util = require('util'),

* @option globalTags {Array=} Optional tags that will be added to every metric
* @option errorHandler {Function=} Optional function to handle errors when callback is not provided
* @maxBufferSize {Number} An optional value for aggregating metrics to send, mainly for performance improvement

@@ -21,3 +24,4 @@ * @bufferFlushInterval {Number} the time out value to flush out buffer if not

*/
var Client = function (host, port, prefix, suffix, globalize, cacheDns, mock, globalTags, maxBufferSize, bufferFlushInterval, telegraf) {
var Client = function (host, port, prefix, suffix, globalize, cacheDns, mock,
globalTags, maxBufferSize, bufferFlushInterval, telegraf) {
var options = host || {},

@@ -53,2 +57,3 @@ self = this;

this.bufferHolder = options.isChild ? options.bufferHolder : { buffer: "" };
this.errorHandler = options.errorHandler;

@@ -178,2 +183,6 @@ // We only want a single flush event per parent and all its child clients

}
else if (this.errorHandler) {
return this.errorHandler(err);
}
throw err;

@@ -252,3 +261,3 @@ }

completed += 1;
if(calledback || typeof callback !== 'function'){
if(calledback){
return;

@@ -258,8 +267,15 @@ }

if(error){
calledback = true;
return callback(error);
if (typeof callback === 'function') {
calledback = true;
callback(error);
}
else if (self.errorHandler) {
calledback = true;
self.errorHandler(error);
}
return;
}
sentBytes += bytes;
if(completed === stat.length){
if(completed === stat.length && typeof callback === 'function'){
callback(null, sentBytes);

@@ -295,3 +311,3 @@ }

//don't want to send if we don't meet the sample ratio
return callback();
return callback ? callback() : undefined;
}

@@ -306,3 +322,3 @@ }

* @param tags {Array} The tags to include (along with global tags). Optional.
* @param callback {Function=} Callback when message is done being delivered. Optional.
* @param callback {Function=} Callback when message is done being delivered (only if maxBufferSize == 0). Optional.
*/

@@ -316,2 +332,5 @@ Client.prototype.send = function (message, tags, callback) {

}
else if (this.errorHandler) {
return this.errorHandler(this.dnsError);
}
throw this.dnsError;

@@ -382,2 +401,10 @@ }

Client.prototype.sendMessage = function(message, callback){
// Guard against "RangeError: Offset into buffer too large" in node 0.10
// https://github.com/nodejs/node-v0.x-archive/issues/7884
if (message === "") {
if (callback) {
callback(null);
}
return;
}
var buf = new Buffer(message);

@@ -392,2 +419,5 @@ try {

}
else if (this.errorHandler) {
this.errorHandler(new Error(errMessage));
}
else {

@@ -403,5 +433,3 @@ console.log(errMessage);

Client.prototype.onBufferFlushInterval = function() {
if(this.bufferHolder.buffer !== "") {
this.flushQueue();
}
this.flushQueue();
};

@@ -417,5 +445,3 @@

if(this.bufferHolder.buffer.length >= 0) {
this.flushQueue();
}
this.flushQueue();

@@ -436,2 +462,5 @@ if (callback) {

}
else if (this.errorHandler) {
this.errorHandler(new Error(errMessage));
}
else {

@@ -443,13 +472,2 @@ console.log(errMessage);

/**
* Creates a child client that adds prefix, suffix and/or tags to this client. Child client can itself have children.
* @param options
* @option prefix {String} An optional prefix to assign to each stat name sent
* @option suffix {String} An optional suffix to assign to each stat name sent
* @option globalTags {Array=} Optional tags that will be added to every metric
*/
Client.prototype.childClient = function(options) {
return new ChildClient(this, options);
};
var ChildClient = function (parent, options) {

@@ -463,2 +481,3 @@ options = options || {};

dnsError : parent.dnsError, // Child inherits an error from parent (if it is there)
errorHandler: options.errorHandler || parent.errorHandler, // Handler for callback errors

@@ -480,3 +499,14 @@ host : parent.host,

/**
* Creates a child client that adds prefix, suffix and/or tags to this client. Child client can itself have children.
* @param options
* @option prefix {String} An optional prefix to assign to each stat name sent
* @option suffix {String} An optional suffix to assign to each stat name sent
* @option globalTags {Array=} Optional tags that will be added to every metric
*/
Client.prototype.childClient = function(options) {
return new ChildClient(this, options);
};
exports = module.exports = Client;
exports.StatsD = Client;
{
"name": "hot-shots",
"description": "Node.js client for StatsD, DogStatsD, and Telegraf",
"version": "3.0.0",
"version": "3.1.0",
"author": "Steve Ivy",
"contributors": [
"Russ Bradberry <rbradberry@gmail.com>",
"Brian Deitte <bdeitte@gmail.com>"
"Brian Deitte <bdeitte@gmail.com>",
"Mikhail Mazurskiy <mikhail.mazursky@gmail.com>"
],

@@ -10,0 +11,0 @@ "keywords": [

@@ -31,2 +31,3 @@ # hot-shots

* `telegraf`: Use Telegraf's StatsD line protocol, which is slightly different than the rest `default: false`
* `errorHandler`: A function with one argument. It is called to handle various errors. `default: none`, errors are thrown/logger to console

@@ -33,0 +34,0 @@ All StatsD methods other than event and close have the same API:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc