paritytech / opstooling-js

Shared functionality for OpsTooling projects
https://www.npmjs.com/package/@eng-automation/js
Apache License 2.0
0 stars 1 forks source link

Support metrics increment in logger #44

Closed mutantcornholio closed 1 year ago

mutantcornholio commented 1 year ago

Currently, it'd take a lot of energy to switch to structurized logging and to build metrics out of that.
However, a simple drop-in way to have metrics based on log level, can be as follows:

If metricsCounter with logLevel label is provided to new Logger({ ..., metricsCounter }), it'll increment the counter on all logger.info(), logger.error(), etc. calls.

All that is needed is for application to use logger from @eng-automation/js and provide Prometheus metrics.