Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
khronus
Advanced tools
Readme
A simple Khronus client for NodeJS applications. This client implements configurable buffering, connections pooling, and automatically groups similar metrics using Khronus message syntax to optimize the amount of bytes transfered to the server.
$ npm install khronus --save
const Khronus = require("khronus");
var khronus = Khronus({
"appName": "testApp", //Application name
"url":"http://myserver:8080/khronus/", //Full Khronus URL to post metrics.
"maxBufferMeasures":10000, //Maximum number of metrics to buffer before flushing to server.
"maxBufferTime":1000, //Maximum time in milliseconds to buffer metrics before flushing to the server.
"maxSockets":10, //Maximum number of sockets to allow per host.
"maxFreeSockets":5, //Maximum number of sockets to leave open in a free state.
"requestTimeout":1000 //Time in milliseconds to wait before aborting posts to server
});
//Counters
khronus.incrementCounter("testCounter");
khronus.incrementCounter("testCounter",10); //With custom increment
khronus.incrementCounter("testCounter",10,1473799222712); //With custom increment and timeStamp
//Timers
khronus.recordTime("testTimer",234);
khronus.recordTime("testTimer",567,1473799222712); //With custom timeStamp
//Gauges
khronus.recordGauge("testGauge",234);
khronus.recordGauge("testGauge",567,1473799222712); //With custom timeStamp
//Forcing buffer flush
khronus.flush();
//Rease resources
khronus.shutDown();
The constructor returns an instance of a Khronus client when calling it with an options
param.
const Khronus = require("khronus");
var client = Khronus(options);
Client inherits from events.EventEmitter. See custom emitted events below.
Used to measure a counter. name
is the counter name, increment
is an integer with the value to be incremented, it has a default of 1
, and timestamp
is used when you want to specify one. If not, the current time will be used.
khronus.incrementCounter("testCounter");
khronus.incrementCounter("testCounter",10); //With custom increment
khronus.incrementCounter("testCounter",10,1473799222712); //With custom increment and timeStamp
Used to measure a timer. name
is the timer name, time
is an integer with the value to be recorded, and timestamp
is used when you want to specify one. If not, the current time will be used.
khronus.recordTime("testTimer",234);
khronus.recordTime("testTimer",567,1473799222712); //With custom timeStamp
Used to measure a gauge. name
is the gauge name, value
is an integer with the value to be recorded, and timestamp
is used when you want to specify one. If not, the current time will be used.
khronus.recordGauge("testGauge",234);
khronus.recordGauge("testGauge",567,1473799222712); //With custom timeStamp
Used to force a client buffer flush to the server
khronus.flush()
It releases allocated resources (buffer timers, connections, etc). It should be called before shutting down the containing process.
process.on("SIGTERM", () => {
khronus.shutDown();
});
Emitted when the client flushes it's buffer to the client. It receives the byteLength
of the message posted.
khronus.on("sendPost", (byteLength) => {
console.log(byteLength + " bytes sent to the server");
});
Emitted when an error is raised when trying to flush the client's buffer to the server. It receives the error
as a param.
khronus.on("sendPostError", (error) => {
console.log(error);
});
Emitted when the configured maxBufferTime
is reached, and the client is going to flush the it's buffer to the server. It receives the measuresInBuffer
as a param.
khronus.on("bufferTimedFlush", (measuresInBuffer) => {
console.log("Max buffering time was reached: " + measuresInBuffer + " measures are going to be sent to the server");
});
Emitted when the configured maxBufferMeasures
is reached, and the client is going to flush the it's buffer to the server. It receives the measuresInBuffer
as a param.
khronus.on("bufferThresholdFlush", (measuresInBuffer) => {
console.log("Max buffering measures was reached: " + measuresInBuffer + " measures are going to be sent to the server");
});
Emitted when the client is starting to flush the it's buffer to the server. It receives the measuresInBuffer
as a param.
khronus.on("bufferFlushStart", (measuresInBuffer) => {
console.log("Staring to send " + measuresInBuffer + " measures to the server");
});
Emitted when the client finished flushing it's buffer to the server. It receives the measuresInBuffer
as a param.
khronus.on("bufferFlushError", (measuresInBuffer) => {
console.log(measuresInBuffer + " measures where flushed to the server");
});
Emitted when an error is raised when trying to flush the client's buffer to the server. It receives the error
as a param.
khronus.on("flushError", (error) => {
console.log(error);
});
Clone the repo:
$ git clone https://github.com/despegar/khronus-nodejs-client.git
Install npm dependencies:
$ cd khronus-nodejs-client
$ npm install
Run tests and generate coverage reports:
$ npm test
The coverage report should be generated on coverage/lcov-report/index.html
, and can be opened with a browser.
FAQs
Client for Khronus time series DB
The npm package khronus receives a total of 1 weekly downloads. As such, khronus popularity was classified as not popular.
We found that khronus 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.