
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@zaplabs/opencensus-core
Advanced tools
OpenCensus is a toolkit for collecting application performance and behavior data.
OpenCensus for Node.js is an implementation of OpenCensus, a toolkit for collecting application performance and behavior monitoring data. It currently includes 3 apis: stats, tracing and tags.
The library is in alpha stage and the API is subject to change.
Install the opencensus-core package with NPM:
npm install @zaplabs/opencensus-core
To enable metrics, we’ll import a few items from OpenCensus Core package.
const { Stats, MeasureUnit, AggregationType } = require('@zaplabs/opencensus-core');
// Create the Stats manager
const stats = new Stats();
// The latency in milliseconds
const mLatencyMs = stats.createMeasureDouble(
"repl/latency",
MeasureUnit.MS,
"The latency in milliseconds"
);
We now determine how our metrics will be organized by creating Views
. We will also create the variable needed to add extra text meta-data to our metrics – methodTagKey
, statusTagKey
, and errorTagKey
.
const methodTagKey = "method";
const statusTagKey = "status";
const errorTagKey = "error";
const latencyView = stats.createView(
"demo/latency",
mLatencyMs,
AggregationType.DISTRIBUTION,
[methodTagKey, statusTagKey, errorTagKey],
"The distribution of the latencies",
// Bucket Boundaries:
// [>=0ms, >=25ms, >=50ms, >=75ms, >=100ms, >=200ms, >=400ms, >=600ms, >=800ms, >=1s, >=2s, >=4s, >=6s]
[0, 25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000]
);
Now we will record the desired metrics. To do so, we will use stats.record()
and pass in measurements.
const [_, startNanoseconds] = process.hrtime();
const tags = {method: "repl", status: "OK"};
stats.record({
measure: mLatencyMs,
tags,
value: sinceInMilliseconds(startNanoseconds)
});
function sinceInMilliseconds(startNanoseconds) {
const [_, endNanoseconds] = process.hrtime();
return (endNanoseconds - startNanoseconds) / 1e6;
}
See Quickstart/Metrics for a full example of registering and collecting metrics.
Apache License 2.0
0.0.7 - 2018-11-12
Contains API breaking changes for stats/metrics implementations
FAQs
Zaplabs - OpenCensus is a toolkit for collecting application performance and behavior data.
The npm package @zaplabs/opencensus-core receives a total of 1 weekly downloads. As such, @zaplabs/opencensus-core popularity was classified as not popular.
We found that @zaplabs/opencensus-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 26 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.