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

apm_error_cb called #723

Open
snmsmanager opened this issue Feb 21, 2025 · 3 comments
Open

apm_error_cb called #723

snmsmanager opened this issue Feb 21, 2025 · 3 comments
Assignees

Comments

@snmsmanager
Copy link

snmsmanager commented Feb 21, 2025

hello,

I'm going to test PINPOINT APM with PHP application and my PHP version is 8.
when I called index.php, I'm able to see transaction (error) in PINPONT and not able to see transaction to mysql DB. Also return below error.

Image

Image

this is my index.php

//enable vendor/autoload.php //if need
require_once DIR . '/vendor/autoload.php';
define('APPLICATION_NAME', 'DEMO-PHP'); // your application name
define('APPLICATION_ID', 'DEMO-PHP'); // your application id
define('PP_REQ_PLUGINS', Pinpoint\Plugins\DefaultRequestPlugin::class);
require_once DIR . '/vendor/pinpoint-apm/pinpoint-php-aop/auto_pinpointed.php';

$stmt = $pdo->query("SELECT id, name, email FROM users");

error log returns

[pinpoint] [201878:201878] [127] add anno_v1 key:stp value:2101
[pinpoint] [201878:201878] [127] add anno_v1 key:SQL value:SELECT id, name, email FROM users
[pinpoint] [201878:201878] call_interceptor_before:pdo::query return type(0) zval
[pinpoint] [201878:201878]replace_ex_caller_parameters return value must be an array
[pinpoint] [201878:201878]apm_error_cb called
[pinpoint] [201878:201878]call_interceptor_end: pdo::query
[pinpoint] [201878:201878]apm_error_cb called
[Fri Feb 21 23:33:56 2025] 192.168.16.1:56439 [500]: GET / - Uncaught TypeError: Pinpoint\Plugins\pinpoint_add_clue(): Argument #2 ($value) must be of type string, null given, called in /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/SysV2/_pdo/pdo7.php on line 51 and defined in /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/functions.php:55
Stack trace:
#0 /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/SysV2/_pdo/pdo7.php(51): Pinpoint\Plugins\pinpoint_add_clue()
#1 [internal function]: Pinpoint\Plugins\PinpointPerRequestPlugins::Pinpoint\Plugins\SysV2_pdo{closure}()
#2 /opt/my-php-app/my-php-app/index.php(11): PDO->query()
#3 {main}
thrown in /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/functions.php on line 55
[pinpoint] [201878:201878] [127] add anno_v2 46:500
[pinpoint] [201878:201878] pinpoint_get_context_key [127] failed with map::at, parameters:__pinpoint__route
[pinpoint] [201878:201878] [127] pinpoint_end_trace Done!
[pinpoint] [201878:201878]this span:({":E":12,":FT":1500,":S":1740161036622,"ERR":{"file":"/opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/functions.php","line":55,"msg":"Uncaught TypeError: Pinpoint\Plugins\pinpoint_add_clue(): Argument #2 ($value) must be of type string, null given, called in /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/SysV2/_pdo/pdo7.php on line 51 and defined in /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/functions.php:55\nStack trace:\n#0 /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/SysV2/_pdo/pdo7.php(51): Pinpoint\Plugins\pinpoint_add_clue()\n#1 [internal function]: Pinpoint\Plugins\PinpointPerRequestPlugins::Pinpoint\Plugins\SysV2\_pdo\{closure}()\n#2 /opt/my-php-app/my-php-app/index.php(11): PDO->query()\n#3 {main}\n thrown"},"appid":"DEMO-PHP","appname":"DEMO-PHP","client":"192.168.16.1","event":[{":E":2,":S":10,":depth":1,":seq":0,"SQL":"SELECT id, name, email FROM users","anno":["46:500"],"name":"PDO::query","stp":"2101"}],"name":"PHP Request: cli-server","server":"192.168.16.6:8080","sid":"1646425384","stp":"1500","tid":"DEMO-PHP^1740161032387^0","uri":"/"})
[pinpoint] [201878:201878]agent try to connect:(192.168.16.6:10000)

@eeliu
Copy link
Collaborator

eeliu commented Feb 24, 2025

It looks the $value is null ...

Uncaught TypeError: Pinpoint\Plugins\pinpoint_add_clue(): Argument https://github.com/pinpoint-apm/pinpoint-c-agent/pull/2 ($value) must be of type string, null given, called in /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/SysV2/_pdo/pdo7.php on line 51 and defined in /opt/my-php-app/my-php-app/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Plugins/functions.php:55

How did you set your db_host ?

https://github.com/pinpoint-apm/pinpoint-php-aop/blob/dev/lib/Pinpoint/Plugins/SysV2/_pdo/PDO_Test.php#L14

@snmsmanager
Copy link
Author

@eeliu ,

Thanks for the update. when I try to use mysqli then it work but no database request in diagram . below is two functions using PDO and mysqli

function call_mysql() {

$username = "demo";
$password = "demo";
$dbname = "testdb";

$conn = new PDO("mysql:host=192.168.16.111;port=3306;dbname=$dbname", $username, $password);
$stmt = $conn->prepare("SELECT * FROM `users` LIMIT 10;");
$stmt->execute();
$stmt->fetchAll();
$stmt->fetch();

$sql = 'SELECT * FROM `users` LIMIT 10';
foreach ($conn->query($sql) as $row) {
    print $row['name'] . "\t";
    print $row['email'] . "\n";
}

$conn = null;

}

function call_mariadb(){
$servername = "192.168.16.111";
$username = "demo";
$password = "demo";
$dbname = "testdb";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";

}

@snmsmanager
Copy link
Author

@eeliu ,

I've managed to resolve PDO. I have added all function available in testapp including Redis and curl. But still not able to see any transactions originate from php application.

[pinpoint] [44211:44211] pinpoint_get_context_key [128] failed with map::at, parameters:__pinpoint__route
[pinpoint] [44211:44211]this span:({":E":9,":FT":1500,":S":1740465885104,"anno":["46:200"],"appid":"cd.dev.test.run","appname":"cd.dev.test.php","client":"192.168.16.1","event":[{":E":1,":S":3,":depth":1,":seq":0,"SQL":"SELECT * FROM users LIMIT 10;","dst":"192.168.16.111","name":"PDO::prepare","stp":"2101"},{":E":1,":S":1,":depth":1,":seq":1,"name":"PDOStatement::execute","stp":"1501"},{":E":0,":S":2,":depth":1,":seq":2,"name":"PDOStatement::fetchAll","stp":"1501"},{":E":0,":S":1,":depth":1,":seq":3,"name":"PDOStatement::fetch","stp":"1501"},{":E":0,":S":0,":depth":1,":seq":4,"SQL":"SELECT * FROM users LIMIT 10","dst":"192.168.16.111","name":"PDO::query","stp":"2101"}],"name":"PHP Request: cli-server","server":"192.168.16.6:8080","sid":"728792307","stp":"1500","tid":"cd.dev.test.run^1740465792139^6","uri":"/"})

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants