eventuo11y 0.7.1.0 → 0.8.0.0
raw patch · 3 files changed
+57/−16 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Observe.Event.Render.InMemory: [when] :: TimedEventAction ts f -> !ts
+ Observe.Event.Render.InMemory: [causedEvents] :: MemoryEvent m appvec ts s -> !appvec (MemoryEvent m appvec ts s)
+ Observe.Event.Render.InMemory: [childEvents] :: MemoryEvent m appvec ts s -> !appvec (MemoryEvent m appvec ts s)
+ Observe.Event.Render.InMemory: [eventTime] :: TimedEventAction ts f -> !ts
- Observe.Event.Render.InMemory: MemoryEvent :: !NewEventArgs (MemoryEvent m appvec ts s) s f -> !ts -> !Maybe (appvec (TimedEventAction ts f)) -> MemoryEvent m appvec ts s
+ Observe.Event.Render.InMemory: MemoryEvent :: !NewEventArgs (MemoryEvent m appvec ts s) s f -> !ts -> !Maybe (appvec (TimedEventAction ts f)) -> !appvec (MemoryEvent m appvec ts s) -> !appvec (MemoryEvent m appvec ts s) -> MemoryEvent m appvec ts s
- Observe.Event.Render.InMemory: inMemoryBackend :: Monad m => InMemoryEffects m appvec ts -> EventBackend m (MemoryEvent m appvec ts s) s
+ Observe.Event.Render.InMemory: inMemoryBackend :: Monad m => InMemoryEffects m appvec ts -> (MemoryEvent m appvec ts s -> m ()) -> EventBackend m (MemoryEvent m appvec ts s) s
- Observe.Event.Render.InMemory: listInMemoryBackend :: (PrimMonad m, MonadIO m) => EventBackend m (MemoryEvent m (ListAppendVector m) UTCTime s) s
+ Observe.Event.Render.InMemory: listInMemoryBackend :: (MemoryEvent IO (ListAppendVector IO) UTCTime s -> IO ()) -> EventBackend IO (MemoryEvent IO (ListAppendVector IO) UTCTime s) s
- Observe.Event.Render.InMemory: listInMemoryEffects :: (PrimMonad m, MonadIO m) => InMemoryEffects m (ListAppendVector m) UTCTime
+ Observe.Event.Render.InMemory: listInMemoryEffects :: InMemoryEffects IO (ListAppendVector IO) UTCTime
- Observe.Event.Render.InMemory: timelessListInMemoryBackend :: PrimMonad m => EventBackend m (MemoryEvent m (ListAppendVector m) () s) s
+ Observe.Event.Render.InMemory: timelessListInMemoryBackend :: PrimMonad m => (MemoryEvent m (ListAppendVector m) () s -> m ()) -> EventBackend m (MemoryEvent m (ListAppendVector m) () s) s
Files
- CHANGELOG.md +7/−0
- eventuo11y.cabal +1/−1
- src/Observe/Event/Render/InMemory.hs +49/−15
CHANGELOG.md view
@@ -1,5 +1,12 @@ # Revision history for eventuo11y +## 0.8.0.0 -- 2023-01-17++- Add `childEvents` and `causedEvents` fields to `MemoryEvent`+- `inMemoryBackend`: Notify the caller when a parentless, causeless event is created+- Rename `when` to `eventTime` in `TimedEventAction`+- Put `listInMemoryBackend` into `IO`+ ## 0.7.1.0 -- 2023-01-14 - Add `Observe.Event.Render.InMemory`
eventuo11y.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: eventuo11y-version: 0.7.1.0+version: 0.8.0.0 synopsis: An event-oriented observability library description: Instrument your Haskell codebase with wide, semantically meaningful events.
src/Observe/Event/Render/InMemory.hs view
@@ -41,9 +41,10 @@ where import Control.Exception-import Control.Monad.IO.Class+import Control.Monad import Control.Monad.Primitive import Data.Kind+import Data.Maybe import Data.Primitive.MutVar import Data.Time.Clock import Observe.Event.Backend@@ -52,14 +53,21 @@ -- -- The 'reference' of an 'Event' from this 'EventBackend' will be a 'MemoryEvent', -- which can be examined to extract information about the 'Event'.-listInMemoryBackend :: (PrimMonad m, MonadIO m) => EventBackend m (MemoryEvent m (ListAppendVector m) UTCTime s) s+listInMemoryBackend ::+ -- | Notify of an 'Event' with no parents or causes+ (MemoryEvent IO (ListAppendVector IO) UTCTime s -> IO ()) ->+ EventBackend IO (MemoryEvent IO (ListAppendVector IO) UTCTime s) s listInMemoryBackend = inMemoryBackend listInMemoryEffects -- | An 'EventBackend' whose 'Event's are essentially plain Haskell values. -- -- The 'reference' of an 'Event' from this 'EventBackend' will be a 'MemoryEvent', -- which can be examined to extract information about the 'Event'.-timelessListInMemoryBackend :: (PrimMonad m) => EventBackend m (MemoryEvent m (ListAppendVector m) () s) s+timelessListInMemoryBackend ::+ (PrimMonad m) =>+ -- | Notify of an 'Event' with no parents or causes+ (MemoryEvent m (ListAppendVector m) () s -> m ()) ->+ EventBackend m (MemoryEvent m (ListAppendVector m) () s) s timelessListInMemoryBackend = inMemoryBackend timelessListInMemoryEffects -- | An 'EventBackend' whose 'Event's are essentially plain Haskell values.@@ -69,25 +77,47 @@ -- -- [@appvec@]: An append-only vector type, see 'AppendVectorEffects' -- [@ts@]: A timestamp, see 'TimestampEffects'-inMemoryBackend :: (Monad m) => InMemoryEffects m appvec ts -> EventBackend m (MemoryEvent m appvec ts s) s-inMemoryBackend InMemoryEffects {..} =+inMemoryBackend ::+ (Monad m) =>+ InMemoryEffects m appvec ts ->+ -- | Notify of an 'Event' with no parents or causes+ (MemoryEvent m appvec ts s -> m ()) ->+ EventBackend m (MemoryEvent m appvec ts s) s+inMemoryBackend (InMemoryEffects {..}) emitDisconnectedEvent = EventBackend { newEvent = \initArgs -> do start <- getTimestamp dynamicValues <- newVector+ childEvents <- newVector+ causedEvents <- newVector+ let reference = MemoryEvent {dynamicValues = Just dynamicValues, ..}+ hasParents <-+ isJust+ <$> traverse+ (\(MemoryEvent {childEvents = cevs}) -> appendVector cevs reference)+ (newEventParent initArgs)+ hasCauses <-+ not . null+ <$> traverse+ (\(MemoryEvent {causedEvents = cevs}) -> appendVector cevs reference)+ (newEventCauses initArgs)+ unless (hasParents || hasCauses) $ emitDisconnectedEvent reference pure $ Event- { reference = MemoryEvent {dynamicValues = Just dynamicValues, ..},- addField = \f -> do- when <- getTimestamp+ { addField = \f -> do+ eventTime <- getTimestamp appendVector dynamicValues $ TimedEventAction {act = AddField f, ..}, finalize = \me -> do- when <- getTimestamp- appendVector dynamicValues $ TimedEventAction {act = Finalize me, ..}+ eventTime <- getTimestamp+ appendVector dynamicValues $ TimedEventAction {act = Finalize me, ..},+ .. }, emitImmediateEvent = \initArgs -> do start <- getTimestamp- pure $ MemoryEvent {dynamicValues = Nothing, ..}+ let dynamicValues = Nothing+ childEvents <- newVector+ causedEvents <- newVector+ pure $ MemoryEvent {..} } where AppendVectorEffects {..} = appendVectorEffects@@ -107,7 +137,11 @@ -- | Event information added during the event's lifecycle -- -- 'Nothing' if this was the result of 'emitImmediateEvent' and thus had no lifecycle- dynamicValues :: !(Maybe (appvec (TimedEventAction ts f)))+ dynamicValues :: !(Maybe (appvec (TimedEventAction ts f))),+ -- | Direct children of this event+ childEvents :: !(appvec (MemoryEvent m appvec ts s)),+ -- | Events directly caused by this event+ causedEvents :: !(appvec (MemoryEvent m appvec ts s)) } -- | An action that occurred during an 'Event' at some time.@@ -115,7 +149,7 @@ -- [@ts@]: A timestamp, see 'TimestampEffects' data TimedEventAction ts f = TimedEventAction { -- | When the event occurred- when :: !ts,+ eventTime :: !ts, -- | The action that occurred act :: !(EventAction f) }@@ -147,11 +181,11 @@ } -- | 'InMemoryEffects' based on 'listAppendVectorEffects' and 'ioTimestampEffects'.-listInMemoryEffects :: (PrimMonad m, MonadIO m) => InMemoryEffects m (ListAppendVector m) UTCTime+listInMemoryEffects :: InMemoryEffects IO (ListAppendVector IO) UTCTime listInMemoryEffects = InMemoryEffects { appendVectorEffects = listAppendVectorEffects,- timestampEffects = hoistTimestampEffects liftIO ioTimestampEffects+ timestampEffects = ioTimestampEffects } -- | 'InMemoryEffects' based on 'listAppendVectorEffects' with meaningless timestamps.