Module: Oboe

Extended by:
OboeBase
Includes:
Oboe_metal
Defined in:
lib/oboe/api.rb,
lib/oboe/base.rb,
lib/oboe/ruby.rb,
lib/oboe/util.rb,
lib/oboe_metal.rb,
lib/joboe_metal.rb,
lib/oboe/config.rb,
lib/oboe/logger.rb,
lib/oboe/xtrace.rb,
lib/oboe/loading.rb,
lib/oboe/support.rb,
lib/oboe/version.rb,
lib/oboe/api/util.rb,
lib/oboe/inst/rack.rb,
lib/oboe/inst/dalli.rb,
lib/oboe/inst/mongo.rb,
lib/oboe/inst/moped.rb,
lib/oboe/inst/redis.rb,
lib/oboe/api/logging.rb,
lib/oboe/api/tracing.rb,
lib/oboe/inst/resque.rb,
lib/oboe/api/memcache.rb,
lib/oboe/inst/faraday.rb,
lib/oboe/thread_local.rb,
lib/oboe/api/layerinit.rb,
lib/oboe/api/profiling.rb,
lib/oboe/inst/memcache.rb,
lib/oboe/inst/cassandra.rb,
lib/oboe/inst/memcached.rb,
lib/oboe/instrumentation.rb,
lib/oboe/frameworks/grape.rb,
lib/oboe/frameworks/rails.rb,
lib/oboe/frameworks/rails.rb,
lib/oboe/frameworks/padrino.rb,
lib/oboe/frameworks/sinatra.rb,
lib/oboe/inst/em-http-request.rb,
lib/oboe/frameworks/padrino/templates.rb,
lib/oboe/frameworks/sinatra/templates.rb,
lib/rails/generators/oboe/install_generator.rb,
lib/oboe/frameworks/rails/inst/action_controller.rb,
lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb,
lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb,
lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb,
lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb,
lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb

Overview

Copyright © 2013 AppNeta, Inc. All rights reserved.

Defined Under Namespace

Modules: API, Config, Grape, Inst, Loading, PadrinoInst, Rails, Ruby, Sinatra, ThreadLocal, Util, Version, XTrace Classes: Event, InstallGenerator, Logger, Rack, Railtie, Reporter

Class Attribute Summary collapse

Attributes included from OboeBase

#loaded, #reporter, #sample_rate, #sample_source

Class Method Summary collapse

Methods included from OboeBase

always?, extended, forking_webserver?, framework?, heroku?, included, log, never?, passthrough?, sample?, set_sample_rate, set_tracing_mode, through?, tracing?, tracing_layer_op?

Methods included from ThreadLocal

#thread_local

Methods included from Oboe_metal

#UdpReporter

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



8
9
10
# File 'lib/oboe/logger.rb', line 8

def logger
  @logger
end

Class Method Details

.sample?(opts = {}) ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/oboe_metal.rb', line 86

def sample?(opts = {})
  begin
    return false unless Oboe.always?

    # Assure defaults since SWIG enforces Strings
    layer   = opts[:layer]      ? opts[:layer].strip      : ''
    xtrace  = opts[:xtrace]     ? opts[:xtrace].strip     : ''
    tv_meta = opts['X-TV-Meta'] ? opts['X-TV-Meta'].strip : ''

    rv = Oboe::Context.sampleRequest(layer, xtrace, tv_meta)

    # For older liboboe that returns true/false, just return that.
    return rv if [TrueClass, FalseClass].include?(rv.class) || (rv == 0)

    # liboboe version > 1.3.1 returning a bit masked integer with SampleRate and
    # source embedded
    Oboe.sample_rate = (rv & SAMPLE_RATE_MASK)
    Oboe.sample_source = (rv & SAMPLE_SOURCE_MASK) >> 24
  rescue StandardError => e
    Oboe.logger.debug "[oboe/error] sample? error: #{e.inspect}"
    false
  end
end

.set_sample_rate(_rate) ⇒ Object



131
132
133
134
135
136
# File 'lib/oboe_metal.rb', line 131

def set_sample_rate(rate)
  return unless Oboe.loaded

  # Update liboboe with the new SampleRate value
  Oboe::Context.setDefaultSampleRate(rate.to_i)
end

.set_tracing_mode(_mode) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/oboe_metal.rb', line 110

