Skip to content

Commit 5577343

Browse files
committed
section for details on how to set the previous trace span link
1 parent 4518d50 commit 5577343

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

text/0141-linking-traces.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,20 @@ For links stored in child spans, SDKs should serialize them to `spans[i].links`:
321321
}
322322
```
323323

324+
### Setting `previous_trace` span links
325+
326+
We can link traces by definint span links on the root spans of respective frontend traces. The general idea is to store the span context of the previous root span in a a storage mechanism of choice (e.g. `sessionStorage` in the browser) and read/write to it when necessary:
327+
328+
Therefore, on root span start:
329+
* Check if there is a previous span context stored
330+
* If yes, add the span link with the `'sentry.link.type': 'previous_trace'` attribute
331+
* Store the root span context as the previous root span in a storage mechanism of choice (e.g. `sessionStorage` in the browser)
332+
333+
SDKs are free to implement heuristics around how long a previous trace span context should be considered (max time) and store additional necessary data.
334+
335+
This means that the last-started root span will be denote the previous trace. In situations, where multiple root spans are started in parallel, the last started span "wins". However, the multiple root spans aspect of this should play a negligible role in Sentry SDKs, given our SDKs don't allow for this by default and it would require significant manual user setup. We acknowledge though that this could lead to potentially confusing relationships.
336+
337+
324338
### Ingest / Relay
325339

326340
Relay should forward the span links in the format that is required for further processing and storage.

0 commit comments

Comments
 (0)