lib/heroku_metal.rb in oboe-heroku-0.9.0.1 vs lib/heroku_metal.rb in oboe-heroku-0.9.7.1
- old
+ new
@@ -42,11 +42,13 @@
##
# Initialize the Oboe Context, reporter and report the initialization
#
def self.start
begin
- Oboe_metal::Context.init()
+ Oboe_metal::Context.init()
+
+ Oboe.logger.debug "[oboe/debug] Initializing Heroku based reporter."
# The Oboe Reporter is configured via Heroku config variables.
Oboe.reporter = Oboe::Reporter.new(nil, nil)
Oboe::API.report_init('rack') unless ["development", "test"].include? ENV['RACK_ENV']
@@ -66,40 +68,49 @@
module Oboe
extend OboeBase
include Oboe_metal
class << self
-
def sample?(opts = {})
# Assure defaults since SWIG enforces Strings
opts[:layer] ||= ''
opts[:xtrace] ||= ''
- opts['TV-Meta'] ||= ''
- Oboe::Context.sampleRequest(opts[:layer], opts[:xtrace], opts['TV-Meta'])
+ opts['X-TV-Meta'] ||= ''
+
+ rv = Oboe::Context.sampleRequest(opts[:layer], opts[:xtrace], opts['X-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
+
+ rv
end
def set_tracing_mode(mode)
return unless Oboe.loaded
value = mode.to_sym
case value
when :never
- # OBOE_TRACE_NEVER
- Oboe::Context.setTracingMode(0)
+ Oboe::Context.setTracingMode(OBOE_TRACE_NEVER)
+
when :always
- # OBOE_TRACE_ALWAYS
- Oboe::Context.setTracingMode(1)
+ Oboe::Context.setTracingMode(OBOE_TRACE_ALWAYS)
+
when :through
- # OBOE_TRACE_THROUGH
- Oboe::Context.setTracingMode(2)
+ Oboe::Context.setTracingMode(OBOE_TRACE_THROUGH)
+
else
Oboe.logger.fatal "[oboe/error] Invalid tracing mode set: #{mode}"
- # OBOE_TRACE_ALWAYS
- Oboe::Context.setTracingMode(1)
+ Oboe::Context.setTracingMode(OBOE_TRACE_THROUGH)
end
end
-
+
def set_sample_rate(rate)
if Oboe.loaded
# Update liboboe with the new SampleRate value
Oboe::Context.setDefaultSampleRate(rate.to_i)
end