diff --git a/broker/conf/broker.conf b/broker/conf/broker.conf index 833488b21cb..1b2b5f171d3 100644 --- a/broker/conf/broker.conf +++ b/broker/conf/broker.conf @@ -224,3 +224,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" diff --git a/broker/config/environments/development.rb b/broker/config/environments/development.rb index a0d0ba77303..4262fce7104 100644 --- a/broker/config/environments/development.rb +++ b/broker/config/environments/development.rb @@ -121,6 +121,7 @@ :use_predictable_gear_uuids => conf.get_bool("USE_PREDICTABLE_GEAR_UUIDS", false), :limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i, :app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false), + :broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"), } config.auth = { diff --git a/broker/config/environments/production.rb b/broker/config/environments/production.rb index 84c3b5132a5..2e591c53c1a 100644 --- a/broker/config/environments/production.rb +++ b/broker/config/environments/production.rb @@ -110,6 +110,7 @@ :use_predictable_gear_uuids => conf.get_bool("USE_PREDICTABLE_GEAR_UUIDS", false), :limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i, :app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false), + :broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"), } config.auth = { diff --git a/broker/config/environments/test.rb b/broker/config/environments/test.rb index a5d1f16e433..05ac3f4a4e1 100644 --- a/broker/config/environments/test.rb +++ b/broker/config/environments/test.rb @@ -119,6 +119,7 @@ :use_predictable_gear_uuids => conf.get_bool("USE_PREDICTABLE_GEAR_UUIDS", false), :limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i, :app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false), + :broker_stats_enabled => conf.get_bool("ENABLE_BROKER_STATS", "false"), } config.auth = { diff --git a/controller/lib/openshift/controller/api_responses.rb b/controller/lib/openshift/controller/api_responses.rb index f51dd52264e..8295ee9fe7e 100644 --- a/controller/lib/openshift/controller/api_responses.rb +++ b/controller/lib/openshift/controller/api_responses.rb @@ -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 @@ -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 @@ -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