New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

metrics-server

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metrics-server - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

16

lib/udpserver.js

@@ -20,3 +20,3 @@ var util = require('util');

UDPServer.prototype.onMessage = function(msg) {
UDPServer.prototype.onAdd = function(msg) {

@@ -44,9 +44,15 @@ var time = msg.time;

(new mongoose.Metric(item)).save(function(err) {
if (err)
console.log(err);
});
(new mongoose.Metric(item)).save();
this.emit('metric', item);
};
UDPServer.prototype.onMessage = function(msg) {
if (Array.isArray(msg)) {
msg.forEach(this.onAdd);
} else {
this.onAdd(msg);
}
};
UDPServer.prototype.start = function() {

@@ -53,0 +59,0 @@ mongoose.start(this.options.mongodb || {});

@@ -25,4 +25,5 @@ var fs = require('fs');

app.get("/count", this.getCount.bind(this));
app.get("/count/:token", this.getMetricCount.bind(this));
app.get("/metric/:token", this.getMetric.bind(this));
app.get("/metric/:token/count", this.getMetricCount.bind(this));
app.get("/metric/:token/:group/:name", this.getStreamMetric.bind(this));

@@ -60,3 +61,3 @@ server.listen(this.options.port, this.options.host);

}
return query;

@@ -104,14 +105,14 @@ };

var _metrics = {};
var count = 0;
metrics.forEach(function(metric) {
_metrics[metric.group] = _metrics[metric.group] || {};
_metrics[metric.group][metric.name] = _metrics[metric.group][metric.name] || [];
_metrics[metric.group][metric.name].push({
time : metric.time,
time : metric.time.getTime(),
metric : metric.metric
});
count++;
});
res.header('x-count', count)
res.json(_metrics);

@@ -121,2 +122,42 @@ });

};
Server.prototype.getStreamMetric = function(req, res) {
var limit = req.query.limit;
var token = req.params.token;
var name = req.params.name;
var group = req.params.group;
var first = true;
var query = {
token : token,
name : name,
group : group
};
var stream = mongoose.Metric.find(query).sort({
'time' : -1
});
if (limit) {
stream.limit(limit)
}
stream = stream.stream();
res.setHeader("Content-Type", "application/json");
res.write('[');
stream.on('data', function(item) {
var prefix = first ? '' : ', ';
res.write(prefix + '[' + item.time.getTime() + ',' + item.metric + ']');
first = false;
});
stream.on('end', function() {
res.write(']');
res.end();
});
};
Server.prototype.start = function() {

@@ -123,0 +164,0 @@ mongoose.start(this.options.mongodb || {});

{
"name": "metrics-server",
"version": "0.0.7",
"version": "0.0.8",
"author": "Tim <mangoraft@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Basic metrics server and client.",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc