PHP agent on Alpine

Prerequisites

  • For prerequisite checks for agent installation, see Prerequisite checks for agent installation.
  • SixthSense Agent - provided by Customer Support.
  • URL/IP of the SixthSense collector (your tenant URL which will be provided by Customer Support).
  • Access token from the SixthSense portal. For accessing the token, see Accessing your Access Token under Getting started with the Observability Portal.
  • Variables: TOKEN from the SixthSense portal. See Accessing your Access Token under Getting started with the Observability Portal.

Installing the agent from source

PHP agent is installed as PHP extension and is responsible for instrumentation of all the incoming and outgoing calls from the system. Since PHP Agent is installed as PHP extension, you will need to build the PHP extension from the source files. The following procedures helps you build the agent.

Install gPRC and Protobuf on Alpine

note

You need cmake version 3.13 or later.

GRPC_RELEASE_TAG=ss-php-agent
GIT_SSL_NO_VERIFY=1
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib64
LD_RUN_PATH=$LD_RUN_PATH:/usr/local/lib:/usr/local/lib64
set -ex && apk --update add --no-cache git ca-certificates autoconf automake libtool g++ make file linux-headers file re2c pkgconf openssl openssl-dev curl-dev cmake
git clone --depth 1 -b ${GRPC_RELEASE_TAG} https://artifacts-observability.sixthsense.rakuten.com/sixthsense-repositories/grpc.git /var/local/git/grpc
cd /var/local/git/grpc && git config --global url.https://github.com/.insteadOf git://github.com/
cd /var/local/git/grpc && git submodule update --init --recursive
cd /var/local/git/grpc/third_party/protobuf && ./autogen.sh
cd /var/local/git/grpc/third_party/protobuf && ./configure
cd /var/local/git/grpc/third_party/protobuf && make -j$(nproc)
cd /var/local/git/grpc/third_party/protobuf && make install
# RUN cd /var/local/git/grpc/third_party/protobuf && ldconfig
cd /var/local/git/grpc && mkdir -p cmake/build cd cmake ../.. -DBUILD_SHARED_LIBS=ON -DgRPC_INSTALL=ON && make -j$(nproc) && make install
# add #include <limit> header in c++ file if we are getting error related to max function
./sixthsense-php-agent.tar /var/local/git/
# add apk boost boost-dev if u r getting error related to no such file or directory
cd /var/local/git/sixthsense-php-agent && phpize && ./configure && make && make install
cd /var/local/git/sixthsense-php-agent && cp php.ini /usr/local/etc/php/conf.d/ext-skywalking.ini

Installing the SixthSense agent on Alpine

  1. Copy SixthSense agent to /tmp directory to build and install the agent.
  2. Ensure that the phpize command is working. If not, install php-devel for your PHP version.
scl enable devtoolset-7 bash # (to change gcc version to v7)
cd /tmp/sixthsense-php-agent && sudo phpize && sudo ./configure && sudo make && sudo make install
sudo cp php.ini <Php extension directory base>/conf.d/ext-skywalking.ini

Configuring the PHP agent ini file

Open the sixthsense.ini file and update the following fields (php --ini shows the ini file).

extension=skywalking.so
skywalking.app_code = <Your_service_name>
skywalking.authentication = <Your_auth_token>
skywalking.teamID = <Your_team_id>
skywalking.enable = 1
skywalking.version = 8
skywalking.grpc = <grpc collector url>
skywalking.log_enable = 1
skywalking.proxy = http://35.200.147.154:3128
skywalking.http = https://http-collector-observability.sixthsense.rakuten.com/oap
skywalking.segmentSize = 3000
skywalking.httpTimeout = 30
skywalking.segmentFlushInterval = 3
skywalking.proxy= <proxy url >

For OneCloud Platform, use the following command:

extension=skywalking.so
skywalking.app_code = <Your_service_name>
skywalking.authentication = <Your_auth_token>
skywalking.teamID = <Your_team_id>
skywalking.enable = 1
skywalking.version = 8
skywalking.log_enable = 1
In case of restricted environment, set the following parameters in the config.ini file:
skywalking.proxy = <proxy used for your internet access>
skywalking.http = https://sixthsense-backend.jpe2-caas1-prod1.caas.jpe2b.r-local.net/oap/
skywalking.segmentSize = 3000
skywalking.httpTimeout = 30
skywalking.segmentFlushInterval = 3
skywalking.proxy= <proxy url >

For running php-fpm, use the following command:

sudo php-fpm --nodaemonize & (won't work without the nodaemonize option)

While running using systemctl, if the libprotobuf.so.3.12.2.0 file is not found and an error is displayed, run the following command.

ln /usr/local/lib64/libprotobuf.so.3.12.2.0 /usr/lib64/libprotobuf.so.3.12.2.0