Sha256: 0788f753368ff41c93886496fbe145ecbccecf93190b76749e0e1e3cef290eca

Contents?: true

Size: 983 Bytes

Versions: 1

Compression:

Stored size: 983 Bytes

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minato-trace-0.1.6.pre.3 lib/minato/trace.rb