1- require 'statsd'
1+ require 'statsd/instrument '
22
33module VCAP ::CloudController ::Metrics
44 class StatsdUpdater
@@ -16,64 +16,50 @@ def update_user_count(user_count)
1616 end
1717
1818 def update_job_queue_length ( pending_job_count_by_queue , total )
19- @statsd . batch do |batch |
20- pending_job_count_by_queue . each do |key , value |
21- batch . gauge ( "cc.job_queue_length.#{ key } " , value )
22- end
23- batch . gauge ( 'cc.job_queue_length.total' , total )
19+ pending_job_count_by_queue . each do |key , value |
20+ @statsd . gauge ( "cc.job_queue_length.#{ key } " , value )
2421 end
22+ @statsd . gauge ( 'cc.job_queue_length.total' , total )
2523 end
2624
2725 def update_job_queue_load ( pending_job_load_by_queue , total )
28- @statsd . batch do |batch |
29- pending_job_load_by_queue . each do |key , value |
30- batch . gauge ( "cc.job_queue_load.#{ key } " , value )
31- end
32- batch . gauge ( 'cc.job_queue_load.total' , total )
26+ pending_job_load_by_queue . each do |key , value |
27+ @statsd . gauge ( "cc.job_queue_load.#{ key } " , value )
3328 end
29+ @statsd . gauge ( 'cc.job_queue_load.total' , total )
3430 end
3531
3632 def update_thread_info_thin ( thread_info )
37- @statsd . batch do |batch |
38- batch . gauge ( 'cc.thread_info.thread_count' , thread_info [ :thread_count ] )
39- batch . gauge ( 'cc.thread_info.event_machine.connection_count' , thread_info [ :event_machine ] [ :connection_count ] )
40- batch . gauge ( 'cc.thread_info.event_machine.threadqueue.size' , thread_info [ :event_machine ] [ :threadqueue ] [ :size ] )
41- batch . gauge ( 'cc.thread_info.event_machine.threadqueue.num_waiting' , thread_info [ :event_machine ] [ :threadqueue ] [ :num_waiting ] )
42- batch . gauge ( 'cc.thread_info.event_machine.resultqueue.size' , thread_info [ :event_machine ] [ :resultqueue ] [ :size ] )
43- batch . gauge ( 'cc.thread_info.event_machine.resultqueue.num_waiting' , thread_info [ :event_machine ] [ :resultqueue ] [ :num_waiting ] )
44- end
33+ @statsd . gauge ( 'cc.thread_info.thread_count' , thread_info [ :thread_count ] )
34+ @statsd . gauge ( 'cc.thread_info.event_machine.connection_count' , thread_info [ :event_machine ] [ :connection_count ] )
35+ @statsd . gauge ( 'cc.thread_info.event_machine.threadqueue.size' , thread_info [ :event_machine ] [ :threadqueue ] [ :size ] )
36+ @statsd . gauge ( 'cc.thread_info.event_machine.threadqueue.num_waiting' , thread_info [ :event_machine ] [ :threadqueue ] [ :num_waiting ] )
37+ @statsd . gauge ( 'cc.thread_info.event_machine.resultqueue.size' , thread_info [ :event_machine ] [ :resultqueue ] [ :size ] )
38+ @statsd . gauge ( 'cc.thread_info.event_machine.resultqueue.num_waiting' , thread_info [ :event_machine ] [ :resultqueue ] [ :num_waiting ] )
4539 end
4640
4741 def update_failed_job_count ( failed_jobs_by_queue , total )
48- @statsd . batch do |batch |
49- failed_jobs_by_queue . each do |key , value |
50- batch . gauge ( "cc.failed_job_count.#{ key } " , value )
51- end
52- batch . gauge ( 'cc.failed_job_count.total' , total )
42+ failed_jobs_by_queue . each do |key , value |
43+ @statsd . gauge ( "cc.failed_job_count.#{ key } " , value )
5344 end
45+ @statsd . gauge ( 'cc.failed_job_count.total' , total )
5446 end
5547
5648 def update_vitals ( vitals )
57- @statsd . batch do |batch |
58- vitals . each do |key , val |
59- batch . gauge ( "cc.vitals.#{ key } " , val )
60- end
49+ vitals . each do |key , val |
50+ @statsd . gauge ( "cc.vitals.#{ key } " , val )
6151 end
6252 end
6353
6454 def update_log_counts ( counts )
65- @statsd . batch do |batch |
66- counts . each do |key , val |
67- batch . gauge ( "cc.log_count.#{ key } " , val )
68- end
55+ counts . each do |key , val |
56+ @statsd . gauge ( "cc.log_count.#{ key } " , val )
6957 end
7058 end
7159
7260 def update_task_stats ( total_running_tasks , total_memory_in_mb )
73- @statsd . batch do |batch |
74- batch . gauge ( 'cc.tasks_running.count' , total_running_tasks )
75- batch . gauge ( 'cc.tasks_running.memory_in_mb' , total_memory_in_mb )
76- end
61+ @statsd . gauge ( 'cc.tasks_running.count' , total_running_tasks )
62+ @statsd . gauge ( 'cc.tasks_running.memory_in_mb' , total_memory_in_mb )
7763 end
7864
7965 def update_synced_invalid_lrps ( lrp_count )
@@ -86,12 +72,12 @@ def start_staging_request_received
8672
8773 def report_staging_success_metrics ( duration_ns )
8874 @statsd . increment ( 'cc.staging.succeeded' )
89- @statsd . timing ( 'cc.staging.succeeded_duration' , nanoseconds_to_milliseconds ( duration_ns ) )
75+ @statsd . measure ( 'cc.staging.succeeded_duration' , nanoseconds_to_milliseconds ( duration_ns ) )
9076 end
9177
9278 def report_staging_failure_metrics ( duration_ns )
9379 @statsd . increment ( 'cc.staging.failed' )
94- @statsd . timing ( 'cc.staging.failed_duration' , nanoseconds_to_milliseconds ( duration_ns ) )
80+ @statsd . measure ( 'cc.staging.failed_duration' , nanoseconds_to_milliseconds ( duration_ns ) )
9581 end
9682
9783 def start_request
@@ -103,11 +89,9 @@ def complete_request(status)
10389 http_status_code = "#{ status . to_s [ 0 ] } XX"
10490 http_status_metric = "cc.http_status.#{ http_status_code } "
10591 @statsd . gauge ( 'cc.requests.outstanding.gauge' , store . decrement_request_outstanding_gauge )
106- @statsd . batch do |batch |
107- batch . decrement 'cc.requests.outstanding'
108- batch . increment 'cc.requests.completed'
109- batch . increment http_status_metric
110- end
92+ @statsd . increment ( 'cc.requests.outstanding' , -1 )
93+ @statsd . increment ( 'cc.requests.completed' )
94+ @statsd . increment ( http_status_metric )
11195 end
11296
11397 private
0 commit comments