Sha256: d2b2015e9671185022a8188217f0ad2734b60f967175229a1264122fe28c6acc

Contents?: true

Size: 1006 Bytes

Versions: 2

Compression:

Stored size: 1006 Bytes

Contents

# 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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/minato-trace-0.2.0/lib/minato/trace.rb
minato-trace-0.2.0 lib/minato/trace.rb