Lifecycle
Flare classifies every span on its own. A trace does not need a root span, and spans can arrive in any order and in different payloads.
Entry Spans
An entry span starts a unit of work: the entry point of your application's execution, which Flare uses to organize and display performance data.
Flare treats a span as an entry span when its category is request, command, job or browser_page, or when its type is operation. The category table lists the span types in each category.
Every other span is assigned to its nearest entry span ancestor. A span without an entry span ancestor is still stored and shown in the trace, it just does not belong to a unit of work. Flare records no failure for it.
Child Statistics, Links and Boot Time
Child statistics (such as the number of queries in a request), links between aggregations, boot time and failed propagation need the whole unit of work in one payload. Flare only calculates them when telemetry.sdk.name is spatie/laravel-flare or spatie/flare-client-php, because those clients send one complete request, command or job per payload. Other clients get correct numbers for the entry span itself (count, duration, failed state and HTTP status codes) but no child statistics, links or boot time.
Application Lifecycle
An optional php_application span can wrap an entry span to capture the full framework lifecycle. An application span without an entry span below it is ignored. The application lifecycle consists of the following phases:
php_application
├── php_application_registration
├── php_application_boot
├── php_request (entry span)
│ ├── php_global_before_middleware
│ ├── php_routing
│ ├── ...
│ └── php_response
└── php_application_terminating
| Span Type | Description |
|---|---|
php_application |
Root span wrapping the entire application lifecycle |
php_application_registration |
Service provider registration phase |
php_application_boot |
Service provider boot phase |
php_application_terminating |
Termination callbacks after the response is sent |
When an application span is present, Flare adjusts the entry span's start time to include boot time, giving a complete picture of the request duration.
The application lifecycle spans are entirely optional. Long-running workers and application servers boot once and then handle many requests or jobs. In these cases it makes sense to only send the entry span (request or job) without wrapping it in an application span. A trace with just a root php_request or laravel_job is perfectly valid.
Nested Entry Spans
Entry spans can be nested. For example, a request that dispatches a synchronous job will have two entry spans:
php_request (entry span)
├── php_query
└── laravel_job (entry span)
├── php_query
└── redis_command
Each entry span defines its own boundary. Child spans are assigned to their nearest entry span ancestor.