Class: PgHero::Database
- Inherits:
-
Object
- Object
- PgHero::Database
- Includes:
- Methods::Basic, Methods::Connections, Methods::Constraints, Methods::Explain, Methods::Indexes, Methods::Kill, Methods::Maintenance, Methods::Queries, Methods::QueryStats, Methods::Replication, Methods::Sequences, Methods::Settings, Methods::Space, Methods::SuggestedIndexes, Methods::System, Methods::Tables, Methods::Users
- Defined in:
- lib/pghero/database.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #aws_access_key_id ⇒ Object (also: #access_key_id)
- #aws_db_instance_identifier ⇒ Object (also: #db_instance_identifier)
- #aws_region ⇒ Object (also: #region)
- #aws_secret_access_key ⇒ Object (also: #secret_access_key)
- #cache_hit_rate_threshold ⇒ Object
- #capture_query_stats? ⇒ Boolean
- #explain_timeout_sec ⇒ Object
- #index_bloat_bytes ⇒ Object
-
#initialize(id, config) ⇒ Database
constructor
A new instance of Database.
- #long_running_query_sec ⇒ Object
- #name ⇒ Object
- #slow_query_calls ⇒ Object
- #slow_query_ms ⇒ Object
- #total_connections_threshold ⇒ Object
Methods included from Methods::Users
Methods included from Methods::Tables
#table_caching, #table_hit_rate, #table_stats, #unused_tables
Methods included from Methods::System
#connection_stats, #cpu_usage, #free_space_stats, #rds_stats, #read_iops_stats, #replication_lag_stats, #system_stats_enabled?, #write_iops_stats
Methods included from Methods::SuggestedIndexes
#autoindex, #best_index, #suggested_indexes, #suggested_indexes_by_query, #suggested_indexes_enabled?
Methods included from Methods::Space
#capture_space_stats, #database_size, #relation_sizes, #relation_space_stats, #space_growth, #space_stats_enabled?, #table_sizes
Methods included from Methods::Settings
#autovacuum_settings, #settings, #vacuum_settings
Methods included from Methods::Sequences
Methods included from Methods::Replication
#replica?, #replicating?, #replication_lag, #replication_slots
Methods included from Methods::QueryStats
#capture_query_stats, #disable_query_stats, #enable_query_stats, #historical_query_stats_enabled?, #missing_query_stats_columns, #query_hash_stats, #query_stats, #query_stats_available?, #query_stats_enabled?, #query_stats_extension_enabled?, #query_stats_readable?, #query_stats_table_exists?, #reset_query_stats, #slow_queries, #supports_query_hash?
Methods included from Methods::Queries
#blocked_queries, #long_running_queries, #running_queries
Methods included from Methods::Maintenance
#analyze, #analyze_tables, #autovacuum_danger, #maintenance_info, #transaction_id_danger, #vacuum_progress
Methods included from Methods::Kill
#kill, #kill_all, #kill_long_running_queries
Methods included from Methods::Indexes
#duplicate_indexes, #index_bloat, #index_caching, #index_hit_rate, #index_usage, #indexes, #invalid_indexes, #last_stats_reset_time, #missing_indexes, #reset_stats, #unused_indexes
Methods included from Methods::Explain
Methods included from Methods::Constraints
Methods included from Methods::Connections
#connection_sources, #connection_states, #total_connections
Methods included from Methods::Basic
#database_name, #quote_ident, #server_version, #server_version_num, #ssl_used?
Constructor Details
#initialize(id, config) ⇒ Database
Returns a new instance of Database.
23 24 25 26 |
# File 'lib/pghero/database.rb', line 23 def initialize(id, config) @id = id @config = config || {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
21 22 23 |
# File 'lib/pghero/database.rb', line 21 def config @config end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/pghero/database.rb', line 21 def id @id end |
Instance Method Details
#aws_access_key_id ⇒ Object Also known as: access_key_id
64 65 66 |
# File 'lib/pghero/database.rb', line 64 def aws_access_key_id config["aws_access_key_id"] || PgHero.config["aws_access_key_id"] || ENV["PGHERO_ACCESS_KEY_ID"] || ENV["AWS_ACCESS_KEY_ID"] end |
#aws_db_instance_identifier ⇒ Object Also known as: db_instance_identifier
76 77 78 |
# File 'lib/pghero/database.rb', line 76 def aws_db_instance_identifier @db_instance_identifier ||= config["aws_db_instance_identifier"] || config["db_instance_identifier"] end |
#aws_region ⇒ Object Also known as: region
72 73 74 |
# File 'lib/pghero/database.rb', line 72 def aws_region config["aws_region"] || PgHero.config["aws_region"] || ENV["PGHERO_REGION"] || ENV["AWS_REGION"] || (defined?(Aws) && Aws.config[:region]) || "us-east-1" end |
#aws_secret_access_key ⇒ Object Also known as: secret_access_key
68 69 70 |
# File 'lib/pghero/database.rb', line 68 def aws_secret_access_key config["aws_secret_access_key"] || PgHero.config["aws_secret_access_key"] || ENV["PGHERO_SECRET_ACCESS_KEY"] || ENV["AWS_SECRET_ACCESS_KEY"] end |
#cache_hit_rate_threshold ⇒ Object
36 37 38 |
# File 'lib/pghero/database.rb', line 36 def cache_hit_rate_threshold (config["cache_hit_rate_threshold"] || PgHero.config["cache_hit_rate_threshold"] || PgHero.cache_hit_rate_threshold).to_i end |
#capture_query_stats? ⇒ Boolean
32 33 34 |
# File 'lib/pghero/database.rb', line 32 def capture_query_stats? config["capture_query_stats"] != false end |
#explain_timeout_sec ⇒ Object
52 53 54 |
# File 'lib/pghero/database.rb', line 52 def explain_timeout_sec (config["explain_timeout_sec"] || PgHero.config["explain_timeout_sec"] || PgHero.explain_timeout_sec).to_i end |
#index_bloat_bytes ⇒ Object
60 61 62 |
# File 'lib/pghero/database.rb', line 60 def index_bloat_bytes (config["index_bloat_bytes"] || PgHero.config["index_bloat_bytes"] || 100.megabytes).to_i end |
#long_running_query_sec ⇒ Object
56 57 58 |
# File 'lib/pghero/database.rb', line 56 def long_running_query_sec (config["long_running_query_sec"] || PgHero.config["long_running_query_sec"] || PgHero.long_running_query_sec).to_i end |
#name ⇒ Object
28 29 30 |
# File 'lib/pghero/database.rb', line 28 def name @name ||= @config["name"] || id.titleize end |
#slow_query_calls ⇒ Object
48 49 50 |
# File 'lib/pghero/database.rb', line 48 def slow_query_calls (config["slow_query_calls"] || PgHero.config["slow_query_calls"] || PgHero.slow_query_calls).to_i end |
#slow_query_ms ⇒ Object
44 45 46 |
# File 'lib/pghero/database.rb', line 44 def slow_query_ms (config["slow_query_ms"] || PgHero.config["slow_query_ms"] || PgHero.slow_query_ms).to_i end |
#total_connections_threshold ⇒ Object
40 41 42 |
# File 'lib/pghero/database.rb', line 40 def total_connections_threshold (config["total_connections_threshold"] || PgHero.config["total_connections_threshold"] || PgHero.total_connections_threshold).to_i end |