Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const tracing = require('@opencensus/nodejs');
- const { StackdriverTraceExporter } = require('@opencensus/exporter-stackdriver');
- const exporter = new StackdriverTraceExporter({projectId: "YOUR-GCP-PROJECT"});
- const tracer = tracing.registerExporter(exporter).start({ samplingRate: 1 }).tracer();
- function A () {
- let traceId;
- tracer.startRootSpan({ name: 'A' }, rootSpan => {
- doSomeWorkInA();
- traceId = rootSpan.traceId();
- rootSpan.end();
- });
- // Pass traceId to another function
- }
- function B () {
- let traceId = 'The trace ID passed from A';
- tracer.startRootSpan({ name: 'B', traceId: traceId }, rootSpan => {
- doSomeWorkInB();
- rootSpan.end();
- });
- // Keep passing the traceId if needed
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement