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

Commit b31daac

Browse files
Add metrics to track how often events are soft_failed (#10156)
Spawned from missing messages we were seeing on `matrix.org` from a federated Gtiter bridged room, https://gitlab.com/gitterHQ/webapp/-/issues/2770. The underlying issue in Synapse is tracked by #10066 where the message and join event race and the message is `soft_failed` before the `join` event reaches the remote federated server. Less soft_failed events = better and usually this should only trigger for events where people are doing bad things and trying to fuzz and fake everything.
1 parent e21c347 commit b31daac

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

changelog.d/10156.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `synapse_federation_soft_failed_events_total` metric to track how often events are soft failed.

synapse/handlers/federation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
)
3434

3535
import attr
36+
from prometheus_client import Counter
3637
from signedjson.key import decode_verify_key_bytes
3738
from signedjson.sign import verify_signed_json
3839
from unpaddedbase64 import decode_base64
@@ -101,6 +102,11 @@
101102

102103
logger = logging.getLogger(__name__)
103104

105+
soft_failed_event_counter = Counter(
106+
"synapse_federation_soft_failed_events_total",
107+
"Events received over federation that we marked as soft_failed",
108+
)
109+
104110

105111
@attr.s(slots=True)
106112
class _NewEventInfo:
@@ -2498,6 +2504,7 @@ async def _check_for_soft_fail(
24982504
event_auth.check(room_version_obj, event, auth_events=current_auth_events)
24992505
except AuthError as e:
25002506
logger.warning("Soft-failing %r because %s", event, e)
2507+
soft_failed_event_counter.inc()
25012508
event.internal_metadata.soft_failed = True
25022509

25032510
async def on_get_missing_events(

0 commit comments

Comments
 (0)