Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data RunResult
- = Success {
- resultTime :: !Double
- name :: !String
- | ErrorStatus { }
- | Error {
- resultTime :: !Double
- exception :: !SomeException
- name :: !String
- | End
- = Success {
- data Event = Event {}
- data Recorder = Recorder {}
- split :: Recorder -> Recorder
- newRecorder :: Int -> IO Recorder
- stopRecorder :: Recorder -> IO ()
- addEvent :: Recorder -> RunResult -> IO ()
- readEvent :: Recorder -> IO (Maybe Event)
- record :: forall a. Recorder -> String -> IO a -> IO a
Documentation
Success | |
| |
ErrorStatus | |
Error | |
| |
End |
stopRecorder :: Recorder -> IO () Source #
record :: forall a. Recorder -> String -> IO a -> IO a Source #
record
is how HTTP actions are profiled. Wrap each action of
interest in a call to record.
import Network.Wreq.Session import Data.Aeson loginReshare :: Recorder -> IO () loginReshare recorder = withSession $ \session -> do let rc = record recorder Object user <- rc "login" $ asJSON =<< ( post session "https://somesite.com/login" $ object [ "email" .= "example@example.com" , "password" .= "12345678" ] ) let Just feedUrl = H.lookup "feed" user itemRef : _ <- rc "get feed" $ asJSON =<< ( post session feedUrl $ object [ "email" .= "example@example.com" , "password" .= "12345678" ] ) rc "reshare" $ post session "https://somesite.com/share" $ object [ "type" : "reshare" , "ref" : itemRef ]
In this case the loginReshare
script would record three actions: "login",
"get feed" and "reshare".
record
measures the elapsed time of the call, and catches
HttpException
in the case of failure. This means failures
must be thrown if they are to be properly recorded.