Skip to content

Commit a6584f2

Browse files
committed
opt-out flag for automatic web instrumentation
1 parent 3df8637 commit a6584f2

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ After requiring the main file, you can further configure with:
4444
| client_custom_labels | A hash of custom labels to send with each client request | `{}` | None |
4545
| client_max_queue_size | The max amount of metrics to send before flushing | `10000` | `ENV['PROMETHEUS_CLIENT_MAX_QUEUE_SIZE']` |
4646
| client_thread_sleep | How often to sleep the worker thread that manages the client buffer (seconds) | `0.5` | `ENV['PROMETHEUS_CLIENT_THREAD_SLEEP']` |
47+
| disable_web_automatic_instrumentation | Opt out flag for Web instrumentation; use `Bigcommerce::Prometheus::Instrumentors::Web.new(app: Rails.application).start` in your app's code to start it up yourself | `0` | `ENV['PROMETHEUS_WEB_DISABLE_AUTOMATIC_INSTRUMENTATION']` |
4748
| puma_collection_frequency | How often to poll puma collection metrics (seconds) | `30` | `ENV['PROMETHEUS_PUMA_COLLECTION_FREQUENCY']` |
4849
| server_host | The host to run the exporter on | `"0.0.0.0"` | `ENV['PROMETHEUS_SERVER_HOST']` |
4950
| server_port | The port to run the exporter on | `9394` | `ENV['PROMETHEUS_SERVER_PORT']` |

lib/bigcommerce/prometheus/configuration.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ module Configuration
5151
resque_collectors: [],
5252
resque_type_collectors: [],
5353
web_collectors: [],
54-
web_type_collectors: []
54+
web_type_collectors: [],
55+
56+
# Additional configuration
57+
web_disable_automatic_instrumentation: ENV.fetch('PROMETHEUS_WEB_DISABLE_AUTOMATIC_INSTRUMENTATION', 0).to_i.positive?
5558
}.freeze
5659

5760
attr_accessor *VALID_CONFIG_KEYS.keys

lib/bigcommerce/prometheus/integrations/railtie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Integrations
2323
#
2424
class Railtie < ::Rails::Railtie
2525
initializer 'zzz.bc_prometheus_ruby.configure_rails_initialization' do |app|
26-
Bigcommerce::Prometheus::Instrumentors::Web.new(app: app).start
26+
Bigcommerce::Prometheus::Instrumentors::Web.new(app: app).start unless ::Bigcommerce::Prometheus.web_disable_automatic_instrumentation
2727
end
2828
end
2929
end

0 commit comments

Comments
 (0)