nri-observability-0.1.1.3: Report log spans collected by nri-prelude.
Safe HaskellNone
LanguageHaskell2010

Reporter.File

Description

Reporting to a file.

This reporter logs debugging information about completed requests to a file or stdout (in that case, pass in `devstdout` as the file to log to).

Every line this reporter logs is a JSON string. This 'structured logging' output is optimized for external logging platforms that display these logs in a pretty UI.

This logger supports sampling of successful requests, to help save money when sending logs to external services.

Synopsis

Documentation

report :: Handler -> Text -> TracingSpan -> IO () Source #

Log tracing information for a request to a file. Tracing information contains nested spans but will appear flattend in the log. Each tracing span will appear on its own line in the log, ordered by its start date.

Example usage:

settings <- File.decode
handler <- File.handler settings
File.report handler "request-id" span

data Handler Source #

Contextual information this reporter needs to do its work. You can create one using handler.

handler :: Settings -> IO Handler Source #

Create a Handler for a specified set of Settings. Do this once when your application starts and reuse the Handler you get.

cleanup :: Handler -> IO () Source #

Clean up your handler after you're done with it. Call this before your application shuts down.

data Settings Source #

Configuration settings for this reporter. A value of this type can be read from the environment using the decoder function.

decoder :: Decoder Settings Source #

Read Settings from environment variables. Default variables will be used in case no environment variable is set for an option.

logFile :: Settings -> FilePath Source #

The file to log too. On unix systems you can set this to devstdout in order to log to stdout.

environment variable
LOG_FILE
default value
app.log

appName :: Settings -> Text Source #

The name of this application. This will be attached to all logs.

environment variable
LOG_ROOT_NAMESPACE
default value
your-application-name-here

appEnvironment :: Settings -> Text Source #

The environment this application is running in. This will be attached to all logs.

environment variable
ENVIRONMENT
default value
development

fractionOfSuccessRequestsLogged :: Settings -> Float Source #

The fraction of requests that should be logged. Set to 1 if you want to log everything, and a lower value to save money.

environment variable
FRACTION_OF_SUCCESS_REQUESTS_LOGGED
default value
1