You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
I'm playing with this library and see how the correlation context is propagated through http request.
Here is the snippet
consttracing=require('@opencensus/nodejs');constConsoleExporter=require('@opencensus/core');constpropagation=require('@opencensus/propagation-tracecontext');consttraceContext=newpropagation.TraceContextFormat();consttracer=tracing.start({propagation: traceContext}).tracer;constexporter=newConsoleExporter.ConsoleExporter({bufferSize: 1,bufferTimeout: 1,logger: console});tracing.registerExporter(exporter);consthttp=require('http');http.get('http://www.google.com',(resp)=>{letdata='';resp.on('data',(chunk)=>{data+=chunk;});resp.on('end',()=>{console.log(`Response end, data length is ${data.length}`);});}).on("error",(err)=>{console.log("Error: "+err.message);});conststdin=process.openStdin();stdin.addListener("data",()=>{});
If I don't add the propagation context, the http instrumentation would successfully create a span for the outgoing request. But if I add the propagation context, it gives me this error. Did I missed anything?
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ClientRequest.setHeader (_http_outgoing.js:469:11)
at Object.setHeader (D:\OpenCensus\node\node_modules\@opencensus\instrumentation-http\build\src\http.js:182:29)
at TraceContextFormat.inject (D:\OpenCensus\node\node_modules\@opencensus\propagation-tracecontext\build\src\tracecontext-format.js:109:20)
at D:\OpenCensus\node\node_modules\@opencensus\instrumentation-http\build\src\http.js:187:29
at contextManager.runAndReturn (D:\OpenCensus\node\node_modules\@opencensus\core\build\src\trace\model\tracer.js:111:20)
at AsyncHooksNamespace.runAndReturn (D:\OpenCensus\node\node_modules\@opencensus\core\build\src\internal\cls-ah.js:51:21)
at CoreTracer.startRootSpan (D:\OpenCensus\node\node_modules\@opencensus\core\build\src\trace\model\tracer.js:84:36)
at Object.outgoingRequest [as get] (D:\OpenCensus\node\node_modules\@opencensus\instrumentation-http\build\src\http.js:159:42)
at Object.<anonymous> (D:\OpenCensus\node\test.js:17:6)
at Module._compile (internal/modules/cjs/loader.js:689:30)
The text was updated successfully, but these errors were encountered:
I'm playing with this library and see how the correlation context is propagated through http request.
Here is the snippet
If I don't add the propagation context, the http instrumentation would successfully create a span for the outgoing request. But if I add the propagation context, it gives me this error. Did I missed anything?
The text was updated successfully, but these errors were encountered: