When I utilize Opentelementry for PHP, I encounter an issue where I am unable to visualize the connection between two microservices within the same network in Jaeger.
In one microservice, I initiate a call to an endpoint, "service1/ping," and within the corresponding method, I make an API request to the second service using Guzzle, specifically to the endpoint "service2/api/products/1".
However, when examining Jaeger, I observe that the two microservices are displayed separately, and there is no apparent connection between them.
Has anyone else encountered a similar issue?
After two days of investigation and reading troubleshooting guides in OpenTelemetry and Jaeger, I identified the problem and would like to share my setup with you. Perhaps it could assist someone else facing a similar situation.
Firstly, I am conducting tests on a Symfony 6.3 project using the original library from OpenTelemetry for PHP. The documentation on how to set it up can be found here: https://opentelemetry.io/docs/instrumentation/php/getting-started/
Subsequently, I came across an article that referred to this example: https://github.com/ecotoneframework/php-ddd-cqrs-event-sourcing-symfony-laravel-ecotone, which did not start properly on my machine. Consequently, I began reverse engineering the implementation of OpenTelemetry for PHP.
Here are the extensions I had to install in my Docker environment where PHP is running:
Note: The preferred method for sending information to Jaeger is gRPC, but unfortunately, I couldn't install it via pecl. I attempted the installation several times, but each attempt took over 2000 seconds, leading me to interrupt the process. Currently, I am using http/protobuf as the protocol - the default one.
Following that, I had to include additional environment variables in my
docker-compose.ymlfile when starting the web server.You should verify that port 4318 is open for Jaeger. This port is utilized for http/protobuf, while port 4317 is reserved for gRPC.
Note: I attempted to add these environment variables to the
.envfile of my Symfony project, but it proved ineffective. After half a day of investigating the issue, I concluded that OpenTelemetry only initializes properly when the variables are set in the environment of the web server. It might be something worth investigating further to understand why it didn't work from the.envfile. If anyone has experience with this and can share insights, it would be greatly appreciated.The last step is to add the needed libraries for open telemetry in composer.json.
Addressing my question and its corresponding answer: When establishing communication between two services, it is essential to utilize libraries that are compatible with PSR-18 for Request Output and PSR-15 for Request Input. In PHP this would be Guzzle. For further details, you can refer to the documentation available here: https://opentelemetry.io/docs/instrumentation/php/propagation/
In conclusion, when initiating a request from one service to another, you should expect to observe something similar in your Jaeger trace:
Enjoy exploring distributed tracing with OpenTelemetry and Jaeger!