Skip to content

Commit

Permalink
feat: statful-middleware-koa implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmtavares committed Jul 12, 2018
1 parent 8b0d3b1 commit 1fd60a7
Show file tree
Hide file tree
Showing 14 changed files with 6,360 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
.history
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.11.3
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js

node_js:
- "8.11.3"
- "node"

install:
- npm install

notifications:
email: false
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Statful

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
![statful](https://avatars1.githubusercontent.com/u/20299158?v=3&s=200)
![koa](https://github.com/koajs/koa/raw/master/docs/logo.png)

# statful-middleware-koa
Middleware for Koa servers to gather and send metrics to Statful.

A common pattern in koa applications it to gather response times from all received requests, this middleware takes care of collecting common useful metrics automatically.

[![npm version](https://badge.fury.io/js/statful-middleware-koa.svg)](https://badge.fury.io/js/statful-middleware-koa) [![Build Status](https://travis-ci.org/statful/statful-middleware-koa.svg?branch=master)](https://travis-ci.org/statful/statful-middleware-koa)

## Installing

```shell
npm install --save statful-middleware-koa statful-client
```

```shell
yarn add statful-middleware-koa statful-client
```

## Getting started

```js
const Koa = require("koa");
const app = new Koa();
const Statful = require("statful-client");
const statfulMiddleware = require("statful-middleware-koa");

const statful = new Statful({
/* statful configuration */
});

app.use(statfulMiddleware(statful));
app.listen(3000);
```

## Configuration

Most of the configuration is done directly in the statful instance. You can read more about the available options directly from the [Statful repository](https://github.com/statful/statful-client-nodejs#global-configuration).

## Default Metrics

By default, the follow metrics are collected, with the corresponding tags:

- `response_time`
- `hostname`,
- `method`: `GET`, `POST`, `PUT`...
- `statusCode`: 200, 400, 404 ...
- `route`: Either the route handler's name, the route path or `unknown_route`. e.g.: `/users/:id?`

## Authors

[Mindera - Software Craft](https://github.com/Mindera)

## License

statful-middleware-koa is available under the MIT license. See the [LICENSE](https://raw.githubusercontent.com/statful/statful-middleware-koa/master/LICENSE.md) file for more information.
Loading

0 comments on commit 1fd60a7

Please sign in to comment.