@immobiliarelabs/fastify-metrics
Advanced tools
Comparing version 5.1.1 to 6.0.0
@@ -43,9 +43,9 @@ 'use strict'; | ||
exports.getLabel = function (request) { | ||
const fastifyPrefix = request.routeConfig.metrics.fastifyPrefix | ||
? `${request.routeConfig.metrics.fastifyPrefix}.` | ||
: request.routeConfig.metrics.fastifyPrefix; | ||
const routePrefix = request.routeConfig.metrics.routesPrefix | ||
? `${request.routeConfig.metrics.routesPrefix}.` | ||
: request.routeConfig.metrics.routesPrefix; | ||
return `${fastifyPrefix}${routePrefix}${request.routeConfig.metrics.routeId}`; | ||
const fastifyPrefix = request.routeOptions.config.metrics.fastifyPrefix | ||
? `${request.routeOptions.config.metrics.fastifyPrefix}.` | ||
: request.routeOptions.config.metrics.fastifyPrefix; | ||
const routePrefix = request.routeOptions.config.metrics.routesPrefix | ||
? `${request.routeOptions.config.metrics.routesPrefix}.` | ||
: request.routeOptions.config.metrics.routesPrefix; | ||
return `${fastifyPrefix}${routePrefix}${request.routeOptions.config.metrics.routeId}`; | ||
}; |
@@ -38,7 +38,7 @@ 'use strict'; | ||
return function () { | ||
return this.request.routeConfig.metrics[kMetricsLabel]; | ||
return this.request.routeOptions.config.metrics[kMetricsLabel]; | ||
}; | ||
} | ||
return function () { | ||
return this.routeConfig.metrics[kMetricsLabel]; | ||
return this.routeOptions.config.metrics[kMetricsLabel]; | ||
}; | ||
@@ -45,0 +45,0 @@ }, |
'use strict'; | ||
exports.shouldSkip = (requestOrReply) => { | ||
return requestOrReply.routeConfig | ||
return requestOrReply?.routeOptions?.config | ||
? !( | ||
requestOrReply.routeConfig && | ||
requestOrReply.routeConfig.metrics && | ||
requestOrReply.routeConfig.metrics.routeId | ||
requestOrReply.routeOptions.config && | ||
requestOrReply.routeOptions.config.metrics && | ||
requestOrReply.routeOptions.config.metrics.routeId | ||
) | ||
: !( | ||
requestOrReply.request.routeConfig && | ||
requestOrReply.request.routeConfig.metrics && | ||
requestOrReply.request.routeConfig.metrics.routeId | ||
requestOrReply.request.routeOptions.config && | ||
requestOrReply.request.routeOptions.config.metrics && | ||
requestOrReply.request.routeOptions.config.metrics.routeId | ||
); | ||
}; |
{ | ||
"name": "@immobiliarelabs/fastify-metrics", | ||
"version": "5.1.1", | ||
"version": "6.0.0", | ||
"description": "A minimalistic and opinionated Fastify plugin that collects metrics and dispatches them to statsd", | ||
@@ -54,30 +54,30 @@ "main": "index.js", | ||
"@semantic-release/changelog": "^6.0.0", | ||
"@semantic-release/commit-analyzer": "^9.0.1", | ||
"@semantic-release/commit-analyzer": "^10.0.1", | ||
"@semantic-release/git": "^10.0.0", | ||
"@semantic-release/github": "^8.0.1", | ||
"@semantic-release/github": "^9.0.3", | ||
"@semantic-release/npm": "^10.0.3", | ||
"@semantic-release/release-notes-generator": "^10.0.2", | ||
"@types/node": "^18.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"@semantic-release/release-notes-generator": "^11.0.4", | ||
"@types/node": "^20.4.1", | ||
"@typescript-eslint/eslint-plugin": "^6.1.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"autocannon": "^7.0.0", | ||
"concurrently": "^8.0.1", | ||
"eslint": "^8.0.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"fastify": "^4.2.1", | ||
"eslint-plugin-prettier": "^5.0.0-alpha.2", | ||
"fastify": "^4.25.1", | ||
"husky": "^8.0.0", | ||
"is-ci": "^3.0.0", | ||
"lint-staged": "^13.0.0", | ||
"lint-staged": "^14.0.1", | ||
"markdown-toc": "^1.2.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.0.5", | ||
"prettier": "^3.0.0", | ||
"sinon": "^15.0.0", | ||
"tap": "^16.0.0", | ||
"tsd": "^0.28.1", | ||
"tsd": "^0.29.0", | ||
"typescript": "^5.0.4" | ||
}, | ||
"dependencies": { | ||
"@dnlup/doc": "^3.1.0", | ||
"@dnlup/doc": "^5.0.2", | ||
"@dnlup/hrtime-utils": "^1.0.1", | ||
@@ -84,0 +84,0 @@ "@immobiliarelabs/dats": "^5.0.0", |
@@ -23,45 +23,44 @@ <p align="center"><img src="./logo.png" alt="logo" width="250px" /></p> | ||
- [Fastify Version Support](#fastify-version-support) | ||
* [Fastify Version Support](#fastify-version-support) | ||
- [Installation](#installation) | ||
* [`npm`](#npm) | ||
* [`yarn`](#yarn) | ||
- [Migrating from version 1](#migrating-from-version-1) | ||
- [Usage](#usage) | ||
- [Route Configuration](#route-configuration) | ||
* [Note](#note) | ||
- [Metrics collected](#metrics-collected) | ||
- [Decorators](#decorators) | ||
* [Fastify decorators](#fastify-decorators) | ||
+ [`metrics`](#metrics) | ||
- [`metrics.namespace`](#metricsnamespace) | ||
- [`metrics.fastifyPrefix`](#metricsfastifyprefix) | ||
- [`metrics.routesPrefix`](#metricsroutesprefix) | ||
- [`metrics.client`](#metricsclient) | ||
- [`metrics.sampler`](#metricssampler) | ||
- [`metrics.hrtime2us`](#metricshrtime2us) | ||
- [`metrics.hrtime2ns`](#metricshrtime2ns) | ||
- [`metrics.hrtime2ms`](#metricshrtime2ms) | ||
- [`metrics.hrtime2s`](#metricshrtime2s) | ||
* [Request and Reply decorators](#request-and-reply-decorators) | ||
+ [`getMetricLabel()`](#getmetriclabel) | ||
+ [`sendTimingMetric(name[, value])`](#sendtimingmetricname-value) | ||
+ [`sendCounterMetric(name[, value])`](#sendcountermetricname-value) | ||
+ [`sendGaugeMetric(name, value)`](#sendgaugemetricname-value) | ||
+ [`sendSetMetric(name, value)`](#sendsetmetricname-value) | ||
- [Hooks](#hooks) | ||
- [Request and Reply routeConfig](#request-and-reply-routeconfig) | ||
- [API](#api) | ||
* [Configuration `options`](#configuration-options) | ||
* [Routes labels generation modes](#routes-labels-generation-modes) | ||
- [computedPrefix](#computedprefix) | ||
+ [`static` mode](#static-mode) | ||
- [`getLabel(options)`](#getlabeloptions) | ||
+ [`dynamic` mode](#dynamic-mode) | ||
- [`getLabel(request, reply)`](#getlabelrequest-reply) | ||
- [Example](#example) | ||
- [Powered Apps](#powered-apps) | ||
- [Support & Contribute](#support--contribute) | ||
- [License](#license) | ||
* [Installation](#installation) | ||
- [`npm`](#npm) | ||
- [`yarn`](#yarn) | ||
* [Migrating from version 1](#migrating-from-version-1) | ||
* [Usage](#usage) | ||
* [Route Configuration](#route-configuration) | ||
- [Note](#note) | ||
* [Metrics collected](#metrics-collected) | ||
* [Decorators](#decorators) | ||
- [Fastify decorators](#fastify-decorators) | ||
- [`metrics`](#metrics) | ||
- [`metrics.namespace`](#metricsnamespace) | ||
- [`metrics.fastifyPrefix`](#metricsfastifyprefix) | ||
- [`metrics.routesPrefix`](#metricsroutesprefix) | ||
- [`metrics.client`](#metricsclient) | ||
- [`metrics.sampler`](#metricssampler) | ||
- [`metrics.hrtime2us`](#metricshrtime2us) | ||
- [`metrics.hrtime2ns`](#metricshrtime2ns) | ||
- [`metrics.hrtime2ms`](#metricshrtime2ms) | ||
- [`metrics.hrtime2s`](#metricshrtime2s) | ||
- [Request and Reply decorators](#request-and-reply-decorators) | ||
- [`getMetricLabel()`](#getmetriclabel) | ||
- [`sendTimingMetric(name[, value])`](#sendtimingmetricname-value) | ||
- [`sendCounterMetric(name[, value])`](#sendcountermetricname-value) | ||
- [`sendGaugeMetric(name, value)`](#sendgaugemetricname-value) | ||
- [`sendSetMetric(name, value)`](#sendsetmetricname-value) | ||
* [Hooks](#hooks) | ||
* [Request and Reply routeConfig](#request-and-reply-routeconfig) | ||
* [API](#api) | ||
- [Configuration `options`](#configuration-options) | ||
- [Routes labels generation modes](#routes-labels-generation-modes) | ||
- [computedPrefix](#computedprefix) | ||
* [`static` mode](#static-mode) | ||
- [`getLabel(options)`](#getlabeloptions) | ||
* [`dynamic` mode](#dynamic-mode) | ||
- [`getLabel(request, reply)`](#getlabelrequest-reply) | ||
- [Example](#example) | ||
* [Powered Apps](#powered-apps) | ||
* [Support & Contribute](#support--contribute) | ||
* [License](#license) | ||
<!-- tocstop --> | ||
@@ -142,3 +141,3 @@ | ||
The plugin internally uses the `routeId` key in the `metrics` object of the `Request.routeConfig` or `Reply.request.routeConfig` object to build the label of the metric of a route. | ||
The plugin internally uses the `routeId` key in the `metrics` object of the `Request.routeOptions` or `Reply.request.routeOptions` object to build the label of the metric of a route. | ||
@@ -280,3 +279,3 @@ See | ||
The plugin adds a `metrics` object to the `Request.routeConfig` and `Reply.request.routeConfig` for convenience with the following properties: | ||
The plugin adds a `metrics` object to the `Request.routeOptions` and `Reply.request.routeOptions` for convenience with the following properties: | ||
@@ -385,3 +384,3 @@ - `routeId` <`string`> The id for the current route | ||
const auth = request.user ? 'user' : 'anonim'; | ||
const { metrics } = request.routeConfig.config; | ||
const { metrics } = request.routeOptions.config; | ||
const routesPrefix = metrics.routesPrefix | ||
@@ -388,0 +387,0 @@ ? `${metrics.routesPrefix}.` |
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
42776
430
+ Added@dnlup/doc@5.0.3(transitive)
- Removed@dnlup/doc@3.1.0(transitive)
Updated@dnlup/doc@^5.0.2