Skip to content
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

Fix deprecations in CommandDataCollector #856

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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