Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@opencensus/nodejs
Advanced tools
Changelog
0.1.0 - 2021-07-27
Readme
OpenCensus Node.js is an implementation of OpenCensus, a toolkit for collecting application performance and behavior monitoring data.
The library is in alpha stage and the API is subject to change.
Please join gitter for help or feedback on this project.
Install OpenCensus with:
npm install @opencensus/nodejs
OpenCensus for Node.js has automatic instrumentation out of the box for those modules:
This means that spans are automatically created for operations of those packages. To use it, simply start the tracing instance.
const tracing = require('@opencensus/nodejs');
tracing.start();
Similarly for Typescript:
import * as tracing from '@opencensus/nodejs';
tracing.start();
In addition to automatic tracing, it is possible to manually create your own root and child spans.
const rootSpanOptions = { name: 'your root span' };
tracing.tracer.startRootSpan(rootSpanOptions, (rootSpan) => {
// You can create as many child spans as needed
childSpan = tracing.tracer.startChildSpan({
name: 'name of your child span'
});
// Do some operation...
// Finish the child span at the end of it's operation
childSpan.end();
// Finish the root span at the end of the operation
rootSpan.end();
});
For manual only instrumentation see the @opencensus/nodejs-base package.
Tracing has many options available to choose from. At tracing.start()
, you can set the following:
Options | Type | Description |
---|---|---|
defaultAttributes | Attributes | Default attributes added to every span created by the tracer |
bufferSize | number | The number of traces to be collected before exporting to a backend |
bufferTimeout | number | Maximum time to wait before exporting to a backend |
logger | Logger | A logger object |
logLevel | number | Level of logger - 0: disable, 1: error, 2: warn, 3: info, 4: debug |
samplingRate | number | Determines the span's sampling rate. Ranges from 0.0 to 1.0 |
propagation | Propagation | A propagation instance to use |
maximumLabelValueSize | number | The maximum number of characters reported on a label value |
plugins | PluginNames | A list of trace instrumentations plugins to load |
exporter | Exporter | An exporter object |
OpenCensus can collect tracing data automatically using plugins. Users can also create and use their own plugins. Currently, OpenCensus supports automatic tracing for:
OpenCensus collects distributed tracing. It is able to do so by propagating span data through services. Currently, OpenCensus supports:
OpenCensus can export trace data to various backends. Currently, OpenCensus supports:
If no exporter is registered in the tracing instance, as default, a console log exporter is used.
FAQs
OpenCensus is a toolkit for collecting application performance and behavior data.
The npm package @opencensus/nodejs receives a total of 3,514 weekly downloads. As such, @opencensus/nodejs popularity was classified as popular.
We found that @opencensus/nodejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
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.