Class: Gitlab::Metrics::Subscribers::Ldap
- Inherits:
-
ActiveSupport::Subscriber
- Object
- ActiveSupport::Subscriber
- Gitlab::Metrics::Subscribers::Ldap
- Defined in:
- lib/gitlab/metrics/subscribers/ldap.rb
Constant Summary collapse
- COUNTER =
:net_ldap_count
- DURATION =
:net_ldap_duration_s
- OBSERVABLE_EVENTS =
Assembled from methods that are instrumented inside Net::LDAP
%i[ open bind add modify modify_password rename delete search ].freeze
Class Method Summary collapse
-
.count ⇒ Integer
The total number of LDAP requests.
-
.duration ⇒ Float
The total duration spent on LDAP requests.
-
.payload ⇒ Hash<Integer, Float>
Used in Gitlab::InstrumentationHelper to merge the LDAP stats into the log output.
Instance Method Summary collapse
-
#observe_event(event) ⇒ Object
Called when an event is triggered in ActiveSupport::Notifications.
Class Method Details
.count ⇒ Integer
Returns the total number of LDAP requests.
28 29 30 |
# File 'lib/gitlab/metrics/subscribers/ldap.rb', line 28 def count Gitlab::SafeRequestStore[COUNTER].to_i end |
.duration ⇒ Float
Returns the total duration spent on LDAP requests.
33 34 35 |
# File 'lib/gitlab/metrics/subscribers/ldap.rb', line 33 def duration Gitlab::SafeRequestStore[DURATION].to_f end |
.payload ⇒ Hash<Integer, Float>
Used in Gitlab::InstrumentationHelper to merge the LDAP stats into the log output
41 42 43 44 45 46 |
# File 'lib/gitlab/metrics/subscribers/ldap.rb', line 41 def payload { net_ldap_count: count, net_ldap_duration_s: duration } end |
Instance Method Details
#observe_event(event) ⇒ Object
Called when an event is triggered in ActiveSupport::Notifications
This method is aliased to the various events triggered by the Net::LDAP library, as the method will be called by those names when triggered.
It stores statistics in the request for output to logs, and also resubmits the event data into Prometheus for monitoring purposes.
57 58 59 60 |
# File 'lib/gitlab/metrics/subscribers/ldap.rb', line 57 def observe_event(event) add_to_request_store(event) expose_metrics(event) end |