OpenCensus Zpages Exporter for Node.js
![Gitter chat](https://badges.gitter.im/census-instrumentation/lobby.svg)
OpenCensus Zpages Exporter implements a collection of HTML pages that display stats and trace data sent from OpenCensus Node.js.
The library is in alpha stage and the API is subject to change.
Installation
npm install @opencensus/nodejs
npm install @opencensus/exporter-zpages
Usage
Zpages always runs on localhost, but you can change the port in the options. If the option startServer
is set to true
, Zpages server will start when a new Zpages instance is created. It's also possible to predefined some span names. These empty spans will be listed on Zpages.
To use Zpages, instance the exporter on your application and pass the options. For javascript:
const tracing = require('@opencensus/nodejs');
const zpages = require('@opencensus/exporter-zipkin');
const options = {
port: 8080,
startServer: true,
spanNames: ['predefined/span1', 'predefined/span2']
}
const exporter = new zpages.ZpagesExporter(options);
Similarly for Typescript:
import * as tracing from '@opencensus/nodejs';
import {ZpagesExporter, ZpagesExporterOptions} from '@opencensus/zpages-exporter';
const options = {
port: 8080,
startServer: true,
spanNames: ['predefined/span1', 'predefined/span2']
} as ZpagesExporterOptions;
const exporter = new ZpagesExporter(options);
Now, register the exporter and start tracing.
tracing.start({'exporter': exporter});
or
tracing.registerExporter(exporter).start();
Starting the Zpages server
If options.startServer
is set to false
, the server can be started by calling startServer
method:
zpages.startServer();
The server will run at http:\\localhost:port
.
Browsing the Zpages pages
There are four pages you can browse.
-
/tracez: Trace list.
-
/traceconfigz: Trace settings.
-
/rpcz: RPC stats (not yet implemented).
-
/stats: Stats page (not yet implemented).
Stoping the Zpages server
If it is necessary to stop the server programmatically, use the following command:
zpages.stopServer();
Useful links
0.0.12 - 2019-05-13
- Add
defaultAttributes
config to Tracer.start(config)
- http-instrumentation: Handle incoming requests with long request url path.
- Add Cumulative (
DoubleCumulative
, LongCumulative
, , DerivedDoubleCumulative
, DerivedLongCumulative
) APIs. - Export
TracerBase
as a separate @opencensus/nodejs-base
package. - Fix(deps): update dependency nyc to v14.
- Fix(deps): update dependency grpc to ~1.20.0
- chore(package): update handlebar to avoid security vulnabirity.
- Move propagation-binaryformat package to dependencies.
- Fix(deps): update dependency @grpc/proto-loader to ^0.5.0
- http-instrumentation: fix propagation errors when using Expect header.
- Consolidate Span and RootSpan to allow Spans to recursively have children.
This release has a breaking change. Please test your code accordingly after upgrading.
- removing Tracer's
startChildSpan(name?: string, kind?: types.SpanKind)
interface
Old code
// Multi argument interface
const span = tracer.startChildSpan('my-span', types.SpanKind.SERVER);
// Or options object interface
const span = tracer.startChildSpan({
name: 'my-span',
kind: types.SpanKind.SERVER
});
New code
// Only options object interface is supported
const span = tracer.startChildSpan({
name: 'my-span',
kind: types.SpanKind.SERVER
});