def set_tracing_mode(mode)
  return unless Oboe.loaded

  value = mode.to_sym

  case value
  when :never
    Oboe::Context.setTracingMode(OBOE_TRACE_NEVER)

  when :always
    Oboe::Context.setTracingMode(OBOE_TRACE_ALWAYS)

  when :through
    Oboe::Context.setTracingMode(OBOE_TRACE_THROUGH)

  else
    Oboe.logger.fatal "[oboe/error] Invalid tracing mode set: #{mode}"
    Oboe::Context.setTracingMode(OBOE_TRACE_THROUGH)
  end
end

.support_reportObject



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
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/oboe/support.rb', line 18

def self.support_report
  Oboe.logger.warn "********************************************************"
  Oboe.logger.warn "* BEGIN TraceView Support Report"
  Oboe.logger.warn "*   Please email the output of this report to [email protected]"
  Oboe.logger.warn "********************************************************"
  Oboe.logger.warn "Ruby: #{RUBY_DESCRIPTION}"
  Oboe.logger.warn "$0: #{$0}"
  Oboe.logger.warn "$1: #{$1}" unless $1.nil?
  Oboe.logger.warn "$2: #{$2}" unless $2.nil?
  Oboe.logger.warn "$3: #{$3}" unless $3.nil?
  Oboe.logger.warn "$4: #{$4}" unless $4.nil?
  Oboe.logger.warn "Oboe.loaded == #{Oboe.loaded}"

  using_jruby = defined?(JRUBY_VERSION)
  Oboe.logger.warn "Using JRuby?: #{yesno(using_jruby)}"
  if using_jruby
    Oboe.logger.warn "Joboe Agent Status: #{Java::ComTracelyticsAgent::Agent.getStatus}"
  end

  on_heroku = Oboe.heroku?
  Oboe.logger.warn "On Heroku?: #{yesno(on_heroku)}"
  if on_heroku
    Oboe.logger.warn "TRACEVIEW_URL: #{ENV['TRACEVIEW_URL']}"
  end

  Oboe.logger.warn "Oboe::Ruby defined?: #{yesno(defined?(Oboe::Ruby))}"
  Oboe.logger.warn "Oboe.reporter: #{Oboe.reporter}"

  Oboe.logger.warn "********************************************************"
  Oboe.logger.warn "* Frameworks"
  Oboe.logger.warn "********************************************************"

  using_rails = defined?(::Rails)
  Oboe.logger.warn "Using Rails?: #{yesno(using_rails)}"
  if using_rails
    Oboe.logger.warn "Oboe::Rails loaded?: #{yesno(defined?(::Oboe::Rails))}"
  end

  using_sinatra = defined?(::Sinatra)
  Oboe.logger.warn "Using Sinatra?: #{yesno(using_sinatra)}"

  using_padrino = defined?(::Padrino)
  Oboe.logger.warn "Using Padrino?: #{yesno(using_padrino)}"

  using_grape = defined?(::Grape)
  Oboe.logger.warn "Using Grape?: #{yesno(using_grape)}"

  Oboe.logger.warn "********************************************************"
  Oboe.logger.warn "* TraceView Libraries"
  Oboe.logger.warn "********************************************************"
  files = Dir.glob('/usr/lib/liboboe*')
  if files.empty?
    Oboe.logger.warn "Error: No liboboe libs!"
  else
    files.each { |f|
      Oboe.logger.warn f
    }
  end

  Oboe.logger.warn "********************************************************"
  Oboe.logger.warn "* Raw __Init KVs"
  Oboe.logger.warn "********************************************************"
  platform_info = Oboe::Util.build_report
  platform_info.each { |k,v|
    Oboe.logger.warn "#{k}: #{v}"
  }
  
  Oboe.logger.warn "********************************************************"
  Oboe.logger.warn "* END TraceView Support Report"
  Oboe.logger.warn "*   Support Email: [email protected]"
  Oboe.logger.warn "*   Support Portal: https://support.tv.appneta.com"
  Oboe.logger.warn "*   Freenode IRC: #appneta"
  Oboe.logger.warn "*   Github: https://github.com/appneta/oboe-ruby"
  Oboe.logger.warn "********************************************************"
  nil
end

.yesno(x) ⇒ Object

yesno

Utility method to translate value/nil to “yes”/“no” strings



14
15
16
# File 'lib/oboe/support.rb', line 14

def self.yesno(x)
  x ? "yes" : "no"
end