Skip to content

Commit e1e80c4

Browse files
wip
1 parent 1ffd096 commit e1e80c4

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

lib/mongo/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ def initialize(addresses_or_uri, options = nil)
592592
@cluster = Cluster.new(
593593
addresses,
594594
@monitoring,
595-
tracer,
596595
cluster_options.merge(srv_uri: srv_uri)
597596
)
598597
end
@@ -642,6 +641,7 @@ def cluster_options
642641
# applications should read these values from client, not from cluster
643642
max_read_retries: options[:max_read_retries],
644643
read_retry_interval: options[:read_retry_interval],
644+
tracer: tracer,
645645
).tap do |options|
646646
# If the client has a cluster already, forward srv_uri to the new
647647
# cluster to maintain SRV monitoring. If the client is brand new,
@@ -912,7 +912,7 @@ def reconnect
912912
@connect_lock.synchronize do
913913
do_close rescue nil
914914

915-
@cluster = Cluster.new(addresses, monitoring, tracer, cluster_options)
915+
@cluster = Cluster.new(addresses, monitoring, cluster_options)
916916

917917
if @options[:auto_encryption_options]
918918
build_encrypter

lib/mongo/cluster.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class Cluster
117117
# - *:deprecation_errors* -- boolean
118118
#
119119
# @since 2.0.0
120-
def initialize(seeds, monitoring, tracer = nil, options = Options::Redacted.new)
120+
def initialize(seeds, monitoring, options = Options::Redacted.new)
121121
if seeds.nil?
122122
raise ArgumentError, 'Seeds cannot be nil'
123123
end
@@ -136,7 +136,7 @@ def initialize(seeds, monitoring, tracer = nil, options = Options::Redacted.new)
136136
@update_lock = Mutex.new
137137
@servers = []
138138
@monitoring = monitoring
139-
@tracer = tracer
139+
@tracer = options[:tracer]
140140
@event_listeners = Event::Listeners.new
141141
@app_metadata = Server::AppMetadata.new(@options.merge(purpose: :application))
142142
@monitor_app_metadata = Server::Monitor::AppMetadata.new(@options.merge(purpose: :monitor))
@@ -299,8 +299,7 @@ def self.create(client, monitoring: nil)
299299
cluster = Cluster.new(
300300
client.cluster.addresses.map(&:to_s),
301301
monitoring || Monitoring.new,
302-
tracer = client.tracer,
303-
client.cluster_options,
302+
client.cluster_options
304303
)
305304
client.instance_variable_set(:@cluster, cluster)
306305
end

lib/mongo/collection/view/aggregation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def effective_read_preference(connection)
120120

121121
end
122122

123-
def send_initial_query(server, context)
123+
def send_initial_query(server, context, operation: nil)
124124
if server.load_balancer?
125125
# Connection will be checked in when cursor is drained.
126126
connection = server.pool.check_out(context: context)

lib/mongo/collection/view/iterable.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def select_cursor(session)
9292
tracer.trace_operation(op, context) do
9393
if respond_to?(:write?, true) && write?
9494
server = server_selector.select_server(cluster, nil, session, write_aggregation: true)
95-
result = send_initial_query(server, context)
95+
result = send_initial_query(server, context, operation: op)
9696

9797
if use_query_cache?
9898
CachingCursor.new(view, result, server, session: session, context: context)
@@ -101,7 +101,7 @@ def select_cursor(session)
101101
end
102102
else
103103
read_with_retry_cursor(session, server_selector, view, context: context) do |server|
104-
send_initial_query(server, context)
104+
send_initial_query(server, context, operation: op)
105105
end
106106
end
107107
end
@@ -169,8 +169,8 @@ def initial_query_op(session)
169169
end
170170
end
171171

172-
def send_initial_query(server, context)
173-
operation = initial_query_op(context.session)
172+
def send_initial_query(server, context, operation: nil)
173+
operation ||= initial_query_op(context.session)
174174
if server.load_balancer?
175175
# Connection will be checked in when cursor is drained.
176176
connection = server.pool.check_out(context: context)

spec/spec_tests/open_telemetry_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
warn "Skipping OpenTelemetry unified spec test: #{filename}"
2222
end
2323

24-
if [ 1, '1', 'yes', 'true' ].include?(ENV['OTEL_SPEC_TESTS'])
25-
define_unified_spec_tests(base, TESTS_TO_RUN)
26-
else
27-
skip 'OTel spec tests are disabled. To enable them set env variable OTEL_SPEC_TESTS to 1'
24+
describe 'CSOT unified spec tests' do
25+
if [ 1, '1', 'yes', 'true' ].include?(ENV['OTEL_SPEC_TESTS'])
26+
define_unified_spec_tests(base, TESTS_TO_RUN)
27+
else
28+
skip 'OTel spec tests are disabled. To enable them set env variable OTEL_SPEC_TESTS to 1'
29+
end
2830
end

spec/support/background_thread_registry.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def verify_empty!
5252
msg << "\n not in an example"
5353
end
5454
end
55-
warn msg
55+
raise msg
5656
end
5757
@records.clear
5858
end

0 commit comments

Comments
 (0)