1. Go to this page and download the library: Download icovn/laravel-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/ */
class MyApiController extends ZipkinBaseController{
// My Api Methods
}
use Mts88\LaravelZipkin\Services\ZipkinService;
class MyAwesomeController extends Controller{
public function __construct(ZipkinService $zipkinService)
{
// Do something with $zipkinService
}
}
use Mts88\LaravelZipkin\Controllers\ZipkinBaseController;
class MyAwesomeController extends ZipkinBaseController {
// My Awesome Methods
}
use Mts88\LaravelZipkin\Services\ZipkinService;
use Mts88\LaravelZipkin\Controllers\ZipkinBaseController;
class MyAwesomeController extends ZipkinBaseController{
public function __construct(ZipkinService $zipkinService)
{
parent::__construct($zipkinService);
// Do something with your override
}
}
// zipkinService instance
$this->zipkinService;
$this->zipkinService = new ZipkinService(); // or you can access in others way
// Create trace
$this->zipkinService->setTracer('my_trace_name', $request->ip());
$tags = [
"my_value1" => "hello",
"my_value2" => "world"
];
// Create RootSpan
$this->zipkinService->createRootSpan('root_span_of_request', $tags);
// Set Annotation
$this->zipkinService->setRootSpanAnnotation('my_annotation_1', \Zipkin\Timestamp\Timestamp\now());
// Dedicated Tags Methods
$this->zipkinService->setRootSpanMethod('GET') // Method of request
->setRootSpanPath('/') // Path of request
->setRootSpanStatusCode("200") // Response Code Server
->setRootAuthUser(Auth::user()); // User that perform request
// Insert others tags
$this->setRootSpanTag('my_value3', "ciao")
->setRootSpanTag('my_value4', "mondo");
// Close rootSpan and tracer
$this->zipkinService->closeSpan();