![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A minimalistic node.js client for statsd server. Fork of original work by sivy
lynx
features:
$ npm install lynx
$ node
> var lynx = require('lynx');
> var metrics = new lynx('localhost', 8125);
{ host: 'localhost', port: 8125 }
> metrics.increment('node_test.int');
> metrics.decrement('node_test.int');
> metrics.timing('node_test.some_service.task.time', 500); // time in ms
> metrics.gauge('gauge.one', 100);
> metrics.set('set.one', 10);
This is the equivalent to:
echo "node_test.int:1|c" | nc -w 0 -u localhost 8125
echo "node_test.int:-1|c" | nc -w 0 -u localhost 8125
echo "node_test.some_service.task.time:500|ms" | nc -w 0 -u localhost 8125
echo "gauge.one:100|g" | nc -w 0 -u localhost 8125
echo "set.one:10|s" | nc -w 0 -u localhost 8125
The protocol is super simple, so feel free to check out the source code to understand how everything works.
If you wish to measure timing you can use the timer()
functionality.
var metrics = new lynx('localhost', 8125)
, timer = metrics.Timer('some.interval')
;
//
// Should send something like "some.interval:100|ms"
//
setTimeout(function () {
timer.stop();
}, 100);
Timers use Date.getTime()
which is known for being imprecise at the ms level. If this is a problem to you please submit a pull request and I'll take it.
Batching is possible for increment
, decrement
, and count:
metrics.decrement(['uno', 'two', 'trezentos']);
If you want to mix more than one type of metrics in a single packet you can use send
, however you need to construct the values yourself. An example:
//
// This code is only to exemplify the functionality
//
// As of the current implementation the sample rate is processed per group
// of stats and not per individual stat, meaning either all would be send
// or none would be sent.
//
metrics.send(
{ "foo" : "-1|c" // count
, "bar" : "15|g" // gauge
, "baz" : "500|ms" // timing
, "boaz": "40|s" // set
, ""
}, 0.1); // sample rate at `0.1`
You can close your open socket when you no longer need it by using metrics.close()
.
By default errors
get logged. If you wish to change this behavior simply specify a onError
function when instantiating the lynx
client.
function onError(err) {
console.log(err.message);
}
var connection = new lynx('localhost', 1234, {onError: onError});
Source code is super minimal, if you want try to get familiar with when errors occur check it out. If you would like to change behavior on how this is handled send a pull request justifying why and including the alterations you would like to propose.
Run the tests with npm
.
npm test
`\. ,/'
|\\____//|
)/_ `' _\(
,'/-`__'-\`\
/. (_><_) ,\
` )/`--'\(`' atc
` '
git clone git://github.com/dscape/lynx.git
(oo)--',-
in caos
FAQs
Minimalistic StatsD client for Node.js programs
We found that lynx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.