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

Commit

Permalink
Add metrics for how often events are soft_failed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MadLittleMods committed Jun 9, 2021
1 parent aec2cf1 commit 1d6b946
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)

import attr
from prometheus_client import Counter
from signedjson.key import decode_verify_key_bytes
from signedjson.sign import verify_signed_json
from unpaddedbase64 import decode_base64
Expand Down Expand Up @@ -101,6 +102,8 @@

logger = logging.getLogger(__name__)

soft_failed_event_counter = Counter("synapse_handlers_federation_soft_failed_event", "")


@attr.s(slots=True)
class _NewEventInfo:
Expand Down Expand Up @@ -2498,6 +2501,7 @@ async def _check_for_soft_fail(
event_auth.check(room_version_obj, event, auth_events=current_auth_events)
except AuthError as e:
logger.warning("Soft-failing %r because %s", event, e)
soft_failed_event_counter.inc()
event.internal_metadata.soft_failed = True

async def on_get_missing_events(
Expand Down

0 comments on commit 1d6b946

Please sign in to comment.