1. Go to this page and download the library: Download beta/otel.base 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/ */
beta / otel.base example snippets
use Otel\Base\Util\RequestHelper;
use Psr\Http\Server\RequestHandlerInterface;
class SomeHttpController implements RequestHandlerInterface
{
public function handle(ServerRequestInterface $request): ResponseInterface
{
$spanManager = RequestHelper::getSpanManagerFromRequest($request);
$spanManager->getSpan()->setAttribute('someSpanAttribute', 'someValue')
$spanManager->getSpan()->addEvent(
'startController',
['firstEventAttribute' => 1, 'secondEventAttribute' => 2]
);
....
}
}
use Otel\Base\OTelMiddleware;
use Otel\Base\OTelFactory;
$oTelFactory = new OTelFactory('./otel.json');
$oTelMiddleware = OTelMiddleware::initWithFactory($oTelFactory);
$someRestApplication->registerMiddleware($oTelMiddleware);
$router = $someRestApplication->getRouter();
$router->registerController('GET', '/api/handle', new SomeHttpController());
$someRestApplication->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.