Created
May 3, 2019 11:13
-
-
Save slashdotdash/f3cdb234527ae27bb0ca28407882c871 to your computer and use it in GitHub Desktop.
A Commanded event handler to produce `:telemetry` events for each recorded event.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Commanded.EventTelemetry do | |
@moduledoc """ | |
A Commanded event handler to produce `:telemetry` events for each recorded | |
event. | |
It produces the following event: | |
- `[:commanded, :event, :published]` | |
""" | |
use Commanded.Event.Handler, name: __MODULE__, start_from: :current | |
def handle(event, metadata) do | |
:telemetry.execute( | |
[:commanded, :event, :published], | |
%{timestamp: Map.get(metadata, :created_at)}, | |
%{event: event, metadata: metadata} | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment