Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
5583e295
Commit
5583e295
authored
9 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Report process open filehandles in metrics
parent
813e54bd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/metrics/__init__.py
+34
-0
34 additions, 0 deletions
synapse/metrics/__init__.py
with
34 additions
and
0 deletions
synapse/metrics/__init__.py
+
34
−
0
View file @
5583e295
...
...
@@ -18,6 +18,8 @@ from __future__ import absolute_import
import
logging
from
resource
import
getrusage
,
getpagesize
,
RUSAGE_SELF
import
os
import
stat
from
.metric
import
(
CounterMetric
,
CallbackMetric
,
DistributionMetric
,
CacheMetric
...
...
@@ -109,3 +111,35 @@ resource_metrics.register_callback("stime", lambda: rusage.ru_stime * 1000)
# pages
resource_metrics
.
register_callback
(
"
maxrss
"
,
lambda
:
rusage
.
ru_maxrss
*
PAGE_SIZE
)
TYPES
=
{
stat
.
S_IFSOCK
:
"
SOCK
"
,
stat
.
S_IFLNK
:
"
LNK
"
,
stat
.
S_IFREG
:
"
REG
"
,
stat
.
S_IFBLK
:
"
BLK
"
,
stat
.
S_IFDIR
:
"
DIR
"
,
stat
.
S_IFCHR
:
"
CHR
"
,
stat
.
S_IFIFO
:
"
FIFO
"
,
}
def
_process_fds
():
counts
=
{(
k
,):
0
for
k
in
TYPES
.
values
()}
counts
[(
"
other
"
,)]
=
0
for
fd
in
os
.
listdir
(
"
/proc/self/fd
"
):
try
:
s
=
os
.
stat
(
"
/proc/self/fd/%s
"
%
(
fd
))
fmt
=
stat
.
S_IFMT
(
s
.
st_mode
)
if
fmt
in
TYPES
:
t
=
TYPES
[
fmt
]
else
:
t
=
"
other
"
counts
[(
t
,)]
+=
1
except
OSError
:
# the dirh itself used by listdir() is usually missing by now
pass
return
counts
get_metrics_for
(
"
process
"
).
register_callback
(
"
fds
"
,
_process_fds
,
labels
=
[
"
type
"
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment