Sha256: 653e3261ec93a9fd26257e2368e831e41385a69adce176d13b86578ca05a48a5
Contents?: true
Size: 917 Bytes
Versions: 3
Compression:
Stored size: 917 Bytes
Contents
# frozen_string_literal: true module Minato module Trace module Middleware class DistributedTraceContext TRACE_HEADER_KEY = "X-Cloud-Trace-Context" def initialize(app) @app = app end def call(env) add_trace_context_header(env) @app.call(env) end private def add_trace_context_header(env) return unless ::Rails.env.production? && Minato::Trace.enabled? return if current_cloud_trace.nil? env.request_headers.merge!({ "#{TRACE_HEADER_KEY}": "#{current_cloud_trace.trace.trace_id};o=1" }) end def current_cloud_trace @current_cloud_trace ||= current_trace_from_google_cloud end def current_trace_from_google_cloud _trace_client = Google::Cloud::Trace.new Google::Cloud::Trace.get end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems