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
5614b4da
Commit
5614b4da
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Add presence metrics
parent
e12ec335
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/handlers/presence.py
+8
-0
8 additions, 0 deletions
synapse/handlers/presence.py
synapse/util/wheel_timer.py
+6
-0
6 additions, 0 deletions
synapse/util/wheel_timer.py
with
14 additions
and
0 deletions
synapse/handlers/presence.py
+
8
−
0
View file @
5614b4da
...
@@ -44,6 +44,9 @@ logger = logging.getLogger(__name__)
...
@@ -44,6 +44,9 @@ logger = logging.getLogger(__name__)
metrics
=
synapse
.
metrics
.
get_metrics_for
(
__name__
)
metrics
=
synapse
.
metrics
.
get_metrics_for
(
__name__
)
notified_presence_counter
=
metrics
.
register_counter
(
"
notified_presence
"
)
presence_updates_counter
=
metrics
.
register_counter
(
"
presence_updates
"
)
# If a user was last active in the last LAST_ACTIVE_GRANULARITY, consider them
# If a user was last active in the last LAST_ACTIVE_GRANULARITY, consider them
# "currently_active"
# "currently_active"
...
@@ -170,6 +173,8 @@ class PresenceHandler(BaseHandler):
...
@@ -170,6 +173,8 @@ class PresenceHandler(BaseHandler):
5000
,
5000
,
)
)
metrics
.
register_callback
(
"
wheel_timer_size
"
,
lambda
:
len
(
self
.
wheel_timer
))
@defer.inlineCallbacks
@defer.inlineCallbacks
def
_on_shutdown
(
self
):
def
_on_shutdown
(
self
):
"""
Gets called when shutting down. This lets us persist any updates that
"""
Gets called when shutting down. This lets us persist any updates that
...
@@ -233,7 +238,10 @@ class PresenceHandler(BaseHandler):
...
@@ -233,7 +238,10 @@ class PresenceHandler(BaseHandler):
# TODO: We should probably ensure there are no races hereafter
# TODO: We should probably ensure there are no races hereafter
presence_updates_counter
.
inc_by
(
len
(
new_states
))
if
to_notify
:
if
to_notify
:
notified_presence_counter
.
inc_by
(
len
(
to_notify
))
yield
self
.
_persist_and_notify
(
to_notify
.
values
())
yield
self
.
_persist_and_notify
(
to_notify
.
values
())
self
.
unpersisted_users_changes
|=
set
(
s
.
user_id
for
s
in
new_states
)
self
.
unpersisted_users_changes
|=
set
(
s
.
user_id
for
s
in
new_states
)
...
...
This diff is collapsed.
Click to expand it.
synapse/util/wheel_timer.py
+
6
−
0
View file @
5614b4da
...
@@ -89,3 +89,9 @@ class WheelTimer(object):
...
@@ -89,3 +89,9 @@ class WheelTimer(object):
ret
.
extend
(
self
.
entries
.
pop
(
0
).
queue
)
ret
.
extend
(
self
.
entries
.
pop
(
0
).
queue
)
return
ret
return
ret
def
__len__
(
self
):
l
=
0
for
entry
in
self
.
entries
:
l
+=
len
(
entry
.
queue
)
return
l
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