skywalking
skywalking copied to clipboard
[Feature] Expose traceId in PHP for Enhanced Observability
Search before asking
- [X] I had searched in the issues and found no similar feature requirement.
Description
I've been using SkyWalking for monitoring and tracing in both Java and PHP environments. One thing I noticed is that in Java, it's straightforward to use traceId for correlating logs and traces, which is super helpful for debugging and observability.
However, in PHP, there doesn't seem to be a straightforward way to access or expose the traceId within the application. This makes it a bit challenging to link logs with traces directly, which is something I believe could greatly benefit PHP developers focused on improving application observability.
Is there any chance we could see a feature in the PHP agent that allows accessing the traceId directly from the PHP code? It would be a huge boost for logging and monitoring practices in PHP applications.
Use case
No response
Related issues
No response
Are you willing to submit a pull request to implement this on your own?
- [ ] Yes I am willing to submit a pull request on my own!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@jmjoy What do you think about this?
Very good, but how to Expose traceId is worth discussing. What I think of is by injecting the $_SERVER variable for php-fpm, or $request->server for swoole.
Is $_SW_TRACE_ID a valid and good variable name for PHP ecosystem?
Is $_SW_TRACE_ID a valid and good variable name for PHP ecosystem?
I think it's ok
In Java, we have trace ID and trace context variables, please refer to this
https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/application-toolkit-logback-1.x/#print-skywalking-context-in-your-logs
We can add SW_TRACE_ID to $_SERVER