0.95.14-2 • Published 4 years ago

swagger-stats-ext v0.95.14-2

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

swagger-stats-ext

fork from https://github.com/slanatech/swagger-stats

More Features

call init manually

import * as swStats from 'swagger-stats-ext'
swStats.init(promConf)

koa middleware, not use express-to-koa

import * as swStats from 'swagger-stats-ext'
const app = new Koa()

app.use(swStats.koaMiddleware())

report calls bewtween modules based on http protocol manually

add metric data for prometheus, "mcall_request_total" labeled

# HELP mcall_request_total The total number of all mcall based on http protocol requests
# TYPE mcall_request_total counter
mcall_request_total{service="user",method="GET",path="/info/get",http_status_code="400",code="0"} 1
import * as swStats from 'swagger-stats-ext'
swStats.reportMCall('user', 'GET', '/info/get', 200, 0)

params for reportMCall

nameoptionaldefaultcomments
serviceNmodule name
methodNhttp method(GET/POST)
pathNhttp path
http_codeNhttp status code
codeY0code returned by module

more settings

const promConf = {
  pm2: false, // use pm2 for node server
  pathProm: '/prometheus', // add route like: "ip:port/{pathProm}",return prometheus metrics data
  // ...
}