This is the Haskell client library for http://yellerapp.com. It lets you automatically detect errors in your application, and reports them via Yeller's API, so you can debug and fix them quickly.
The Yeller client for Haskell REQUIRES that your production executables be built with profiling, AND that all the libraries you're using get built with profiling. Otherwise you won't get decent stacktraces.
To enable profiling in your build:
cabal configure --enable-executable-profiling --enable-library-profiling
To ensure dependencies are installed with profiling under a cabal sandbox, create a file called cabal.config
in the same directory as your $MYAPP.cabal
file with the following contents:
library-profiling: True
executable-profiling: True
Then make sure you reinstall libraries (if you're using cabal sandbox, the easiest way to do this is to cabal sandbox delete && cabal sandbox init && cabal install --only-dependencies
)
Add the package to your cabal
file:
yeller >= 0.1.0.4
Make a client
import Network.Yeller
yellerClient <- client (defaultClientSettings { clientSettingsToken = YellerToken "YOUR_TOKEN_HERE" })
When handling errors that you'd like to log to Yeller:
sendError yellerClient myError emptyExtraErrorInfo
Yeller can track a whole bunch of extra information to give you context when debugging errors:
User-Agent
on the server to get this)Aeson
library)These are all optional, you just add the fields you want to the ExtraErrorInfo
argument to SendError
. Here's a full fledged example:
sendError yellerClient myError
(emptyExtraErrorInfo {
errorURL = Just "http://example.com",
errorLocation = Just "myhttphandler",
errorUser = Just (UserInfo 14567),
errorHTTPRequest = Just (HTTPRequest "the User-Agent header"))
To ignore errors in development/test environments, initialize the client with TestEnvironment
:
yellerClient <- client (defaultClientSettings { clientSettingsToken = YellerToken "YOUR_TOKEN_HERE", clientSettingsEnvironment = TestEnvironment })
If you have additional environments you can differentiate them by setting the environment to something other than the default (which is "production")
yellerClient <- client (defaultClientSettings { clientSettingsToken = YellerToken "YOUR_TOKEN_HERE", clientSettingsEnvironment = ApplicationEnvironment "staging" })
Yeller can highlight stacktrace lines coming from your application, and hide those that don't. This can make a big difference when reading what can otherwise be very long Haskell stacktraces:
To activate this feature, Yeller has to know which packages are the root of your application, so you have to set them using one of the client starting functions that accepts a package name:
yellerClient <- client (defaultClientSettings { clientSettingsToken = YellerToken "YOUR_TOKEN_HERE", clientSettingsApplicationPackage = ApplicationPackage "MyApp" })
Without this flag set, Yeller will just display the most recent frames in the stacktrace by default.
Note that this doesn't affect which frames you can see - you can always display all the frames:
Yeller has a typeclass for converting things into errors. This lets you send things that aren't actually Exception
(e.g. an error type you're using inside an EitherT
):
class (Data.Typeable.Typeable a, Show a) => ToError a where
toError :: a -> ErrorNotification b -> ErrorNotification b
Here's what an implementation looks like for SomeException
instance ToError Control.Exception.SomeException where
toError e current = current {
errorType = T.pack . show $ Data.Typeable.typeOf e
, errorMessage = T.pack $ show e
}
The source code is up on Github, and api documentation can be found on Hackage
If you have any questions, feel free to shoot me an email, .
If you're curious about this library, it's open source, and available on: github