lib/google/cloud/trace/async_reporter.rb in google-cloud-trace-0.40.0 vs lib/google/cloud/trace/async_reporter.rb in google-cloud-trace-0.41.0
- old
+ new
@@ -34,11 +34,11 @@
attr_reader :service, :max_bytes, :max_count, :max_queue, :interval,
:threads
##
# @private Creates a new AsyncReporter instance.
- def initialize service, max_count: 1000, max_bytes: 4000000,
+ def initialize service, max_count: 1000, max_bytes: 4_000_000,
max_queue: 100, interval: 5, threads: 10
# init MonitorMixin
super()
@service = service
@@ -109,11 +109,11 @@
break if @stopped
@stopped = true
patch_batch!
@cond.broadcast
- @thread_pool.shutdown if @thread_pool
+ @thread_pool&.shutdown
end
self
end
@@ -217,11 +217,11 @@
# interval met, publish the batch...
patch_batch!
@cond.wait
else
# still waiting for the interval to publish the batch...
- @cond.wait(@batch.publish_wait)
+ @cond.wait @batch.publish_wait
end
end
end
end
@@ -293,11 +293,12 @@
end
##
# @private
class Batch
- attr_reader :created_at, :traces
+ attr_reader :created_at
+ attr_reader :traces
def initialize reporter
@reporter = reporter
@traces = []
@traces_bytes = reporter.project.bytesize + 4 # initial size
@@ -335,10 +336,10 @@
@created_at + @reporter.interval
end
def publish_wait
publish_wait = publish_at - Time.now
- return 0 if publish_wait < 0
+ return 0 if publish_wait.negative?
publish_wait
end
def addl_bytes_for trace
trace.to_grpc.to_proto.bytesize + 2