tdeekens / promster Goto Github PK
View Code? Open in Web Editor NEWβ°A Prometheus exporter for Hapi, express and Marble.js servers to automatically measure request timings π
License: MIT License
β°A Prometheus exporter for Hapi, express and Marble.js servers to automatically measure request timings π
License: MIT License
Is your feature request related to a problem? Please describe.
I'd like to expose metrics (e. g. request duration by status code, by method, by path) for a specific endpoint or endpoint group. Of course this requires the package to know what dynamic parts of the URL exist. One could solve this by passing a list of to be monitored URLs including wildcards. See how express-prom-bundle handles this:
https://github.com/jochen-schweizer/express-prom-bundle#more-details-on-includepath-option
Describe the solution you'd like
One solution could be this:
https://github.com/jochen-schweizer/express-prom-bundle#more-details-on-includepath-option
Describe alternatives you've considered
Getting endpoints from swagger definitions - I dislike the idea though because not everyone has or wanna use swagger. Personally I am using NestJS for swagger docs so I don't even have a swagger definition file.
Hello,
First, I'd like to thank you for all the metrics you allow me to export.
I'm interesting by the metric you use in the README.md :
network_concurrent_connections_count
How can I expose it ? Do I have to implement it myself ? If yes, do you have any exemple ? I think something using : server.getConnections
Thank you for your help,
Benjamin
Tech context:
npm i @promster/hapi --save
npm install
added this to my Hapi17 project
const { createPlugin } = require('@promster/hapi');
started the app:
-> error:
Error: Cannot find module '../package.json'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/project/node_modules/@promster/hapi/modules/plugin/plugin.js:1:75)
comes from this line:
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
.github/workflows/release.yml
actions/checkout v4
pnpm/action-setup v4.0.0
actions/setup-node v4
dotansimha/changesets-action v1.5.2
.github/workflows/test.yml
actions/checkout v4
pnpm/action-setup v4.0.0
actions/setup-node v4
package.json
@babel/core 7.24.5
@babel/eslint-parser 7.24.5
@babel/preset-env 7.24.5
@babel/preset-typescript 7.24.1
@changesets/changelog-github 0.5.0
@changesets/cli 2.27.1
@commitlint/cli 19.3.0
@commitlint/config-conventional 19.2.2
@manypkg/cli 0.21.4
@preconstruct/cli 2.8.4
@tsconfig/node18 18.2.4
@types/node 20.12.11
@types/semver 7.5.8
@typescript-eslint/eslint-plugin 7.7.1
@typescript-eslint/parser 7.7.1
check-node-version 4.2.1
codecov 3.8.3
cross-env 7.0.3
eslint 8.57.0
eslint-config-prettier 9.1.0
eslint-config-xo 0.44.0
eslint-config-xo-typescript 4.0.0
eslint-formatter-pretty 5.0.0
eslint-plugin-jest 28.3.0
eslint-plugin-prettier 5.1.3
husky 9.0.11
jest 29.7.0
jest-runner-eslint 2.2.0
jest-watch-typeahead 2.2.2
lint-staged 15.2.2
prettier 3.2.5
rimraf 5.0.7
ts-jest 29.1.2
typescript 5.4.5
node >=22
npm >=10
pnpm >=9
pnpm 9.0.6
packages/apollo/package.json
@apollo/server 4.10.4
merge-options 3.0.4
tslib 2.6.2
@graphql-tools/schema 10.0.3
@graphql-tools/utils 10.2.0
apollo-server 3.13.0
graphql 16.8.1
parse-prometheus-text-format 1.1.1
node >=20
npm >=8
packages/express/package.json
merge-options 3.0.4
tslib 2.6.2
@types/express 4.17.21
express 4.19.2
parse-prometheus-text-format 1.1.1
node >=20
npm >=8
packages/fastify/package.json
fastify-plugin ^4.5.1
merge-options 3.0.4
parse-prometheus-text-format 1.1.1
fastify 4.26.2
node >=20
npm >=8
packages/hapi/package.json
merge-options 3.0.4
semver 7.6.0
tslib 2.6.2
@hapi/boom 10.0.1
@hapi/hapi 21.3.9
@types/hapi__hapi 21.0.0
@types/semver 7.5.8
parse-prometheus-text-format 1.1.1
node >=20
npm >=8
packages/marblejs/package.json
merge-options 3.0.4
rxjs ^7.8.1
tslib 2.6.2
@marblejs/core 4.1.0
@marblejs/http 4.1.0
fp-ts 2.16.5
parse-prometheus-text-format 1.1.1
node >=20
npm >=8
packages/metrics/package.json
lodash.memoize 4.1.2
lodash.once 4.1.1
merge-options 3.0.4
prometheus-gc-stats 1.1.0
tslib 2.6.2
url-value-parser 2.2.0
@types/lodash.once 4.1.9
@types/node 20.12.11
prom-client 15.1.2
typescript 5.4.5
prom-client 13.x.x || 14.x || 15.x
node >=20
npm >=8
packages/server/package.json
tslib 2.6.2
@types/node 20.12.11
node >=20
npm >=8
packages/types/package.json
ts-essentials 9.4.2
prom-client 15.1.2
prom-client 13.x.x || 14.x || 15.x
node >=20
npm >=8
.nvmrc
node 22
Describe the bug
start
in the request
callback: https://github.com/tdeekens/promster/blob/master/packages/hapi/modules/plugin/plugin.js#L49To Reproduce
Steps to reproduce the behavior:
import { createPlugin } from '@promster/hapi'
import { createServer as createMetricsServer } from '@promster/server'
import Hapi from '@hapi/hapi'
const server = Hapi.server({
port: 4000,
host: process.env.HOST,
})
await server.register(createPlugin())
server.route({
method: 'GET',
path: '/',
handler: (request, h) => {
return 'hello!'
}
})
await server.start()
console.log('Server running on %s', server.info.uri)
await createMetricsServer({ port: 4001 })
console.log(`@promster/server started on port ${process.env.METRICS_PORT}.`)
await server.register(createPlugin())
TypeError: Cannot read property 'start' of undefined
at Object.onResponseHandler [as listener] (/...../myserver/node_modules/@promster/hapi/modules/plugin/plugin.js:54:40)
Expected behavior
request.promster
available in onResponseHandler
Additional context
Running:
18.3.1
@promster/hapi 2.2.4
@promster/server 2.1.1
According to the docs the request
-event callback uses the function(request, event, tags)
signature rather than (request, h) => {}
as in
According to the docs the request.plugins
is the place to set things like the promster
object:
Plugin-specific state. Provides a place to store and pass request-level plugin data. The
onRequestHandler
wouldn't get called on incoming requests.Is your feature request related to a problem? Please describe.
Would be nice to use this module with https://github.com/fastify/fastify
Describe the solution you'd like
Adding middleware for fastify
what do you think?
After reading the section https://github.com/tdeekens/promster#promstermetrics of the readme.md
I'm a little bit confused: The section is called @promster/metrics
, but in the example snippet you do:
const { getSummary, getContentType } = require('@promster/express');
I've seen that @promster/express
and @promster/hapi
export these functions too. But why do I then have to use/install @promster/metrics
at all?
Describe the bug
I'm trying to create a middleware for an express app, using @promster/express
' createMiddleware
function. Before the package moved to TS, the following worked
createMiddleware({ options: { metricTypes: ['countOfGcs', 'durationOfGc', 'reclaimedInGc'] } });
and gave me the metrics I wanted. Now, however, after the move, I get an error from TS stating that buckets
and percentiles
are missing.
To Reproduce
Steps to reproduce the behavior:
Using TS 3.9, the following shows the error
import { createMiddleware } from '@promster/express';
createMiddleware({ options: { metricTypes: ['countOfGcs', 'durationOfGc', 'reclaimedInGc'] } });
Expected behavior
No TypeScript errors should occur
Additional context
Any place I found in the source code that uses either of these values has a fallback default value, so shouldn't these two be optional?
Right now, TPromsterOptions
is defined with
buckets: [number];
percentiles: [number];
}
From what I saw, these can be optional in the interface. I can open a PR with this small change, if that would be deemed appropriate, and would help
The up metric is created, but it is never set nor exposed to be set?
Am i missing something?
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)
Describe the bug
The hapi plugin throws errors on every request with current version (2.2.6) and hapi 18.3
To Reproduce
please look at additional context.
Expected behavior
no errors are fine
Screenshots
Additional context
The handler onResponseHandler uses the reply argument, but the hapi api does not have this argument in the signature (Hapi-API). I think the return statement is not needed, but i'am not sure.
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'continue' of undefined
at Object.onResponseHandler [as listener] (/app/node_modules/@promster/hapi/modules/plugin/plugin.js:75:67)
at module.exports.internals.Podium.internals.Podium.emit (/app/node_modules/podium/lib/index.js:228:107)
at Request._finalize (/app/node_modules/hapi/lib/request.js:447:27)
at Request._reply (/app/node_modules/hapi/lib/request.js:391:14)
at process._tickCallback (internal/process/next_tick.js:68:7)
Describe the bug
get below vulnerabilities reports, caused by gc-stats, and I find that gc-stats is optional dependency.
https://github.com/tdeekens/promster/blob/main/packages/metrics/package.json#L53-L55
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Manual Review β
β Some vulnerabilities require your attention to resolve β
β β
β Visit https://go.npm.me/audit-guide for additional guidance β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Low β Regular Expression Denial of Service β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β braces β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=2.3.1 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β cpx [dev] β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β cpx > chokidar > anymatch > micromatch > braces β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/786 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Low β Prototype Pollution β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=0.2.1 <1.0.0 || >=1.2.3 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > gc-stats > β
β β node-pre-gyp > mkdirp > minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1179 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Low β Prototype Pollution β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=0.2.1 <1.0.0 || >=1.2.3 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > gc-stats > β
β β node-pre-gyp > tar > mkdirp > minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1179 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Low β Prototype Pollution β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=0.2.1 <1.0.0 || >=1.2.3 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > gc-stats > β
β β node-pre-gyp > rc > minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1179 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Low β Prototype Pollution β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β ini β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >1.3.6 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > gc-stats > β
β β node-pre-gyp > rc > ini β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1589 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
To Reproduce
Steps to reproduce the behavior:
npm audit --registry=https://registry.npmjs.org
Expected behavior
Is it possible to remove gc-stats?
Additional context
Add any other context about the problem here.
Describe the bug
When using @promster/hapi
, which depends on @promster/metrics
the following warning is outputted via yarn
.
warning "@promster/hapi > @promster/metrics > [email protected]" has unmet peer dependency "typescript@>=4.1.0".
To Reproduce
Steps to reproduce the behavior:
@promster/hapi
, e.g.:{
"name": "example",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@promster/hapi": "^6.1.3"
}
}
yarn
yarn add v1.22.17
info No lockfile found.
[1/4] π Resolving packages...
warning @promster/hapi > @promster/metrics > url > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
[2/4] π Fetching packages...
[3/4] π Linking dependencies...
warning "@promster/hapi > @promster/[email protected]" has unmet peer dependency "[email protected] || 14.x".
warning "@promster/hapi > @promster/metrics > [email protected]" has unmet peer dependency "typescript@>=4.1.0".
Expected behavior
Peer dependencies would be met by @promster/hapi
or redeclared as a needed peer dependency of the package, so it's obvious that consumers of the package need to add the dependency themselves.
Is your feature request related to a problem? Please describe.
any thoughts on supporting a graphql framework running on express or other servers?
Describe the solution you'd like
bring in the best prometheus implementations for graphql setups to present data in a comparable way or build out similar implementations
Describe the bug
@promster/hapi
in version 6.1.0
causes an unhandled promise rejection when using raw response object to build response in hapi:
TypeError: Cannot read properties of undefined (reading 'content-length')
at Object.onResponseHandler [as listener] (/home/stefan/tmp/promster-issue/node_modules/@promster/hapi/dist/promster-hapi.cjs.dev.js:162:33)
at module.exports.internals.Podium.emit (/home/stefan/tmp/promster-issue/node_modules/@hapi/podium/lib/index.js:221:110)
at Request._finalize (/home/stefan/tmp/promster-issue/node_modules/@hapi/hapi/lib/request.js:514:27)
at Request._abort (/home/stefan/tmp/promster-issue/node_modules/@hapi/hapi/lib/request.js:492:14)
at Request._reply (/home/stefan/tmp/promster-issue/node_modules/@hapi/hapi/lib/request.js:446:18)
at Request._execute (/home/stefan/tmp/promster-issue/node_modules/@hapi/hapi/lib/request.js:282:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
This can be a problem for integration with other libraries (e.g. NextJS or Apollo) as those might use the raw response to write their responses.
To Reproduce
Steps to reproduce the behavior: Run the minimal example code from below.
/does-not-work
Expected behavior
Promster does not include the response in the response size metric, or reads the header from the raw response.
Additional context
Minimal example:
const { createPlugin } = require('@promster/hapi');
const Hapi = require('@hapi/hapi');
process.on('unhandledRejection', (err) => {
console.log(err);
process.exit(1);
});
(async () => {
const server = Hapi.server({
port: 3000,
host: 'localhost'
});
await server.register(createPlugin());
// Default way to render route response works fine
server.route({
method: 'GET',
path: '/works',
handler: (request, h) => {
return 'Hello World!';
}
});
// Using raw reponse causes unhandled promise rejection
server.route({
method: 'GET',
path: '/does-not-work',
handler: (request, h) => {
request.raw.res.statusCode = 200;
request.raw.res.write("Hello World!");
return h.close;
}
});
await server.start();
})();
In path normalizer in @promster/metrics, url-value-parser is being used to prevent duplicate paths. /path/1 and /path/2 both map to /path/#val. However, url-value-parser has some issues. It doesn't detect every pattern, only certain (UUID, decimal, etc). So, if somebody hits the server with randomized urls (undetected by url-value-parser), it should go out of memory. In fact, the /metrics call can become so big it can timeout. How do I handle this?
Node.js documentation lists process.hrtime([time])
as a legacy feature. It is no longer recommended for use, and should be avoided.
Documentation recommends the use of process.hrtime.bigint()
, that works slightly different. It does not support an additional time argument since bigint that it returns can easily be subtracted to find the difference.
Example from the documentation:
import { hrtime } from 'process';
const start = hrtime.bigint();
// 191051479007711n
setTimeout(() => {
const end = hrtime.bigint();
// 191052633396993n
console.log(`Benchmark took ${end - start} nanoseconds`);
// Benchmark took 1154389282 nanoseconds
}, 1000);
Is your feature request related to a problem? Please describe.
I'm trying to implement Prometheus according to my company's standard requirements, but this requires me to also provide details of outbound client network requests using the same metric as is used for in-bound server network requests -- using a role
label of client
instead of the server
value used for in-bound requests.
Describe the solution you'd like
In just 3 hours I've been able to configure promster
to meet the fairly exacting standards docs at my company except this one small detail π. If the observeRequest
request-observer was exposed on app.locals
in the same way as prom-client
is, then I'd now be fully compliant π.
Any chance you'd consider exposing this observer too? Thanks in advance, Dominic.
Describe alternatives you've considered
The only alternative I can think of is to fork as I don't think it's possible for me to grab this reference any other way.
Additional context
None.
Describe the bug
Hey
$ npm info @promster/express
returns:
npm ERR! code E404
npm ERR! 404 '@promster/express' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! 404
npm ERR! 404 '@promster/express@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
Was the package removed from npm registry or it's a npm issue?
Additional context
node v12.13.1 (npm v6.12.1)
Also https://registry.npmjs.com/@promster/express and https://registry.yarnpkg.com/@promster/express return 404
Is your feature request related to a problem? Please describe.
PromQL is powerful and a great tool but can have a steep learning curve.
I totally agree with this statement in the readme as I am very new to Prometheus and Grafana.
For me it was easy to include promster into a hapi server app.
But building a Grafana dashboard is a little more complicated than I thought.
Describe the solution you'd like
I would appreciate an example Grafana dashboard definition as a starting point.
Describe alternatives you've considered
Well, building one on my own obviously π
Additional context
n/a
Describe the bug
It seems that metricPrefix option is not applied consistently on all collected metrics. Specifically, the prefix is not applied on the http_requests_total metric.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would expect all metrics to be prefixed with the provided prefix i.e. my_nice_prefix_. This happens for all metrics apart from the http_requests_total metric. See annotated screenshot below:
Describe the bug
skip
in TMiddlewareOptions
requires 2 generic Q
and S
that can't be extended with Request
and Response
from express
.
I might be using it wrong, a helpful usage example would be greatly appreciated π
To Reproduce
Steps to reproduce the behavior:
import type { Request } from 'express';
import { createMiddleware as createPrometheusMiddleware } from '@promster/express';
app.use(
createPrometheusMiddleware({
app,
options: {
skip: <Q extends Request>(req: Q) =>
req.url.includes('products') || req.url.includes('carts'),
},
})
);
Types of parameters 'req' and 'request' are incompatible.
Type 'Q' is not assignable to type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'
This type parameter might need an `extends e.Request<ParamsDictionary, any, any, QueryString.ParsedQs, Record<string, any>>` constraint.
Expected behavior
I expect the skip
method to work without TS error or even better to have a different signature for example like this without the use of generics
app.use(
createPrometheusMiddleware({
app,
options: {
skip: (req: Request) =>
req.url.includes('products') || req.url.includes('carts'),
},
})
);
Additional context
Versions installed
"prom-client": "^14.2.0",
"@promster/express": "^7.0.6",
"@promster/server": "^7.0.8",
"@promster/types": "^3.2.5",
One an unrelated note, it would be really nice if the express
middleware exports the types as well so we don't have to install @promster/types
to get typing for TMiddlewareOptions
π
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
requestBucket
and sizeBucket
?Describe alternatives you've considered
We can also set up one big bucket that ranges from a very small unit (e.g. 0.01
) to a very large unit (e.g. 1000000
.) However, that leads to unnecessarily large metrics storage sizes.
Additional context
N/A
Describe the bug
Calling promster.createMiddleware() twice results in an error being thrown: A metric with the name up has already been registered.
To Reproduce
const promster = require('@promster/express');
promster.createMiddleware({});
promster.createMiddleware({});
node test.js
The following error occurs:
/path/to/node_modules/prom-client/lib/registry.js:85
throw new Error(
^
Error: A metric with the name up has already been registered.
at Registry.registerMetric (/Users/jburn9/projects/eap/dam-common/node_modules/prom-client/lib/registry.js:85:10)
at Gauge.config.registers.forEach.registryInstance (/Users/jburn9/projects/eap/dam-common/node_modules/prom-client/lib/gauge.js:76:21)
at Array.forEach (<anonymous>)
at new Gauge (/Users/jburn9/projects/eap/dam-common/node_modules/prom-client/lib/gauge.js:75:20)
at getDefaultMetrics (/Users/jburn9/projects/eap/dam-common/node_modules/@promster/metrics/modules/create-metric-types/create-metric-types.js:80:7)
at createMetricTypes (/Users/jburn9/projects/eap/dam-common/node_modules/@promster/metrics/modules/create-metric-types/create-metric-types.js:156:26)
at Object.createMiddleware (/Users/jburn9/projects/eap/dam-common/node_modules/@promster/express/modules/middleware/middleware.js:30:23)
at Object.<anonymous> (/Users/jburn9/projects/eap/dam-common/test.js:4:10)
at Module._compile (internal/modules/cjs/loader.js:721:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
Additional context
This isn't particularly a problem at runtime because I only instantiate one of these middleware per service. But it's an issue in unit testing. I want to call a function which instantiates this middleware multiple times to test with different parameters, but I can't because this call blows up.
Describe the bug
This lib causes typescript project builds to fail unless enabling the allowSyntheticDefaultImports
flag.
The build error:
node_modules/@promster/server/dist/modules/server/server.d.ts:1:8 - error TS1192: Module '"http"' has no default export.
1 import http from 'http';
To Reproduce
tsconfig.json
file that does not have either of these options enabled:{
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}
import { createServer } from '@promster/server';
Expected behavior
Properly typed libraries should not require the allowSyntheticDefaultImports
or esModuleInterop
flags to be enabled.
After upgrading from 4.1.2 -> 4.1.9 of @promster/express, my application encountered the following error:
internal/modules/cjs/loader.js:796
throw err;
^
Error: Cannot find module 'tslib'
Require stack:
- /usr/src/app/node_modules/@promster/express/dist/modules/middleware/middleware.js
- /usr/src/app/node_modules/@promster/express/dist/modules/middleware/index.js
- /usr/src/app/node_modules/@promster/express/dist/modules/index.js
- SNIP
- SNIP
- /usr/src/app/src/app.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/src/app/node_modules/@promster/express/dist/modules/middleware/middleware.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/src/app/node_modules/@promster/express/dist/modules/middleware/index.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/src/app/node_modules/@promster/express/dist/modules/middleware/middleware.js',
'/usr/src/app/node_modules/@promster/express/dist/modules/middleware/index.js',
'/usr/src/app/node_modules/@promster/express/dist/modules/index.js',
SNIP,
SNIP,
SNIP
]
tslib
is not listed as a dependency in https://github.com/tdeekens/promster/blob/master/packages/express/package.json, but in the compiled code under node_modules/@promster/express/dist/modules/middleware/middleware.js, there is
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const http_1 = require("http");
I can work around this by requiring tslib
in my own application, but shouldn't @promster/express require its own dependencies?
While the current metrics can be used for almost any use case, it would be nice to provide this metric to be more consistent with other prometheus exporters.
Prometheus official docs also use this metric as an example:
https://prometheus.io/docs/prometheus/latest/querying/examples/
https://github.com/prometheus/docs/blob/master/content/docs/practices/naming.md#metric-names
While the official docs use http_requests_total, a lot of libraries are using http_server_requests_total as an alternative because it's more declarative. Either way, this can be solved with relabeling configs.
Some insights about this can be found on https://www.robustperception.io/on-the-naming-of-things
A lot of projects leverage on Grafana Dashboards which display graphs and values based on this metric. For example, we have a dashboard which provides metrics for all of our services. Having to add a second query only to provide compatibility with our NodeJS services seems very odd.
As satated by @tdeekens in #12, the requests/s example provided in the prometheus docs can be achieved by doing
sum(rate(http_request_duration_buckets_milliseconds_count[1m])) * 60)
Do you think it would be relevant to add this metric? We can provide an option to disable it as well.
Cheers!
I was wondering whether passing the full req object to the normalizePath (as second argument) would be a nice addition to ease path normalization; for example, if using express one could use the req.route info to map paths like /a/666/store/22334455 into '/a/:areaId/id/:storeId', thus reducing cardinality a lot
Describe the bug
This library currently causes 10 high severity vulnerabilities to be reported by npm audit
due to the node-gcstats
dependency which it includes.
PR #703 recently attempted to address this by moving to a more up-to-date fork, @sematext/node-gcstats
. Unfortunately, this fork is also somewhat behind. It still includes the deprecated node-pre-gyp
package.
For what it's worth, I've submitted a PR to that fork to update it but we'll see if it gets a response: adnanrahic/node-gcstats#4
To Reproduce
Here's what npm audit
shows currently:
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite due to insufficient β
β β absolute path sanitization β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=3.2.2 <4.0.0 || >=4.4.14 <5.0.0 || >=5.0.6 <6.0.0 || β
β β >=6.1.1 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1770 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite due to insufficient β
β β absolute path sanitization β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=3.2.2 <4.0.0 || >=4.4.14 <5.0.0 || >=5.0.6 <6.0.0 || β
β β >=6.1.1 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/server β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/server > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1770 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite via insufficient symlink β
β β protection due to directory cache poisoning β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=3.2.3 <4.0.0 || >=4.4.15 <5.0.0 || >=5.0.7 <6.0.0 || β
β β >=6.1.2 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1771 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite via insufficient symlink β
β β protection due to directory cache poisoning β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=3.2.3 <4.0.0 || >=4.4.15 <5.0.0 || >=5.0.7 <6.0.0 || β
β β >=6.1.2 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/server β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/server > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1771 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite via insufficient symlink β
β β protection due to directory cache poisoning using symbolic β
β β links β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=4.4.16 <5.0.0 || >=5.0.8 <6.0.0 || >=6.1.7 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1779 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite via insufficient symlink β
β β protection due to directory cache poisoning using symbolic β
β β links β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=4.4.16 <5.0.0 || >=5.0.8 <6.0.0 || >=6.1.7 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/server β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/server > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1779 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite via insufficient symlink β
β β protection due to directory cache poisoning using symbolic β
β β links β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=4.4.18 <5.0.0 || >=5.0.10 <6.0.0 || >=6.1.9 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1780 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite via insufficient symlink β
β β protection due to directory cache poisoning using symbolic β
β β links β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=4.4.18 <5.0.0 || >=5.0.10 <6.0.0 || >=6.1.9 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/server β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/server > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1780 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite on Windows via β
β β insufficient relative path sanitization β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=4.4.18 <5.0.0 || >=5.0.10 <6.0.0 || >=6.1.9 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/express β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/express > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1781 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Arbitrary File Creation/Overwrite on Windows via β
β β insufficient relative path sanitization β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=4.4.18 <5.0.0 || >=5.0.10 <6.0.0 || >=6.1.9 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β @promster/server β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β @promster/server > @promster/metrics > @sematext/gc-stats > β
β β node-pre-gyp > tar β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1781 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Additional context
While we wait for the node-gcstats problem child to be updated, is there anything that can be done to reduce the number of audit problems that Promster is inheriting from this unmaintained dependency? Even the person who forked it says they aren't really maintaining the code. They just bumped dependencies. So it seems likely that this will continue to be a problem.
Exploring options:
npm install
and npm ci
to globally omit all optional dependencies in all packages. A workable solution for clients would get the manifests into a shape that npm ci
can be used as normal without any global flags being applied.Is your feature request related to a problem? Please describe.
I wanna enrich my application with further custom metrics which are very business specific (e. g. consumed messages from a message queue). Therefore I am not in the right context to get the prom client registry instance to add my own metrics. Additionally I want to avoid "lazy metrics" which means I wanna initialize them with 0, so that Grafana shows the data is 0 and not "unknown".
Is there any chance we can get the registry or do I need to create a second prom-client registry to solve this?
Even easier: Make promster accept a prom-client registry :-).
Describe the bug
Errors thrown in GraphQL execute phase are not handled:
node_1 | Error: Added label "field_name" is not included in initial labelset: [ 'operation_name', 'operation_name', 'phase' ]
node_1 | at validateLabel (/opt/node_app/node_modules/prom-client/lib/validation.js:20:10)
node_1 | at Counter.inc (/opt/node_app/node_modules/prom-client/lib/counter.js:24:4)
node_1 | at /opt/node_app/node_modules/@promster/apollo/dist/promster-apollo.cjs.dev.js:164:28
node_1 | at Array.forEach (<anonymous>)
node_1 | at /opt/node_app/node_modules/@promster/apollo/dist/promster-apollo.cjs.dev.js:163:160
node_1 | at /opt/node_app/node_modules/apollo-server-core/dist/utils/dispatcher.js:57:17
node_1 | at /opt/node_app/node_modules/apollo-server-core/dist/utils/schemaInstrumentation.js:76:56
node_1 | at processTicksAndRejections (node:internal/process/task_queues:96:5)
To Reproduce
Steps to reproduce the behavior:
And directive which throws an error in execute phase won't be handled / counted.
Expected behavior
Expect graphql_errors_total
to increment
Additional context
Attempted to write a test for the issue here, not sure if the solution is correct https://github.com/tdeekens/promster/compare/main...earnubs:errors-in-execution-phase?expand=1
According to Prometheus Best Practices, unit for time is "seconds".
To mesure duration under the second, we need to use float with suffisant level of precision.
The choice to implement different units, each one of them, mapped to a specific level of precision make impossible to follow Prometheus Best Practices.
What do you think about de-couple precision and unit ?
Describe the bug
After #791, fractional values are truncated (i.e. http_request_duration_seconds
does not record fractional seconds).
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
The / operator also works as expected with whole numbers β but operations with a fractional result will be truncated when used with a BigInt value β they wonβt return any fractional digits.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
http_request_duration_seconds_sum
should show fractional seconds.
A patch version increase in @promster/hapi
from 4.1.3
to 4.1.10
changed the signature of the hapi's decoration, making the static Promster property instead a function that returns the Promster instance. This seems to have been done in the PR that converted the package to TypeScript.
I added a comment to the PR on the affected line: #352 (review)
packages/hapi/modules/plugin/plugin.ts
--- server.decorate('server', 'Prometheus', Prometheus);
+++ server.decorate('server', 'Prometheus', () => Prometheus);
Since our software specificed @promster/hapi
version ^4.0.0
, updating to this broke our application, since previously accessing server.Promster didn't require an additional invocation:
const { Prometheus } = server // the hapi server instance
const reportingService = new ReportingService(Prometheus)
Describe the bug
A clear and concise description of what the bug is.
Does TYPE up gauge always return 0 whether server is started or not?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
β― node ./express.js
Prometheus metrics available on http://localhost:8080
Express app listening at http://localhost:80
http://localhost/ ----> I am the server!
http://localhost:8080/ -----> as Screenshots, TYPE up gauge returns 0
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Describe the bug
Using prom-client AggregatorRegistry.setRegistries
with promster defaultRegister
throws an error.
TypeError: Expected Registry, got object
at node_modules/prom-client/lib/cluster.js:140:11
at Array.forEach (<anonymous>)
at Function.setRegistries (node_modules/prom-client/lib/cluster.js:138:8)
at Object.<anonymous> (test.js:4:20)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
at internal/main/run_main_module.js:17:11
To Reproduce
npm install prom-client @promster/express
const { AggregatorRegistry } = require('prom-client');
const { defaultRegister } = require('@promster/express');
AggregatorRegistry.setRegistries(defaultRegister);
Expected behavior
defaultRegister
can be used with AggregatorRegistry
.
Describe the bug
After installation of package, audit checks in our pipelines fail.
The culprit are several minimist dependencies from gc-stats
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No error. found 0 vulnerabilities
More information
Reproduced in MacOS.
β― node --version
v14.8.0
β― npm --version
6.14.7
Also reproduces in Azure pipelines agent, Ubuntu 18.04
Hi everybody!
I started to work with the new typescript integration (I'm using Express), and I got an error with the createMidleware function
theapp variable is defined as Express.Application
,
TS Error:
Type 'Application' is missing the following properties from type 'TApp': setTimeout, maxHeadersCount, timeout, headersTimeout, and 9 more.ts(2740)
Should I change the typing of the application?
thanks you!
I'm trying to use promster in a large hapi server with a lot of tests. The tests keep making and destroying lots of hapi server instances. For some subset of it, the promster plugin gets loaded. After a few tests, we get
(node:55880) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 stats listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:281:17)
at EventEmitter.addListener (events.js:297:10)
at /redacted/node_modules/@promster/metrics/modules/create-gc-observer/create-gc-observer.js:20:8
My guess is that this is because of
It adds an event listener, but nothing ever cleans that up again.
This is probably only a problem during testing because normally in production code you're only going to make one hapi server and register promster once.
Describe the bug
I get the following warning when using promster:
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
This is due to promster/metrics
using the (external) url
package. NodeJS provides the same functionality which was deprecated for some time, but that has been revoked.
To Reproduce
Steps to reproduce the behavior:
"@promster/express"
npm. install
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
Expected behavior
No deprecation warnings when using promster.
Additional context
commitizen
/ the pre-commit hook to workDescribe the bug
We've noticed that our log entries describe cases where we receive a 400 response (Or 404 as the default in Koa) but they are not logged in the metrics.
This seems to happen when there are errors in the form of ECONNRESET - when the underlying socket of the request throws some error.
To Reproduce
Using express, we can imitate this behavior using the following code
const express = require('express')
const app = express();
const { createMiddleware, getSummary, getContentType } = require('@promster/express');
const port = 3000;
app.use('/metrics', async (req, res) => {
req.statusCode = 200;
res.setHeader('Content-Type', getContentType());
res.end(await getSummary());
});
app.use(createMiddleware({ app }));
app.get('/', (req, res) => {
res.send('Hello World!')
});
app.get('/error', (req, res) => {
req.socket.emit('error', new Error('boom'));
});
app.listen(port);
Expected behavior
The /metrics
route to record the request to the /error
route.
Additional context
It seems that the response finished event does not trigger in such cases (code)
Using a module such as https://www.npmjs.com/package/on-finished does trigger the callback and record the request correctly
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
Describe alternatives you've considered
prom-client
or equivalent directlyAdditional context
We want this feature as part of our monitoring system. While we've implemented this manually, that would be great if promster
supports this out of the box. Are there any needs by others?
BTW, thank you for this great tool!
While trying to integrate promster with our service written in TypeScript I noticed that there don't seem to be typings for @promster/express. So needless to say, I'd love to see Typescript support for this.
like micrometer with spring boot,
It will be a great feature to get how long the longest request took in the last minute
ex:
http_server_requests_seconds_max{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/blah",} 0.040648985
http_server_requests_seconds_max{exception="ResourceNotFoundException",method="GET",outcome="CLIENT_ERROR",status="404",uri="/blahblah",} 0.0
Is your feature request related to a problem? Please describe.
β Empty
Describe the solution you'd like
β Empty
Describe alternatives you've considered
β Empty
Additional context
Could add package to measure metrics from Electron
This is great project, I wonder how to use this for k8s? Does this have docker repo? And how to integrate to the running nodej's mircoservice?
Thanks!
Describe the bug
I did not deep-dive here but it looks like the property "buckets" on TPromsterOptions in the typings package might have the incorrect type. Should it not be number[]
or Array<number>
as opposed to [number]
?
https://github.com/tdeekens/promster/blob/main/packages/types/src/index.ts#L20
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.