-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: statful-middleware-koa implementation
- Loading branch information
Showing
14 changed files
with
6,360 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
coverage | ||
.history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8.11.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.