Trace Context Propagation with HTTP instrumentation produce the invalid RootSpan
See original GitHub issueWhat version of OpenCensus are you using?
I use the OpenCensus libraries which versions are 0.0.13.
@opencensus/core@0.0.13
@opencensus/exporter-stackdriver@0.0.13
@opencensus/instrumentation-http@0.0.13
@opencensus/nodejs@0.0.13
@opencensus/propagation-tracecontext@0.0.13
What version of Node are you using?
Node v10.15.3 (on macOS Mojave 10.14.4)
$ node -v
v10.15.3
What did you do?
I have written a simple Express app with OpenCensus.
import { Tracer } from "@opencensus/core";
import { StackdriverTraceExporter } from "@opencensus/exporter-stackdriver";
import * as instrumentationHttp from "@opencensus/instrumentation-http";
import tracing from "@opencensus/nodejs";
import { TraceContextFormat } from "@opencensus/propagation-tracecontext";
import express from 'express';
import * as http from 'http';
const propagation = new TraceContextFormat();
const exporter = new StackdriverTraceExporter({ projectId: "project-id" });
const tracer = tracing.start({ propagation, exporter }).tracer;
instrumentationHttp.plugin.enable(http, tracer as Tracer, process.versions.node, {});
const app = express();
app.get('/ping', (_req, res) => {
res.send('pong');
});
app.listen(3000, () => {
console.log("App listening on 3000");
});
When I request the curl http://localhost:3000/ping
and then the Stackdriver exporter doesn’t export any trace. The error told me the RootSpan’s TraceID is invalid.
What did you expect to see?
I want to use instrumentation-http
with propagation-tracecontext
. The TraceID should be a valid string.
What did you see instead?
HTTP instrumentation produces the invalid Span when I use with Trace Context propagation. This “invalid” means the TraceID is to be an empty string. But the TraceID should be hexadecimal 32-bits string. So the exporter raises the error and the exporter does not export.
Additional context
I tried to use HTTP instrumentation with B3 Propagation and Stackdriver Propagation. Both B3 and Stackdriver propagation and HTTP instrumentation combination create proper Span. So this problem may be caused by using HTTP instrumentation and Trace Context Propagation.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top GitHub Comments
@yamadayuki The new release is available (0.0.14) with this fix.
I think, the
extract
method should returnnull
if there is no incomingtraceID
/spanID
, rather than fillSpanContext
object with empty strings. I will open a PR to fix this.