fastify-metrics
Advanced tools
Comparing version 4.0.9 to 5.0.0
@@ -5,2 +5,13 @@ # Changelog | ||
## [5.0.0](https://gitlab.com/m03geek/fastify-metrics/compare/v4.0.7...v5.0.0) (2020-02-26) | ||
### ⚠ BREAKING CHANGES | ||
* new default metrics and types (see prom-client v12 release notes) | ||
### Features | ||
* update to prom-client v12 ([6d4d949](https://gitlab.com/m03geek/fastify-metrics/commit/6d4d949b94c6156655812ff6e5bf8d6ed6fa83ea)) | ||
### [4.0.7](https://gitlab.com/m03geek/fastify-metrics/compare/v4.0.6...v4.0.7) (2019-10-11) | ||
@@ -7,0 +18,0 @@ |
/// <reference types="node" /> | ||
/// <reference types="dist" /> | ||
import { FastifyInstance } from 'fastify'; | ||
import * as http from 'http'; | ||
import { labelValues } from 'prom-client'; | ||
import { LabelValues } from 'prom-client'; | ||
import { PluginOptions, FastifyMetrics } from './plugin'; | ||
declare module 'fastify' { | ||
interface FastifyInstance< | ||
HttpServer = http.Server, | ||
HttpRequest = http.IncomingMessage, | ||
HttpResponse = http.ServerResponse | ||
> { | ||
/** | ||
* Metrics interface | ||
*/ | ||
metrics: FastifyMetrics; | ||
} | ||
interface RouteSchema { | ||
/** | ||
* Hides metric route from swagger/openapi documentation | ||
*/ | ||
hide?: boolean; | ||
} | ||
interface FastifyRequest<HttpRequest, Query, Params, Headers, Body> { | ||
metrics?: { | ||
/** | ||
* Request duration histogram | ||
* @param labels metric labels | ||
*/ | ||
hist: (labels?: labelValues) => void; | ||
/** | ||
* Request duration summary by quantiles | ||
* @param labels metric labels | ||
*/ | ||
sum: (labels?: labelValues) => void; | ||
}; | ||
} | ||
interface FastifyInstance<HttpServer = http.Server, HttpRequest = http.IncomingMessage, HttpResponse = http.ServerResponse> { | ||
/** | ||
* Metrics interface | ||
*/ | ||
metrics: FastifyMetrics; | ||
} | ||
interface RouteSchema { | ||
/** | ||
* Hides metric route from swagger/openapi documentation | ||
*/ | ||
hide?: boolean; | ||
} | ||
interface FastifyRequest<HttpRequest, Query, Params, Headers, Body> { | ||
metrics?: { | ||
/** | ||
* Request duration histogram | ||
* @param labels metric labels | ||
*/ | ||
hist: (labels?: LabelValues<string>) => void; | ||
/** | ||
* Request duration summary by quantiles | ||
* @param labels metric labels | ||
*/ | ||
sum: (labels?: LabelValues<string>) => void; | ||
}; | ||
} | ||
} | ||
declare const _default: ( | ||
instance: FastifyInstance< | ||
http.Server, | ||
http.IncomingMessage, | ||
http.ServerResponse | ||
>, | ||
options: PluginOptions, | ||
callback: (err?: import('fastify').FastifyError | undefined) => void | ||
) => void; | ||
declare const _default: (instance: FastifyInstance<http.Server, http.IncomingMessage, http.ServerResponse>, options: PluginOptions, callback: (err?: import("fastify").FastifyError | undefined) => void) => void; | ||
export = _default; | ||
//# sourceMappingURL=index.d.ts.map | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
*/ | ||
const fastifyMetricsPlugin = function fastifyMetrics(fastify, { enableDefaultMetrics = true, groupStatusCodes = false, pluginName = 'metrics', interval = 5000, blacklist, register, prefix, endpoint, metrics = {}, } = {}, next) { | ||
const fastifyMetricsPlugin = function fastifyMetrics(fastify, { enableDefaultMetrics = true, groupStatusCodes = false, pluginName = 'metrics', blacklist, register, prefix, endpoint, metrics = {} } = {}, next) { | ||
const plugin = { client: prom_client_1.default }; | ||
@@ -31,5 +31,3 @@ if (enableDefaultMetrics) { | ||
}; | ||
const defaultOpts = { | ||
timeout: interval, | ||
}; | ||
const defaultOpts = {}; | ||
const opts = { | ||
@@ -40,3 +38,3 @@ histogram: { | ||
labelNames: ['status_code', 'method', 'route'], | ||
buckets: [0.05, 0.1, 0.5, 1, 3, 5, 10], | ||
buckets: [0.05, 0.1, 0.5, 1, 3, 5, 10] | ||
}, | ||
@@ -47,4 +45,4 @@ summary: { | ||
labelNames: ['status_code', 'method', 'route'], | ||
percentiles: [0.5, 0.9, 0.95, 0.99], | ||
}, | ||
percentiles: [0.5, 0.9, 0.95, 0.99] | ||
} | ||
}; | ||
@@ -64,3 +62,3 @@ if (register) { | ||
.filter(opts.hasOwnProperty.bind(opts)) | ||
.forEach((key) => { | ||
.forEach(key => { | ||
Object.assign(opts[key], metrics[key]); | ||
@@ -81,3 +79,3 @@ }); | ||
reply.type('text/plain').send(data); | ||
}, | ||
} | ||
}); | ||
@@ -89,3 +87,3 @@ } | ||
hist: routeHist.startTimer(), | ||
sum: routeSum.startTimer(), | ||
sum: routeSum.startTimer() | ||
}; | ||
@@ -108,3 +106,3 @@ } | ||
route: routeId, | ||
status_code: statusCode, | ||
status_code: statusCode | ||
}); | ||
@@ -114,3 +112,3 @@ request.metrics.hist({ | ||
route: routeId, | ||
status_code: statusCode, | ||
status_code: statusCode | ||
}); | ||
@@ -126,4 +124,4 @@ } | ||
fastify: '>=2.0.0', | ||
name: 'fastify-metrics', | ||
name: 'fastify-metrics' | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -55,7 +55,2 @@ import promClient from 'prom-client'; | ||
/** | ||
* Metrics collection interval in ms | ||
* @default 5000 | ||
*/ | ||
interval?: number; | ||
/** | ||
* Routes blacklist that will be excluded from metrics collection | ||
@@ -62,0 +57,0 @@ */ |
{ | ||
"name": "fastify-metrics", | ||
"version": "4.0.9", | ||
"version": "5.0.0", | ||
"description": "Prometheus metrics exporter for Fastify", | ||
@@ -34,3 +34,3 @@ "main": "dist/index.js", | ||
"prerelease": "npm run typedoc", | ||
"release": "git add -A && standard-version -A", | ||
"release": "git add -A && standard-version -a", | ||
"typedoc": "rm -rf ./docs/* && typedoc --excludeExternals --name \"$npm_package_name\" --readme none --mode file --includeDeclarations --theme markdown --out ./docs" | ||
@@ -55,18 +55,18 @@ }, | ||
"fastify-plugin": "^1.6.0", | ||
"prom-client": "^11.5.3" | ||
"prom-client": "^12.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^24.0.18", | ||
"@types/node": "^12.7.12", | ||
"@types/jest": "^25.0.0", | ||
"@types/node": "^13.0.0", | ||
"eslint": "^6.5.1", | ||
"eslint-config-google": "^0.14.0", | ||
"fastify": "^2.9.0", | ||
"jest": "^24.9.0", | ||
"jest": "^25.0.0", | ||
"replace": "^1.1.1", | ||
"standard-version": "^7.0.0", | ||
"ts-jest": "^24.1.0", | ||
"ts-jest": "^25.0.0", | ||
"ts-node": "^8.4.1", | ||
"tslint": "^5.20.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typedoc": "^0.15.0", | ||
"typedoc": "^0.16.0", | ||
"typedoc-plugin-markdown": "^2.2.10", | ||
@@ -73,0 +73,0 @@ "typescript": "^3.6.4" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22881
228
+ Addedprom-client@12.0.0(transitive)
- Removedprom-client@11.5.3(transitive)
Updatedprom-client@^12.0.0