-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Removing caller_pid
from log entries break some integrations
#2843
Comments
caller_pid
from log entries break integrationscaller_pid
from log entries break some integrations
The |
Thanks, I look forward to seeing that make it in. That would be useful for our tracing library in many different ways. |
@josevalim what would be a recommended way of having log metadata in the multi-preload queries now that Elixir 1.8 is out? Would you saw developers should handle this themselves or? So far, this is what I arrived at to extra metadata from the caller process – would you say this is normal approach to have require Logger
Logger.metadata(request_id: "03872725-6411-4746-acb8-047f10aa0072")
telemetry_fn = fn a,b,c,d ->
case Process.info(self())[:dictionary][:"$callers"] do
[caller_process] ->
{:dictionary, stuff} = Process.info(caller_process, :dictionary)
{true, log_metadata} = stuff[:logger_metadata]
Logger.info("We're in a task process, preloading some assoc, request_id is #{log_metadata[:request_id]}")
_ ->
Logger.info("We've in a caller process itself")
end
end
:telemetry.attach("my-handler", [:my_app, :repo, :query], telemetry_fn, nil)
# Test
post = Repo.insert!(%Post{author_id: 1})
Repo.insert!(%Comment{post_id: post.id, state: "approved"})
Repo.insert!(%Comment{post_id: post.id, state: "disapproved"})
Repo.insert!(%Comment{post_id: post.id, state: "pending"})
Repo.preload(post, [:comments, :author]) |
Exactly. Just replace |
In this commit: 8d09248#diff-152ab0727a1d450c0fe74d178e80d1f0
LogEntry had its
caller_pid
field removed. However,spandex_ecto
(which has its own problems but we're going to resolve those), relies on that field being set to tie parent process trace data with the metrics in the log entry. It also seems like this information is not present in the telemetry information. Any suggestions on how we might go about getting query data into traces in a similar format? We don't want to have to wrap all calls to a repo in traces/spans.The text was updated successfully, but these errors were encountered: