Skip to content

Commit

Permalink
Introduce config option to disable statsd metrics
Browse files Browse the repository at this point in the history
This config option allows to send metrics only via prometheus
  • Loading branch information
kathap committed Jan 5, 2024
1 parent c54d2bd commit 793c109
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/cloud_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ staging:

statsd_host: "127.0.0.1"
statsd_port: 8125
disable_statsd_metrics: false

perform_blob_cleanup: false

Expand Down
1 change: 1 addition & 0 deletions lib/cloud_controller/config_schemas/base/api_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class ApiSchema < VCAP::Config

statsd_host: String,
statsd_port: Integer,
optional(:disable_statsd_metrics) => bool,
system_hostnames: [String],
default_app_ssh_access: bool,

Expand Down
1 change: 1 addition & 0 deletions lib/cloud_controller/config_schemas/base/clock_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class ClockSchema < VCAP::Config

statsd_host: String,
statsd_port: Integer,
optional(:disable_statsd_metrics) => bool,

max_labels_per_resource: Integer,
max_annotations_per_resource: Integer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class DeploymentUpdaterSchema < VCAP::Config

statsd_host: String,
statsd_port: Integer,
optional(:disable_statsd_metrics) => bool,

max_labels_per_resource: Integer,
max_annotations_per_resource: Integer,
Expand Down
26 changes: 26 additions & 0 deletions lib/cloud_controller/dependency_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,30 @@ def create_paginated_collection_renderer(opts={})
})
end
end

class NullDependencyLocator
include Singleton

def config
Struct.new
end

def statsd_client
@statsd_client ||= NullStatsdClient.new
end

def statsd_updater
# Null implementation
end

class NullStatsdClient
def timing(_key, _value)
# Null implementation
end

def increment(_key)
# Null implementation
end
end
end
end
6 changes: 5 additions & 1 deletion lib/cloud_controller/deployment_updater/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class << self
def start
with_error_logging('cc.deployment_updater') do
config = CloudController::DependencyLocator.instance.config
statsd_client = CloudController::DependencyLocator.instance.statsd_client
if config.get(:disable_statsd_metrics) == false
statsd_client = CloudController::DependencyLocator.instance.statsd_client
else
statsd_client = CloudController::NullDependencyLocator.instance.statsd_client
end

update_step = proc {
update(
Expand Down
7 changes: 6 additions & 1 deletion lib/cloud_controller/diego/messenger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ def bbs_stager_client
end

def statsd_updater
CloudController::DependencyLocator.instance.statsd_updater
config = CloudController::DependencyLocator.instance.config
if config.get(:disable_statsd_metrics) == false
CloudController::DependencyLocator.instance.statsd_updater
else
CloudController::NullDependencyLocator.instance.statsd_updater
end
end

def prometheus_updater
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/config/port_8181_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ droplets:

statsd_host: "127.0.0.1"
statsd_port: 8125
disable_statsd_metrics: false

perform_blob_cleanup: false

Expand Down

0 comments on commit 793c109

Please sign in to comment.