lib/google/cloud/logging/logger.rb in google-cloud-logging-1.5.7 vs lib/google/cloud/logging/logger.rb in google-cloud-logging-1.6.0
- old
+ new
@@ -60,11 +60,11 @@
# entry. If it is nil, no trace ID is sent.
#
# The log_name is a String that controls the name of the Stackdriver
# log to write to. If it is nil, the default log_name for this Logger
# is used.
- RequestInfo = ::Struct.new :trace_id, :log_name, :env
+ RequestInfo = ::Struct.new :trace_id, :log_name, :env, :trace_sampled
##
# The Google Cloud writer object that calls to `#write_entries` are made
# on. Either an AsyncWriter or Project object.
attr_reader :writer
@@ -454,12 +454,13 @@
# @param [String, nil] log_name The log name to use, or nil to use
# this logger's default.
# @param [Hash, nil] env The request's Rack environment or `nil` if not
# available.
#
- def add_request_info info: nil, env: nil, trace_id: nil, log_name: nil
- info ||= RequestInfo.new trace_id, log_name, env
+ def add_request_info info: nil, env: nil, trace_id: nil, log_name: nil,
+ trace_sampled: nil
+ info ||= RequestInfo.new trace_id, log_name, env, trace_sampled
@request_info_var.value = info
info
end
@@ -547,14 +548,15 @@
if info
actual_log_name = info.log_name || actual_log_name
unless info.trace_id.nil? || @project.nil?
entry.trace = "projects/#{@project}/traces/#{info.trace_id}"
end
+ entry.trace_sampled = info.trace_sampled if entry.trace_sampled.nil?
end
writer.write_entries entry, log_name: actual_log_name,
resource: resource,
- labels: entry_labels(info)
+ labels: entry_labels(info)
end
##
# @private generate the labels hash for a log entry.
def entry_labels info