The Life Cycle of a FusionReactor Span¶
The Start of a Span¶
Generally, FusionReactor creates a span when an action is started, such as when a particular method is called for example.
When a span is created, the parent is either extracted from a received request's trace parent header, chosen by a specified trace context or the currently active transaction on the thread. If no such parent is found, the span becomes a root span.
It is then decided whether the span shall be sampled or not. If the span has a parent, the span is uses the parent's sample state. Otherwise, it's decided via probability.
The span is given a default name (the transaction's flavour) and a span kind.
A trace parent header is also injected if the span is of the necessary flavour type (HttpClient, OkHttp,...), so that trace information can be propagated to other instances/services.
During a Span¶
If an error is thrown during the span, an event will be recorded on the span. This will include the exception type, message and stacktrace.
|An example of a span with a trace, displaying a captured error and a limited example of attributes.|
The End of a Span¶
When a span ends it is passed through ITT processing. This will decide whether the span was an interesting transaction or not. In the case that the span is an ITT but isn't sampled, the span will become sampled and set to be exported.
The span name is changed if a more detailed one is available. Span attributes are also added according to the transaction flavour.
The span is then added to the exporting/shipping queue and await shipment via HTTP request.
The span is exported/shipped as part of a batch of spans after being converted to the OpenTelemetry Protobuf format.