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

Drop support for PHP 7.4 and 8.0, introduce support for PHP 8.4, fix semconv deprecations #315

Merged
merged 16 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 3 additions & 31 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.0', '8.1', '8.2', '8.3']
php-version: ['8.1', '8.2', '8.3', '8.4']
# Sorted alphabetically to ease finding the desired run in the GitHub Workflow UI.
project: [
'Aws',
Expand Down Expand Up @@ -55,46 +55,18 @@ jobs:
'Symfony',
]
exclude:
- project: 'Instrumentation/IO'
php-version: 8.0
- project: 'Instrumentation/IO'
php-version: 8.1
- project: 'Instrumentation/Curl'
php-version: 7.4
- project: 'Instrumentation/Curl'
php-version: 8.0
- project: 'Instrumentation/Curl'
php-version: 8.1
- project: 'Instrumentation/MySqli'
php-version: 7.4
- project: 'Instrumentation/MySqli'
php-version: 8.0
- project: 'Instrumentation/MySqli'
php-version: 8.1
- project: 'Instrumentation/PDO'
php-version: 8.0
- project: 'Instrumentation/PDO'
php-version: 8.1
- project: 'Instrumentation/Psr3'
php-version: 8.0
- project: 'Instrumentation/ExtAmqp'
php-version: 8.0
- project: 'Instrumentation/ExtAmqp'
php-version: 8.1
- project: 'Instrumentation/ExtRdKafka'
php-version: 7.4
- project: 'Instrumentation/ExtRdKafka'
php-version: 8.0
- project: 'Instrumentation/ExtRdKafka'
php-version: 8.1
- project: 'Instrumentation/OpenAIPHP'
php-version: 8.0
- project: 'Logs/Monolog'
php-version: 8.0
- project: 'Sampler/RuleBased'
php-version: 8.0
- project: 'Symfony'
php-version: 8.0
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -130,7 +102,7 @@ jobs:

- name: Check Style
working-directory: src/${{ matrix.project }}
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --stop-on-violation --using-cache=no -vvv
run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --stop-on-violation --using-cache=no -vvv

