Module: OboeBase

Included in:
Oboe
Defined in:
lib/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loadedObject

Returns the value of attribute loaded.



27
28
29
# File 'lib/base.rb', line 27

def loaded
  @loaded
end

#reporterObject

Returns the value of attribute reporter.



26
27
28
# File 'lib/base.rb', line 26

def reporter
  @reporter
end

#sample_rateObject

Returns the value of attribute sample_rate.



29
30
31
# File 'lib/base.rb', line 29

def sample_rate
  @sample_rate
end

#sample_sourceObject

Returns the value of attribute sample_source.



28
29
30
# File 'lib/base.rb', line 28

def sample_source
  @sample_source
end

Class Method Details

.included(cls) ⇒ Object



31
32
33
# File 'lib/base.rb', line 31

def self.included(cls)
  self.loaded = true
end

Instance Method Details

#always?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/base.rb', line 35

def always?
  Oboe::Config[:tracing_mode].to_s == "always"
end

#forking_webserver?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/base.rb', line 65

def forking_webserver?
  (defined?(::Unicorn) and ($0 =~ /unicorn/i)) ? true : false
end

#heroku?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/base.rb', line 61

def heroku?
  false
end

#log(layer, label, options = {}) ⇒ Object



57
58
59
# File 'lib/base.rb', line 57

def log(layer, label, options = {})
  Context.log(layer, label, options = options)
end

#never?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/base.rb', line 39

def never?
  Oboe::Config[:tracing_mode].to_s == "never"
end

#passthrough?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/base.rb', line 43

def passthrough?
  ["always", "through"].include?(Oboe::Config[:tracing_mode])
end

#sample?(opts = {}) ⇒ Boolean

These methods should be implemented by the descendants (Oboe_metal, Oboe_metal (JRuby), Heroku_metal)

Returns:

  • (Boolean)


73
74
75
# File 'lib/base.rb', line 73

def sample?(opts = {})
  raise "sample? should be implemented by metal layer."
end

#set_sample_rate(rate) ⇒ Object



85
86
87
# File 'lib/base.rb', line 85

def set_sample_rate(rate)
  raise "set_sample_rate should be implemented by metal layer."
end

#set_tracing_mode(mode) ⇒ Object



81
82
83
# File 'lib/base.rb', line 81

def set_tracing_mode(mode)
  raise "set_tracing_mode should be implemented by metal layer."
end

#through?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/base.rb', line 47

def through?
  Oboe::Config[:tracing_mode] == "through"
end

#tracing?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
# File 'lib/base.rb', line 51

def tracing?
  return false unless Oboe.loaded

  Oboe::Context.isValid and not Oboe.never?
end