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
PHP - Connecting logs with traces #18272
Comments
Thanks @TomKeur for bringing this up! We'll take a look and be back in touch. |
We encounter the same issue when using Monolog V3. In Monolog V2, we can add a first-level key "dd" since the LogRecord is an array. However, in Monolog V3, the LogRecord is an object, as mentioned in the changelog, and we are unable to set the "dd" key as the first-level key. |
@yankewei I've fixed it by adding this I'm ingesting my logs as JSON. |
@TomKeur Thank you, that would be helpful. |
Hi @maycmlee, this seems to describe the way to get it connected :). Just to let you know, I see saw a new version of the PHP agent adds Auto Log Correlation (0.90.0): DataDog/dd-trace-php#2118 but I think it's good it's still documented somewhere. Also, keep in mind that not every is able to run the latest version of the Datadog PHP extension, for example I'm not able to run it myself (running Dockerized, but was unable to install it during a new Rust dependency |
Documentation Page
https://docs.datadoghq.com/tracing/other_telemetry/connect_logs_and_traces/php/
Issue Description
It's not really clear, but when you're using the Monolog v3 version with the Json formatter you can just use the same code with:
For monolog v3:
but in the Logging configuration (inside Datadog) you can addextra.dd.trace_id
to Trace ID Option.My logs and traces are now connected, with the same code :).
Also, the code below: "If your application uses json logs format instead of appending trace_id and span_id to the log message you can add first-level key “dd” containing these ids:"
Is not working Monolog v3, so maybe that should be placed in another place on the page, because I think it creates confusion this way, at least it did for me :).
I've tried contributing this myself, but somehow I was not able to get the local build system (with Docker running).
Hopefully you will benefit from my contribution
The text was updated successfully, but these errors were encountered: