Skip to content

Commit

Permalink
More error and callback doc info
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Deitte committed Jan 10, 2016
1 parent 8488a19 commit 456e9c7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ The event method has the following API:
var StatsD = require('hot-shots'),
client = new StatsD();

// Catch socket errors so they don't go unhandled, as explained
// in the Errors section below
client.socket.on('error', function(error) {
console.error("Error in socket: ", error);
});

// Timing: sends a timing command with the specified milliseconds
client.timing('response_time', 42);

Expand Down Expand Up @@ -91,7 +97,8 @@ The event method has the following API:
// Tags, this will add user-defined tags to the data (DataDog and Telegraf only)
client.histogram('my_histogram', 42, ['foo', 'bar']);

// Using the callback
// Using the callback. This is the same format for the callback
// with all non-close calls
client.set(['foo', 'bar'], 42, function(error, bytes){
//this only gets called once after all messages have been sent
if(error){
Expand Down Expand Up @@ -134,7 +141,7 @@ In the event that there is a socket error, `hot-shots` will allow this error to

```javascript
client.socket.on('error', function(error) {
return console.error("Error in socket: ", error);
console.error("Error in socket: ", error);
});
```

Expand Down

0 comments on commit 456e9c7

Please sign in to comment.