You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: sqlcommenter for PDO, MySqli, PostgreSql (pdo_mysql, pdo_pgsql) (#442)
* Initial
* Added SqlCommenter and its tests
* Added context propagator and updated PDO
* Fixed the dependencies
* Changed for MySqli
* Changed for PostgreSql
* nits
* Updated README.md
* Simplify PostgreSqlInstrumentation
* Considered the attributes in PostgreSql
* Updated
* Updated
* Typo
* Updated README.md(s)
* Added comments
* Remove the query command re-extraction
* Moved Context Propagator into SqlCommenter to make it per component
* Renamed env variable OTEL_PHP_SQLCOMMENTER_CONTEXT_PROPAGATORS
* Renamed other environment variables
* Moved logic to SqlCommenter
* nits
Copy file name to clipboardExpand all lines: src/Instrumentation/MySqli/src/MySqliInstrumentation.php
+57-10Lines changed: 57 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -20,12 +20,14 @@
20
20
21
21
/**
22
22
* @phan-file-suppress PhanParamTooFewUnpack
23
+
* @phan-file-suppress PhanUndeclaredClassMethod
23
24
*/
24
25
class MySqliInstrumentation
25
26
{
26
27
use LogsMessagesTrait;
27
28
28
29
publicconstNAME = 'mysqli';
30
+
privateconstUNDEFINED = 'undefined';
29
31
30
32
privateconstMYSQLI_CONNECT_ARG_OFFSET = 0;
31
33
privateconstMYSQLI_REAL_CONNECT_ARG_OFFSET = 1; // The mysqli_real_connect function in procedural mode requires a mysqli object as its first argument. The remaining arguments are consistent with those used in other connection methods, such as connect or __construct
@@ -98,7 +100,7 @@ public static function register(): void
98
100
null,
99
101
'mysqli_query',
100
102
pre: staticfunction (...$args) use ($instrumentation, $tracker) {
@@ -466,6 +500,19 @@ private static function queryPostHook(CachedInstrumentation $instrumentation, My
466
500
467
501
}
468
502
503
+
/**
504
+
* multi_query can execute multiple queries in one call. We will create a span for the multi_query call, but we will also track the individual queries and their results, creating spans for each query in the multi_query call.
505
+
* The individual query spans will be created in the next_result hook, which is called to fetch the results of each query in the multi_query call.
506
+
* As QueryPreHook has database span context propagation logic, we need to create this multiQueryPrehook function for multi_query to keep the pre-hook function unchanged.
0 commit comments