Class: EzLogsAgent::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ez_logs_agent/configuration.rb

Overview

Configuration for the EzLogsAgent.

Noise Filtering Overview

EzLogsAgent captures events but filters out noise at the agent level. Each capturer has its own exclusion mechanism:

HTTP Requests (middleware/http_request.rb)

  • excluded_paths: URL paths to ignore (supports * wildcard for prefix match)

  • DEFAULT_EXCLUDED_EXTENSIONS: Static file extensions (.js, .css, .png, etc.)

  • excluded_graphql_operations: GraphQL operations to skip (introspection, etc.)

Database Callbacks (capturers/database_capturer.rb)

  • excluded_tables: Table names to ignore (Rails internals, job queues, etc.)

  • IGNORED_ATTRIBUTES: Technical fields (created_at, lock_version, etc.)

  • SENSITIVE_PATTERNS: Attributes containing passwords, tokens, secrets

Background Jobs (capturers/job_capturer.rb)

  • excluded_job_classes: Job class names to ignore (health checks, etc.)

Server-Side vs Agent-Side Filtering

The filtering philosophy:

  • Agent filters NOISE (introspection, assets, health checks, Rails internals)

  • Server classifies SIGNIFICANCE (reads vs writes) for UI filtering

This means GraphQL queries and GET requests ARE captured by the agent, but the server classifies them as “background” so users can toggle visibility.

Constant Summary collapse

DEFAULT_EXCLUDED_PATHS =

Default paths excluded from HTTP capture - common Rails noise

[
  "/rails/active_storage*",  # File uploads/downloads
  "/assets*",                # Asset pipeline
  "/packs*",                 # Webpacker assets
  "/vite*",                  # Vite assets
  "/health*",                # Health checks
  "/up",                     # Rails 7.1+ health check
  "/alive",                  # Kubernetes liveness probe
  "/ready",                  # Kubernetes readiness probe
  "/metrics",                # Prometheus metrics endpoint
  "/favicon.ico",            # Browser favicon
  "/*.hot-update.*",         # Hot module replacement
  "/.well-known*",           # Well-known URIs (security.txt, etc.)
  "/robots.txt",             # Search engine crawler config
  "/sitemap.xml",            # Sitemap for crawlers
  "/cable*",                 # ActionCable WebSocket connections
  "/sidekiq",                # Sidekiq Web UI dashboard root (the conventional mount)
  "/sidekiq/*",              # Sidekiq Web UI sub-paths (auto-poll noise)
  # Authentication pages - not meaningful business actions
  # Use */path* patterns to match auth routes anywhere (e.g., /admin/logout)
  "*/sign_in*",              # Devise and common sign in (matches /users/sign_in, /admin/sign_in)
  "*/sign_out*",             # Devise and common sign out
  "*/login*",                # Common auth pattern (matches /login, /admin/login)
  "*/logout*",               # Common auth pattern (matches /logout, /admin/logout)
  "/users/password*",        # Devise password reset/edit
  "/session*"                # Common auth pattern
].freeze
DEFAULT_EXCLUDED_EXTENSIONS =

Default file extensions excluded from HTTP capture - static assets These are matched against the path suffix regardless of directory

%w[
  .js .css .map
  .png .jpg .jpeg .gif .svg .ico .webp
  .woff .woff2 .ttf .eot .otf
].freeze
DEFAULT_EXCLUDED_TABLES =

Default tables excluded from database capture - Rails internal tables

[
  "schema_migrations",
  "ar_internal_metadata",
  "sessions",                         # ActiveRecord session store (plural)
  "session",                          # ActiveRecord session store (singular)
  "active_storage_blobs",             # ActiveStorage internals
  "active_storage_attachments",
  "active_storage_variant_records",
  "solid_queue_jobs",                 # SolidQueue internals
  "solid_queue_scheduled_executions",
  "solid_queue_ready_executions",
  "solid_queue_claimed_executions",
  "solid_queue_blocked_executions",
  "solid_queue_failed_executions",
  "solid_queue_pauses",
  "solid_queue_processes",
  "solid_queue_semaphores",
  "solid_queue_recurring_tasks",
  "solid_queue_recurring_executions",
  "solid_cache_entries",              # SolidCache internals
  "solid_cable_messages"              # SolidCable internals
].freeze
DEFAULT_EXCLUDED_JOB_CLASSES =

Default job classes excluded from background job capture - infrastructure/health check jobs

[
  "SidekiqAlive::Worker",             # Sidekiq health check
  "SolidQueue::CleanupJob",           # SolidQueue maintenance
  "SolidQueue::RecurringJob"          # SolidQueue scheduler internals
].freeze
DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS =

Default GraphQL operations excluded from capture - introspection and IDE queries Supports exact match and prefix match (patterns ending with *)

[
  "IntrospectionQuery",               # Standard IDE introspection query
  "__*"                               # All introspection fields (__schema, __type, etc.)
].freeze
DEFAULT_SERVER_URL =
"https://app.ezlogs.io"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/ez_logs_agent/configuration.rb', line 147

