-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ApiCallMonitor::getProcessMonitor getter + start and end method adjus…
…tement
- Loading branch information
1 parent
2a0e49c
commit 94178df
Showing
3 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
namespace Smart\CoreBundle\Monitoring; | ||
|
||
use Smart\CoreBundle\Entity\ApiCallInterface; | ||
use Smart\CoreBundle\Entity\ProcessInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* @author Mathieu Ducrot <[email protected]> | ||
|
@@ -15,9 +15,9 @@ public function __construct(private readonly ProcessMonitor $processMonitor) | |
{ | ||
} | ||
|
||
public function start(ApiCallInterface $apiCall, Request $request): ApiCallInterface | ||
public function start(ApiCallInterface $apiCall, Request $request, bool $flush = false): ApiCallInterface | ||
{ | ||
$this->processMonitor->start($apiCall); | ||
$this->processMonitor->start($apiCall, $flush); | ||
$apiCall->setMethod($request->getMethod()); | ||
$apiCall->setRouteUrl($request->getUri()); | ||
$apiCall->setType($request->attributes->get('_route')); | ||
|
@@ -29,6 +29,11 @@ public function start(ApiCallInterface $apiCall, Request $request): ApiCallInter | |
public function end(ApiCallInterface $apiCall, int $statusCode, bool $flush = true): void | ||
{ | ||
$apiCall->setStatusCode($statusCode); | ||
$this->processMonitor->end($apiCall, $statusCode >= 200 && $statusCode < 300, $flush); | ||
$this->processMonitor->end($apiCall, $statusCode >= Response::HTTP_CONTINUE && $statusCode < Response::HTTP_BAD_REQUEST, $flush); | ||
} | ||
|
||
public function getProcessMonitor(): ProcessMonitor | ||
{ | ||
return $this->processMonitor; | ||
} | ||
} |
This file contains 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