Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
/ hyperf-tracer Public archive
forked from hyperf/tracer

Commit

Permalink
[CORE-909] Adiciona nome do Span raiz (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
leocavalcante authored Dec 6, 2022
1 parent c6f1ae7 commit 91c0f2a
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 45 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
vendor/
*.cache
/.idea
.idea/
clover-coverage-report.xml
coverage/
runtime/
vendor/
16 changes: 12 additions & 4 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
'location' => 'after_declare_strict',
],
'array_syntax' => [
'syntax' => 'short'
'syntax' => 'short',
],
'list_syntax' => [
'syntax' => 'short'
'syntax' => 'short',
],
'concat_space' => [
'spacing' => 'one'
'spacing' => 'one',
],
'blank_line_before_statement' => [
'statements' => [
Expand All @@ -38,7 +38,7 @@
],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author'
'author',
],
],
'ordered_imports' => [
Expand Down Expand Up @@ -80,9 +80,17 @@
'single_quote' => true,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
'php_unit_test_class_requires_covers' => false,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('public')
->exclude('runtime')
->exclude('vendor')
->in(__DIR__)
)
Expand Down
46 changes: 46 additions & 0 deletions bin/phpunit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf + PicPay.
*
* @link https://github.com/PicPay/hyperf-tracer
* @document https://github.com/PicPay/hyperf-tracer/wiki
* @contact @PicPay
* @license https://github.com/PicPay/hyperf-tracer/blob/main/LICENSE
*/
ini_set('display_errors', 'on');
ini_set('display_startup_errors', 'on');

require_once __DIR__ . '/../config/consts.php';
require_once __DIR__ . '/../vendor/autoload.php';

error_reporting(E_ALL);
date_default_timezone_set('America/Sao_Paulo');

Hyperf\Di\ClassLoader::init();

Swoole\Runtime::enableCoroutine(true);

Swoole\Coroutine::set([
'hook_flags' => SWOOLE_HOOK_ALL,
'exit_condition' => static fn (): bool => Swoole\Coroutine::stats()['coroutine_num'] === 0,
]);

$code = 0;
Swoole\Coroutine\run(static function () use (&$code): void {
try {
$code = PHPUnit\TextUI\Command::main(false);
} catch (PHPUnit\TextUI\RuntimeException $e) {
if ($e->getMessage() === 'swoole exit') {
return;
}

throw $e;
} finally {
Swoole\Timer::clearAll();
Hyperf\Utils\Coordinator\CoordinatorManager::until(Hyperf\Utils\Coordinator\Constants::WORKER_EXIT)->resume();
}
});
exit($code);
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,9 @@
"hyperf": {
"config": "Hyperf\\Tracer\\ConfigProvider"
}
},
"scripts": {
"test": "php bin/phpunit.php",
"lint": "php-cs-fixer fix"
}
}
60 changes: 31 additions & 29 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions config/autoload/annotations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf + PicPay.
*
* @link https://github.com/PicPay/hyperf-tracer
* @document https://github.com/PicPay/hyperf-tracer/wiki
* @contact @PicPay
* @license https://github.com/PicPay/hyperf-tracer/blob/main/LICENSE
*/
return [
'scan' => [
'paths' => [
BASE_PATH . '/src',
],
'ignore_annotations' => [
'mixin',
],
],
];
17 changes: 17 additions & 0 deletions config/consts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf + PicPay.
*
* @link https://github.com/PicPay/hyperf-tracer
* @document https://github.com/PicPay/hyperf-tracer/wiki
* @contact @PicPay
* @license https://github.com/PicPay/hyperf-tracer/blob/main/LICENSE
*/
! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1));
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL);
! defined('DEFAULT_TIMEZONE') && define('DEFAULT_TIMEZONE', 'America/Sao_Paulo');
! defined('DEFAULT_APP_NAME') && define('DEFAULT_APP_NAME', 'ms-transaction-refund');
! defined('DEFAULT_APP_ENV') && define('DEFAULT_APP_ENV', 'dev');
! defined('CURRENT_VERSION') && define('CURRENT_VERSION', '0.1.0');
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" colors="true">
<coverage>
<include>
<directory>src</directory>
</include>
<report>
<clover outputFile="clover-coverage-report.xml" />
<html outputDirectory="coverage" />
</report>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
1 change: 1 addition & 0 deletions src/Adapter/HttpClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Hyperf\Guzzle\ClientFactory as GuzzleClientFactory;
use RuntimeException;

use function strlen;

class HttpClientFactory
Expand Down
1 change: 1 addition & 0 deletions src/Adapter/JaegerTracerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use OpenTracing\Tracer;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Log\LoggerInterface;

use const Jaeger\SAMPLER_TYPE_CONST;

class JaegerTracerFactory implements NamedFactoryInterface
Expand Down
3 changes: 0 additions & 3 deletions src/Annotation/Trace.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
*/
class Trace extends AbstractAnnotation
{
/**
* @var string
*/
public string $name = '';

/**
Expand Down
Loading

0 comments on commit 91c0f2a

Please sign in to comment.