def initialize
  @server_url = DEFAULT_SERVER_URL
  @project_token = nil
  @capture_http = true
  @capture_jobs = true
  @capture_database = true
  @excluded_paths = []                 # User-defined; combined with DEFAULT_EXCLUDED_PATHS
  @excluded_tables = []                # User-defined; combined with DEFAULT_EXCLUDED_TABLES
  @excluded_job_classes = []           # User-defined; combined with DEFAULT_EXCLUDED_JOB_CLASSES
  @excluded_graphql_operations = []    # User-defined; combined with DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS
  @excluded_graphql_variable_keys = [] # User-defined; additional sensitive variable key patterns to filter
  @buffer_size = 10_000                # Increased for high-volume workloads (job-heavy apps)
  @retry_attempts = 3
  @send_interval = 3                   # More frequent sends for better throughput
  @log_level = :warn
  @actor_from_request = nil  # Not configured by default
  @display_name_for = {}     # Not configured by default
end

Instance Attribute Details

#actor_from_requestObject

Actor extraction hook for HTTP requests (optional) Must be a callable (lambda/proc) that accepts (request, controller) and returns { kind:, id:, label:, metadata: } or nil



52
53
54
# File 'lib/ez_logs_agent/configuration.rb', line 52

def actor_from_request
  @actor_from_request
end

#buffer_sizeObject

Returns the value of attribute buffer_size.



44
45
46
# File 'lib/ez_logs_agent/configuration.rb', line 44

def buffer_size
  @buffer_size
end

#capture_databaseObject

Returns the value of attribute capture_database.



38
39
40
# File 'lib/ez_logs_agent/configuration.rb', line 38

def capture_database
  @capture_database
end

#capture_httpObject

Returns the value of attribute capture_http.



36
37
38
# File 'lib/ez_logs_agent/configuration.rb', line 36

def capture_http
  @capture_http
end

#capture_jobsObject

Returns the value of attribute capture_jobs.



37
38
39
# File 'lib/ez_logs_agent/configuration.rb', line 37

def capture_jobs
  @capture_jobs
end

#display_name_forObject

Display name field mapping for database records (optional) Maps model class names to attribute names used for human-readable display

Example:

config.display_name_for = {
  "User" => :email,
  "Product" => :name,
  "Order" => :number
}

IMPORTANT: Only use direct attributes, not associations. Associations will trigger database queries and should be avoided.

If not configured for a model, falls back to: name → title → number → “##id”



68
69
70
# File 'lib/ez_logs_agent/configuration.rb', line 68

def display_name_for
  @display_name_for
end

#excluded_graphql_operationsObject

Returns the value of attribute excluded_graphql_operations.



42
43
44
# File 'lib/ez_logs_agent/configuration.rb', line 42

def excluded_graphql_operations
  @excluded_graphql_operations
end

#excluded_graphql_variable_keysObject

Returns the value of attribute excluded_graphql_variable_keys.



43
44
45
# File 'lib/ez_logs_agent/configuration.rb', line 43

def excluded_graphql_variable_keys
  @excluded_graphql_variable_keys
end

#excluded_job_classesObject

Returns the value of attribute excluded_job_classes.



41
42
43
# File 'lib/ez_logs_agent/configuration.rb', line 41

def excluded_job_classes
  @excluded_job_classes
end

#excluded_pathsObject

Returns the value of attribute excluded_paths.



39
40
41
# File 'lib/ez_logs_agent/configuration.rb', line 39

def excluded_paths
  @excluded_paths
end

#excluded_tablesObject

Returns the value of attribute excluded_tables.



40
41
42
# File 'lib/ez_logs_agent/configuration.rb', line 40

def excluded_tables
  @excluded_tables
end

#log_levelObject

Returns the value of attribute log_level.



47
48
49
# File 'lib/ez_logs_agent/configuration.rb', line 47

def log_level
  @log_level
end

#project_tokenObject

Returns the value of attribute project_token.



35
36
37
# File 'lib/ez_logs_agent/configuration.rb', line 35

def project_token
  @project_token
end

#retry_attemptsObject

Returns the value of attribute retry_attempts.



45
46
47
# File 'lib/ez_logs_agent/configuration.rb', line 45

def retry_attempts
  @retry_attempts
end

#send_intervalObject

Returns the value of attribute send_interval.



46
47
48
# File 'lib/ez_logs_agent/configuration.rb', line 46

def send_interval
  @send_interval
end

#server_urlObject

Returns the value of attribute server_url.



34
35
36
# File 'lib/ez_logs_agent/configuration.rb', line 34

def server_url
  @server_url
end

Instance Method Details

#all_excluded_graphql_operationsObject

Returns all excluded GraphQL operations (defaults + user-configured)



182
183
184
# File 'lib/ez_logs_agent/configuration.rb', line 182

def all_excluded_graphql_operations
  DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS + (@excluded_graphql_operations || [])
end

#all_excluded_job_classesObject

Returns all excluded job classes (defaults + user-configured)



177
178
179
# File 'lib/ez_logs_agent/configuration.rb', line 177

def all_excluded_job_classes
  DEFAULT_EXCLUDED_JOB_CLASSES + (@excluded_job_classes || [])
end

#all_excluded_pathsObject

Returns all excluded paths (defaults + user-configured)



167
168
169
# File 'lib/ez_logs_agent/configuration.rb', line 167

def all_excluded_paths
  DEFAULT_EXCLUDED_PATHS + (@excluded_paths || [])
end

#all_excluded_tablesObject

Returns all excluded tables (defaults + user-configured)



172
173
174
# File 'lib/ez_logs_agent/configuration.rb', line 172

def all_excluded_tables
  DEFAULT_EXCLUDED_TABLES + (@excluded_tables || [])
end