Skip to content

Commit

Permalink
Send both cast and dump params to telemetry events (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-rychlewski authored Dec 10, 2022
1 parent c1ba621 commit 8de3a14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit 8de3a14

Please sign in to comment.