You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@bbc/http-transport-statsd

Package Overview
Dependencies
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbc/http-transport-statsd - npm Package Compare versions

Comparing version

to
2.0.0

test/mocha.opts

32

lib/stats.js

@@ -12,19 +12,19 @@ 'use strict';

module.exports = (stats, statsName, feedName) => {
return (ctx, next) => {
return next()
.catch((err) => {
stats.increment(`${createStatsName(statsName, feedName)}.request_errors`);
stats.timing(`${createStatsName(statsName, feedName)}.attempts`, ctx.res.retries.length + 1);
throw err;
})
.then(() => {
stats.increment(`${createStatsName(statsName, feedName)}.requests`);
stats.increment(`${createStatsName(statsName, feedName)}.responses.${ctx.res.statusCode}`);
stats.timing(`${createStatsName(statsName, feedName)}.response_time`, ctx.res.elapsedTime);
stats.timing(`${createStatsName(statsName, feedName)}.attempts`, ctx.res.retries.length + 1);
ctx.res.retries.forEach(() => {
return stats.increment(`${createStatsName(statsName, feedName)}.retries`);
});
});
return async (ctx, next) => {
try {
await next();
} catch (err) {
stats.increment(`${createStatsName(statsName, feedName)}.request_errors`);
stats.timing(`${createStatsName(statsName, feedName)}.attempts`, ctx.retryAttempts.length + 1);
throw err;
}
stats.increment(`${createStatsName(statsName, feedName)}.requests`);
stats.increment(`${createStatsName(statsName, feedName)}.responses.${ctx.res.statusCode}`);
stats.timing(`${createStatsName(statsName, feedName)}.response_time`, ctx.res.elapsedTime);
stats.timing(`${createStatsName(statsName, feedName)}.attempts`, ctx.retryAttempts.length + 1);
ctx.retryAttempts.forEach(() => {
return stats.increment(`${createStatsName(statsName, feedName)}.retries`);
});
};
};
{
"name": "@bbc/http-transport-statsd",
"version": "1.0.0",
"version": "2.0.0",
"description": "Provides stats for statsD ",

@@ -20,3 +20,3 @@ "main": "index.js",

"engines": {
"node": ">=4.0.0"
"node": ">=8.0.0"
},

@@ -34,6 +34,6 @@ "keywords": [

"devDependencies": {
"@bbc/http-transport": "0.0.1",
"@bbc/http-transport": "^3.0.0",
"chai": "^4.1.2",
"eslint": "^2.4.0",
"eslint-config-iplayer-es6": "^1.3.0",
"eslint": "^4.11.0",
"eslint-config-iplayer-es6": "^3.1.1",
"istanbul": "^0.4.1",

@@ -46,4 +46,7 @@ "lodash": "^4.17.4",

"eslintConfig": {
"extends": "iplayer-es6"
"extends": "iplayer-es6",
"parserOptions": {
"ecmaVersion": 2017
}
}
}

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

[![Build Status](https://travis-ci.org/bbc/http-transport-statsd.svg)](https://travis-ci.org/bbc/http-transport-statsd) [![Coverage Status](https://coveralls.io/repos/github/bbc/http-transport-statsd/badge.svg?branch=master)](https://coveralls.io/github/bbc/http-transport-statsd?branch=master)
# http-transport-statsd

@@ -21,3 +19,3 @@

```
npm install --save http-transport-statsd
npm install --save @bbc/http-transport-statsd
```

@@ -30,4 +28,4 @@

const url = 'http://example.com/';
const HttpTransport = require('http-transport');
const sendStats = require('http-transport-statsd');
const HttpTransport = require('@bbc/http-transport');
const sendStats = require('@bbc/http-transport-statsd');
const StatsD = require('node-statsd');

@@ -37,3 +35,3 @@ const statsD = new StatsD();

HttpTransport.createClient()
.useGlobal(sendStats(statsd))
.use(sendStats(statsd)) // send stats for this request
.get(url)

@@ -40,0 +38,0 @@ .asBody()

Sorry, the diff of this file is not supported yet