grafana / faro-web-sdk

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.
https://grafana.com/oss/faro/
Apache License 2.0
688 stars 62 forks source link

Add span context when sending faro events which belong to specific spans #510

Closed codecapitano closed 4 months ago

codecapitano commented 4 months ago

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 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

Links

Checklist