perftools / xhgui

Web interface for XHProf profiling data can store data in MongoDB or PDO database
1.65k stars 343 forks source link

[error] he 'cursor' option is required, except for aggregation explain #221

Closed liangmingran closed 6 years ago

liangmingran commented 6 years ago

if you mongo version >3.5 , you will see the error in Recent runs pages by clicking an url link

the 'cursor' option is required, except for aggregation explain

fix it by modify /path/xhgui/src/Xhgui/Profiles.php

$this->_collection->aggregate(array(
            array('$match' => $match),
            array(
                '$project' => array(
                    'date' => $col,
                    'profile.main()' => 1
                )
            ),
            array(
                '$group' => array(
                    '_id' => '$date',
                    'row_count' => array('$sum' => 1),
                    'wall_times' => array('$push' => '$profile.main().wt'),
                    'cpu_times' => array('$push' => '$profile.main().cpu'),
                    'mu_times' => array('$push' => '$profile.main().mu'),
                    'pmu_times' => array('$push' => '$profile.main().pmu'),
                )
            ),
            array(
                '$project' => array(
                    'date' => '$date',
                    'row_count' => '$row_count',
                    'raw_index' => array(
                        '$multiply' => array(
                            '$row_count',
                            $percentile / 100
                        )
                    ),
                    'wall_times' => '$wall_times',
                    'cpu_times' => '$cpu_times',
                    'mu_times' => '$mu_times',
                    'pmu_times' => '$pmu_times',
                )
            ),
            array('$sort' => array('_id' => 1)),
        ),array('cursor' => array('batchSize' => 0)));
markstory commented 6 years ago

Any chance you could send a pull request for this fix? I don't use mongo > 3.5.

skors commented 6 years ago

Hi,

I've added a pull request #228 for this to patch, based on @liangmingran informations

markstory commented 6 years ago

Thanks @skors