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

Opentelemetry not working with php version 7.1 in laravel #900

Closed
jbpal123 opened this issue Dec 15, 2022 · 12 comments
Closed

Opentelemetry not working with php version 7.1 in laravel #900

jbpal123 opened this issue Dec 15, 2022 · 12 comments

Comments

@jbpal123
Copy link

I tried to integrate opentelemetry in php 7.1 project in laravel. But its not working. Can anyone provide me steps how to properly integrate opentelemetry in php 7.1 or lower version projects created using laravel?

@prondubuisi
Copy link
Contributor

Hello @jbpal123 , are you getting any errors when trying to use the package within your Laravel 7.1 application?

@jbpal123
Copy link
Author

jbpal123 commented Dec 15, 2022

Hi @prondubuisi yes getting these errors

Fatal error: Uncaught TypeError: Argument 2 passed to OpenTelemetry\SDK\Common\T
ime\SystemClock::calculateReferenceTime() must be of the type int, float given,
called in C:\wamp\www\evp\testing_telemetry\vendor\open-telemetry\opentelemetry
src\SDK\Common\Time\SystemClock.php on line 59 and defined in C:\wamp\www\evp\te
sting_telemetry\vendor\open-telemetry\opentelemetry\src\SDK\Common\Time\SystemCl
ock.php on line 66

TypeError: Argument 2 passed to OpenTelemetry\SDK\Common\Time\SystemClock::calcu
lateReferenceTime() must be of the type int, float given, called in C:\wamp\www
evp\testing_telemetry\vendor\open-telemetry\opentelemetry\src\SDK\Common\Time\Sy
stemClock.php on line 59 in C:\wamp\www\evp\testing_telemetry\vendor\open-teleme
try\opentelemetry\src\SDK\Common\Time\SystemClock.php on line 66

@jbpal123
Copy link
Author

jbpal123 commented Dec 15, 2022

@prondubuisi I followed steps mentioned in below url
https://opentelemetry.io/docs/instrumentation/php/getting-started/

@bobstrecansky
Copy link
Collaborator

Note: versions of PHP prior to 7.4 are not officially supported.

https://github.com/open-telemetry/opentelemetry-php#requirements

@brettmc
Copy link
Collaborator

brettmc commented Dec 15, 2022

It sounds like you're on a 32-bit platform: https://www.php.net/manual/en/function.hrtime.php#refsect1-function.hrtime-returnvalues (hrtime behaves differently on 32bit vs 64bit, and likely a bunch of other parts of open-telemetry as well).

Are you able to reproduce this on a currently-supported PHP version ?

@jbpal123
Copy link
Author

Hi @bobstrecansky
I tried installing this package on php version 8.0 project build in laravel

Once i run below command:
composer require open-telemetry/opentelemetry

I get bellow error:
Problem 1
- Root composer.json requires open-telemetry/opentelemetry ^0.0.17 -> satisfiable by open-telemetry/opentelemetry[0.0.17]. - open-telemetry/opentelemetry 0.0.17 requires php-http/async-client-implementation ^1.0 -> could not be found in any version, but the following packages provide it:
- symfony/http-client Provides powerful methods to fetch HTTP resources synchronously or asynchronously
- php-http/guzzle6-adapter Guzzle 6 HTTP Adapter
- symfony/symfony The Symfony PHP framework
- php-http/curl-client PSR-18 and HTTPlug Async client with cURL
- php-http/guzzle7-adapter Guzzle 7 HTTP Adapter
- php-http/mock-client Mock HTTP client
- php-http/react-adapter React HTTP Adapter
- voku/httpful A Readable, Chainable, REST friendly, PHP HTTP Client
- swisnl/php-http-fixture-client Fixture client for PHP-HTTP
- mushroomcloud/guzzle6-adapter Guzzle 6 HTTP Adapter
- neur0toxine/pock PSR-18 compatible HTTP mock library
- netlogix/nxsentry Sentry integration
- phpgt/fetch Asynchronous HTTP client with promises.
- christophwurst/nextcloud-http-client HTTPlug and PSR7 adapter for Nextcloud
- betalabs/guzzle6-adapter Guzzle 6 HTTP Adapter
- john_zuk/php-nbp-api NBP (Narodowy Bank Polski) API client
- friendsofphp/well-known-implementations
- phpgt/curl cURL object wrapper.
- devster/http-client Symfony HttpClient component
- eslizn/polaris app framework for php
... and 8 more.
Consider requiring one of these to satisfy the php-http/async-client-implementation requirement.

