Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4ca0e4ab
Commit
4ca0e4ab
authored
Jan 25, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate rack attack instrumentation into structured logs
parent
c4e11db3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
lib/gitlab/instrumentation_helper.rb
lib/gitlab/instrumentation_helper.rb
+10
-1
spec/lib/gitlab/instrumentation_helper_spec.rb
spec/lib/gitlab/instrumentation_helper_spec.rb
+3
-1
No files found.
lib/gitlab/instrumentation_helper.rb
View file @
4ca0e4ab
...
...
@@ -15,7 +15,8 @@ module Gitlab
:elasticsearch_duration_s
,
*::
Gitlab
::
Instrumentation
::
Redis
.
known_payload_keys
,
*::
Gitlab
::
Metrics
::
Subscribers
::
ActiveRecord
::
DB_COUNTERS
,
*::
Gitlab
::
Metrics
::
Subscribers
::
ExternalHttp
::
KNOWN_PAYLOAD_KEYS
]
*::
Gitlab
::
Metrics
::
Subscribers
::
ExternalHttp
::
KNOWN_PAYLOAD_KEYS
,
*::
Gitlab
::
Metrics
::
Subscribers
::
RackAttack
::
PAYLOAD_KEYS
]
end
def
add_instrumentation_data
(
payload
)
...
...
@@ -26,6 +27,7 @@ module Gitlab
instrument_throttle
(
payload
)
instrument_active_record
(
payload
)
instrument_external_http
(
payload
)
instrument_rack_attack
(
payload
)
end
def
instrument_gitaly
(
payload
)
...
...
@@ -80,6 +82,13 @@ module Gitlab
payload
.
merge!
(
db_counters
)
end
def
instrument_rack_attack
(
payload
)
rack_attack_redis_count
=
::
Gitlab
::
Metrics
::
Subscribers
::
RackAttack
.
payload
[
:rack_attack_redis_count
]
return
if
rack_attack_redis_count
==
0
payload
.
merge!
(
::
Gitlab
::
Metrics
::
Subscribers
::
RackAttack
.
payload
)
end
# Returns the queuing duration for a Sidekiq job in seconds, as a float, if the
# `enqueued_at` field or `created_at` field is available.
#
...
...
spec/lib/gitlab/instrumentation_helper_spec.rb
View file @
4ca0e4ab
...
...
@@ -39,7 +39,9 @@ RSpec.describe Gitlab::InstrumentationHelper do
:db_write_count
,
:db_cached_count
,
:external_http_count
,
:external_http_duration_s
:external_http_duration_s
,
:rack_attack_redis_count
,
:rack_attack_redis_duration_s
]
expect
(
described_class
.
keys
).
to
eq
(
expected_keys
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment