Module: OboeBase

Extended by:
Oboe::ThreadLocal
Included in:
Oboe
Defined in:
lib/oboe-heroku/base.rb

Overview

This module is the base module for the various implementations of Oboe reporting. Current variations as of 2014-09-10 are a c-extension, JRuby (using TraceView Java instrumentation) and a Heroku c-extension (with embedded tracelyzer)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Oboe::ThreadLocal

thread_local

Instance Attribute Details

#collectorObject

Returns the value of attribute collector.



33
34
35
# File 'lib/oboe-heroku/base.rb', line 33

def collector
  @collector
end

#loadedObject

Returns the value of attribute loaded.



34
35
36
# File 'lib/oboe-heroku/base.rb', line 34

def loaded
  @loaded
end

#reporterObject

Returns the value of attribute reporter.



32
33
34
# File 'lib/oboe-heroku/base.rb', line 32

def reporter
  @reporter
end

Class Method Details

.included(_) ⇒ Object



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

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

Instance Method Details

#always?Boolean

Returns true if the tracing_mode is set to always. False otherwise

Returns:

  • (Boolean)


55
56
57
# File 'lib/oboe-heroku/base.rb', line 55

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

#forking_webserver?Boolean

Determines if we are running under a forking webserver

Returns:

  • (Boolean)


105
106
107
# File 'lib/oboe-heroku/base.rb', line 105

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

#framework?Boolean

Indicates whether a supported framework is in use or not

Returns:

  • (Boolean)


113
114
115
# File 'lib/oboe-heroku/base.rb', line 113

def framework?
  defined?(::Rails) or defined?(::Sinatra) or defined?(::Padrino) or defined?(::Grape)
end

#heroku?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/oboe-heroku/base.rb', line 98

def heroku?
  ENV['TRACEVIEW_URL']
end

#log(_layer, _label, _options = {}) ⇒ Object



93
94
95
96
# File 'lib/oboe-heroku/base.rb', line 93

def log(layer, label, options = {})
  # WARN: Oboe.log will be deprecated in a future release.  Please use Oboe::API.log instead.
  Oboe::API.log(layer, label, options)
end

#never?Boolean

Returns true if the tracing_mode is set to never. False otherwise

Returns:

  • (Boolean)


63
64
65
# File 'lib/oboe-heroku/base.rb', line 63

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

#passthrough?Boolean

Returns true if the tracing_mode is set to always or through. False otherwise

Returns:

  • (Boolean)


71
72
73
# File 'lib/oboe-heroku/base.rb', line 71

def passthrough?
  %w(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)


121
122
123
# File 'lib/oboe-heroku/base.rb', line 121

def sample?(_opts = {})
  fail 'sample? should be implemented by metal layer.'
end

#set_sample_rate(_rate) ⇒ Object



133
134
135
# File 'lib/oboe-heroku/base.rb', line 133

def set_sample_rate(_rate)
  fail 'set_sample_rate should be implemented by metal layer.'
end

#set_tracing_mode(_mode) ⇒ Object



129
130
131
# File 'lib/oboe-heroku/base.rb', line 129

def set_tracing_mode(_mode)
  fail 'set_tracing_mode should be implemented by metal layer.'
end

#through?Boolean

Returns true if the tracing_mode is set to through. False otherwise

Returns:

  • (Boolean)


79
80
81
# File 'lib/oboe-heroku/base.rb', line 79

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

#tracing?Boolean

Returns true if we are currently tracing a request False otherwise

Returns:

  • (Boolean)


87
88
89
90
91
# File 'lib/oboe-heroku/base.rb', line 87

def tracing?
  return false unless Oboe.loaded

  Oboe::Context.isValid && !Oboe.never?
end

#tracing_layer_op?(operation) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
# File 'lib/oboe-heroku/base.rb', line 43

def tracing_layer_op?(operation)
  if operation.is_a?(Array)
    return operation.include?(Oboe.layer_op)
  else
    return Oboe.layer_op == operation
  end
end