lib/heroku_metal.rb in oboe-heroku-0.9.13.3 vs lib/heroku_metal.rb in oboe-heroku-0.9.14.4
- old
+ new
@@ -1,45 +1,14 @@
# Copyright (c) 2013 AppNeta
# All rights reserved.
-require 'base'
+require 'oboe-heroku/base'
-module Oboe_metal
- class Context
- class << self
- attr_accessor :layer_op
-
- def log(layer, label, options = {}, with_backtrace = false)
- evt = Oboe::Context.createEvent()
- evt.addInfo("Layer", layer.to_s)
- evt.addInfo("Label", label.to_s)
+module Oboe
+ extend OboeBase
+ include Oboe_metal
- options.each_pair do |k, v|
- evt.addInfo(k.to_s, v.to_s)
- end
-
- evt.addInfo("Backtrace", Oboe::API.backtrace) if with_backtrace
-
- Oboe.reporter.sendReport(evt) if Oboe.loaded
- end
-
- def tracing_layer_op?(operation)
- if operation.is_a?(Array)
- return operation.include?(@layer_op)
- else
- return @layer_op == operation
- end
- end
- end
- end
-
- class Event
- def self.metadataString(evt)
- evt.metadataString()
- end
- end
-
class Reporter
##
# Initialize the Oboe Context, reporter and report the initialization
#
def self.start
@@ -52,13 +21,13 @@
end
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.reporter = Oboe_metal::Reporter.new(nil, nil)
Oboe::API.report_init
rescue Exception => e
$stderr.puts e.message
raise
@@ -67,18 +36,21 @@
def self.sendReport(evt)
Oboe.reporter.sendReport(evt) if Oboe.loaded
end
end
-end
-module Oboe
- extend OboeBase
- include Oboe_metal
+ class Event
+ def self.metadataString(evt)
+ evt.metadataString()
+ end
+ end
class << self
def sample?(opts = {})
+ return false unless Oboe.always?
+
# Assure defaults since SWIG enforces Strings
opts[:layer] ||= ''
opts[:xtrace] ||= ''
opts['X-TV-Meta'] ||= ''
@@ -92,10 +64,10 @@
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