Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PGHero to the demo app #1294

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Commits on Mar 21, 2024

  1. Add PGHero to the demo app

    We want to show any helpful performance data in the GoodJob demo app so
    we are installing PGHero:
    
    https://github.com/ankane/pghero
    
    We have to add Sprockets to the Rails app so the PGHero assets get loaded
    correctly, whilst we could have used a more modern asset pipeline,
    Sprockets is well supported and a simple drop in to get PGHero running.
    
    PGHero is available at `/pghero`.
    
    We have not enabled:
    
    - [Suggested indexes](https://github.com/ankane/pghero/blob/master/guides/Rails.md#suggested-indexes)
    - [Historical query stats](https://github.com/ankane/pghero/blob/master/guides/Rails.md#query-stats)
    - [Historical space stats](https://github.com/ankane/pghero/blob/master/guides/Rails.md#historical-space-stats)
    
    As these may not be suitable for the demo application and can always be
    added later.
    mec committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    79638b5 View commit details
    Browse the repository at this point in the history
  2. Add spec to cover PgHero basic auth

    We want to be sure PgHero is behind basic auth. This spec validates that
    once the correct environment variables are set, PgHero will require
    basic authentication.
    
    We have to use the rack_test driver so we can use `basic_authorize` to
    set the headers, rack_test is the default in RSpec/Capybara, but we have
    explicitly set the driver just in case.
    mec committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    d3ae492 View commit details
    Browse the repository at this point in the history
  3. Enable PgHero Query Stats

    This does the work to enable historical query stats in PgHero, but the
    Postgres instance backing the service must also be configured, see:
    
    https://github.com/ankane/pghero/blob/master/guides/Rails.md#query-stats
    
    We are:
    
    - adding the tables to store stats
    - setting up a GoodJob cron job to collect the stats and clean old ones
    (the demo app generates a lot of queries)
    
    For reference, the recommended settings for `postgres.conf`:
    
    ```
    shared_preload_libraries = 'pg_stat_statements'
    pg_stat_statements.track = all
    pg_stat_statements.max = 10000
    track_activity_query_size = 2048
    ```
    
    See:
    
    https://github.com/ankane/pghero/blob/master/guides/Query-Stats.md
    mec committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    639323f View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2024

  1. Configuration menu
    Copy the full SHA
    0fd1ce7 View commit details
    Browse the repository at this point in the history

Commits on Mar 23, 2024

  1. Configuration menu
    Copy the full SHA
    7db14d0 View commit details
    Browse the repository at this point in the history

Commits on Mar 24, 2024

  1. Configuration menu
    Copy the full SHA
    6ab7460 View commit details
    Browse the repository at this point in the history