diff --git a/CHANGELOG.md b/CHANGELOG.md index b13014e..be80cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [1.3.X] + +- Update time spent calculation for EventSource block - Remove support for system event tracing (Updated the wiki to create wrapper for system event tracing) ## [1.2.X] - 2018.02.24 diff --git a/README.md b/README.md index d80c060..6076469 100644 --- a/README.md +++ b/README.md @@ -453,7 +453,7 @@ end ## Traceability -EventBus comes with a good enough data structure to track the event life cycle with its optional parameters. For a traceable system, it is highly recommend to fill optional fields on event data. It is also encouraged to use `Event.nofify` block/yield to automatically set the `initialized_at` and `occurred_at` values. +EventBus comes with a good enough data structure to track the event life cycle with its optional parameters. For a traceable system, it is highly recommend to fill optional fields on event data. It is also encouraged to use `EventSource.nofify` block/yield to automatically set the `initialized_at` and `occurred_at` values. ### System Events diff --git a/lib/event_bus/event_source.ex b/lib/event_bus/event_source.ex index 89961f8..fd54f32 100644 --- a/lib/event_bus/event_source.ex +++ b/lib/event_bus/event_source.ex @@ -9,6 +9,7 @@ defmodule EventBus.EventSource do defmacro __using__(_) do quote do require EventBus.EventSource + alias EventBus.EventSource alias EventBus.Model.Event end @@ -20,6 +21,7 @@ defmodule EventBus.EventSource do """ defmacro build(params, do: yield) do quote do + started_at = System.monotonic_time(:micro_seconds) initialized_at = System.os_time(:micro_seconds) params = unquote(params) @@ -35,13 +37,15 @@ defmodule EventBus.EventSource do {params[:topic], result} end + time_spent = System.monotonic_time(:micro_seconds) - started_at + %Event{ id: params[:id], topic: topic, transaction_id: params[:transaction_id], data: data, initialized_at: initialized_at, - occurred_at: System.os_time(:micro_seconds), + occurred_at: initialized_at + time_spent, source: source, ttl: params[:ttl] }