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

Send both cast and dump params to telemetry events #464

Merged
merged 3 commits into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions integration_test/sql/logging.exs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,24 @@ defmodule Ecto.Integration.LoggingTest do
end

test "cast params" do
uuid = Ecto.UUID.generate()
uuid_module =
if TestRepo.__adapter__() == Ecto.Adapters.Tds do
Tds.Ecto.UUID
else
Ecto.UUID
end

uuid = uuid_module.generate()
dumped_uuid = uuid_module.dump!(uuid)

log = fn _event_name, _measurements, metadata ->
assert [uuid] == metadata.params
assert [dumped_uuid] == metadata.params
assert [uuid] == metadata.cast_params
send(self(), :logged)
end

Process.put(:telemetry, log)
TestRepo.all(from l in Logging, where: l.uuid == ^uuid )
TestRepo.all(from l in Logging, where: l.uuid == ^uuid)
assert_received :logged
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/ecto/adapters/sql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,8 @@ defmodule Ecto.Adapters.SQL do
type: :ecto_sql_query,
repo: repo,
result: result,
params: log_params,
params: params,
cast_params: opts[:cast_params],
query: query,
source: source,
stacktrace: stacktrace,
Expand Down