The Grafana Faro Web SDK, part of the Grafana Faro project, is a highly configurable web SDK for real user monitoring (RUM) that instruments browser frontend applications to capture observability signals. Frontend telemetry can then be correlated with backend and infrastructure data for full-stack observability.
The new faro.trace.* events which are sent per child span have always the same traceId and spanId.
TraceID of course is correct when they belong to the same trace, but the spanId is different.
Problem
When attaching TraceContext (spanId and traceId) to a signal, Faro pulls the active span from the otel context and receives the IDs from this span.
This is not always correct.
Say we want to send a signal for a specific span:
With the old behavior each call to a Faro api, e. g. pushEvent will auto receive traceId and spanId from the active span, which is wrong.
Solution
Provide an option to inject spanContext for the specific span when calling an Faro api.
The API will pick up the spanContext and uses that values instead of the active span.
What
Update each Faro api except pushTraces to be able to inject a spanContext.
This is not === the otel SpanContext. We only need the traceId and spanId
Update sendFaroEvents in traceEsporterUtils to inject the spanContext of the child span (kind=client)
Why
Issue
The new
faro.trace.*
events which are sent per child span have always the same traceId and spanId. TraceID of course is correct when they belong to the same trace, but the spanId is different.Problem
When attaching
TraceContext
(spanId
andtraceId
) to a signal, Faro pulls the active span from the otel context and receives the IDs from this span.This is not always correct. Say we want to send a signal for a specific span: With the old behavior each call to a Faro api, e. g.
pushEvent
will auto receivetraceId
andspanId
from the active span, which is wrong.Solution
Provide an option to inject
spanContext
for the specific span when calling an Faro api. The API will pick up thespanContext
and uses that values instead of the active span.What
pushTraces
to be able to inject a spanContext.traceId
andspanId
sendFaroEvents
intraceEsporterUtils
to inject the spanContext of the child span (kind=client)Links
Checklist