Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3664 from matrix-org/rav/federation_metrics
Browse files Browse the repository at this point in the history
more metrics for the federation and appservice senders
  • Loading branch information
richvdh authored Aug 8, 2018
2 parents 8521ae1 + e6d73b8 commit bb89c84
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/3664.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add some metrics for the appservice and federation event sending loops
10 changes: 9 additions & 1 deletion synapse/federation/transaction_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from synapse.handlers.presence import format_user_presence_state, get_interested_remotes
from synapse.metrics import (
LaterGauge,
event_processing_loop_counter,
event_processing_loop_room_count,
events_processed_counter,
sent_edus_counter,
sent_transactions_counter,
Expand Down Expand Up @@ -253,7 +255,13 @@ def handle_room_events(events):
synapse.metrics.event_processing_last_ts.labels(
"federation_sender").set(ts)

events_processed_counter.inc(len(events))
events_processed_counter.inc(len(events))

event_processing_loop_room_count.labels(
"federation_sender"
).inc(len(events_by_room))

event_processing_loop_counter.labels("federation_sender").inc()

synapse.metrics.event_processing_positions.labels(
"federation_sender").set(next_token)
Expand Down
10 changes: 10 additions & 0 deletions synapse/handlers/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

import synapse
from synapse.api.constants import EventTypes
from synapse.metrics import (
event_processing_loop_counter,
event_processing_loop_room_count,
)
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.util.logcontext import make_deferred_yieldable, run_in_background
from synapse.util.metrics import Measure
Expand Down Expand Up @@ -136,6 +140,12 @@ def handle_room_events(events):

events_processed_counter.inc(len(events))

event_processing_loop_room_count.labels(
"appservice_sender"
).inc(len(events_by_room))

event_processing_loop_counter.labels("appservice_sender").inc()

synapse.metrics.event_processing_lag.labels(
"appservice_sender").set(now - ts)
synapse.metrics.event_processing_last_ts.labels(
Expand Down
13 changes: 13 additions & 0 deletions synapse/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ def collect(self):

events_processed_counter = Counter("synapse_federation_client_events_processed", "")

event_processing_loop_counter = Counter(
"synapse_event_processing_loop_count",
"Event processing loop iterations",
["name"],
)

event_processing_loop_room_count = Counter(
"synapse_event_processing_loop_room_count",
"Rooms seen per event processing loop iteration",
["name"],
)


# Used to track where various components have processed in the event stream,
# e.g. federation sending, appservice sending, etc.
event_processing_positions = Gauge("synapse_event_processing_positions", "", ["name"])
Expand Down

0 comments on commit bb89c84

Please sign in to comment.