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
The global fetch support has been introduced in this PR #3258.
But the injected headers in order to link the traces between them are not correctly configured.
Expected behaviour
When I use global fetch the tracing headers should be injected in order to link related traces.
Actual behaviour
Currently, the tracing headers are not correctly injected.
I checked your test suite. And it seems I found the missing test case:
it('should inject its parent span in the existing headers',done=>{constapp=express()app.get('/user',(req,res)=>{expect(req.get('foo')).to.be.a('string')expect(req.get('x-datadog-trace-id')).to.be.a('string')expect(req.get('x-datadog-parent-id')).to.be.a('string')res.status(200).send()})getPort().then(port=>{agent.use(traces=>{expect(traces[0][0].meta).to.have.property('http.status_code','200')}).then(done).catch(done)appListener=server(app,port,()=>{fetch(`http://localhost:${port}/user?foo=bar`,{headers: {'foo': 'bar'}})})})})
The tracing headers are not correctly injected when we already have initial headers in the fetch request.
As explained in my description, the injected headers are not included in message.headers. And since we use it as second argument, I suppose it overrides the injected headers included in the first argument (via message.req).
See https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-instrumentations/src/fetch.js#L23
The global fetch support has been introduced in this PR #3258.
But the injected headers in order to link the traces between them are not correctly configured.
Expected behaviour
When I use global fetch the tracing headers should be injected in order to link related traces.
Actual behaviour
Currently, the tracing headers are not correctly injected.
Detailed description
https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-instrumentations/src/fetch.js#L24
We are using
message.headers
but this object does not contain the injected headers.Something is probably missing here: https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-plugin-fetch/src/index.js#L22C5-L22C59
We should probably make
message.headers = args.options.headers
in order to take advantage of https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-plugin-http/src/client.js#L66.BTW Are we sure the _inject method is useful?
Environment
The text was updated successfully, but these errors were encountered: