languages / ruby / integrations / rack

Ruby Integrations - Rack

The Timber for Ruby Rack integration enhances and augments your Rack logs automatically.

  1. Structured data
  2. What you can do
  3. Installation
  4. Disable

Structured Data

You'll Get
context.session
context.user
event.http_request
event.http_response

What you can do

  1. Trace HTTP requests
  2. Inspect HTTP requests & their parameters
  3. Tail a user
  4. Inspect Rack logs and view their associated metadata
  5. Search on Rack structured data
  6. Alert on Rack structured data
  7. Graph & visualize Rack structured data

Installation

⚠ If you are using Rails, this integration is installed automatically. There is nothing you need to do.

  1. In your config.ru file, insert the Timber middleware:

    1
    2
    3
    4
    # config.ru
    Timber::Integrations::Rack.middlewares.each do |middleware|
      use middleware
    end
    

Disable

Timber allows you to disable this integration entirely, reverting all Rack logs to their previous unstructured, pre-Timber format. Please note, it is highly recommended to avoid doing this as it provides the means to perform very useful actions, such as tracing HTTP requests. If you are attempting to reduce log data, please see the optimizing data usage doc.

To disable this integration, simply set the following configuration flag:

1
2
# config/initializers/timber.rb
Timber.config.integrations.rack.disable = true

For finer grained control, you can disable each specific Rack integration like so:

1
2
3
4
5
6
# config/initializers/timber.rb
Timber.config.integrations.rack.error_event.disable = true
Timber.config.integrations.rack.http_context.disable = true
Timber.config.integrations.rack.http_events.disable = true
Timber.config.integrations.rack.session_context.disable = true
Timber.config.integrations.rack.user_context.disable = true

Each is described below:

  1. error_event disables the structuring of exceptions. By disablign this integration exceptions will appear as multi-line raw text logs.
  2. http_context disables setting the http context. It is highly recommended to avoid this, as it provides the mens to perform very useful features, like tracing HTTP requests.
  3. http_event disables the structuring of http_request and http_response events.
  4. session_context disables setting the session context.
  5. user_context disables setting the user context.
Questions?

Chat with us, just click the talk button in the bottom right of this page.

Chat with us
Sign Up

Log better and solve problems faster, today. Install in under a minute.

Sign Up