Sha256: db57a6e40d7eb7a8bfbf63c1391057db2bc000b10149b90e4d77833ec51a1fff

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 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::Trace.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

2 entries across 2 versions & 1 rubygems

Version Path
minato-trace-0.1.6.pre.5 lib/minato/trace.rb
minato-trace-0.1.6.pre.4 lib/minato/trace.rb