feat: log request ids to map xml dumps of bpn api communication

This commit is contained in:
Björn Fromme
2026-03-16 12:02:27 +01:00
parent fedfcc247e
commit f55ed3dc4c
5 changed files with 67 additions and 3 deletions
+10 -2
View File
@@ -25,6 +25,7 @@ use App\Form\Model\RegistrationDto;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\SerializerInterface;
@@ -55,6 +56,7 @@ class ApiClient
private readonly FilesystemOperator $xmlDump,
private readonly LoggerInterface $logger,
private readonly BookingDataProcessor $bookingDataProcessor,
private readonly RequestStack $requestStack,
array $options,
) {
$this->config = $this->resolveOptions($options);
@@ -516,7 +518,7 @@ class ApiClient
*/
private function doSendRawXml(string $xml, bool $debug = false): string
{
$requestId = date(DATE_ATOM).uniqid();
$requestId = $this->getRequestId();
$doc = new \DOMDocument();
if (false === @$doc->loadXML($xml)) {
@@ -631,7 +633,7 @@ class ApiClient
*/
private function doSendRequest(string $type, array $data, array $additionalArgs = [], bool $debug = false): mixed
{
$requestId = date(DATE_ATOM).uniqid();
$requestId = $this->getRequestId();
$body = $this
->serializer
@@ -685,6 +687,12 @@ class ApiClient
}
}
private function getRequestId(): string
{
return $this->requestStack->getMainRequest()?->attributes->get('request_id')
?? date(DATE_ATOM).uniqid();
}
private function createKey(string $username, string $password, string $type): string
{
$date = (new \DateTimeImmutable())->format('Ymd');