Class: Instana::Config

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

Instance Method Summary collapse

Constructor Details

#initialize(logger: ::Instana.logger, agent_host: ENV['INSTANA_AGENT_HOST'], agent_port: ENV['INSTANA_AGENT_PORT']) ⇒ Config

Returns a new instance of Config.



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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/instana/config.rb', line 6

def initialize(logger: ::Instana.logger, agent_host: ENV['INSTANA_AGENT_HOST'], agent_port: ENV['INSTANA_AGENT_PORT'])
  @config = {}
  if agent_host
    logger.debug "Using custom agent host location specified in INSTANA_AGENT_HOST (#{ENV['INSTANA_AGENT_HOST']})"
    @config[:agent_host] = agent_host
  else
    @config[:agent_host] = '127.0.0.1'
  end
  if agent_port
    logger.debug "Using custom agent port specified in INSTANA_AGENT_PORT (#{ENV['INSTANA_AGENT_PORT']})"
    @config[:agent_port] = agent_port
  else
    @config[:agent_port] = 42699
  end

  # 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 }

  # Enable/disable tracing exit spans as root spans
  @config[:allow_exit_as_root] = ENV['INSTANA_ALLOW_EXIT_AS_ROOT'] == '1'

  # Enable/Disable logging
  @config[:logging] = { :enabled => true }

  # Collector interval
  @config[:collector] = { :enabled => true, :interval => 1 }

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

  # In Ruby, backtrace collection is very expensive so it's
  # (unfortunately) disabled by default.  If you still want
  # backtraces, it can be enabled with this config option.
  # ::Instana.config[:collect_backtraces] = true
  @config[:collect_backtraces] = false

  # By default, collected SQL will be sanitized to remove potentially sensitive bind params such as:
  #   > SELECT  "blocks".* FROM "blocks"  WHERE "blocks"."name" = "Mr. Smith"
  #
  # ...would be sanitized to be:
  #   > SELECT  "blocks".* FROM "blocks"  WHERE "blocks"."name" = ?
  #
  # This sanitization step can be disabled by setting the following value to false.
  # ::Instana.config[:sanitize_sql] = false
  @config[:sanitize_sql] = true

  # W3C Trace Context Support
  @config[:w3c_trace_correlation] = ENV['INSTANA_DISABLE_W3C_TRACE_CORRELATION'].nil?

  @config[:post_fork_proc] = proc { ::Instana.agent.spawn_background_thread }

  @config[:action_controller]  = { :enabled => true }
  @config[:action_view]        = { :enabled => true }
  @config[:active_record]      = { :enabled => true }
  @config[:bunny]              = { :enabled => true }
  @config[:dalli]              = { :enabled => true }
  @config[:excon]              = { :enabled => true }
  @config[:grpc]               = { :enabled => true }
  @config[:graphql]            = { :enabled => true }
  @config[:nethttp]            = { :enabled => true }
  @config[:redis]              = { :enabled => true }
  @config[:'resque-client']    = { :enabled => true, :propagate => true }
  @config[:'resque-worker']    = { :enabled => true, :'setup-fork' => true }
  @config[:'rest-client']      = { :enabled => true }
  @config[:sequel]             = { :enabled => true }
  @config[:'sidekiq-client']   = { :enabled => true }
  @config[:'sidekiq-worker']   = { :enabled => true }
end

Instance Method Details

#[](key) ⇒ Object



82
83
84
# File 'lib/instana/config.rb', line 82

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

#[]=(key, value) ⇒ Object



86
87
88
# File 'lib/instana/config.rb', line 86

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