question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trace Context Propagation with HTTP instrumentation produce the invalid RootSpan

See original GitHub issue

What 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mayurkale22commented, Jun 4, 2019

@yamadayuki The new release is available (0.0.14) with this fix.

1reaction
mayurkale22commented, May 23, 2019

I think, the extract method should return null if there is no incoming traceID/spanID, rather than fill SpanContext object with empty strings. I will open a PR to fix this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenTracing shim doesn't change context #2016 - GitHub
OpenTelemetry HTTP instrumentation span actually belongs to the root span instead of span create by the library. So trace has the following ...
Read more >
Tracing SDK - OpenTelemetry
Context with parent Span . The Span's SpanContext may be invalid to indicate a root span. TraceId of the Span to be created....
Read more >
Instrumenting with OpenCensus - SFlanders
Creating a Root Span. Here is what my code looks like after I add instrumentation to create a root span: import io.opencensus.common.
Read more >
Spring Cloud Sleuth
Sleuth includes default logic to join a trace across HTTP or messaging boundaries. For example, HTTP propagation works over Zipkin-compatible request headers.
Read more >
Context Management in OpenTelemetry NodeJS | by Amir B
You are developing an instrumentation plugin for opentelemetry in node. ... following code will produce a correct trace where the three HTTP ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found