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

Commit c4dcfb2

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 3d45f51 commit c4dcfb2

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
@@ -241,3 +241,7 @@ MIN_NODE_DISK_BUFFER="5"
241241

242242
# Additional rubygems (space seperated) that will be loaded in the broker's Gemfile.
243243
# ADDITIONAL_RUBYGEMS=""
244+
245+
# Enables logging of stats like current request id,
246+
# heap memory, #objects, #symbols for the broker process.
247+
ENABLE_BROKER_STATS="false"

broker/config/environments/development.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
125125
:auth_user_lookup_fail_msg => conf.get("AUTH_USER_LOOKUP_FAIL_MESSAGE", "This cluster is configured for user lookup only. Please contact your system administrator for provisioning your user account."),
126126
:min_node_disk_buffer => (conf.get("MIN_NODE_DISK_BUFFER", "5")).to_i
127+
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
127128
}
128129

129130
config.auth = {

broker/config/environments/production.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
114114
:auth_user_lookup_fail_msg => conf.get("AUTH_USER_LOOKUP_FAIL_MESSAGE", "This cluster is configured for user lookup only. Please contact your system administrator for provisioning your user account."),
115115
:min_node_disk_buffer => (conf.get("MIN_NODE_DISK_BUFFER", "5")).to_i
116+
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
116117
}
117118

118119
config.auth = {

broker/config/environments/test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
123123
:auth_user_lookup_fail_msg => conf.get("AUTH_USER_LOOKUP_FAIL_MESSAGE", "This cluster is configured for user lookup only. Please contact your system administrator for provisioning your user account."),
124124
:min_node_disk_buffer => (conf.get("MIN_NODE_DISK_BUFFER", "5")).to_i
125+
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
125126
}
126127

127128
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)