Skip to content

Commit f7ba771

Browse files
committed
Instrument Net::LDAP#open
1 parent 5334dfd commit f7ba771

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

lib/net/ldap.rb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -577,18 +577,21 @@ def open
577577
# all generate auth failures if the bind was unsuccessful.
578578
raise Net::LDAP::LdapError, "Open already in progress" if @open_connection
579579

580-
begin
581-
@open_connection =
582-
Net::LDAP::Connection.new \
583-
:host => @host,
584-
:port => @port,
585-
:encryption => @encryption,
586-
:instrumentation_service => @instrumentation_service
587-
@open_connection.bind(@auth)
588-
yield self
589-
ensure
590-
@open_connection.close if @open_connection
591-
@open_connection = nil
580+
instrument "open.net_ldap" do |payload|
581+
begin
582+
@open_connection =
583+
Net::LDAP::Connection.new \
584+
:host => @host,
585+
:port => @port,
586+
:encryption => @encryption,
587+
:instrumentation_service => @instrumentation_service
588+
payload[:connection] = @open_connection
589+
payload[:bind] = @open_connection.bind(@auth)
590+
yield self
591+
ensure
592+
@open_connection.close if @open_connection
593+
@open_connection = nil
594+
end
592595
end
593596
end
594597

0 commit comments

Comments
 (0)