Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 support #108

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4d33273
todo list
jky-yy Aug 26, 2020
d21c078
Migrate from travis to GitHub Actions
nauxliu Dec 25, 2020
e0b75d8
Support opentracing v1.0
nauxliu Dec 25, 2020
c3bdb70
Change CI php version
nauxliu Dec 25, 2020
e30d6a4
Fix phpunit tests
nauxliu Dec 25, 2020
11db654
Update README
nauxliu Dec 25, 2020
b1dc43f
Bump PHPStan level 4
nauxliu Dec 25, 2020
19db2ac
Disable test on PHP 8
nauxliu Dec 25, 2020
f7d394a
Merge branch 'dev_v3' into next-major-version
nauxliu Dec 26, 2020
e0317a8
Merge pull request #98 from nauxliu/next-major-version
nauxliu Dec 26, 2020
8a67a8f
Add php-cs-fixer to format code
nauxliu Dec 26, 2020
9ee1ce5
PHP 7.1 syntax
nauxliu Dec 26, 2020
b92a7db
Add GitHub Action Lint job
nauxliu Dec 26, 2020
936d373
Improve PHPDoc
nauxliu Dec 26, 2020
34d6051
Add span property type doc
nauxliu Dec 26, 2020
e151e51
Update README.md
nauxliu Dec 26, 2020
4294caa
Fix call to undefined on Reference
nauxliu Dec 26, 2020
3e44d9a
Require ext-json
nauxliu Dec 26, 2020
7a9ddf8
Code style improvements
nauxliu Dec 26, 2020
c00b243
Refactor thrift
jky-yy Dec 29, 2020
28cec1a
unit test of JaegerThrift
jky-yy Dec 29, 2020
65e3611
unit test of transportUdp
jky-yy Dec 30, 2020
3c3a767
unit test of propagator
jky-yy Dec 30, 2020
6f56e26
unit test of config
jky-yy Dec 30, 2020
7843d62
PHPStan: ignore thrift functions not found errors
nauxliu Dec 31, 2020
349ea9d
Remove unmatch ignored error pattern
nauxliu Dec 31, 2020
ef00bc9
Improve TransportUdp type hint
nauxliu Jan 6, 2021
5c7e72b
Code format
nauxliu Jan 7, 2021
3a6cda7
Fix PHPStan errors
nauxliu Jan 7, 2021
641abfc
Fix opentracing/opentracing 1.0.1 return type
nauxliu Jan 14, 2021
41b0e3a
Fix always send data to localhost:6831
nauxliu Feb 2, 2021
f34d658
Fix int tag values always be 0
nauxliu Feb 2, 2021
5e599ca
Update README.md
jky-yy Apr 16, 2021
1341e84
Fix type for php 8.1
revenkroz May 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
# - '8.0'
dependency-version: [prefer-stable]
name: ${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

- name: Execute PHPStan
run: vendor/bin/phpstan analyse src tests

- name: PHP CS Fixer Check
run: vendor/bin/php-cs-fixer fix --dry-run --diff 1>&2
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
# - '8.0'
dependency-version: [prefer-stable]
name: ${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

- name: Execute tests
run: ./vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.buildpath
.project
.idea
.php_cs.cache
composer.lock
vendor/*
build
22 changes: 22 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the TYPO3 project.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

// Define in which folders to search and which folders to exclude
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('src/Jaeger/Thrift')
->in(__DIR__);

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
])
->setFinder($finder);
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# jaeger-php

[![Build Status](https://travis-ci.com/jukylin/jaeger-php.svg?branch=master)](https://travis-ci.com/jukylin/jaeger-php)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)](https://php.net/)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg)](https://php.net/)
[![License](https://img.shields.io/github/license/jukylin/jaeger-php.svg)](https://github.com/jukylin/jaeger-php/blob/master/LICENSE)
[![Coverage Status](https://coveralls.io/repos/github/jukylin/jaeger-php/badge.svg?branch=master)](https://coveralls.io/github/jukylin/jaeger-php?branch=master)

Expand All @@ -10,7 +12,6 @@
Install via composer.

```
composer config minimum-stability dev
composer require jukylin/jaeger-php
```

Expand Down Expand Up @@ -101,3 +102,10 @@ $config->flush();
[OpenTracing](https://opentracing.io/)

[Jaeger](https://uber.github.io/jaeger/)


## TODO
- [x] Implement the latest opentracing/opentracing
- [ ] Improve documentation
- [x] Refactor thrift
- [ ] Improve unit test coverage
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"license": "Apache-2.0",
"minimum-stability": "stable",
"require": {
"php": ">=5.6.0",
"packaged/thrift" : "0.10.0",
"opentracing/opentracing" : "1.0.0-beta5"
"php": ">=7.1",
"ext-json": "*",
"packaged/thrift" : "~0.13.0",
"opentracing/opentracing" : "^1.0.1"
},
"authors": [
{
Expand All @@ -24,10 +25,14 @@
]
},
"scripts": {
"test": "./vendor/bin/phpunit"
"test": "./vendor/bin/phpunit",
"phpcs": "./vendor/bin/php-cs-fixer fix --ansi",
"phpstan": "./vendor/bin/phpstan analyse src tests"
},
"require-dev": {
"phpunit/phpunit": "^5",
"php-coveralls/php-coveralls": "^1.0"
"php-coveralls/php-coveralls": "^v2.4.3",
"phpstan/phpstan": "^0.12.64",
"friendsofphp/php-cs-fixer": "^2.17"
}
}
29 changes: 17 additions & 12 deletions example/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,34 @@
* the License.
*/

require_once dirname(dirname(dirname(dirname(__FILE__)))).'/autoload.php';
require_once dirname(__FILE__, 2).'/vendor/autoload.php';

use Jaeger\Config;
use GuzzleHttp\Client;
use Jaeger\Config;
use OpenTracing\Formats;
use OpenTracing\Reference;

unset($_SERVER['argv']);


//init server span start
$config = Config::getInstance();

$config->gen128bit();

$config::$propagator = Jaeger\Constants\PROPAGATOR_ZIPKIN;

$tracer = $config->initTracer('example', '0.0.0.0:6831');
$tracer = $config->initTracer('example', 'localhost:6831');

$injectTarget = [];
$spanContext = $tracer->extract(Formats\TEXT_MAP, $_SERVER);
$serverSpan = $tracer->startSpan('example HTTP', ['child_of' => $spanContext]);
$serverSpan->addBaggageItem("version", "1.8.9");
print_r($serverSpan->getContext());

$options = [];
if (null != $spanContext) {
$options = ['child_of' => $spanContext];
}

$serverSpan = $tracer->startSpan('HTTP', $options);
//$serverSpan->addBaggageItem('version', '1.8.9');
$tracer->inject($serverSpan->getContext(), Formats\TEXT_MAP, $_SERVER);

//init server span end
Expand All @@ -50,13 +55,13 @@
$method = 'GET';
$url = 'https://github.com/';
$client = new Client();
$res = $client->request($method, $url,['headers' => $injectTarget1]);
$res = $client->request($method, $url, ['headers' => $injectTarget1]);

$clientSpan1->setTag('http.status_code', 200);
$clientSpan1->setTag('http.method', 'GET');
$clientSpan1->setTag('http.url', $url);

$clientSpan1->log(['message' => "HTTP1 ". $method .' '. $url .' end !']);
//$clientSpan1->log(['message' => 'HTTP1 '.$method.' '.$url.' end !']);
$clientSpan1->finish();
//client span1 end

Expand All @@ -65,8 +70,8 @@
$spanContext = $clientTracer->extract(Formats\TEXT_MAP, $_SERVER);
$clientSpan2 = $clientTracer->startSpan('HTTP2',
['references' => [
Reference::create(Reference::FOLLOWS_FROM, $clientSpan1->spanContext),
Reference::create(Reference::CHILD_OF, $spanContext)
//Reference::createForSpan(Reference::FOLLOWS_FROM, $clientSpan1),
Reference::createForSpan(Reference::CHILD_OF, $clientSpan1),
]]);

$clientTracer->inject($clientSpan2->spanContext, Formats\TEXT_MAP, $injectTarget2);
Expand All @@ -80,7 +85,7 @@
$clientSpan2->setTag('http.method', 'GET');
$clientSpan2->setTag('http.url', $url);

$clientSpan2->log(['message' => "HTTP2 ". $method .' '. $url .' end !']);
//$clientSpan2->log(['message' => 'HTTP2 '.$method.' '.$url.' end !']);
$clientSpan2->finish();
//client span2 end

Expand Down
17 changes: 6 additions & 11 deletions example/HTTP2.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<?php

require_once dirname(dirname(dirname(dirname(__FILE__)))).'/autoload.php';
require_once dirname(__FILE__, 2).'/vendor/autoload.php';

use Jaeger\Config;
use GuzzleHttp\Client;
use OpenTracing\Formats;
use OpenTracing\Reference;

unset($_SERVER['argv']);


//init server span start
$config = Config::getInstance();

Expand All @@ -20,22 +16,21 @@
$third = $tracer->startActiveSpan('level third');

$num = 0;
for ($i = 0; $i < 10; $i++){
$num += 1;
for ($i = 0; $i < 10; ++$i) {
++$num;
}
$third->getSpan()->setTag("num", $num);
$third->getSpan()->setTag('num', $num);
sleep(1);
$third->close();

$num = 0;
for ($i = 0; $i < 10; $i++){
for ($i = 0; $i < 10; ++$i) {
$num += 2;
}
$third->getSpan()->setTag("num", $num);
$third->getSpan()->setTag('num', $num);
sleep(1);
$second->close();


$top->close();

//trace flush
Expand Down
16 changes: 6 additions & 10 deletions example/Hprose.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
* the License.
*/

require_once dirname(dirname(dirname(dirname(__FILE__)))).'/autoload.php';
require_once dirname(__FILE__, 2).'/vendor/autoload.php';

use Hprose\Client;
use Jaeger\Config;
use OpenTracing\Formats;


unset($_SERVER['argv']);

//init server span start
Expand All @@ -37,33 +36,30 @@
$header = [];
$spanContext = $clientTracer->extract(Formats\TEXT_MAP, $_SERVER);
$clientSpan = $clientTracer->startSpan('get', ['child_of' => $spanContext]);
$clientSpan->addBaggageItem("version", "2.0.0");
$clientSpan->addBaggageItem('version', '2.0.0');

$clientTracer->inject($clientSpan->spanContext, Formats\TEXT_MAP, $header);

$url = 'http://0.0.0.0:8080/main';
$client = Client::create($url, false);

if($header){
foreach($header as $key => $val){
if ($header) {
foreach ($header as $key => $val) {
$client->setHeader($key, $val);
}
}
$clientSpan->setTag('http.url', $url);
$clientSpan->setTag('http.method' , 'POST');
$clientSpan->setTag('http.method', 'POST');

$result = $client->get("Hprose");
$result = $client->get('Hprose');

$clientSpan->log(['http.result' => $result]);
$clientSpan->finish();
//client span end


//server span end
$serverSpan->finish();
//trace flush
$config->flush();

echo "success\r\n";


Loading