lib/minato/trace.rb in minato-trace-0.1.6.pre.2 vs lib/minato/trace.rb in minato-trace-0.1.6.pre.3

- old
+ new

@@ -7,14 +7,33 @@ module Minato module Trace BLACKLIST_PATHS = ["/health/alive", "/health/ready"].freeze - def self.init - Google::Cloud.configure do |config| - config.use_logging = false - config.use_trace = true - config.trace.sampler = Google::Cloud::Trace::TimeSampler.new(path_blacklist: BLACKLIST_PATHS.dup) + def self.init(app) + if Minato::Trace.enabled? + Minato::Trance.configure_loggging(app) + Minato::Trace.configure_trace(app) + end + + app + end + + def self.enabled? + ENV["MINATO_TRACE_DISABLED"] != "true" + end + + def self.configure_trace(app) + app.configure do + config.google_cloud.use_trace = true + config.google_cloud.trace.sampler = Google::Cloud::Trace::TimeSampler.new(path_blacklist: BLACKLIST_PATHS.dup) + config.minato_logger.trace_logs = Minato::Trace::Middleware::IntegrateWithCloudLogging.new + end + end + + def self.configure_loggging(app) + app.configure do + config.google_cloud.use_logging = false end end end end