Skip to content

Commit 52b3622

Browse files
authored
RCBC-534: Correctly set tracer to external tracer if one is provided (#199)
1 parent 199cb9e commit 52b3622

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

lib/couchbase/cluster.rb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -401,20 +401,22 @@ def initialize(connection_string, *args)
401401
end
402402

403403
@observability = Observability::Wrapper.new do |w|
404-
if !(open_options[:enable_tracing].nil? && !open_options[:enable_tracing])
405-
w.tracer = Tracing::NoopTracer.new
406-
elsif tracer.nil?
407-
w.tracer = Tracing::ThresholdLoggingTracer.new(
408-
emit_interval: open_options[:threshold_emit_interval],
409-
kv_threshold: open_options[:key_value_threshold],
410-
query_threshold: open_options[:query_threshold],
411-
views_threshold: open_options[:view_threshold],
412-
search_threshold: open_options[:search_threshold],
413-
analytics_threshold: open_options[:analytics_threshold],
414-
management_threshold: open_options[:management_threshold],
415-
sample_size: open_options[:threshold_sample_size],
416-
)
417-
end
404+
w.tracer = if !(open_options[:enable_tracing].nil? && !open_options[:enable_tracing])
405+
Tracing::NoopTracer.new
406+
elsif tracer.nil?
407+
Tracing::ThresholdLoggingTracer.new(
408+
emit_interval: open_options[:threshold_emit_interval],
409+
kv_threshold: open_options[:key_value_threshold],
410+
query_threshold: open_options[:query_threshold],
411+
views_threshold: open_options[:view_threshold],
412+
search_threshold: open_options[:search_threshold],
413+
analytics_threshold: open_options[:analytics_threshold],
414+
management_threshold: open_options[:management_threshold],
415+
sample_size: open_options[:threshold_sample_size],
416+
)
417+
else
418+
tracer
419+
end
418420
end
419421

420422
@backend = Backend.new

test/utils/tracing/test_span.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
module Couchbase
2020
module TestUtilities
21-
class TestSpan < RequestSpan
21+
class TestSpan < Couchbase::Tracing::RequestSpan
2222
attr_accessor :name
2323
attr_accessor :start_time, :end_time
2424
attr_accessor :attributes
2525
attr_accessor :parent
2626
attr_accessor :children
2727

2828
def initialize(name, parent: nil, start_timestamp: nil)
29-
super
29+
super()
3030
@name = name
3131
@start_time = start_timestamp.nil? ? Time.now : start_timestamp
3232
@parent = parent

test/utils/tracing/test_tracer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
module Couchbase
2222
module TestUtilities
23-
class TestTracer < RequestTracer
23+
class TestTracer < Couchbase::Tracing::RequestTracer
2424
def initialize
2525
super
2626
@spans = []

0 commit comments

Comments
 (0)