Incrementally consuming the eventlog

Johan Tibell johan.tibell at
Sun May 1 10:44:40 CEST 2011

On Fri, Apr 29, 2011 at 12:00 AM, Don Stewart <dons00 at> wrote:
> I'm very interested in what the best way to get incremental event data
> from a running GHC process would be.
> Looking at the code, we flush the event buffer fairly regularly, but
> the event parser is currently strict.
> So we'd need a lazy (or incremental) parser, that'll return a list of
> successful event parses, then block. I suspect this mode would be
> supported.
> *My evil plan is to write a little monitoring web app that just
> attaches to the event stream and renders it in a useful "heartbeat"
> format* , but I need incremental parsing.

A less general solution might be to have the program itself start a
little web server on some port and use the API I proposed to serve
JSON data with the aggregate statistics you care about. Example:

    main = do
      eventData <- newIORef
      server <- serveOn 8080 $ \ _req -> readIORef eventData >>=
sendResponse eventData
      registerEventListener $ \ ev -> updateEventData eventData ev

You can wrap the creation of the webserver in a little helper function
an make any program "monitorable" simply by doing

    main = withMonitoring runApp

withMonitoring would take care of starting/stopping the webserver and
processing events.

Just a thought.


More information about the Glasgow-haskell-users mailing list