PHP code example of cusodede / yii2-opentracing

1. Go to this page and download the library: Download cusodede/yii2-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/ */

    

cusodede / yii2-opentracing example snippets


$config = [
	...
	'bootstrap' => ['log', 'opentracing'], //Обязательно добавляем в bootstrap
	...
	'components' => [
		...
		'opentracing' => [ //Подключаем сам компонент
			'class' => OpenTracingComponent::class,
			'excludedRequestsPaths' => [
				'assets/*'
			],
			'handlers' => [//Указываем хендлеры логирования
				HttpClientEventsHandler::class
			]
		],
		'log' => [
			...
			'targets' => [
				...
				[//добавляем target для логирования событий категории opentracing, OpenTracingFileTarget позволяет гибче конфигурировать имя файла
					'class' => OpenTracingFileTarget::class,
					'categories' => ['opentracing'],
					'logVars' => [],
					'logFile' => fn():string => '@app/runtime/logs/ot-'.date('YmdH').'.log'
				]
			],
		],
		...
];