@@ -57,6 +57,8 @@ class Collection
57
57
# Delegate to the cluster for the next primary.
58
58
def_delegators :cluster , :next_primary
59
59
60
+ def_delegators :client , :tracer
61
+
60
62
# Options that can be updated on a new Collection instance via the #with method.
61
63
#
62
64
# @since 2.1.0
@@ -865,19 +867,22 @@ def insert_one(document, opts = {})
865
867
session : session ,
866
868
operation_timeouts : operation_timeouts ( opts )
867
869
)
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
881
886
end
882
887
end
883
888
end
0 commit comments