faro-web-sdk
faro-web-sdk copied to clipboard
Fetch/XHR Instrumentation: Annotate server side context
Goal
Create links between events this instrumentation created and server-side spans.
Description
When a server communicates their span context down via headers, the fetch instrumentation should pick it up and annotate the trace / span id on the event.
On the server side, we should be able to pick up a request from a client side session and we should be able to annotate the session id on the server span.
Proposed solution
- instrumentation watches request
- instrumentations adds header
x-grafana-sessionwith a value of the session id - server works request, extracts
x-grafana-sessionand adds it to the server span - instrumentation sees
server-timing,traceparentortraceresponseheaders containing a traceparent compatible value in response - instrumentation adds value to log event
Resources
- traceresponse working draft - https://w3c.github.io/trace-context/#trace-context-http-response-headers-format
- traceparent standard - https://w3c.github.io/trace-context/#trace-context-http-request-headers-format
- https://raintank-corp.slack.com/archives/C04LHN01GN7/p1688052486783109?thread_ts=1688040850.841279&cid=C04LHN01GN7
### Tasks
- [ ] https://github.com/grafana/faro-web-sdk/issues/151#issuecomment-1678233608
Some info I got form Gabor.
We can get the traceId for the "backend request", The traceId that is created for every grafana ajax request, and arrives back in the browser in the
Grafana-Trace-Id: response-headerthere’s even some code to show that traceId as a “debug” thing in the query-inspector (but that’s behind the showTraceId feature flag).