RepoPilotOpen in app →

MiniProfiler/rack-mini-profiler

Profiler for your development and production Ruby rack apps.

Healthy

Healthy across the board

Use as dependencyHealthy

Permissive license, no critical CVEs, actively maintained — safe to depend on.

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • Last commit 2w ago
  • 32+ active contributors
  • Distributed ownership (top contributor 23% of recent commits)
Show 3 more →
  • MIT licensed
  • CI configured
  • Tests present

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Healthy" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Healthy
[![RepoPilot: Healthy](https://repopilot.app/api/badge/miniprofiler/rack-mini-profiler)](https://repopilot.app/r/miniprofiler/rack-mini-profiler)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/miniprofiler/rack-mini-profiler on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: MiniProfiler/rack-mini-profiler

Generated by RepoPilot · 2026-05-10 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/MiniProfiler/rack-mini-profiler shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

GO — Healthy across the board

  • Last commit 2w ago
  • 32+ active contributors
  • Distributed ownership (top contributor 23% of recent commits)
  • MIT licensed
  • CI configured
  • Tests present

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live MiniProfiler/rack-mini-profiler repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/MiniProfiler/rack-mini-profiler.

What it runs against: a local clone of MiniProfiler/rack-mini-profiler — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in MiniProfiler/rack-mini-profiler | Confirms the artifact applies here, not a fork | | 2 | License is still MIT | Catches relicense before you depend on it | | 3 | Default branch master exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 43 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>MiniProfiler/rack-mini-profiler</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of MiniProfiler/rack-mini-profiler. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/MiniProfiler/rack-mini-profiler.git
#   cd rack-mini-profiler
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of MiniProfiler/rack-mini-profiler and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "MiniProfiler/rack-mini-profiler(\\.git)?\\b" \\
  && ok "origin remote is MiniProfiler/rack-mini-profiler" \\
  || miss "origin remote is not MiniProfiler/rack-mini-profiler (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
  && ok "license is MIT" \\
  || miss "license drift — was MIT at generation time"

# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
  && ok "default branch master exists" \\
  || miss "default branch master no longer exists"

# 4. Critical files exist
test -f "lib/mini_profiler.rb" \\
  && ok "lib/mini_profiler.rb" \\
  || miss "missing critical file: lib/mini_profiler.rb"
test -f "lib/mini_profiler/config.rb" \\
  && ok "lib/mini_profiler/config.rb" \\
  || miss "missing critical file: lib/mini_profiler/config.rb"
test -f "lib/mini_profiler_rails/railtie.rb" \\
  && ok "lib/mini_profiler_rails/railtie.rb" \\
  || miss "missing critical file: lib/mini_profiler_rails/railtie.rb"
test -f "lib/mini_profiler/context.rb" \\
  && ok "lib/mini_profiler/context.rb" \\
  || miss "missing critical file: lib/mini_profiler/context.rb"
test -f "lib/mini_profiler/storage/abstract_store.rb" \\
  && ok "lib/mini_profiler/storage/abstract_store.rb" \\
  || miss "missing critical file: lib/mini_profiler/storage/abstract_store.rb"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 43 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~13d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/MiniProfiler/rack-mini-profiler"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

rack-mini-profiler is a Rack middleware that injects a real-time performance profiling badge into HTML responses, showing per-request metrics for Ruby web apps. It captures database queries (MySQL2, Postgres, Oracle, Mongoid), CPU time via flamegraphs (using stackprof), and memory allocation data (via memory_profiler), all without requiring app restarts—designed for both development and production use. Monolithic gem structure: lib/mini_profiler/ contains the core engine, lib/html/ holds the UI assets (JavaScript, SCSS, HTML templates including Speedscope flamegraph viewer), lib/generators/ provides Rails installation scaffolding. The entry point is lib/mini_profiler.rb; config lives in lib/mini_profiler/config.rb, and Rails-specific patches are opt-in via lib/enable_rails_patches.rb.

👥Who it's for

Ruby developers building Rails or Rack-based web applications who need to diagnose performance bottlenecks in development and optionally in production; specifically those working on teams that want shared, shareable profiling results without setting up external APM vendors.

🌱Maturity & risk

This is a production-ready, actively maintained project. The repo shows Rails 3.2+ support, comprehensive test coverage via RSpec (Guardfile present), CI/CD via GitHub Actions (workflows/ci.yml), and a CHANGELOG tracking releases. Last activity and dependency management via Dependabot suggest active maintenance, though the codebase is 10+ years old and stabilized.

Low risk for core profiling: it's a well-established gem with a community and no critical external dependencies in the gemspec. However, note that it monkey-patches Rails internals (see lib/enable_rails_patches.rb for legacy behavior); in v2.0.0+ it switched to ActiveSupport::Notifications to reduce patch surface. Maintenance is community-driven, and the README explicitly requests help triaging issues, suggesting resource constraints.

Active areas of work

The repo is actively maintained with Dependabot managing dependencies and GitHub Actions CI running on commits. The README indicates a restructuring effort underway (central UI repo + language implementations) and calls for community help with issue triage. Version 2.0.0 moved away from Rails patching toward ActiveSupport::Notifications, indicating recent architectural shifts.

🚀Get running

git clone https://github.com/MiniProfiler/rack-mini-profiler.git
cd rack-mini-profiler
bundle install
bundle exec rspec

Daily commands: For development: bundle exec rake (runs default Rake task). For testing: bundle exec rspec. No standalone server—this is middleware; integration is via Rails/Rack app. The Gemfile suggests testing against multiple Rails versions. Guardfile indicates guard can watch for test-driven development.

🗺️Map of the codebase

  • lib/mini_profiler.rb — Main entry point and core profiler initialization; every contributor must understand the public API and lifecycle
  • lib/mini_profiler/config.rb — Central configuration registry controlling storage, sampling, and feature flags across the entire system
  • lib/mini_profiler_rails/railtie.rb — Rails integration layer that boots the profiler middleware and patches database adapters
  • lib/mini_profiler/context.rb — Request-scoped profiling context holding timers and results; critical for understanding data flow during a request
  • lib/mini_profiler/storage/abstract_store.rb — Abstract storage interface defining how profiling results are persisted and retrieved
  • lib/patches/db/activerecord.rb — Database query instrumentation for ActiveRecord; demonstrates the patching pattern used across all adapters
  • lib/mini_profiler/timer_struct/page.rb — Page-level timing data structure aggregating all profiling metrics for serialization to UI

🛠️How to make changes

Add support for a new database driver

  1. Create new patch file in lib/patches/db/ (e.g., lib/patches/db/sqlite3.rb) following the pattern of activerecord.rb (lib/patches/db/activerecord.rb)
  2. Patch the query execution method to create an SQL timer via Rack::MiniProfiler.record_sql() (lib/mini_profiler/profiling_methods.rb)
  3. Add conditional require in lib/enable_rails_patches.rb to load your patch when the driver is present (lib/enable_rails_patches.rb)
  4. Test with spec/integration/middleware_spec.rb to ensure queries are captured (spec/integration/middleware_spec.rb)

Add a new storage backend

  1. Create new store class in lib/mini_profiler/storage/ inheriting from AbstractStore (lib/mini_profiler/storage/abstract_store.rb)
  2. Implement required methods: save(name, value), load(name), set_unviewed(user), get_unviewed_ids(user) (lib/mini_profiler/storage/redis_store.rb)
  3. Register store in Rack::MiniProfiler.config.storage = YourStore.new (lib/mini_profiler/config.rb)

Add a new UI feature or profiling metric

  1. Add data collection logic to lib/mini_profiler/context.rb or create new timer_struct subclass (lib/mini_profiler/context.rb)
  2. Serialize metric into page/request result objects via lib/mini_profiler/timer_struct/page.rb (lib/mini_profiler/timer_struct/page.rb)
  3. Update lib/html/includes.tmpl and lib/html/includes.js to render the new metric in the badge/detail view (lib/html/includes.tmpl)
  4. Add client-side handler in lib/html/profile_handler.js if interactive functionality is needed (lib/html/profile_handler.js)

Add a new configuration option

  1. Define the option in lib/mini_profiler/config.rb with a default value and attr_accessor (lib/mini_profiler/config.rb)
  2. Document in the template initializer lib/generators/rack_mini_profiler/templates/rack_mini_profiler.rb (lib/generators/rack_mini_profiler/templates/rack_mini_profiler.rb)
  3. Use the config value in the appropriate component (e.g., middleware in lib/mini_profiler.rb, storage in lib/mini_profiler/config.rb) (lib/mini_profiler.rb)

🔧Why these technologies

  • Rack middleware — Works with any Rack-based framework (Rails, Sinatra, etc.); intercepts requests/responses without app changes
  • Multiple storage backends (Redis, Memcache, File, Memory) — Enables profiling in production (Redis for multi-process) and development (Memory for simplicity)
  • Database adapter patching (alias_method, prepend) — Non-invasive instrumentation of third-party libraries without modifying user code
  • Client-side JS badge + AJAX detail fetch — Minimal performance overhead in production; profile details lazy-loaded on-demand

🪤Traps & gotchas

  1. Gem load order matters: README explicitly states rack_mini_profiler must be required after pg/mysql gems in Gemfile, else SQL instrumentation won't work. 2. Rails patches opt-in: v2.0.0 removed default Rails patches; legacy apps need require: ['enable_rails_patches'] in Gemfile or profiling of Rails internals won't work. 3. Storage backend: Middleware defaults to in-memory storage; production use typically needs Redis or other persistent backend (configured in config.rb). 4. Authorization: Profiler UI is not auth-gated by default—requires explicit middleware config to restrict access in production. 5. stackprof/memory_profiler optional: Flamegraphs and memory profiling are disabled if gems not in Gemfile; no fallback.

🏗️Architecture

💡Concepts to learn

  • Rack Middleware — rack-mini-profiler is a Rack middleware that wraps every request/response cycle; understanding middleware architecture (how it intercepts, modifies, and chains with other middleware) is essential to modifying or debugging the profiler's behavior.
  • ActiveSupport::Notifications — As of v2.0.0, the profiler listens to Rails instrumentation events (e.g., 'sql.active_record', 'render_template.action_view') via this pub-sub system instead of monkey-patching; this is the modern integration point.
  • Flame Graphs — rack-mini-profiler uses flame graphs (via stackprof) to visualize CPU time hierarchically by gem/method; understanding the flamegraph output format and stackprof sampling is key to interpreting performance results.
  • Memory Profiling / Allocation Tracking — The optional memory_profiler integration shows per-request memory allocations and GC stats; understanding how Ruby allocates objects and GC behavior helps interpret these metrics.
  • SQL Query Instrumentation — The profiler patches or listens to database adapters (MySQL2, Postgres, Oracle, Mongoid) to capture and measure SQL queries; understanding how each adapter is instrumented is crucial for extending database profiling.
  • Server-Sent Events (SSE) for Profile Sharing — The profiler likely uses SSE or similar techniques to share profiles between users (see lib/html/share.html); understanding real-time communication patterns is relevant for the 'sharing' feature.
  • JavaScript Injection into HTML — The profiler injects lib/html/includes.js and the badge UI into every HTML response; understanding when/how this injection happens, CSP (Content Security Policy) implications, and avoiding script conflicts is important for integration and debugging.
  • rails/rails — Direct dependency for Rails apps; rack-mini-profiler hooks into Rails via ActiveSupport::Notifications and optional monkey-patching
  • MiniProfiler/ui — Central UI repository (mentioned in README as part of repo restructuring); likely contains shared frontend components and design for all MiniProfiler language implementations
  • flamegraph/flamegraph.pl — Flamegraph visualization pioneer; rack-mini-profiler bundles Speedscope (lib/html/speedscope/) as an alternative, but both serve the same CPU profiling visualization purpose
  • SamSaffron/memory_profiler — Companion optional gem for memory profiling; explicitly recommended in README and integrated into rack-mini-profiler's optional features
  • tmm1/stackprof — Companion optional gem for call-stack flamegraph profiling; explicitly recommended in README and integrated into rack-mini-profiler's optional features

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add comprehensive tests for storage backends (Redis, Memcache, File)

The repo has 5 storage implementations (abstract_store.rb, memory_store.rb, redis_store.rb, memcache_store.rb, file_store.rb) but there's no visible test directory in the file structure. Each backend has different failure modes and edge cases (connection timeouts, serialization, concurrent access) that need dedicated test coverage. This is critical since storage backends are the persistence layer for profiling data.

  • [ ] Create spec/storage/ directory structure mirroring lib/mini_profiler/storage/
  • [ ] Add spec/storage/redis_store_spec.rb with tests for connection failures, data persistence, and cache expiration
  • [ ] Add spec/storage/memcache_store_spec.rb with tests for key collision handling and server unavailability
  • [ ] Add spec/storage/file_store_spec.rb with tests for disk I/O errors, file locking, and cleanup
  • [ ] Add shared_examples for AbstractStore interface that all backends must satisfy

Add integration tests for database profiling with multiple drivers

The README claims support for 'Mysql2, Postgres, Oracle, and Mongoid3' but there's no visible test matrix in .github/workflows/ci.yml. Database profiling is a core feature with driver-specific implementation details. Contributors and maintainers need clear test coverage showing that each driver's SQL interception and timing works correctly.

  • [ ] Review lib/mini_profiler/profiling_methods.rb for database driver detection logic
  • [ ] Add to .github/workflows/ci.yml a test matrix job running against Postgres and MySQL services using Docker
  • [ ] Create spec/integration/database_profiling_spec.rb with tests for SQL timing capture across different drivers
  • [ ] Add tests verifying that Oracle and Mongoid adapters degrade gracefully if gems aren't installed
  • [ ] Document the test setup in a new TESTING.md file with instructions for running database-dependent tests locally

Add unit tests for timer_struct classes and profiling_methods serialization

The timer_struct directory contains 5 classes (base.rb, client.rb, custom.rb, page.rb, request.rb, sql.rb) that form the core data model for profiling results. Similarly, profiling_methods.rb orchestrates the timing and SQL interception logic. These are complex classes with domain logic (time calculations, nesting, aggregation) that need isolated unit tests to prevent regressions during refactoring.

  • [ ] Create spec/timer_struct/ directory structure mirroring lib/mini_profiler/timer_struct/
  • [ ] Add spec/timer_struct/request_spec.rb testing time aggregation, child timing nesting, and JSON serialization
  • [ ] Add spec/timer_struct/sql_spec.rb testing SQL parameterization, timing accuracy, and bind parameter handling
  • [ ] Add spec/profiling_methods_spec.rb testing the call-stack instrumentation hook injection and teardown
  • [ ] Ensure all classes handle edge cases: zero-duration timers, orphaned SQL queries, concurrent timing conflicts

🌿Good first issues

  • Add integration tests for Oracle database profiling (oracle_enhanced ~> 1.5.0 mentioned in README but no test fixtures visible in file list). File: spec/integration/ or similar—create test app with Oracle adapter and verify SQL capture.: Multiple database adapters are supported but test coverage is unclear; this expands confidence in non-Postgres/MySQL paths.
  • Document memory_profiler integration in the generated initializer template (lib/generators/rack_mini_profiler/templates/rack_mini_profiler.rb). Currently the template likely only covers basic config; add examples of memory_profiler::enabled options with explanations.: README mentions memory profiling but the boilerplate scaffold doesn't show users how to enable it, creating friction for adoption.
  • Add browser localStorage detection for client_settings persistence (lib/html/includes.js). Currently client settings may not survive page reloads; enhance lib/mini_profiler/client_settings.rb to sync with browser storage and restore on revisit.: UX improvement: user preferences (e.g., 'hide badge') reset on reload; this is a concrete, scoped feature that improves usability without deep refactoring.

Top contributors

Click to expand

📝Recent commits

Click to expand
  • d4ed8d4 — Bump actions/checkout from 4 to 6 (#664) (dependabot[bot])
  • 44ff2fe — CI: Tell dependabot to update GH Actions (#660) (olleolleolle)
  • 03a4584 — CI: update memcached service to 1.6.41 (#663) (nateberkopec)
  • f8df97b — Lint: Rails/EnvLocal: since Rails 7.1 (#661) (olleolleolle)
  • 8d7db99 — Drop support for Ruby 3.1 as it is EOL (#658) (larouxn)
  • 92610ca — Fix the CI matrix (#655) (Flink)
  • b55de0b — Update CHANGELOG.md (#654) (nna774)
  • cabebb8 — README.md: Mention Ruby 3.1+ (#652) (olleolleolle)
  • 227d931 — amend CI to point to correct rack version (SamSaffron)
  • 30237f7 — new release (SamSaffron)

🔒Security observations

  • High · Potential XSS Vulnerability in Client-Side Profiling Display — lib/html/includes.js, lib/html/profile_handler.js, lib/html/rack-mini-profiler.js. The codebase includes multiple JavaScript files (includes.js, profile_handler.js, rack-mini-profiler.js) that process and display profiling data. Without explicit content security policy and proper output encoding, there's a risk of XSS attacks if profiling data (SQL queries, method names, file paths) contains malicious content injected during request processing. Fix: Implement strict Content Security Policy (CSP) headers, sanitize all profiling data before rendering in HTML/JavaScript, use textContent instead of innerHTML where possible, and validate all user-controlled inputs that appear in profiling output.
  • High · Potential SQL Injection in Database Profiling Patches — lib/patches/db/activerecord.rb, lib/patches/db/mysql2.rb, lib/patches/db/pg.rb, lib/patches/db/mongo.rb. The codebase includes database-specific patches (activerecord.rb, mysql2.rb, pg.rb, mongo.rb, etc.) that intercept and log SQL queries. If these patches capture and display raw SQL without proper sanitization, attackers could inject malicious SQL that gets logged and displayed in profiling output, potentially exposing sensitive data. Fix: Implement strict parameterized query logging, mask sensitive data (passwords, tokens) in captured SQL, apply output encoding when displaying queries, and implement access controls to restrict who can view profiling data.
  • High · Sensitive Data Exposure in Profiling Output — lib/mini_profiler/storage/, lib/mini_profiler/snapshots_transporter.rb. Rack-mini-profiler captures detailed information about application execution including SQL queries, method call stacks, memory usage, and timing data. This information could expose sensitive business logic, database schema, API endpoints, and other confidential information if profiling data is accessible to unauthorized users or stored insecurely. Fix: Implement strict authorization controls to restrict profiling access to authenticated users only, implement data masking for sensitive values (PII, tokens, credentials), configure secure storage with encryption, implement automatic expiration of profiling snapshots, and disable profiling in production or restrict it to specific IP addresses.
  • Medium · Unencrypted Data Storage in File and Memory Stores — lib/mini_profiler/storage/file_store.rb, lib/mini_profiler/storage/memory_store.rb. The file storage and memory store implementations (file_store.rb, memory_store.rb) may store profiling data without encryption. If sensitive profiling information is persisted to disk or retained in memory, it could be exposed through unauthorized file access or memory dumps. Fix: Implement encryption for persisted profiling data at rest, use secure temporary file locations with restricted permissions, implement data retention policies with automatic cleanup, and consider using encrypted storage backends.
  • Medium · Missing CSRF Protection Configuration — lib/mini_profiler/actions.rb. The middleware provides endpoints for profiling actions and snapshot management (lib/mini_profiler/actions.rb). If these endpoints accept state-changing requests, they may be vulnerable to CSRF attacks if proper CSRF token validation is not implemented. Fix: Implement CSRF token validation for all state-changing endpoints, use SameSite cookie attributes, validate request origins, and implement proper HTTP method constraints (GET for retrieval, POST for state changes).
  • Medium · Potential Information Disclosure via Snapshots Transport — lib/mini_profiler/snapshots_transporter.rb. The snapshots transporter (snapshots_transporter.rb) may transmit profiling data over the network. If this transmission is not secured with HTTPS and proper authentication, it could expose sensitive profiling information. Fix: Enforce HTTPS for all profiling data transmission, implement authentication and authorization for snapshot access, encrypt sensitive data before transmission, and validate all network communications.
  • Medium · Missing Security Headers Configuration — lib/html/, lib/mini_profiler/config.rb. The middleware serves HTML, CSS, and JavaScript assets (lib/html/ directory) but configuration files don't indicate implementation of security headers like X-Frame-Options, X-Content-Type-Options, or strict CSP directives. Fix: Configure and enforce security headers including

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Healthy signals · MiniProfiler/rack-mini-profiler — RepoPilot