@@ -57,6 +57,8 @@ class Collection
5757 # Delegate to the cluster for the next primary.
5858 def_delegators :cluster , :next_primary
5959
60+ def_delegators :client , :tracer
61+
6062 # Options that can be updated on a new Collection instance via the #with method.
6163 #
6264 # @since 2.1.0
@@ -865,19 +867,22 @@ def insert_one(document, opts = {})
865867 session : session ,
866868 operation_timeouts : operation_timeouts ( opts )
867869 )
868- write_with_retry ( write_concern , context : context ) do |connection , txn_num , context |
869- Operation ::Insert . new (
870- :documents => [ document ] ,
871- :db_name => database . name ,
872- :coll_name => name ,
873- :write_concern => write_concern ,
874- :bypass_document_validation => !!opts [ :bypass_document_validation ] ,
875- :options => opts ,
876- :id_generator => client . options [ :id_generator ] ,
877- :session => session ,
878- :txn_num => txn_num ,
879- :comment => opts [ :comment ]
880- ) . execute_with_connection ( connection , context : context )
870+ operation = Operation ::Insert . new (
871+ :documents => [ document ] ,
872+ :db_name => database . name ,
873+ :coll_name => name ,
874+ :write_concern => write_concern ,
875+ :bypass_document_validation => !!opts [ :bypass_document_validation ] ,
876+ :options => opts ,
877+ :id_generator => client . options [ :id_generator ] ,
878+ :session => session ,
879+ :comment => opts [ :comment ]
880+ )
881+ tracer . trace_operation ( 'insert_one' , operation , context ) do
882+ write_with_retry ( write_concern , context : context ) do |connection , txn_num , context |
883+ operation . txn_num = txn_num
884+ operation . execute_with_connection ( connection , context : context )
885+ end
881886 end
882887 end
883888 end
0 commit comments