Skip to content

Conversation

ChrisLightfootWild
Copy link
Contributor

Proposal to prevent the SDK from auto-loading during composer script execution.

During a composer script, the packaged dependencies in the composer.phar are currently locked to PSR-3 v2 and thus any local application dependencies which expect v3 can trigger a fatal error.

By preventing the SdkAutoloader from being auto-loaded, we can hopefully avoid the fatal error from triggering.

Fixes #1673.


To test, we can perform the following actions:

make update PHP_VERSION=8.3

make bash PHP_VERSION=8.3

OTEL_PHP_AUTOLOAD_ENABLED=true composer run-script test-psr3

Before:

> OpenTelemetry\Tests\Integration\Composer\Psr3CompatabilityTest::run

Fatal error: Declaration of Psr\Log\AbstractLogger::emergency(Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerInterface::emergency($message, array $context = []) in /usr/src/myapp/vendor/psr/log/src/LoggerTrait.php on line 18
echo $?
255

After:

> OpenTelemetry\Tests\Integration\Composer\Psr3CompatabilityTest::run
echo $?
0

@ChrisLightfootWild ChrisLightfootWild requested a review from a team as a code owner October 10, 2025 15:26
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.32%. Comparing base (ddb222d) to head (9ec2a8c).

Files with missing lines Patch % Lines
src/SDK/_autoload.php 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1727      +/-   ##
============================================
- Coverage     68.37%   68.32%   -0.05%     
  Complexity     2971     2971              
============================================
  Files           448      448              
  Lines          9020     9021       +1     
============================================
- Hits           6167     6164       -3     
- Misses         2853     2857       +4     
Flag Coverage Δ
8.1 68.06% <0.00%> (+<0.01%) ⬆️
8.2 68.30% <0.00%> (+0.05%) ⬆️
8.3 68.30% <0.00%> (+0.08%) ⬆️
8.4 68.21% <0.00%> (-0.03%) ⬇️
8.5 68.16% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/SDK/_autoload.php 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddb222d...9ec2a8c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* if the version of PSR-3 installed in ./vendor conflicts with that of the
* packaged composer PSR-3 library.
*
* If COMPOSER_DEV_MODE is present, then we can assume that a composer script
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if you were starting your application through a composer script? eg something like composer run-my-application ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, if you were using a compatible version of psr/log then the SDK would bootstrap.

If you were using an incompatible version, it would cause a fatal exception.


With the proposed changes, the SDK is essentially disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Psr\Log\AbstractLogger Fatal Error

2 participants