Sha256: 75ace1baaf10822c5c652ce64a2c5bd6f79bc1b5353eee9008df0a04a75726dc

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

# Copyright (c) 2013 AppNeta, Inc.
# All rights reserved.

module OboeBase
  attr_accessor :reporter
  attr_accessor :loaded

  def self.included(cls)
    self.loaded = true
  end
  
  def always?
    Oboe::Config[:tracing_mode].to_s == "always"
  end
  
  def never?
    Oboe::Config[:tracing_mode].to_s == "never"
  end

  def passthrough?
    ["always", "through"].include?(Oboe::Config[:tracing_mode])
  end
  
  def through?
    Oboe::Config[:tracing_mode] == "through"
  end
  
  def tracing?
    return false unless Oboe.loaded

    Oboe::Context.isValid and not Oboe.never?
  end
  
  def log(layer, label, options = {})
    Context.log(layer, label, options = options)
  end

  ##
  # These methods should be implemented by the descendants
  # (Oboe_metal, Oboe_metal (JRuby), Heroku_metal)
  #
  def sample?(opts = {})
    raise "sample? should be implemented by metal layer."
  end
  
  def log(layer, label, options = {})
    raise "log should be implemented by metal layer."
  end
    
  def set_tracing_mode(mode)
    raise "set_tracing_mode should be implemented by metal layer."
  end
  
  def set_sample_rate(rate)
    raise "set_sample_rate should be implemented by metal layer."
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
oboe-2.3.4.1 lib/base.rb
oboe-heroku-0.9.0.1 lib/base.rb
oboe-2.3.3.7 lib/base.rb