Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit ff47976

Browse files
Ravi Sankar PentaMiciah
authored andcommitted
Add ENABLE_BROKER_STATS to broker.conf
Add instrumentation in the controller to log Passenger memory usage statistics after every request. Add ENABLE_BROKER_STATS setting (default false) to /etc/openshift/broker.conf to enable collecting and logging of these statistics. These log entries can be used by the oo-plot-broker-stats command, added in commit 10d6463, to generate data for gnuplot.
1 parent a4adf17 commit ff47976

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

broker/conf/broker.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,7 @@ ALLOW_REGION_SELECTION="true"
230230

231231
# Additional rubygems (space seperated) that will be loaded in the broker's Gemfile.
232232
# ADDITIONAL_RUBYGEMS=""
233+
234+
# Enables logging of stats like current request id,
235+
# heap memory, #objects, #symbols for the broker process.
236+
ENABLE_BROKER_STATS="false"

broker/config/environments/development.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
:limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i,
123123
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
124124
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
125+
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
125126
}
126127

127128
config.auth = {

broker/config/environments/production.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
:limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i,
112112
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
113113
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
114+
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
114115
}
115116

116117
config.auth = {

broker/config/environments/test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
:limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i,
121121
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
122122
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
123+
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
123124
}
124125

125126
config.auth = {

controller/lib/openshift/controller/api_responses.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def render_error(status, msg, err_code=nil, field=nil, msg_type=nil, messages=ni
4747
end
4848
@analytics_tracker.track_event(event_name, @domain, @application, {'request_path' => request.fullpath, 'request_method' => request.method, 'status_code' => status, 'error_code' => err_code, 'error_field' => field})
4949
end
50+
log_broker_stats(request.uuid)
5051
respond_with reply, :status => reply.status
5152
end
5253

@@ -225,6 +226,7 @@ def render_success(status, type, data, message=nil, result=nil ,extra_messages=n
225226
else
226227
log_action(action_log_tag, status, true, message, log_args)
227228
end
229+
log_broker_stats(request.uuid)
228230
respond_with reply
229231
end
230232

@@ -277,6 +279,17 @@ def extract_node_messages(ex, code=nil, message=nil, field=nil)
277279
end
278280
[code, message, messages]
279281
end
282+
283+
def log_broker_stats(request_uuid)
284+
if Rails.configuration.openshift[:broker_stats_enabled]
285+
stats = Hash.new
286+
stats[:request_id] = request_uuid
287+
stats[:gc_stat] = GC::stat
288+
stats[:count_objects] = ObjectSpace.count_objects
289+
stats[:count_objects][:T_SYMBOL] = Symbol.all_symbols.size
290+
Rails.logger.info("BROKER_STATS => #{stats.to_json}")
291+
end
292+
end
280293
end
281294
end
282295
end

0 commit comments

Comments
 (0)