Skip to main content

Configuration

Configure the SDK to match your needs.

Basic Configuration

config/initializers/brainzlab.rb
BrainzLab.configure do |config|
  # Required: Your secret key
  config.secret_key = ENV['BRAINZLAB_SECRET_KEY']

  # Optional: Override environment detection
  config.environment = Rails.env

  # Optional: Service name (defaults to app name)
  config.service = 'my-app'
end

Full Configuration

config/initializers/brainzlab.rb
BrainzLab.configure do |config|
  # Authentication
  config.secret_key = ENV['BRAINZLAB_SECRET_KEY']

  # Environment
  config.environment = Rails.env
  config.service = 'my-app'
  config.host = Socket.gethostname

  # Git context (auto-detected if not set)
  config.commit = ENV['GIT_COMMIT']
  config.branch = ENV['GIT_BRANCH']

  # Recall (Logging)
  config.recall_enabled = true
  config.recall_min_level = :debug
  config.recall_buffer_size = 50
  config.recall_flush_interval = 5

  # Reflex (Error Tracking)
  config.reflex_enabled = true
  config.reflex_excluded_exceptions = [
    'ActionController::RoutingError',
    'ActiveRecord::RecordNotFound'
  ]

  # Data scrubbing
  config.scrub_fields = [
    :password,
    :credit_card,
    /token/i
  ]
end

Environment Variables

All options can be set via environment variables:
BRAINZLAB_SECRET_KEY=sk_live_xxx
BRAINZLAB_ENVIRONMENT=production
BRAINZLAB_SERVICE=my-app

# Git context
GIT_COMMIT=abc123
GIT_BRANCH=main

# Product URLs (self-hosting only)
# Via Traefik subdomains (recommended)
RECALL_URL=https://recall.mycompany.com
REFLEX_URL=https://reflex.mycompany.com
PULSE_URL=https://pulse.mycompany.com

# Or via direct ports (local development)
# RECALL_URL=http://localhost:3001
# REFLEX_URL=http://localhost:3002
# PULSE_URL=http://localhost:3003

Per-Environment Configuration

config/initializers/brainzlab.rb
BrainzLab.configure do |config|
  config.secret_key = ENV['BRAINZLAB_SECRET_KEY']

  if Rails.env.development?
    config.recall_min_level = :debug
  else
    config.recall_min_level = :info
  end

  if Rails.env.test?
    config.recall_enabled = false
    config.reflex_enabled = false
  end
end

Configuration Options

General

OptionDescriptionDefault
secret_keyYour API keyRequired
environmentEnvironment nameRails.env
serviceService/app nameApp name
hostServer hostnameSocket.gethostname

Recall

OptionDescriptionDefault
recall_enabledEnable loggingtrue
recall_min_levelMinimum log level:debug
recall_buffer_sizeLogs to buffer before flush50
recall_flush_intervalSeconds between flushes5

Reflex

OptionDescriptionDefault
reflex_enabledEnable error trackingtrue
reflex_excluded_exceptionsExceptions to ignore[]
reflex_max_breadcrumbsBreadcrumbs to keep100