open-telemetry / opentelemetry-php

The OpenTelemetry PHP Library
https://opentelemetry.io/docs/instrumentation/php/
Apache License 2.0
713 stars 174 forks source link

[opentelemetry-php-contrib] Cannot use opentelemetry-auto-laravel's latest version 0.0.27 as it requires ext-opentelemetry * #1364

Closed tnolet closed 2 weeks ago

tnolet commented 3 weeks ago

Describe your environment

Steps to reproduce run

pecl install opentelemetry
composer require open-telemetry/opentelemetry-auto-laravel

output:

Cannot use open-telemetry/opentelemetry-auto-laravel's latest version 0.0.27 as it requires ext-opentelemetry * which is missing from your platform.

In PackageDiscoveryTrait.php line 318:

  Package open-telemetry/opentelemetry-auto-laravel has requirements incompatible with your PHP version, PHP extensions and Composer version:  
    - open-telemetry/opentelemetry-auto-laravel 0.0.27 requires ext-opentelemetry * but it is not present.            

What is the expected behavior? it installs with no version conflict.

What is the actual behavior? It errors out.

Additional context Add any other context about the problem here.

brettmc commented 3 weeks ago

ext-opentelemetry is installed, but perhaps not enabled ? Between the first and second step above, what is the output of php --ri opentelemetry (or php -m | grep opentelemetry) ?

tnolet commented 2 weeks ago

@brettmc thanks for responding. Both comments show zero output, so that is probably the issue. I'm super new to PHP and I guess my Mac installation has some errors.

tnolet commented 2 weeks ago

I fixed it. For those bumping into this issue, here's the cause and fix.

  1. I used Herd to create a PHP environment on my Mac M2.
  2. Herd ships with a precompiled version of PHP. I followed the standard instructions on adding an extension.

My php.ini at vi ~Library/Application\ Support/Herd/config/php/82/php.ini now looks as follows:

// other stuff
extension=/opt/homebrew/lib/php/pecl/20220829/opentelemetry.so                                                                         

Running php --ri opentelemetry however reports the extension is not found.

Solution. My terminal session was not initialized with a specific Herd env variable (HERD_PHP_82_INI_SCAN_DIR) that points to the correct php.ini

Running source ~/.zshrc fixed all of this.

timnolet@MacBook-Pro-van-Tim otel-laravel % php --ri opentelemetry                                                    

opentelemetry

opentelemetry hooks => enabled
extension version => 1.0.3

Directive => Local Value => Master Value
opentelemetry.conflicts => no value => no value
opentelemetry.validate_hook_functions => On => On
opentelemetry.allow_stack_extension => Off => Off

@brettmc this can be closed