File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -1139,6 +1139,8 @@ class Net::LDAP::Connection #:nodoc:
11391139 MaxSaslChallenges = 10
11401140
11411141 def initialize ( server )
1142+ @instrumentation_service = server [ :instrumentation_service ]
1143+
11421144 begin
11431145 @conn = TCPSocket . new ( server [ :host ] , server [ :port ] )
11441146 rescue SocketError
@@ -1233,6 +1235,21 @@ def setup_encryption(args)
12331235 end
12341236 end
12351237
1238+ # Internal: Instrument a block with the defined instrumentation service.
1239+ #
1240+ # Returns the return value of the block.
1241+ def instrument ( event , payload = { } )
1242+ return yield unless instrumentation_service
1243+
1244+ instrumentation_service . instrument ( event , payload ) do
1245+ yield
1246+ end
1247+ end
1248+ private :instrument
1249+
1250+ attr_reader :instrumentation_service
1251+ private :instrumentation_service
1252+
12361253 #--
12371254 # This is provided as a convenience method to make sure a connection
12381255 # object gets closed without waiting for a GC to happen. Clients shouldn't
@@ -1244,12 +1261,16 @@ def close
12441261 end
12451262
12461263 def read ( syntax = Net ::LDAP ::AsnSyntax )
1247- @conn . read_ber ( syntax )
1264+ instrument "read.net_ldap_connection" , :syntax => syntax do
1265+ @conn . read_ber ( syntax )
1266+ end
12481267 end
12491268 private :read
12501269
12511270 def write ( packet )
1252- @conn . write ( packet )
1271+ instrument "write.net_ldap_connection" , :packet => packet do
1272+ @conn . write ( packet )
1273+ end
12531274 end
12541275 private :write
12551276
You can’t perform that action at this time.
0 commit comments