Class CausalScope
The causal id in scope on this thread: a 128-bit W3C-compatible trace id that every profiler span begun here carries, so the Workbench can tie engine work back to the HTTP request or client command that caused it (#1517).
public static class CausalScope
- Inheritance
-
CausalScope
- Inherited Members
Remarks
Takes precedence over Current. A span reads the scoped id first and only falls back to the ambient
Activity when none is set. Tick work runs on workers that never read the Activity (it costs too much per span there), so the scoped id is the only
way a cause reaches them. HTTP work needs nothing from here: the request's Activity is an AsyncLocal and follows every await, which a
thread-static set when the request started would not.
Work that crosses threads carries its cause explicitly: Capture() where the work is queued, Enter(CausalId) where it runs. An application that stages writes into the tick does exactly this.
Everything here is a no-op while ProfilerCorrelationActive is off.
Properties
Current
The id in scope on this thread, or None.
public static CausalId Current { get; }
Property Value
Methods
Capture()
The id in scope, or the ambient Current's trace id, to carry onto another thread.
public static CausalId Capture()
Returns
Enter(CausalId)
Puts id in scope until the returned scope is disposed, which restores what was there before.
public static CausalScope.Scope Enter(CausalId id)
Parameters
idCausalId