From c3fc93e5c366fd0c95e5bfe30356029ba5b47e9f Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Tue, 13 Feb 2024 18:16:08 +0100 Subject: [PATCH 1/6] improved http client tests --- .../HttpClientInstrumentationTest.php | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/tests/Instrumentation/HttpClientInstrumentationTest.php b/tests/Instrumentation/HttpClientInstrumentationTest.php index 4289ca7..d9aded5 100644 --- a/tests/Instrumentation/HttpClientInstrumentationTest.php +++ b/tests/Instrumentation/HttpClientInstrumentationTest.php @@ -1,6 +1,5 @@ 0]), + $http = Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); $root = Tracer::newSpan('root')->start(); @@ -36,16 +27,16 @@ $httpSpan = Arr::get($spans, count($spans) - 2); - $request = Server::received()[0]; + $request = Http::recorded()->first()[0]; + assert($request instanceof \Illuminate\Http\Client\Request); expect($request) - ->hasHeader('traceparent')->toBeTrue() - ->getHeader('traceparent')->toBe([sprintf('00-%s-%s-01', $traceId, $httpSpan->getSpanId())]); + ->header('traceparent')->toBe([sprintf('00-%s-%s-01', $traceId, $httpSpan->getSpanId())]); }); it('create http client span', function () { - Server::enqueue([ - new Response(200, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); Http::withTrace()->get(Server::$url); @@ -70,8 +61,8 @@ }); it('set span status to error on 4xx and 5xx status code', function () { - Server::enqueue([ - new Response(500, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 500, ['Content-Length' => 0]), ]); Http::withTrace()->get(Server::$url); @@ -94,8 +85,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); Http::withHeaders([ @@ -119,8 +110,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0, 'Content-Type' => 'text/html; charset=UTF-8']), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0, 'Content-Type' => 'text/html; charset=UTF-8']), ]); Http::withTrace()->get(Server::$url); @@ -144,8 +135,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); Http::withHeaders(['x-foo' => 'bar'])->withTrace()->get(Server::$url); @@ -167,8 +158,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0, 'Set-Cookie' => 'cookie']), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0, 'Set-Cookie' => 'cookie']), ]); Http::withHeaders([ From 04c5624806a502bd52a8d159e7c7d91d08edf734 Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Tue, 13 Feb 2024 18:34:40 +0100 Subject: [PATCH 2/6] drop laravel 9 --- .github/workflows/run-tests.yml | 2 +- .gitignore | 1 + composer.json | 12 ++++++------ phpunit.xml.dist | 29 +++++++---------------------- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e57a8d0..1d799a4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -23,7 +23,7 @@ jobs: fail-fast: false matrix: php: [ 8.1, 8.2, 8.3 ] - laravel: [ ^9.0, ^10.0 ] + laravel: [ ^10.0 ] stability: [ prefer-stable, prefer-lowest ] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} diff --git a/.gitignore b/.gitignore index 0a63bc1..13d442a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .php_cs .php_cs.cache .phpunit.result.cache +.phpunit.cache build composer.lock coverage diff --git a/composer.json b/composer.json index ea6531e..d5eb2c9 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ ], "require": { "php": "^8.1", - "illuminate/contracts": "^9.0 || ^10.0", - "illuminate/support": "^9.0 || ^10.0", + "illuminate/contracts": "^10.0", + "illuminate/support": "^10.0", "open-telemetry/exporter-otlp": "^1.0", "open-telemetry/context": "^1.0.1", "open-telemetry/sdk": "^1.0", @@ -32,13 +32,13 @@ "larastan/larastan": "^2.7", "laravel/pint": "^1.2", "nesbot/carbon": "^2.69 || ^3.0", - "nunomaduro/collision": "^6.0 || ^7.0", + "nunomaduro/collision": "^7.0", "open-telemetry/exporter-zipkin": "^1.0", "open-telemetry/extension-propagator-b3": "^1.0", "open-telemetry/transport-grpc": "^1.0", - "orchestra/testbench": "^7.0 || ^8.0", - "pestphp/pest": "^1.23", - "pestphp/pest-plugin-laravel": "^1.4", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.0", + "pestphp/pest-plugin-laravel": "^2.0", "php-http/guzzle7-adapter": "^1.0", "phpstan/extension-installer": "^1.3", "phpstan/phpstan": "^1.10.51", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d3b29ad..9473520 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,32 +1,12 @@ - + tests - - ./src - @@ -39,4 +19,9 @@ + + + ./src + + From 776894c44a1f76b46087446929935911f3cbac9b Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Tue, 13 Feb 2024 18:43:38 +0100 Subject: [PATCH 3/6] support laravel 11 --- .github/workflows/run-tests.yml | 2 +- composer.json | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1d799a4..05dee5d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -23,7 +23,7 @@ jobs: fail-fast: false matrix: php: [ 8.1, 8.2, 8.3 ] - laravel: [ ^10.0 ] + laravel: [ ^10.0, ^11.0 ] stability: [ prefer-stable, prefer-lowest ] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} diff --git a/composer.json b/composer.json index d5eb2c9..8de5d1a 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ ], "require": { "php": "^8.1", - "illuminate/contracts": "^10.0", - "illuminate/support": "^10.0", + "illuminate/contracts": "^10.0 || ^11.0", + "illuminate/support": "^10.0 || ^11.0", "open-telemetry/exporter-otlp": "^1.0", "open-telemetry/context": "^1.0.1", "open-telemetry/sdk": "^1.0", @@ -32,11 +32,11 @@ "larastan/larastan": "^2.7", "laravel/pint": "^1.2", "nesbot/carbon": "^2.69 || ^3.0", - "nunomaduro/collision": "^7.0", + "nunomaduro/collision": "^7.0 || ^8.0", "open-telemetry/exporter-zipkin": "^1.0", "open-telemetry/extension-propagator-b3": "^1.0", "open-telemetry/transport-grpc": "^1.0", - "orchestra/testbench": "^8.0", + "orchestra/testbench": "^8.0 || ^9.0", "pestphp/pest": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", "php-http/guzzle7-adapter": "^1.0", @@ -87,6 +87,6 @@ ] } }, - "minimum-stability": "stable", + "minimum-stability": "dev", "prefer-stable": true } From 3d3f0751c1ea84942d9c77d14490f427184fa5d1 Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Tue, 13 Feb 2024 18:46:29 +0100 Subject: [PATCH 4/6] exclude php 8.1 for laravel 11 --- .github/workflows/run-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 05dee5d..a845757 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -25,6 +25,9 @@ jobs: php: [ 8.1, 8.2, 8.3 ] laravel: [ ^10.0, ^11.0 ] stability: [ prefer-stable, prefer-lowest ] + exclude: + - php: 8.1 + laravel: ^11.0 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} From 36eba168b4cf987c42fce143d0703f2a87d4a62f Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Tue, 13 Feb 2024 18:53:44 +0100 Subject: [PATCH 5/6] wip --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a845757..2f949d7 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -56,7 +56,7 @@ jobs: - name: Install dependencies run: | composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress + composer update --${{ matrix.stability }} --prefer-stable --prefer-dist --no-interaction --no-progress - name: Execute tests run: vendor/bin/pest From b69ecb2d8e3a4399ee25e01651fc7b6b6881d8cc Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Tue, 13 Feb 2024 19:47:49 +0100 Subject: [PATCH 6/6] wip --- .github/workflows/run-tests.yml | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 2f949d7..a845757 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -56,7 +56,7 @@ jobs: - name: Install dependencies run: | composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-stable --prefer-dist --no-interaction --no-progress + composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress - name: Execute tests run: vendor/bin/pest diff --git a/composer.json b/composer.json index 8de5d1a..a6423ce 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,9 @@ "php": "^8.1", "illuminate/contracts": "^10.0 || ^11.0", "illuminate/support": "^10.0 || ^11.0", - "open-telemetry/exporter-otlp": "^1.0", "open-telemetry/context": "^1.0.1", - "open-telemetry/sdk": "^1.0", + "open-telemetry/exporter-otlp": "^1.0", + "open-telemetry/sdk": "^1.0.1", "open-telemetry/sem-conv": "^1.23", "spatie/laravel-package-tools": "^1.16", "thecodingmachine/safe": "^2.0"