This topic describes how to import trace data from PHP applications to Log Service by using Zipkin.

Background information

Procedure

  1. Click here to download the official sample code of Zipkin.
  2. Modify the parameters in the functions.php file.
    1. Modify the $httpReporterURL parameter.
      Replace the ${endpoint} variable in the code with the actual value. For more information about the variables, see Table 1.
      $httpReporterURL = 'https://${endpoint}/zipkin/api/v2/spans';
      Table 1. Variables
      Variable Description Example
      ${endpoint} The endpoint. The format is ${project}.${region-endpoint}, where:
      • ${project}: the name of the Log Service project.
      • ${region-endpoint}: the endpoint of the project. You can access Log Service by using an endpoint of the Internet, the classic network, or a virtual private cloud (VPC). For more information, see Endpoints.
      test-project.cn-hangzhou.log.aliyuncs.com
    2. Add the headers parameter when you create the Zipkin\Reporters\Http file.
      Replace the variables in the following code with the actual values. For more information about the variables, see Table 2.
          $reporter = new Zipkin\Reporters\Http(
              \Zipkin\Reporters\Http\CurlFactory::create(),
              ['endpoint_url' => $httpReporterURL,
                     'headers' => ['x-sls-otel-project' => '${project}',
                            'x-sls-otel-instance-id' => '${instance}',
                            'x-sls-otel-ak-id' => '${access-key-id}',
                            'x-sls-otel-ak-secret' => '${access-key-secret}']
              ]
          );
      Table 2. Variables
      Variable Description Example
      ${project} The name of the Log Service project. test-project
      ${instance} The name of the trace instance. test-traces
      ${access-key-id} The AccessKey ID of your Alibaba Cloud account.

      We recommend that you use the AccessKey pair of a Resource Access Management (RAM) user who has only the write permissions on the Log Service project. An AccessKey pair consists of an AccessKey ID and an AccessKey secret. For information about how to grant the write permissions on a specific project to a RAM user, see Use custom policies to grant permissions to a RAM user. For information about how to obtain an AccessKey pair, see AccessKey pair.

      None
      ${access-key-secret} The AccessKey secret of your Alibaba Cloud account.

      We recommend that you use the AccessKey pair of a RAM user who has only the write permissions on the Log Service project.

      None
  3. Install dependencies.
    composer install
  4. Start the service.
    composer run-frontend
    composer run-backend
  5. Access the service and then send the trace data to Log Service.
    curl http://localhost:8081

What to do next