kezhenxu94 commented on pull request #20:
URL: https://github.com/apache/skywalking-nodejs/pull/20#issuecomment-753322571
> I have one issue though, why did you remove `span.async()` and
`config.span.resync()` in AxiosPlugin? Were you getting a problem? Because I
put them back and my test still works fine.
Yes that was what I would ask you to have a double check.
> In the case here what happens is that the axios request is about to return
synchronously so it calls `span.async()` to remove itself from the current
async task span list
From what I've tested, if you remove itself (by `span.async()`), the
underlying `http` module will create a new span instead of using the existing
exit span, so the result becomes
```yaml
segmentItems:
- serviceName: server
segmentSize: 1
segments:
- segmentId: 99239d3627cc45c891da83ad70cc2ed2
spans:
- operationName: /axios
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: 1609509943404
endTime: 1609509943412
componentId: 49
isError: false
spanType: Entry
peer: server:5000
skipAnalysis: false
tags:
- {key: http.url, value: 'server:5000/axios'}
- {key: http.status.code, value: '200'}
refs:
- {parentEndpoint: '', networkAddress: 'server:5000', refType:
CrossProcess,
parentSpanId: 2, parentTraceSegmentId:
2417bad1936c4ee88df68a619d534d0f, parentServiceInstance: ae93997659b8,
parentService: client, traceId: 551f3481f8fc4a84aa262455391e2f43}
- operationName: /json
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Http
startTime: 1609509943407
endTime: 1609509944263
componentId: 4005
isError: false
spanType: Exit
peer: httpbin.org
skipAnalysis: false
tags:
- {key: http.url, value: httpbin.org/json}
- {key: http.status.code, value: '200'}
- {key: http.status.msg, value: OK}
- operationName: /json
operationId: 0
parentSpanId: -1
spanId: 2
spanLayer: Http
startTime: 1609509943415
endTime: 1609509944268
componentId: 2
isError: false
spanType: Exit
peer: httpbin.org:80
skipAnalysis: false
tags:
- {key: http.url, value: 'httpbin.org:80/json'}
- {key: http.status.code, value: '200'}
- {key: http.status.msg, value: OK}
- serviceName: client
segmentSize: 1
segments:
- segmentId: 2417bad1936c4ee88df68a619d534d0f
spans:
- operationName: /axios
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: 1609509943388
endTime: 1609509943392
componentId: 49
isError: false
spanType: Entry
peer: localhost:5001
skipAnalysis: false
tags:
- {key: http.url, value: 'localhost:5001/axios'}
- {key: http.status.code, value: '200'}
- operationName: /axios
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Http
startTime: 1609509943390
endTime: 1609509944272
componentId: 4005
isError: false
spanType: Exit
peer: server:5000
skipAnalysis: false
tags:
- {key: http.url, value: 'server:5000/axios'}
- {key: http.status.code, value: '200'}
- {key: http.status.msg, value: OK}
- operationName: /axios
operationId: 0
parentSpanId: -1
spanId: 2
spanLayer: Http
startTime: 1609509943395
endTime: 1609509944276
componentId: 2
isError: false
spanType: Exit
peer: server:5000
skipAnalysis: false
tags:
- {key: http.url, value: 'server:5000/axios'}
- {key: http.status.code, value: '200'}
- {key: http.status.msg, value: OK}
```
Note the 2 exit spans for the same, one from `axios` and one from `http`
module.
> If this mechanism is removed then if there is something that creates a
span between when axios.Axios.prototype.request() returns and when the
axios.interceptors.request.use() handler gets control then that span will have
this request as its parent. This something can be synchronous code that runs
after the return from request()
Seems the correct `http` span should be the "something" 👆?
Unless there is another bug or the `axios.request` doesn't return
asynchronously (which doesn't seem to be the case through the `axios` codes).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]