
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Monyt provides abstraction interfaces of monitoring and logging for Node.js Applications.
$ npm i -S monyt
monitor.js
import Monyt, {
RequestCountMetrics,
ErrorCountMetrics,
MemoryMetrics,
GarbageCollectionMetrics,
EventLoopLagMetrics,
GraphiteSender
} from 'monyt';
const interval = 60000; //default is 30000(ms)
const senders = [new GraphiteSender({
host: 'my.graphite.host.com',
port: '2003' //port of plaintext protocol
})];
const metricses = [
new RequestCountMetrics(),
new ErrorCountMetrics(),
new MemoryMetrics(),
new GarbageCollectionMetrics(),
new EventLoopLagMetrics()
];
const monitor = new Monyt({
interval,
prefix: `${application}.${hostname}.${clusterId}`, //This could be server hostname or application name or clusterId and etc.
senders,
metricses
});
export default monitor;
server.js
import Express from 'express';
import monitor from './monitor';
const logger = monitor.getLogger();
monitor.listen(results => {
results
.then(metricses=>logger.debug(metricses))
.catch(error=>logger.error(error));
});
const app = new Express();
app.use(monyt.middlewares());
app.use('/', (req, res, next) => {
logger.info('This is index.');
res.send('hello monyt!');
});
ProductBuyMetrics.js
import { Metrics } from 'monyt';
export default class ProductBuyMetrics extends Metrics {
constructor() {
super();
this.name = 'product.buy';
this.value = {}
}
buy(productId) {
this.value[productId] = this.value[productId] || 0;
this.value[productId] = this.value[productId] + 1;
}
}
MongoDBSender.js
import { Sender } from 'monyt';
export default class MongoDBSender extends Sender {
constructor(options = {}) {
super();
this.client = options.db.collection('metrics');
}
send(metrics) {
return new Promise((resolve, reject)=> {
this.client.insert(metrics, (error, result) => {
if (error) {
return reject(error);
}
return resolve(result);
});
});
}
}
monitor.js
...
const productBuyMetrics = new ProductBuyMetrics()
const senders = [new MongoDBSender({db: mongodbClient});]
const metricses = [new ProductBuyMetrics()];
const monitor = new Monyt({
...
senders,
metricses,
...
});
export default monitor;
export productBuyMetrics;
your-app.js
import { productBuyMetrics } from './monitor';
app.post('/buy/:user/:productId', (req, res, next) => {
//...buying process...
productBuyMetrics.buy(req.params.productId);
res.send(buyResult);
});
This software is free to use under the Minkyu Cho. MIT license. See the LICENSE file for license text and copyright information.
Please don't hesitate to send a small pull-request or just leave anything you want as an issue.
git checkout -b feature/my-new-feature
git commit -am 'Add some feature'
git push origin feature/my-new-feature
0.3.0
FAQs
## Extensible Monitor and Logger for Node.js Applications
The npm package monyt receives a total of 5 weekly downloads. As such, monyt popularity was classified as not popular.
We found that monyt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.