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

PHP - Connecting logs with traces #18272

Open
TomKeur opened this issue May 25, 2023 · 6 comments
Open

PHP - Connecting logs with traces #18272

TomKeur opened this issue May 25, 2023 · 6 comments

Comments

@TomKeur
Copy link

TomKeur commented May 25, 2023

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 add extra.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

@maycmlee
Copy link
Contributor

maycmlee commented Jun 1, 2023

Thanks @TomKeur for bringing this up! We'll take a look and be back in touch.

@yankewei
Copy link

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.
If you can support connecting logs with traces even when we put the "dd" key into the extra key, that would be great.

@TomKeur
Copy link
Author

TomKeur commented Jun 21, 2023

@yankewei I've fixed it by adding this extra.dd.trace_id to the "Preprocessing for JSON logs", see screenshot.
Screenshot 2023-06-21 at 11 39 49

I'm ingesting my logs as JSON.

@yankewei
Copy link

@TomKeur Thank you, that would be helpful.

@maycmlee
Copy link
Contributor

Thanks @TomKeur @yankewei for your patience! I've opened a PR to update the docs. If you have any feedback let me know!

@TomKeur
Copy link
Author

TomKeur commented Aug 16, 2023

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 rust).

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

3 participants