-
Notifications
You must be signed in to change notification settings - Fork 65
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 PDO instrumentation in PHP 8.4 #993
base: php84
Are you sure you want to change the base?
Conversation
|
Great job with the investigation and fix! |
508be9b
to
bbe7ed0
Compare
62506bd
to
2f8830a
Compare
2f8830a
to
dcc238f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## php84 #993 +/- ##
==========================================
- Coverage 78.03% 77.47% -0.57%
==========================================
Files 196 196
Lines 27084 26987 -97
==========================================
- Hits 21134 20907 -227
- Misses 5950 6080 +130
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
dcc238f
to
9807f77
Compare
ea6cce9
to
043f6bf
Compare
e121c97
to
4387b13
Compare
PHP 8.4 includes implementation of PDO driver specific sub-classes RFC (see https://wiki.php.net/rfc/pdo_driver_specific_subclasses). This means that when database access code uses new factory method `PDO::connect` to create PDO object, an instance of driver specific sub-class of `PDO` is returned instead of an instance of generic `PDO` class. This means that instrumentation of generic `PDO` class is not enough to provide instrumentation of datastores. Add wrappers for driver specific subclasses of `PDO` supported by the agent: `Pdo\Firebird`, `Pdo\Mysql`, `Pdo\Odbc`, `Pdo\Pgsql`, `Pdo\Sqlite`.
Back in 2015 when datastore integration tests were refactored to extract common configuration into `config.php`, setting the value of global variable `$MYSQL_DB` to the value of `MYSQL_DB` env var with help of `isset_or` was not preserved - it was left out as a TODO item. However, since mysql tests need to occasionally create tables in the database, as well as insert data into those tables, `$MYSQL_USER` needs permissions to do that. When mysqldb test service is provisioned, permissions are granted automatically for the database name stored in `$MYSQL_DB` env var. Therefore `$MYSQL_DB` must be set to the value of `MYSQL_DB` env var in order for create table to work. However, this means that all queries about MySQL's tables metadata stored in `information_schema` database need to specify full table path, i.e.: `SELECT * from information_schema.tables` rather than just `SELECT * from tables`.
Test output depends on PHP version and backing database - value for id column can be returned as int or string. Instead of splitting the test by PHP version and backing database normalize test output to always return value of id column as int.
4387b13
to
e1aa516
Compare
Test that agent creates datastore metrics when `PDO::query` and `PDO::execute` are provided connection object created using either `PDO::connect` factory method or PDO's specialized subclass constructor.
Test different variants of calls to PDO::query with various types of conn object for mysql, pgsql and sqlite databases.
e1aa516
to
81f0369
Compare
Test that agent creates datastore metrics, datastore spans and slow sql traces when `PDO::prepare` is provided connection object created using all supported methods: either `PDO::connect` factory method or PDO's base class or specialized subclass constructor.
3405121
to
5a40841
Compare
*/ | ||
|
||
/*INI | ||
;comment=Set explain_threshold to 0 to ensure that the slow query is recorded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the comments explaining these settings to be as close to the settings as possible. The reason for ;comment=...
construct is because integration_runner
expects key=value
format for anything (including comments) in INI
directive.
PHP 8.4 includes implementation of PDO driver specific sub-classes RFC (see https://wiki.php.net/rfc/pdo_driver_specific_subclasses). This means that when database access code uses new factory method
PDO::connect
to create PDO object, an instance of driver specific sub-class ofPDO
is returned instead of an instance of genericPDO
class. This means that instrumentation of genericPDO
class is not enough to provide instrumentation of datastores. Add wrappers for driver specific subclasses ofPDO
supported by the agent:Pdo\Firebird
,Pdo\Mysql
,Pdo\Odbc
,Pdo\Pgsql
,Pdo\Sqlite
.