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

I need some help #596

Open
killen9 opened this issue Apr 15, 2024 · 66 comments · Fixed by #600
Open

I need some help #596

killen9 opened this issue Apr 15, 2024 · 66 comments · Fixed by #600
Assignees

Comments

@killen9
Copy link

killen9 commented Apr 15, 2024

I need some help ...

##############PINPOINT###########################
require_once DIR.'/../vendor/autoload.php';
define('APPLICATION_NAME','php');
define('APPLICATION_ID','2');
define('AOP_CACHE_DIR',DIR.'/../Cache/');
define('PLUGINS_DIR',DIR.'/../Plugins/');
define('PINPOINT_USE_CACHE','YES');
require_once DIR.'/../vendor/pinpoint-apm/pinpoint-php-aop/auto_pinpointed.php';
#################################################

collector.log

[2024-04-15 13:56:50.024840042] INFO client:10.0.0.167:35716 is online
[2024-04-15 13:56:50.024928028] INFO send handshake msg:{"appid":"no","appname":"no","time":"1713141240"}

why "appid":"no","appname":"no ?

@eeliu
Copy link
Collaborator

eeliu commented Apr 15, 2024

why "appid":"no","appname":"no ?

it's an old setting, deprecated now. (agent information can be set at collector-agent side)

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

how setting?

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

Please tell me how to set up the collector-agent.

@eeliu
Copy link
Collaborator

eeliu commented Apr 15, 2024

collector-agent

https://github.com/pinpoint-apm/pinpoint-c-agent/blob/dev/DOC/collector-agent/readme.md

php agent

define('APPLICATION_NAME','php');
define('APPLICATION_ID','2');

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

what?

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

.bash_profile

export PP_COLLECTOR_AGENT_SPAN_IP=127.0.0.1
export PP_COLLECTOR_AGENT_SPAN_PORT=9993
export PP_COLLECTOR_AGENT_AGENT_IP=127.0.0.1
export PP_COLLECTOR_AGENT_AGENT_PORT=9991
export PP_COLLECTOR_AGENT_STAT_IP=127.0.0.1
export PP_COLLECTOR_AGENT_STAT_PORT=9992
export PP_COLLECTOR_AGENT_ISDOCKER=false
export PP_LOG_DIR=/app/pinpoint/logs
export PP_Log_Level=INFO
export PP_ADDRESS=0.0.0.0@9999

php.ini

[pinpoint_php]
extension = pinpoint_php.so
pinpoint_php.CollectorHost = tcp:211.45.120.7:9999
pinpoint_php.SendSpanTimeOutMs = 0
pinpoint_php.TraceLimit = -1
pinpoint_php.DebugReport = true

[error_log]
error_reporting = E_ALL
#log_errors = On
error_log = /var/log/php/php-error.log

common.php

##############PINPOINT###########################
require_once DIR.'/../vendor/autoload.php';
define('APPLICATION_NAME','GNB');
define('APPLICATION_ID','2');
define('AOP_CACHE_DIR',DIR.'/../Cache/');
define('PLUGINS_DIR',DIR.'/../Plugins/');
define('PINPOINT_USE_CACHE','YES');
require_once DIR.'/../vendor/pinpoint-apm/pinpoint-php-aop/auto_pinpointed.php';
#################################################

Is it different?

It is not registered on the web and cannot be connected to pinpoint-collector.

@eeliu
Copy link
Collaborator

eeliu commented Apr 15, 2024

Please attach the output of php agent.

https://github.com/pinpoint-apm/pinpoint-c-agent/blob/dev/testapps/PHP/php.ini

Does your pinpoint-collector locate at "PP_COLLECTOR_AGENT_SPAN_IP=127.0.0.1" ?

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

It is installed locally.

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

collector-agent / pinpoint-collector is installed locally.

@eeliu
Copy link
Collaborator

eeliu commented Apr 15, 2024

collector.log

[2024-04-15 13:56:50.024840042] INFO client:10.0.0.167:35716 is online
[2024-04-15 13:56:50.024928028] INFO send handshake msg:{"appid":"no","appname":"no","time":"1713141240"}

why "appid":"no","appname":"no ?

Please tell me how to set up the collector-agent.

it looks collector-agent woks fine.

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

collector.log

[2024-04-15 17:10:43.110591367] INFO client:127.0.0.1:50806 is online
[2024-04-15 17:10:43.110772605] INFO send handshake msg:{"appid":"no","appname":"no","time":"1713165831"}
[2024-04-15 17:10:43.111114644] WARN no FT
[2024-04-15 17:10:43.111140757] WARN dispather packet with an exception: no FT
[2024-04-15 17:10:43.111154559] WARN parseInComePacket catches error:no FT,client:127.0.0.1:50806
[2024-04-15 17:10:43.11116987] INFO connection:127.0.0.1:50806 is shutdown

