Skip to content

Commit 8415699

Browse files
Revert "Creates metrics endpoint for use by prom-scraper"
This change is dependent on cloudfoundry/cf-deployment#970 This reverts commit b278a04.
1 parent b278a04 commit 8415699

File tree

20 files changed

+55
-820
lines changed

20 files changed

+55
-820
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ gem 'sequel_pg', require: 'sequel'
4040
gem 'sinatra', '~> 2.2'
4141
gem 'sinatra-contrib'
4242
gem 'statsd-ruby', '~> 1.4.0'
43-
gem 'prometheus-client'
4443
gem 'steno'
4544
gem 'talentbox-delayed_job_sequel', '~> 4.3.0'
4645
gem 'thin'

Gemfile.lock

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ GEM
352352
ast (~> 2.4.1)
353353
pg (1.3.5)
354354
posix-spawn (0.3.15)
355-
prometheus-client (3.0.0)
356355
protobuf (3.6.12)
357356
activesupport (>= 3.2)
358357
middleware
@@ -601,7 +600,6 @@ DEPENDENCIES
601600
parallel_tests
602601
pg
603602
posix-spawn (~> 0.3.15)
604-
prometheus-client
605603
protobuf (= 3.6.12)
606604
pry-byebug
607605
psych (>= 4.0.4)
@@ -642,4 +640,4 @@ DEPENDENCIES
642640
yajl-ruby
643641

644642
BUNDLED WITH
645-
2.2.26
643+
2.1.4

app/controllers/internal/metrics_controller.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/controllers/internal/staging_completion_controller.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,15 @@ def report_metrics(bbs_staging_response)
117117
duration = Time.now.utc.to_i * 1e9 - bbs_staging_response[:created_at]
118118
if bbs_staging_response[:failed]
119119
statsd_updater.report_staging_failure_metrics(duration)
120-
prometheus_updater.report_staging_failure_metrics(duration)
121120
else
122121
statsd_updater.report_staging_success_metrics(duration)
123-
prometheus_updater.report_staging_success_metrics(duration)
124122
end
125123
end
126124

127125
def statsd_updater
128126
@statsd_updater ||= VCAP::CloudController::Metrics::StatsdUpdater.new
129127
end
130128

131-
def prometheus_updater
132-
@prometheus_updater ||= VCAP::CloudController::Metrics::PrometheusUpdater.new # this should be using singleton
133-
end
134-
135129
attr_reader :stagers
136130

137131
def read_body

app/jobs/diego/sync.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,15 @@ module VCAP::CloudController
77
module Jobs
88
module Diego
99
class Sync < VCAP::CloudController::Jobs::CCJob
10-
def initialize(statsd=Statsd.new, prometheus_updater=VCAP::CloudController::Metrics::PrometheusUpdater.new)
10+
def initialize(statsd=Statsd.new)
1111
@statsd = statsd
12-
@prometheus_updater = prometheus_updater
1312
end
1413

1514
def perform
1615
config = CloudController::DependencyLocator.instance.config
17-
begin
18-
## TODO: At some point in the future, start using a monotonic time source, rather than wall-clock time!
19-
start = Time.now
16+
@statsd.time('cc.diego_sync.duration') do
2017
VCAP::CloudController::Diego::ProcessesSync.new(config: config).sync
2118
VCAP::CloudController::Diego::TasksSync.new(config: config).sync
22-
ensure
23-
finish = Time.now
24-
## NOTE: We're taking time in seconds and multiplying by 1000 because we don't have
25-
## access to time in milliseconds. If you ever get access to reliable time in
26-
## milliseconds, then do know that the lack of precision here is not desired
27-
## so feed in the entire value!
28-
elapsed_ms = ((finish - start) * 1000).round
29-
30-
@statsd.timing('cc.diego_sync.duration', elapsed_ms)
31-
@prometheus_updater.report_diego_cell_sync_duration(elapsed_ms)
3219
end
3320
end
3421

lib/cloud_controller/dependency_locator.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
require 'cloud_controller/opi/instances_client'
3535
require 'cloud_controller/opi/stager_client'
3636
require 'cloud_controller/opi/task_client'
37-
require 'cloud_controller/metrics/prometheus_updater'
3837

3938
require 'bits_service_client'
4039

@@ -71,13 +70,6 @@ def runners
7170
@dependencies[:runners] || register(:runners, VCAP::CloudController::Runners.new(config))
7271
end
7372

74-
def prometheus_updater
75-
unless @dependencies[:prometheus_updater]
76-
register(:prometheus_updater, VCAP::CloudController::Metrics::PrometheusUpdater.new)
77-
end
78-
@dependencies[:prometheus_updater]
79-
end
80-
8173
def stagers
8274
@dependencies[:stagers] || register(:stagers, VCAP::CloudController::Stagers.new(config))
8375
end

lib/cloud_controller/deployment_updater/scheduler.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ def start
1010
with_error_logging('cc.deployment_updater') do
1111
config = CloudController::DependencyLocator.instance.config
1212
statsd_client = CloudController::DependencyLocator.instance.statsd_client
13-
prometheus_updater = CloudController::DependencyLocator.instance.prometheus_updater
1413

