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
5df76410
Commit
5df76410
authored
Aug 12, 2021
by
Changzheng Liu
Committed by
Matthias Käppler
Aug 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include Puma worker PID in structured log
Changelog: other
parent
bcdf86cb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
15 deletions
+26
-15
doc/administration/logs.md
doc/administration/logs.md
+5
-2
lib/gitlab/instrumentation_helper.rb
lib/gitlab/instrumentation_helper.rb
+5
-0
spec/lib/gitlab/grape_logging/loggers/perf_logger_spec.rb
spec/lib/gitlab/grape_logging/loggers/perf_logger_spec.rb
+10
-13
spec/lib/gitlab/instrumentation_helper_spec.rb
spec/lib/gitlab/instrumentation_helper_spec.rb
+6
-0
No files found.
doc/administration/logs.md
View file @
5df76410
...
...
@@ -97,7 +97,8 @@ Line breaks were added to examples for legibility:
"cpu_s"
:
17.50
,
"db_duration_s"
:
0.08
,
"view_duration_s"
:
2.39
,
"duration_s"
:
20.54
"duration_s"
:
20.54
,
"pid"
:
81836
}
```
...
...
@@ -120,6 +121,7 @@ seconds:
-
`redis_<instance>_duration_s`
: Total time to retrieve data from a Redis instance
-
`redis_<instance>_read_bytes`
: Total bytes read from a Redis instance
-
`redis_<instance>_write_bytes`
: Total bytes written to a Redis instance
-
`pid`
: Process ID of the Puma worker
User clone and fetch activity using HTTP transport appears in the log as
`action: git_upload_pack`
.
...
...
@@ -190,7 +192,8 @@ Starting with GitLab 12.5, if an error occurs, an
"cpu_s"
:
17.50
,
"db_duration_s"
:
0.08
,
"view_duration_s"
:
2.39
,
"duration_s"
:
20.54
"duration_s"
:
20.54
,
"pid"
:
81836
,
"exception.class"
:
"NameError"
,
"exception.message"
:
"undefined local variable or method `adsf' for #<Admin::DashboardController:0x00007ff3c9648588>"
,
"exception.backtrace"
:
[
...
...
lib/gitlab/instrumentation_helper.rb
View file @
5df76410
...
...
@@ -30,6 +30,7 @@ module Gitlab
instrument_cpu
(
payload
)
instrument_thread_memory_allocations
(
payload
)
instrument_load_balancing
(
payload
)
instrument_pid
(
payload
)
end
def
instrument_gitaly
(
payload
)
...
...
@@ -99,6 +100,10 @@ module Gitlab
payload
[
:cpu_s
]
=
cpu_s
.
round
(
DURATION_PRECISION
)
if
cpu_s
end
def
instrument_pid
(
payload
)
payload
[
:pid
]
=
Process
.
pid
end
def
instrument_thread_memory_allocations
(
payload
)
counters
=
::
Gitlab
::
Memory
::
Instrumentation
.
measure_thread_memory_allocations
(
::
Gitlab
::
RequestContext
.
instance
.
thread_memory_allocations
)
...
...
spec/lib/gitlab/grape_logging/loggers/perf_logger_spec.rb
View file @
5df76410
...
...
@@ -3,26 +3,23 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
GrapeLogging
::
Loggers
::
PerfLogger
do
subject
{
described_class
.
new
}
let
(
:mock_request
)
{
OpenStruct
.
new
(
env:
{})
}
describe
".parameters"
do
let
(
:mock_request
)
{
OpenStruct
.
new
(
env:
{}
)
}
subject
{
described_class
.
new
.
parameters
(
mock_request
,
nil
)
}
describe
'when no performance datais are present'
do
it
'returns an empty Hash'
do
expect
(
subject
.
parameters
(
mock_request
,
nil
)).
to
eq
({})
end
let
(
:perf_data
)
{
{
redis_calls:
1
}
}
describe
'when no performance data present'
do
it
{
is_expected
.
not_to
include
(
perf_data
)
}
end
describe
'when
Redis calls are
present'
,
:request_store
do
it
'returns a Hash with Redis information'
do
describe
'when
performance data
present'
,
:request_store
do
before
do
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
get
(
'perf-logger-test'
)
}
payload
=
subject
.
parameters
(
mock_request
,
nil
)
expect
(
payload
[
:redis_calls
]).
to
eq
(
1
)
expect
(
payload
[
:redis_duration_s
]).
to
be
>=
0
end
it
{
is_expected
.
to
include
(
perf_data
)
}
end
end
end
spec/lib/gitlab/instrumentation_helper_spec.rb
View file @
5df76410
...
...
@@ -83,6 +83,12 @@ RSpec.describe Gitlab::InstrumentationHelper do
expect
(
payload
).
to
include
(
:cpu_s
)
end
it
'logs the process ID'
do
subject
expect
(
payload
).
to
include
(
:pid
)
end
context
'when logging memory allocations'
do
include
MemoryInstrumentationHelper
...
...
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