Potential causes:

@bobstrecansky
Copy link
Collaborator

@jbpal123 - the async-client-implementation is explicitly left to the end user, because there are many different options and implementations may have different needs. You should be able to satisfy that requirement with one of those packages listed.

@jbpal123
Copy link
Author

Hi All,
I have installed required dependency. Still getting error after command - php GettingStarted.php.
Now, getting below error:|

Fatal error: Uncaught TypeError: OpenTelemetry\SDK\Common\Time\SystemClock::calc
ulateReferenceTime(): Argument #2 ($upTime) must be of type int, float given, ca
lled in C:\wamp\www\long-term-investment\telemetry_test\vendor\open-telemetry\op
entelemetry\src\SDK\Common\Time\SystemClock.php on line 59 and defined in C:\wam
p\www\long-term-investment\telemetry_test\vendor\open-telemetry\opentelemetry\sr
c\SDK\Common\Time\SystemClock.php on line 66

TypeError: OpenTelemetry\SDK\Common\Time\SystemClock::calculateReferenceTime():
Argument #2 ($upTime) must be of type int, float given, called in C:\wamp\www\lo
ng-term-investment\telemetry_test\vendor\open-telemetry\opentelemetry\src\SDK\Co
mmon\Time\SystemClock.php on line 59 in C:\wamp\www\long-term-investment\telemet
ry_test\vendor\open-telemetry\opentelemetry\src\SDK\Common\Time\SystemClock.php
on line 66

further more

@brettmc
Copy link
Collaborator

brettmc commented Dec 19, 2022

Thanks for the additional information!
The issue is that you're using 32bit PHP, and we've developed against 64bit. Is 64bit PHP an option for you? https://www.wampserver.com/en/download-wampserver-64bits/

@jbpal123
Copy link
Author

Hi @brettmc
Thanks for the info. I have updated php from 32 bit to 64 bit. Now that issue is fixed.
But now, I am getting only bellow texts aftre running "php GettingStarted.php" command -
Starting ConsoleSpanExporter
OpenTelemetry welcomes PHP

As per the https://opentelemetry.io/docs/instrumentation/php/getting-started/ doc, I should get some json data as output.

@brettmc
Copy link
Collaborator

brettmc commented Dec 21, 2022

Yes, you should see some JSON data. The example works for me, so my guess is that this is a windows-specific problem, likely an output stream issue (ie, its sending the output to somewhere that's not valid in windows, or at least not visible to you).

The "ConsoleSpanExporter" attempts to write to php://stdout, I can't find any references to that being problematic on windows... Can you try swapping out the tracer provider setup for this?

$tracerProvider =  new TracerProvider(
    new SimpleSpanProcessor(
        (new \OpenTelemetry\SDK\Trace\SpanExporter\ConsoleSpanExporter(
            new \OpenTelemetry\SDK\Common\Export\Stream\StreamTransport(
                fopen('php://output', 'ab'),
                'application/json'
            )))
    )
);

This is slightly different to what the original factory code does:

  • uses php://output instead of php://stdout
  • does not use a stream context

@brettmc
Copy link
Collaborator

brettmc commented Feb 15, 2023

Closing due to inactivity. @jbpal123 feel free to reopen or submit a new issue.

@brettmc brettmc closed this as completed Feb 15, 2023
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

No branches or pull requests

4 participants