Skip to content

Commit

Permalink
Make the lag monitor send along the class for which the lag is being …
Browse files Browse the repository at this point in the history
…reported to statistics methods
  • Loading branch information
airhorns committed Nov 2, 2012
1 parent e54d6e3 commit 6f4e56a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/multi_db/lag_monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def self.replication_lag_too_high?(connection)

def self.slave_lag(klass)
cache_fetch("slave_lag:#{klass.name}") {
actual_slave_lag(klass.retrieve_connection)
actual_slave_lag(klass)
}
end

Expand All @@ -42,12 +42,13 @@ def self.report_lag_statistic(lag)
# hook method
end

def self.actual_slave_lag(connection)
def self.actual_slave_lag(connection_class)
connection = connection_class.retrieve_connection
result = connection.execute("SHOW SLAVE STATUS")
index = result.fields.index("Seconds_Behind_Master")
lag = result.first.try(:[], index).to_i

report_lag_statistic(lag)
report_lag_statistic(connection_class.name, lag)

lag
end
Expand Down

0 comments on commit 6f4e56a

Please sign in to comment.