why isn't registered on the web?

@eeliu
Copy link
Collaborator

eeliu commented Apr 15, 2024

Enable "log_errors= On " and share us the logging of your php application.

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

no logging

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

collector.log

[2024-04-15 17:51:14.645184858] INFO client:10.0.0.167:60632 is online
[2024-04-15 17:51:14.645371276] INFO send handshake msg:{"appid":"no","appname":"no","time":"1713171031"}
[2024-04-15 17:51:14.64558775] DEBUG size: 275 packetType: 1 body:{":E":252,":FT":1500,":S":1713171074392,"appid":"php-1","appname":"GNB","client":"192.168.10.20","clues":["46:200"],"name":"PHP Request: fpm-fcgi","server":"10.0.0.167","sid":"1718730853","stp":"1500","tid":"php-1^1713171066709^0","uri":"/gnuboard/bbs/board.php?bo_table=qa"}
[2024-04-15 17:51:14.645708234] WARN no FT
[2024-04-15 17:51:14.645762668] WARN dispather packet with an exception: no FT
[2024-04-15 17:51:14.645790138] WARN parseInComePacket catches error:no FT,client:10.0.0.167:60632
[2024-04-15 17:51:14.645831342] INFO connection:10.0.0.167:60632 is shutdown

@eeliu
Copy link
Collaborator

eeliu commented Apr 15, 2024

collector.log

[2024-04-15 17:51:14.645184858] INFO client:10.0.0.167:60632 is online [2024-04-15 17:51:14.645371276] INFO send handshake msg:{"appid":"no","appname":"no","time":"1713171031"} [2024-04-15 17:51:14.64558775] DEBUG size: 275 packetType: 1 body:{":E":252,":FT":1500,":S":1713171074392,"appid":"php-1","appname":"GNB","client":"192.168.10.20","clues":["46:200"],"name":"PHP Request: fpm-fcgi","server":"10.0.0.167","sid":"1718730853","stp":"1500","tid":"php-1^1713171066709^0","uri":"/gnuboard/bbs/board.php?bo_table=qa"} [2024-04-15 17:51:14.645708234] WARN no FT [2024-04-15 17:51:14.645762668] WARN dispather packet with an exception: no FT [2024-04-15 17:51:14.645790138] WARN parseInComePacket catches error:no FT,client:10.0.0.167:60632 [2024-04-15 17:51:14.645831342] INFO connection:10.0.0.167:60632 is shutdown

Try the latest collector-agent .
docker pull ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.5.0

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

#define PHP_PINPOINT_PHP_VERSION "0.2.1"

@eeliu
Copy link
Collaborator

eeliu commented Apr 15, 2024

please update the collector-agent

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

don't go build

[pin@Zenius collector-agent]$ go build
common/config.go:9:2: no required module provides package github.com/pinpoint-apm/pinpoint-c-agent/collector-agent/pinpoint-grpc-idl/proto/v1; to add it:
go get github.com/pinpoint-apm/pinpoint-c-agent/collector-agent/pinpoint-grpc-idl/proto/v1

@killen9
Copy link
Author

killen9 commented Apr 15, 2024

make error

[pin@Zenius collector-agent]$ make
protoc --go_out=pinpoint-grpc-idl/proto/ --go-grpc_out=pinpoint-grpc-idl/proto --proto_path=pinpoint-grpc-idl/proto/ --go-grpc_opt=paths=source_relative v1/Annotation.proto v1/Cmd.proto v1/CustomMetric.proto v1/Service.proto v1/Span.proto v1/Stat.proto v1/ThreadDump.proto
google/protobuf/wrappers.proto: File not found.
v1/Annotation.proto: Import "google/protobuf/wrappers.proto" was not found or had errors.
v1/Annotation.proto:15:5: "google.protobuf.StringValue" is not defined.
v1/Annotation.proto:20:5: "google.protobuf.StringValue" is not defined.
v1/Annotation.proto:21:5: "google.protobuf.StringValue" is not defined.
v1/Annotation.proto:26:5: "google.protobuf.StringValue" is not defined.
v1/Annotation.proto:27:5: "google.protobuf.StringValue" is not defined.
v1/Annotation.proto:36:5: "google.protobuf.StringValue" is not defined.
v1/Annotation.proto:47:5: "google.protobuf.StringValue" is not defined.
v1/Annotation.proto:48:5: "google.protobuf.StringValue" is not defined.
make: *** [makefile:8: protoc] Error 1

@eeliu
Copy link
Collaborator

eeliu commented Apr 16, 2024

you missed the submodule

git clone --recurse-submodules https://github.com/pinpoint-apm/pinpoint-c-agent.git

