Skip to content

Commit

Permalink
Fix deprecations in CommandDataCollector (#856)
Browse files Browse the repository at this point in the history
* Fix deprecations in CommandDataCollector

* Fix spaces
  • Loading branch information
andrey-tech authored Sep 30, 2024
1 parent 0642b8b commit fdc40f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"homepage": "http://www.doctrine-project.org",
"require": {
"php": "^8.1",
"ext-mongodb": "^1.5",
"ext-mongodb": "^1.16",
"composer-runtime-api": "^2.0",
"doctrine/mongodb-odm": "^2.6",
"doctrine/persistence": "^3.0",
Expand Down
6 changes: 3 additions & 3 deletions src/DataCollector/CommandDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\ODM\MongoDB\APM\Command;
use Doctrine\ODM\MongoDB\APM\CommandLogger;
use MongoDB\BSON\Document;
use stdClass;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -16,8 +17,6 @@
use function array_reduce;
use function count;
use function json_decode;
use function MongoDB\BSON\fromPHP;
use function MongoDB\BSON\toCanonicalExtendedJSON;

/** @internal */
final class CommandDataCollector extends DataCollector
Expand All @@ -33,10 +32,11 @@ public function collect(Request $request, Response $response, ?Throwable $except
'commands' => array_map(
static function (Command $command): array {
$dbProperty = '$db';
$document = Document::fromPHP($command->getCommand());

return [
'database' => $command->getCommand()->$dbProperty ?? '',
'command' => json_decode(toCanonicalExtendedJSON(fromPHP($command->getCommand()))),
'command' => json_decode($document->toCanonicalExtendedJSON()),
'durationMicros' => $command->getDurationMicros(),
];
},
Expand Down

0 comments on commit fdc40f3

Please sign in to comment.