1. Go to this page and download the library: Download taisph/laravel-opentracing 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/ */
taisph / laravel-opentracing example snippets
// Create the application.
$app = new \Illuminate\Foundation\Application(realpath(__DIR__ . '/../'));
// Bind important interfaces.
// ...
// Register important providers.
$app->register(\LaravelOpenTracing\TracingServiceProvider::class);
// Enable tracing span context in log messages.
$app->configureMonologUsing(function (\Monolog\Logger $logger) {
$logger->pushProcessor(new \LaravelOpenTracing\Log\Processor\LocalTracerProcessor());
});
// Return the application.
return $app;
function a() {
// We don't care about tracing this specifically.
doSomething();
app(\LaravelOpenTracing\TracingService::class)->trace(
'app.do_something_else',
function () {
doSomethingElse();
}
);
}
app(\LaravelOpenTracing\TracingService::class)->trace(
'app.do_stuff',
function () {
a();
}
);
$title = 'Make more coffee';
$item = app(\LaravelOpenTracing\TracingService::class)->trace(
'todo.store_item',
function () use ($title) {
return \App\Models\TodoListItem::create(['title' => $title]);
},
['tags' => ['title' => $title]]
);