# frozen_string_literal: true require "minato/trace/version" require "minato/trace/middleware" if defined? Rails::Railtie require "google/cloud/trace/rails" require "minato/trace/railtie" end module Minato module Trace BLACKLIST_PATHS = ["/health/alive", "/health/ready"].freeze def self.init(app) if Minato::Trace.enabled? Minato::Trace.configure_loggging Minato::Trace.configure_trace end app end def self.enabled? ENV["MINATO_TRACE_DISABLED"] != "true" end def self.configure_trace Google::Cloud.configure do |config| config.use_trace = true config.trace.sampler = Google::Cloud::Trace::TimeSampler.new(path_blacklist: BLACKLIST_PATHS.dup) end end def self.configure_loggging Google::Cloud.configure do |config| config.use_logging = false end end def self.skip_trace?(trace) BLACKLIST_PATHS.any? { |path| trace.name.start_with?(path) } end end end