PHP code example of extraswoft / zipkin

1. Go to this page and download the library: Download extraswoft/zipkin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

extraswoft / zipkin example snippets


        "jcchavezs/zipkin-opentracing": "^0.1.2",
        "opentracing/opentracing": "1.0.0-beta5",
        "extraswoft/zipkin": "*"

      'beanScan' => [
        "ExtraSwoft\\Zipkin\\"
    ],

    'serverDispatcher' => [
        'middlewares' => [
            \Swoft\View\Middleware\ViewMiddleware::class,
            ZipkinMiddleware::class
//             \Swoft\Devtool\Middleware\DevToolMiddleware::class,
            // \Swoft\Session\Middleware\SessionMiddleware::class,
        ]
    ],

  #Zipkin
ZIPKIN_HOST=http://0.0.0.0:9411
ZIPKIN_RAND=100

$client = new Client(['adapter' => new AddZipkinAdapter()]);


         Log::profileStart($profileKey);
+        App::trigger('Mysql', 'start', $profileKey, $sql);
         $connection->prepare($sql);
         $params = self::transferParams($params);
         $result = $connection->execute($params);

         $this->release();

         Log::profileEnd($this->profileKey);
+        App::trigger('Mysql', 'end', $this->profileKey);
         return $result;

         $connectPool = App::getPool($this->poolName);
         /* @var ConnectionInterface $client */
         $connection = $connectPool->getConnection();
+        App::trigger('Redis', 'start', $method, $params);
         $result     = $connection->$method(...$params);
         $connection->release(true);
+        App::trigger('Redis', 'end');

         return $result;

 if ($query !== '') $path .= '?' . $query;

         $client->setDefer();
+        App::trigger('HttpClient', 'start', $request, $options);
         $client->execute($path);

         App::profileEnd($profileKey);

         $this->recv();
         $result = $client->body;
         $client->close();
+        App::trigger('HttpClient', 'end');
         $headers = value(function () {
             $headers = [];

   docker run -d -p 9411:9411 openzipkin/zipkin