1514
update_step = proc { update(
1615
update_frequency: config.get(:deployment_updater, :update_frequency_in_seconds),
17-
statsd_client: statsd_client,
18-
prometheus_updater: prometheus_updater
16+
statsd_client: statsd_client
1917
)
2018
}
2119

@@ -41,20 +39,14 @@ def start
4139

4240
private
4341

44-
def update(update_frequency:, statsd_client:, prometheus_updater:)
42+
def update(update_frequency:, statsd_client:)
4543
logger = Steno.logger('cc.deployment_updater.scheduler')
4644

4745
update_start_time = Time.now
48-
Dispatcher.dispatch
46+
statsd_client.time('cc.deployments.update.duration') do
47+
Dispatcher.dispatch
48+
end
4949
update_duration = Time.now - update_start_time
50-
## NOTE: We're taking time in seconds and multiplying by 1000 because we don't have
51-
## access to time in milliseconds. If you ever get access to reliable time in
52-
## milliseconds, then do know that the lack of precision here is not desired
53-
## so feed in the entire value!
54-
update_duration_ms = update_duration * 1000
55-
statsd_client.timing('cc.deployments.update.duration', update_duration_ms)
56-
prometheus_updater.report_deployment_duration(update_duration_ms)
57-
5850
logger.info("Update loop took #{update_duration}s")
5951

6052
sleep_duration = update_frequency - update_duration

lib/cloud_controller/metrics/periodic_updater.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
module VCAP::CloudController::Metrics
55
class PeriodicUpdater
6-
def initialize(start_time, log_counter, logger=Steno.logger, updaters=[StatsdUpdater.new, PrometheusUpdater.new])
6+
def initialize(start_time, log_counter, logger=Steno.logger, updaters=[StatsdUpdater.new])
77
@start_time = start_time
88
@updaters = updaters
99
@log_counter = log_counter
@@ -15,7 +15,7 @@ def initialize(start_time, log_counter, logger=Steno.logger, updaters=[StatsdUpd
1515

1616
def setup_updates
1717
update!
18-
EM.add_periodic_timer(600) { catch_error { update_user_count } }
18+
EM.add_periodic_timer(600) { catch_error { record_user_count } }
1919
EM.add_periodic_timer(30) { catch_error { update_job_queue_length } }
2020
EM.add_periodic_timer(30) { catch_error { update_thread_info } }
2121
EM.add_periodic_timer(30) { catch_error { update_failed_job_count } }
@@ -26,7 +26,7 @@ def setup_updates
2626
end
2727

2828
def update!
29-
update_user_count
29+
record_user_count
3030
update_job_queue_length
3131
update_thread_info
3232
update_failed_job_count
@@ -67,10 +67,10 @@ def update_deploying_count
6767
@updaters.each { |u| u.update_deploying_count(deploying_count) }
6868
end
6969

70-
def update_user_count
70+
def record_user_count
7171
user_count = VCAP::CloudController::User.count
7272

73-
@updaters.each { |u| u.update_user_count(user_count) }
73+
@updaters.each { |u| u.record_user_count(user_count) }
7474
end
7575

7676
def update_job_queue_length

lib/cloud_controller/metrics/prometheus_updater.rb

Lines changed: 0 additions & 143 deletions
This file was deleted.

lib/cloud_controller/metrics/request_metrics.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,25 @@
33
module VCAP::CloudController
44
module Metrics
55
class RequestMetrics
6-
def initialize(statsd=Statsd.new, prometheus_updater=PrometheusUpdater.new)
6+
def initialize(statsd=Statsd.new)
77
@counter = 0
88
@statsd = statsd
9-
@prometheus_updater = prometheus_updater
109
end
1110

1211
def start_request
1312
@counter += 1
1413
@statsd.gauge('cc.requests.outstanding.gauge', @counter)
1514
@statsd.increment 'cc.requests.outstanding'
16-
17-
@prometheus_updater.update_gauge_metric(:cc_requests_outstanding_gauge, @counter, 'Requests Outstanding Gauge')
18-
@prometheus_updater.increment_gauge_metric(:cc_requests_outstanding, 'Requests Outstanding')
1915
end
2016

2117
def complete_request(status)
22-
http_status_code = "#{status.to_s[0]}XX"
23-
http_status_metric = "cc.http_status.#{http_status_code}"
2418
@counter -= 1
2519
@statsd.gauge('cc.requests.outstanding.gauge', @counter)
2620
@statsd.batch do |batch|
2721
batch.decrement 'cc.requests.outstanding'
2822
batch.increment 'cc.requests.completed'
29-
batch.increment http_status_metric
23+
batch.increment "cc.http_status.#{status.to_s[0]}XX"
3024
end
31-
32-
@prometheus_updater.update_gauge_metric(:cc_requests_outstanding_gauge, @counter, 'Requests Outstanding Gauge')
33-
@prometheus_updater.decrement_gauge_metric(:cc_requests_outstanding, 'Requests Outstanding')
34-
@prometheus_updater.increment_gauge_metric(:cc_requests_completed, 'Requests Completed')
35-
@prometheus_updater.increment_gauge_metric(http_status_metric.gsub('.', '_').to_sym, "Times HTTP status #{http_status_code} have been received")
3625
end
3726
end
3827
end

0 commit comments

Comments
 (0)