Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 249
FOUR-20464 view server timing data in LogRocket#7825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,6 +11,7 @@ | ||
| use Illuminate\Notifications\Events\NotificationSent; | ||
| use Illuminate\Support\Facades; | ||
| use Illuminate\Support\Facades\DB; | ||
| use Illuminate\Support\Facades\Log; | ||
| use Illuminate\Support\Facades\URL; | ||
| use Laravel\Dusk\DuskServiceProvider; | ||
| use Laravel\Horizon\Horizon; | ||
| @@ -403,11 +404,16 @@ public static function getQueryTime(): float | ||
| /** | ||
| * Set the boot time for service providers. | ||
| * | ||
| * @param string $package | ||
| * @param float $time | ||
| */ | ||
| public static function setPackageBootStart(string $package, $time): void | ||
| public static function setPackageBootStart(string $package, float $time): void | ||
| { | ||
| $package = ucfirst(\Str::camel(str_replace(['ProcessMaker\Packages\\', '\\'], '', $package))); | ||
| if ($time < 0) { | ||
| Log::info("Server Timing: Invalid boot time for package: {$package}, time: {$time}"); | ||
| $time = 0; | ||
| } | ||
| self::$packageBootTiming[$package] = [ | ||
| 'start' => $time, | ||
| @@ -418,11 +424,16 @@ public static function setPackageBootStart(string $package, $time): void | ||
| /** | ||
| * Set the boot time for service providers. | ||
| * | ||
| * | ||
| * @param float $time | ||
| */ | ||
| public static function setPackageBootedTime(string $package, $time): void | ||
| { | ||
| $package = ucfirst(\Str::camel(str_replace(['ProcessMaker\Packages\\', '\\'], '', $package))); | ||
| if (!isset(self::$packageBootTiming[$package]) || $time < 0) { | ||
| Log::info("Server Timing: Invalid booted time for package: {$package}, time: {$time}"); | ||
| return; | ||
| } | ||
| self::$packageBootTiming[$package]['end'] = $time; | ||
devmiguelangel marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,24 +30,36 @@ public function __construct($app) | ||
| { | ||
| parent::__construct($app); | ||
| $this->booting(function () { | ||
| self::$bootStart = microtime(true); | ||
| $package = $this->getPackageName(); | ||
| $package = defined('static::name') ? static::name : $this::class; | ||
| $this->booting(function () use ($package) { | ||
| self::$bootStart = microtime(true); | ||
| ProcessMakerServiceProvider::setPackageBootStart($package, self::$bootStart); | ||
| }); | ||
| $this->booted(function () { | ||
| $this->booted(function () use ($package) { | ||
| self::$bootTime = microtime(true); | ||
| $package = defined('static::name') ? static::name : $this::class; | ||
| ProcessMakerServiceProvider::setPackageBootedTime($package, self::$bootTime); | ||
| }); | ||
| } | ||
| /** | ||
| * Get the package name for the Server Timing header | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getPackageName(): string | ||
| { | ||
devmiguelangel marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (defined('static::name')) { | ||
| return ucfirst(\Str::camel(static::name)); | ||
| } | ||
| return substr(static::class, strrpos(static::class, '\\') + 1); | ||
devmiguelangel marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| /** | ||
| * Boot the PM plug-in. | ||
| */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.