Module: Oboe

Extended by:
OboeBase
Includes:
Oboe_metal
Defined in:
lib/oboe/api.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/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/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/rails.rb,
lib/oboe/frameworks/rails.rb,
lib/oboe/frameworks/padrino.rb,
lib/oboe/frameworks/sinatra.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, Inst, Loading, PadrinoInst, Rails, Ruby, Sinatra, Util, Version, XTrace Classes: InstallGenerator, Logger, Rack, Railtie

Class Attribute Summary collapse

Attributes included from OboeBase

#loaded, #reporter, #sample_rate, #sample_source

Class Method Summary collapse

Methods included from OboeBase

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

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)


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/oboe_metal.rb', line 80

def sample?(opts = {})
  begin
    # 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) or (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



123
124
125
126
127
128
# File 'lib/oboe_metal.rb', line 123

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

.set_tracing_mode(mode) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/oboe_metal.rb', line 102

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