instana / ruby-sensor

💎 Ruby Distributed Tracing & Metrics Sensor for Instana
https://www.instana.com/
MIT License
26 stars 25 forks source link

How to disable Instana? Configuration docs not working #172

Closed kurko closed 5 years ago

kurko commented 5 years ago

I need to disable Instana in some environments or when I open the Rails console, and I want to do it via code. I tried the following:

# config/initializers/instana.rb
# ...
::Instana.config[:enabled] = false
::Instana.config[:tracing][:enabled] = false

It doesn't work. I open the console, though, and I keep getting these really annoying messages:

make_host_agent_request:agent.rb:437: execution expired
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/socksify-1.7.1/lib/socksify.rb:178:in `initialize'
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/socksify-1.7.1/lib/socksify.rb:178:in `initialize'
/opt/rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:937:in `open'
/opt/rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:937:in `block in connect'
/opt/rbenv/versions/2.5.1/lib/ruby/2.5.0/timeout.rb:103:in `timeout'
/opt/rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:935:in `connect'
/opt/rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:920:in `do_start'
/opt/rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:909:in `start'
/opt/rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:1455:in `request'
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/instana-1.9.5/lib/instana/instrumentation/net-http.rb:9:in `request_with_instana'
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/instana-1.9.5/lib/instana/agent.rb:430:in `make_host_agent_request'
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/instana-1.9.5/lib/instana/agent.rb:371:in `run_discovery'
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/instana-1.9.5/lib/instana/agent.rb:316:in `host_agent_available?'
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/instana-1.9.5/lib/instana/agent.rb:153:in `start'
/home/[REDACTED]/vendor/bundle/ruby/2.5.0/gems/instana-1.9.5/lib/instana/agent.rb:103:in `block (2 levels) in spawn_background_thread'
Host agent not available.  Will retry periodically. (Set env INSTANA_QUIET=1 to shut these messages off)

I know I can do ::Instana.logger = Logger.new(::IO::NULL), but I don't want to just shut it up, I want it to stop working so it's one less vector for bugs.

How do I disable Instana?

pglombardo commented 5 years ago

Hi @kurko - that option (::Instana.config[:enabled]) was recently deprecated in favor of an environment variable (INSTANA_DISABLE).

If you update to the latest Ruby gem and set that environment variable to any value, it will completely disable the gem (and avoid that logging output).

Some docs here as well: https://docs.instana.io/ecosystem/ruby/configuration/#global-enabledisable

Let me know if this resolves the issue for you.

kurko commented 5 years ago

Should INSTANA_DISABLE work in 1.9.5? It's not. I'm trying to keep updates to a minimum because we have a ton of moving parts at this moment.

If this env var only works on 1.10.something, please let me know.

pglombardo commented 5 years ago

This option was added in https://github.com/instana/ruby-sensor/releases/tag/1.10.7

kurko commented 5 years ago

Alright. Going to give it a try. Thanks for the assistance.