Sha256: 02a9be32c68c774519beec517532d07cdc4a740c1bf316ad54b8c0fd387a9b8b
Contents?: true
Size: 889 Bytes
Versions: 2
Compression:
Stored size: 889 Bytes
Contents
# frozen_string_literal: true module Minato module Trace module Middleware class IntegrateWithCloudLogging def call(log) return log unless ::Rails.env.production? && Minato::Trace.enabled? add_trace_to_logs(log) end private def add_trace_to_logs(log) trace_log = "projects/#{current_cloud_trace.trace.project_id}/traces/#{current_cloud_trace.trace.trace_id}" log.merge({ "logging.googleapis.com/trace": trace_log, "logging.googleapis.com/spanId": current_cloud_trace.span_id.to_s }) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
minato-trace-0.1.6.pre.4 | lib/minato/trace/middleware/integrate_with_cloud_logging.rb |
minato-trace-0.1.6.pre.3 | lib/minato/trace/middleware/integrate_with_cloud_logging.rb |