# frozen_string_literal: true require "minato/trace/version" require "minato/trace/railtie" require "minato/trace/middleware" require "google/cloud/trace/rails" module Minato module Trace BLACKLIST_PATHS = ["/health/alive", "/health/ready"].freeze 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