Module: OboeBase

Extended by:
Oboe::ThreadLocal
Included in:
Oboe
Defined in:
lib/oboe/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

#loadedObject

Returns the value of attribute loaded.



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

def loaded
  @loaded
end

#reporterObject

Returns the value of attribute reporter.



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

def reporter
  @reporter
end

#sample_rateObject

Returns the value of attribute sample_rate.



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

def sample_rate
  @sample_rate
end

#sample_sourceObject

Returns the value of attribute sample_source.



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

def sample_source
  @sample_source
end

Class Method Details

.extended(cls) ⇒ Object



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

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

.included(cls) ⇒ Object



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

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

Instance Method Details

#always?Boolean

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

Returns:

  • (Boolean)


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

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

#forking_webserver?Boolean

Determines if we are running under a forking webserver

Returns:

  • (Boolean)


108
109
110
# File 'lib/oboe/base.rb', line 108

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)


116
117
118
# File 'lib/oboe/base.rb', line 116

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

#heroku?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/oboe/base.rb', line 101

def heroku?
  ENV.key?('TRACEVIEW_URL')
end

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



96
97
98
99
# File 'lib/oboe/base.rb', line 96

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)


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

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)


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

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)


124
125
126
# File 'lib/oboe/base.rb', line 124

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

#set_sample_rate(_rate) ⇒ Object



136
137
138
# File 'lib/oboe/base.rb', line 136

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

#set_tracing_mode(_mode) ⇒ Object



132
133
134
# File 'lib/oboe/base.rb', line 132

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)


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

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

#tracing?Boolean

Returns true if we are currently tracing a request False otherwise

Returns:

  • (Boolean)


90
91
92
93
94
# File 'lib/oboe/base.rb', line 90

def tracing?
  return false unless Oboe.loaded

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

#tracing_layer_op?(operation) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
# File 'lib/oboe/base.rb', line 46

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