@killen9
Copy link
Author

killen9 commented Apr 16, 2024

fail

사용자 지정 1

@eeliu
Copy link
Collaborator

eeliu commented Apr 16, 2024

please check the dockerfile of collector-agent
https://github.com/pinpoint-apm/pinpoint-c-agent/blob/dev/collector-agent/Dockerfile

Script for compile collector-agent

...
apk add make protobuf-dev
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
...

@killen9
Copy link
Author

killen9 commented Apr 16, 2024

what's mean?

i'm not use docker.

@killen9
Copy link
Author

killen9 commented Apr 16, 2024

[root@Zenius collector-agent]# go build
common/config.go:9:2: no required module provides package github.com/pinpoint-apm/pinpoint-c-agent/collector-agent/pinpoint-grpc-idl/proto/v1; to add it:
go get github.com/pinpoint-apm/pinpoint-c-agent/collector-agent/pinpoint-grpc-idl/proto/v1

1

@eeliu
Copy link
Collaborator

eeliu commented Apr 16, 2024

please check this #596 (comment)

@killen9
Copy link
Author

killen9 commented Apr 16, 2024

image

Dockerfile?

apk?

[root@Zenius collector-agent]# apk add --no-cache make protobuf-dev
bash: apk: command not found...

????

@killen9
Copy link
Author

killen9 commented Apr 16, 2024

I want to install it as server, not as docker

CentOS Linux release 8.5.2111

@eeliu
Copy link
Collaborator

eeliu commented Apr 16, 2024

I tried by docker of centos 8 ,while it's EOL.

image

Here is checklist:

  • go version (1.18)
  • protoc version (3.6.1)

image

@killen9
Copy link
Author

killen9 commented Apr 18, 2024

my project
html.zip

@eeliu
Copy link
Collaborator

eeliu commented Apr 18, 2024

As c-level function does not support yet, I will re-implement all plugins to support c-level in future.

sorry

@killen9
Copy link
Author

killen9 commented Apr 18, 2024

I don't know how to create a custom plugin.
I'm just an operator, not a developer.
Can you tell me how to set it up?

@eeliu
Copy link
Collaborator

eeliu commented Apr 18, 2024

@killen9

I find your project does not follow the psr-4, that means you can't use this version, even the custom plugin.

Ref

@eeliu eeliu added this to the 0.6-php-c-level milestone Apr 18, 2024
@eeliu
Copy link
Collaborator

eeliu commented Apr 18, 2024

I tag this issue into next major version.

@killen9
Copy link
Author

killen9 commented Apr 19, 2024

In addition to db information, I also want to display call-tree (trace) information and mem information.
I would appreciate your help.

@killen9
Copy link
Author

killen9 commented Apr 19, 2024

image

image

image

@eeliu
Copy link
Collaborator

eeliu commented Apr 19, 2024

@killen9

you can use Pinpoint\Plugins\Sys\PDO as your PDO plugins on php.

Supported list:
https://github.com/pinpoint-apm/pinpoint-php-aop/tree/dev/lib/Pinpoint/Plugins/Sys

@killen9
Copy link
Author

killen9 commented Apr 19, 2024

How should I apply it?

@eeliu
Copy link
Collaborator

eeliu commented Apr 19, 2024

hmm, I find your project use mysql_connect , it's not support any more.

try use PDO, or mysqli

Ref

@killen9
Copy link
Author

killen9 commented Apr 19, 2024

I don't know much about php.
I would appreciate it if you could tell me how to apply it to my project.

@eeliu
Copy link
Collaborator

eeliu commented Apr 19, 2024

OK,

  1. remove deprecated style for handle mysql, use PDO_MYSQL or msyqli instead.
  2. After 1 is done, use pinpoint plugins class to replace PDO_MYSQL or msyqli
  • PDO -> Pinpoint\Plugins\Sys\PDO\PDO
  • mysqli=Pinpoint\Plugins\Sys\mysqli\mysqli

this older file may help you https://github.com/pinpoint-apm/pinpoint-c-agent/blob/v0.4.10/testapps/PHP/Plugins/setting.ini

@killen9
Copy link
Author

killen9 commented Apr 23, 2024

I deleted the DB and installed mariadb 10.11 using yum.

However, DB information and trace still do not appear.

@eeliu
Copy link
Collaborator

eeliu commented Apr 24, 2024

Which db extension you used ? PDO or mysqli ?

I will post an example for you.

eeliu added a commit to eeliu/pinpoint-c-agent that referenced this issue Apr 25, 2024
- example for php

> hopes to help  pinpoint-apm#596
@eeliu eeliu mentioned this issue Apr 25, 2024
4 tasks
eeliu added a commit to eeliu/pinpoint-c-agent that referenced this issue Apr 25, 2024
- example for php

