feat: add kernel boot time as tracing attribute#13
feat: add kernel boot time as tracing attribute#13cyve wants to merge 1 commit intoworldia:masterfrom
Conversation
| $startTime = $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true); // Float with microsecond precision | ||
| $kernelBootTime = round(microtime(true) - $startTime, 3); |
There was a problem hiding this comment.
I think REQUEST_TIME_FLOAT is always present, no matter what.
I would also suggest to move that has first instruction, if microseconds matters lets be as precise as possible.
| $startTime = $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true); // Float with microsecond precision | |
| $kernelBootTime = round(microtime(true) - $startTime, 3); | |
| $startTimeInMs = $_SERVER['REQUEST_TIME_FLOAT']; | |
| $kernelBootTime = round(microtime(true) - $startTimeInMs, 3); |
I don't find how to add a comment on a line that you did not modify so I put it here:
You must change the priority of the event, a lot of listeners (sentry, monolog, debug, dump, etc) have a higher priority. Otherwise it's not really the "kernel boot time".
There was a problem hiding this comment.
@camilledejoye Are you saying that REQUEST_TIME_FLOAT is set in CLI sapi context?
| public function onRequestEvent(Event\RequestEvent $event): void | ||
| { | ||
| $request = $event->getRequest(); | ||
| $startTime = $request->server->get('REQUEST_TIME_FLOAT'); // Float with microsecond precision |
There was a problem hiding this comment.
As before I suggest to retrieve the current time as soon as possible.
And remove the comment since a name has the advantage of providing the information everywhere it's used and not becoming stale.
| $startTime = $request->server->get('REQUEST_TIME_FLOAT'); // Float with microsecond precision | |
| $startTimeInMs = $request->server->get('REQUEST_TIME_FLOAT'); | |
| $currentTimeInMs = microtime(true); |
As for the commands, there is other subscribers/listeners being executing before this one.
As a reminder bin/console debug:event-dispatcher kernel.request list those registered in a SF application with their priority.
|
Why would this be an attribute? Shouldn't it be considered as a subspan? |
80cb469 to
a8ef73a
Compare
633595f to
cee36ca
Compare
8b71925 to
a8fc0aa
Compare
|
It's not really the kernel boot duration, more the time between fpm level request start and dispatching of the |
9aec428 to
890bfba
Compare
Add
sf.kernel_boot_durationattribute to the trace containing the elapsed time between the very beginning of the request and the dispatch of thekernel.requestevent (in HTTP) or thekernel.consoleevent (in CLI), representing the booting duration of the Symfony Kernel.This is useful when we try to improve the Symfony configuration to speed up the kernel boot.