Class: Instana::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/instana/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/instana/config.rb', line 4

def initialize
  @config = {}

  @config[:agent_host] = '127.0.0.1'
  @config[:agent_port] = 42699

  # Global on/off switch for prebuilt environments
  # Setting this to false will disable this gem
  # from doing anything.
  @config[:enabled] = true

  # Enable/disable metrics globally or individually (default: all enabled)
  @config[:metrics] = { :enabled => true }
  @config[:metrics][:gc]     = { :enabled => true }
  @config[:metrics][:memory] = { :enabled => true }
  @config[:metrics][:thread] = { :enabled => true }

  # Enable/disable tracing (default: enabled)
  @config[:tracing] = { :enabled => true }

  if ENV.key?('INSTANA_GEM_DEV')
    @config[:collector] = { :enabled => true, :interval => 3 }
  else
    @config[:collector] = { :enabled => true, :interval => 1 }
  end

  # EUM Related
  @config[:eum_api_key] = nil
  @config[:eum_baggage] = {}

  # Instrumentation
  @config[:action_controller]  = { :enabled => true }
  @config[:action_view]        = { :enabled => true }
  @config[:active_record]      = { :enabled => true }
  @config[:dalli]              = { :enabled => true }
  @config[:excon]              = { :enabled => true }
  @config[:nethttp]            = { :enabled => true }
  @config[:'rest-client']      = { :enabled => true }
end

Instance Method Details

#[](key) ⇒ Object



44
45
46
# File 'lib/instana/config.rb', line 44

def [](key)
  @config[key.to_sym]
end

#[]=(key, value) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/instana/config.rb', line 48

def []=(key, value)
  @config[key.to_sym] = value

  if key == :enabled
    # Configuring global enable/disable flag, then set the
    # appropriate children flags.
    @config[:metrics][:enabled] = value
    @config[:tracing][:enabled] = value
  end
end