diff --git a/lib/ecto.ex b/lib/ecto.ex index b6241a0880..689259f2a3 100644 --- a/lib/ecto.ex +++ b/lib/ecto.ex @@ -637,6 +637,16 @@ defmodule Ecto do Ecto.Schema.Loader.unsafe_load(schema_or_types, data, &Ecto.Type.embedded_load(&1, &2, format)) end + @doc """ + Dumps the given struct defined by an embedded schema. + + This converts the given embedded schema to a map to be serialized + with the given format. For example: + + iex> Ecto.embedded_dump(%Post{}, :json) + %{title: "hello"} + + """ @spec embedded_dump(Ecto.Schema.t(), format :: atom()) :: map() def embedded_dump(%schema{} = data, format) do Ecto.Schema.Loader.safe_dump(data, schema.__schema__(:dump), &Ecto.Type.embedded_dump(&1, &2, format)) diff --git a/lib/ecto/repo.ex b/lib/ecto/repo.ex index dc4e7e8669..48e9851e1c 100644 --- a/lib/ecto/repo.ex +++ b/lib/ecto/repo.ex @@ -92,7 +92,20 @@ defmodule Ecto.Repo do * `:telemetry_options` - Extra options to attach to telemetry event name. See the next section for more information - ### Telemetry events + ## Telemetry events + + There are two types of telemetry events. The ones emitted by Ecto and the + ones that are adapter specific. + + ### Ecto telemetry events + + The following events are emitted by all Ecto repositories: + + * `[:ecto, :repo, :init]` - it is invoked whenever a repository starts. + The measurement is a single `system_time` entry in native unit. The + metadata is the `:repo` and all initialization options under `:opts`. + + ### Adapter-specific events We recommend adapters to publish certain `Telemetry` events listed below. Those events will use the `:telemetry_prefix` outlined above which defaults