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

Commit

Permalink
Add ENABLE_BROKER_STATS to broker.conf
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ravi Sankar Penta authored and Miciah committed Jul 28, 2016
1 parent e501551 commit b927a40
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions broker/conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,7 @@ ALLOW_REGION_SELECTION="true"

# Additional rubygems (space seperated) that will be loaded in the broker's Gemfile.
# ADDITIONAL_RUBYGEMS=""

# Enables logging of stats like current request id,
# heap memory, #objects, #symbols for the broker process.
ENABLE_BROKER_STATS="false"
1 change: 1 addition & 0 deletions broker/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
: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."),
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
}

config.auth = {
Expand Down
1 change: 1 addition & 0 deletions broker/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
: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."),
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
}

config.auth = {
Expand Down
1 change: 1 addition & 0 deletions broker/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
:auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false),
: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."),
:broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"),
}

config.auth = {
Expand Down
13 changes: 13 additions & 0 deletions controller/lib/openshift/controller/api_responses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def render_error(status, msg, err_code=nil, field=nil, msg_type=nil, messages=ni
end
@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})
end
log_broker_stats(request.uuid)
respond_with reply, :status => reply.status
end

Expand Down Expand Up @@ -225,6 +226,7 @@ def render_success(status, type, data, message=nil, result=nil ,extra_messages=n
else
log_action(action_log_tag, status, true, message, log_args)
end
log_broker_stats(request.uuid)
respond_with reply
end

Expand Down Expand Up @@ -277,6 +279,17 @@ def extract_node_messages(ex, code=nil, message=nil, field=nil)
end
[code, message, messages]
end

def log_broker_stats(request_uuid)
if Rails.configuration.openshift[:broker_stats_enabled]
stats = Hash.new
stats[:request_id] = request_uuid
stats[:gc_stat] = GC::stat
stats[:count_objects] = ObjectSpace.count_objects
stats[:count_objects][:T_SYMBOL] = Symbol.all_symbols.size
Rails.logger.info("BROKER_STATS => #{stats.to_json}")
end
end
end
end
end

0 comments on commit b927a40

Please sign in to comment.