> hopes to help  pinpoint-apm#596
eeliu added a commit to eeliu/pinpoint-c-agent that referenced this issue Apr 25, 2024
- example for php

> hopes to help  pinpoint-apm#596
github-merge-queue bot pushed a commit that referenced this issue Apr 26, 2024
- example for php

> hopes to help  #596
@eeliu
Copy link
Collaborator

eeliu commented Apr 26, 2024

@killen9

I created an example for you. It reveals how to use pinpoint-php

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
// 33061 , is the port of mariadb server
$mysqli = new mysqli($mariadb_host, "root", "password", "test", 33061);
$result = $mysqli->query("SELECT * FROM `contacts` LIMIT 1000;");
printf("Select returned %d rows.\n", $result->num_rows);

docker compose up simple-php

@eeliu eeliu linked a pull request Apr 26, 2024 that will close this issue
4 tasks
@killen9
Copy link
Author

killen9 commented Apr 30, 2024

sorry. My reply was late due to a business trip.

[root@Zenius ext]# pwd
/usr/include/php/ext
[root@Zenius ext]# ls
date dom filter gd gmp hash iconv json libxml mbstring mysqli mysqlnd pcre pdo phar session simplexml sockets spl standard xml

i used mysqli

@eeliu
Copy link
Collaborator

eeliu commented Apr 30, 2024

@killen9
Copy link
Author

killen9 commented May 2, 2024

[30-Apr-2024 13:03:57 Asia/Seoul] PHP Warning: Use of undefined constant PLUGINS_DIR - assumed 'PLUGINS_DIR' (this will throw an Error in a future version of PHP) in /var/www/html/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Common/PinpointDriver.php on line 37
[30-Apr-2024 13:03:57 Asia/Seoul] PHP Warning: Use of undefined constant PLUGINS_DIR - assumed 'PLUGINS_DIR' (this will throw an Error in a future version of PHP) in /var/www/html/vendor/pinpoint-apm/pinpoint-php-aop/lib/Pinpoint/Common/PinpointDriver.php on line 37
[30-Apr-2024 13:03:57 Asia/Seoul] PHP Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'gnuboard'@'localhost' (using password: YES) in /var/www/html/run.php:22
Stack trace:
#0 /var/www/html/run.php(22): mysqli->__construct()
#1 /var/www/html/run.php(36): call_mysqli()
#2 /var/www/html/run.php(39): main()
#3 {main}
thrown in /var/www/html/run.php on line 22

run.zip

@eeliu
Copy link
Collaborator

eeliu commented May 6, 2024

I got your problem, try this version:

"pinpoint-apm/pinpoint-php-aop": "v2.2.0",

https://github.com/pinpoint-apm/pinpoint-c-agent/blob/dev/testapps/SimplePHP/composer.json

@killen9
Copy link
Author

killen9 commented May 7, 2024

[2024-05-07 14:04:27.805790368] INFO client:10.0.0.167:45674 is online
[2024-05-07 14:04:27.805922761] INFO send handshake msg:{"appid":"no","appname":"no","time":"1715058267805","version":"v0.5.0"}
[2024-05-07 14:04:27.806853315] DEBUG size:150 packetType:1 body:{":E":1,":FT":1500,":S":1715058267805,"SQL":"SELECT * FROM g5_login WHERE lo_ip=?","dst":"127.0.0.1 via TCP/IP","name":"Mysqli::prepare","stp":"2101"}
[2024-05-07 14:04:27.806988765] WARN tid in wrong format
[2024-05-07 14:04:27.807044482] WARN no appid
[2024-05-07 14:04:27.807077759] WARN dispatcher packet with an exception: no appid
[2024-05-07 14:04:27.807102949] WARN parsePacket catches error:no appid,client:10.0.0.167:45674
[2024-05-07 14:04:27.807145559] INFO connection:10.0.0.167:45674 is shutdown

@eeliu
Copy link
Collaborator

eeliu commented May 7, 2024

Did you foget this SimplePHP\RequestPlugin , it looks does not loading.
Check this source tree : https://github.com/pinpoint-apm/pinpoint-c-agent/tree/dev/testapps/SimplePHP
image

@killen9
Copy link
Author

killen9 commented May 13, 2024

It has been confirmed that DB information is displayed through SimplePHP.

1
2

But it doesn't appear in my project.
3

Do I need other settings?

@eeliu
Copy link
Collaborator

eeliu commented May 20, 2024

@killen9

Hello, use is just namespace aliasing. It should be placed at the file which that namespace was used.

use_mysqli_file.php
<?php

use Pinpoint\Plugins\Sys\mysqli\Mysqli;

.....

Reference

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

Successfully merging a pull request may close this issue.

2 participants