- name: Run Phan
working-directory: src/${{ matrix.project }}
Expand Down Expand Up @@ -179,7 +151,7 @@ jobs:
- name: Code Coverage
uses: codecov/codecov-action@v4
# only generate coverage against the latest PHP version
if: ${{ matrix.php-version == '8.3' }}
if: ${{ matrix.php-version == '8.4' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: src/${{ matrix.project }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ packages-composer: ## Validate all composer packages
bash: ## Bash shell
$(DC_RUN_PHP) bash
style: ## Run php-cs-fixer
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no -vvv
$(DC_RUN_PHP) env XDEBUG_MODE=off PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no -vvv
split: ## git-split dry run
${DOCKER_COMPOSE} -f docker/gitsplit/docker-compose.yaml --env-file ./.env up
FORCE:
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-json": "*"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_VERSION=8.0
ARG PHP_VERSION=8.1
FROM ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION}

USER root
Expand Down
6 changes: 3 additions & 3 deletions src/Aws/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"open-telemetry/api": "^1.0",
"open-telemetry/sdk": "^1.0",
"aws/aws-sdk-php": "^3.232"
Expand All @@ -28,8 +28,8 @@
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "~9",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.0"
"psalm/plugin-phpunit": "^0.19.2",
"vimeo/psalm": "6.4.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/Aws/src/AwsSdkInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function getTracer(): TracerInterface
return $this->tracerProvider->getTracer('io.opentelemetry.contrib.php');
}

/** @psalm-api */
public function instrumentClients($clientsArray) : void
{
$this->clients = $clientsArray;
Expand All @@ -87,7 +88,7 @@ public function instrumentClients($clientsArray) : void
public function activate(): bool
{
try {
$middleware = Middleware::tap(function ($cmd, $req) {
$middleware = Middleware::tap(function ($cmd, $_req) {
$tracer = $this->getTracer();
$propagator = $this->getPropagator();

Expand Down
6 changes: 3 additions & 3 deletions src/Aws/src/Ecs/Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private function getMetadataEndpointV4Resource(): ResourceInfo

$containerMetadata = json_decode($containerResponse->getBody()->getContents(), true);
$taskMetadata = json_decode($taskResponse->getBody()->getContents(), true);

$launchType = isset($taskMetadata['LaunchType']) ? strtolower($taskMetadata['LaunchType']) : null;
$taskFamily = isset($taskMetadata['Family']) ? $taskMetadata['Family'] : null;
$taskRevision = isset($taskMetadata['Revision']) ? $taskMetadata['Revision'] : null;
Expand Down Expand Up @@ -208,7 +208,7 @@ private function getMetadataEndpointV4Resource(): ResourceInfo
}

$containerArn = isset($containerMetadata['ContainerARN']) ? $containerMetadata['ContainerARN'] : null;

$logResource = ResourceInfoFactory::emptyResource();
if (isset($containerMetadata['LogOptions']) && isset($containerMetadata['LogDriver']) && $containerMetadata['LogDriver'] === 'awslogs') {
$logOptions = $containerMetadata['LogOptions'];
Expand All @@ -218,7 +218,7 @@ private function getMetadataEndpointV4Resource(): ResourceInfo
$logsGroupArns = [];
$logsStreamArns = [];
if (isset($containerMetadata['ContainerARN']) && preg_match('/arn:aws:ecs:([^:]+):([^:]+):.*/', $containerMetadata['ContainerARN'], $matches)) {
[$arn, $awsRegion, $awsAccount] = $matches;
[$_arn, $awsRegion, $awsAccount] = $matches;

$logsGroupArns = ['arn:aws:logs:' . $awsRegion . ':' . $awsAccount . ':log-group:' . $logsGroupName];
$logsStreamArns = ['arn:aws:logs:' . $awsRegion . ':' . $awsAccount . ':log-group:' . $logsGroupName . ':log-stream:' . $logsStreamName];
Expand Down
4 changes: 2 additions & 2 deletions src/Aws/src/Eks/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getK8sHeader(): ?string
return null;
}

return 'Bearer' . file_get_contents($this->k8sTokenPath);
return 'Bearer' . (file_get_contents($this->k8sTokenPath) ?: '');
}

// Check if there exists a k8s certification file
Expand All @@ -43,6 +43,6 @@ public function getCgroupData(): ?array
return null;
}

return file($this->cGroupPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
return file($this->cGroupPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: null;
}
}
1 change: 1 addition & 0 deletions src/Aws/src/Xray/IdGenerator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Copyright The OpenTelemetry Authors
*
Expand Down
1 change: 1 addition & 0 deletions src/Aws/src/Xray/Propagator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Copyright The OpenTelemetry Authors
*
Expand Down
6 changes: 3 additions & 3 deletions src/Context/Swoole/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"open-telemetry/context": "^1.0"
},
"autoload": {
Expand All @@ -28,9 +28,9 @@
"php-http/mock-client": "*",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"psalm/plugin-phpunit": "^0.18.4",
"psalm/plugin-phpunit": "^0.19.2",
"open-telemetry/sdk": "^1.0",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^5.0"
"vimeo/psalm": "6.4.0"
}
}
4 changes: 2 additions & 2 deletions src/Context/Swoole/src/SwooleContextHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function splitOffChildCoroutines(): void
}
}

private function isForked(int $cid): bool
private function isForked(int $_cid): bool
{
return isset(Coroutine::getContext($cid)[__CLASS__]);
return isset(Coroutine::getContext($_cid)[__CLASS__]);
}

private function forkCoroutine(int $cid): void
Expand Down
7 changes: 4 additions & 3 deletions src/Context/Swoole/src/SwooleContextStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OpenTelemetry\Context\ContextStorageScopeInterface;
use OpenTelemetry\Context\ExecutionContextAwareInterface;

/** @psalm-api */
final class SwooleContextStorage implements ContextStorageInterface, ExecutionContextAwareInterface
{
/** @var ContextStorageInterface&ExecutionContextAwareInterface */
Expand All @@ -26,21 +27,21 @@ public function __construct(ContextStorageInterface $storage)
$this->handler = new SwooleContextHandler($storage);
}

public function fork($id): void
public function fork(int|string $id): void
{
$this->handler->switchToActiveCoroutine();

$this->storage->fork($id);
}

public function switch($id): void
public function switch(int|string $id): void
{
$this->handler->switchToActiveCoroutine();

$this->storage->switch($id);
}

public function destroy($id): void
public function destroy(int|string $id): void
{
$this->handler->switchToActiveCoroutine();

Expand Down
8 changes: 4 additions & 4 deletions src/Instrumentation/CakePHP/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-opentelemetry": "*",
"cakephp/cakephp": "^4 || ^5",
"open-telemetry/api": "^1.0",
Expand All @@ -23,10 +23,10 @@
"phpstan/phpstan-mockery": "^1.1.0",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"psalm/plugin-phpunit": "^0.18.4",
"psalm/plugin-phpunit": "^0.19.2",
"open-telemetry/sdk": "^1.0",
"phpunit/phpunit": "^9.5|^10.5",
"vimeo/psalm": "^5.24",
"vimeo/psalm": "6.4.0",
"symfony/http-client": "^6 || ^7"
},
"suggest": {
Expand Down Expand Up @@ -54,4 +54,4 @@
"php-http/discovery": true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;

/** @psalm-suppress UnusedClass */
class CommandTest extends TestCase
{
use ConsoleIntegrationTestTrait;
Expand Down
6 changes: 3 additions & 3 deletions src/Instrumentation/CodeIgniter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-opentelemetry": "*",
"codeigniter4/framework": "^4.3",
"open-telemetry/api": "^1.0",
Expand All @@ -22,9 +22,9 @@
"php-http/mock-client": "*",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"psalm/plugin-phpunit": "^0.18.4",
"psalm/plugin-phpunit": "^0.19.2",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^5.0"
"vimeo/psalm": "6.4.0"
},
"autoload": {
"psr-4": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CodeIgniterInstrumentation
{
public const NAME = 'codeigniter';

/** @psalm-api */
public static function register(): void
{
$instrumentation = new CachedInstrumentation(
Expand All @@ -34,12 +35,16 @@ public static function register(): void
// properties, thus reflection is required to read them.
$reflectedIgniter = new \ReflectionClass(CodeIgniter::class);
$requestProperty = $reflectedIgniter->getProperty('request');
/** @psalm-suppress UnusedMethodCall */
$requestProperty->setAccessible(true);
$controllerProperty = $reflectedIgniter->getProperty('controller');
/** @psalm-suppress UnusedMethodCall */
$controllerProperty->setAccessible(true);
$controllerMethodProperty = $reflectedIgniter->getProperty('method');
/** @psalm-suppress UnusedMethodCall */
$controllerMethodProperty->setAccessible(true);

/** @psalm-suppress UnusedFunctionCall */
hook(
CodeIgniter::class,
'handleRequest',
Expand All @@ -66,7 +71,7 @@ public static function register(): void
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);

$parent = Context::getCurrent();

if ($request) {
$parent = Globals::propagator()->extract($request, RequestPropagationGetter::instance());

Expand Down Expand Up @@ -135,7 +140,7 @@ public static function register(): void
$prop->inject($response, ResponsePropagationSetter::instance(), $scope->context());
}
}

$controller = $controllerProperty->getValue($igniter);
$controllerClassName = CodeIgniterInstrumentation::getControllerClassName($controller);
$controllerMethod = $controllerMethodProperty->getValue($igniter);
Expand Down Expand Up @@ -169,7 +174,7 @@ protected static function getControllerClassName(mixed $controller): ?string
protected static function normalizeRouteName(string $controllerClassName, string $controllerMethod): string
{
$lastSegment = strrchr($controllerClassName, '\\');

if ($lastSegment === false) {
return $controllerClassName . '.' . $controllerMethod;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public static function instance(): self
return $instance ??= new self();
}

/** @psalm-suppress InvalidReturnType */
/** @psalm-suppress InvalidReturnType
* @psalm-suppress PossiblyUnusedMethod
*/
public function keys($carrier): array
{
assert($carrier instanceof MessageInterface);
Expand Down
4 changes: 2 additions & 2 deletions src/Instrumentation/Curl/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"php-http/mock-client": "*",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"psalm/plugin-phpunit": "^0.18.4",
"psalm/plugin-phpunit": "^0.19.2",
"open-telemetry/sdk": "^1.0",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^5.0"
"vimeo/psalm": "6.4.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading
Loading