Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend logging for outgoing pushes #334

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/334.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extend logging for outgoing pushes.
27 changes: 18 additions & 9 deletions sygnal/apnspushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,11 @@ async def _dispatch_request(
device: Device,
shaved_payload: Dict[str, Any],
prio: int,
notif_id: str,
) -> List[str]:
"""
Actually attempts to dispatch the notification once.
"""

# this is no good: APNs expects ID to be in their format
# so we can't just derive a
# notif_id = context.request_id + f"-{n.devices.index(device)}"

notif_id = str(uuid4())

log.info(f"Sending as APNs-ID {notif_id}")
span.set_tag("apns_id", notif_id)

device_token = base64.b64decode(device.pushkey).hex()
Expand Down Expand Up @@ -344,8 +337,24 @@ async def _dispatch_notification_unlimited(
"apns_dispatch_try", tags=span_tags, child_of=span_parent
) as span:
assert shaved_payload is not None

# this is no good: APNs expects ID to be in their format
# so we can't just derive a
# notif_id = context.request_id + f"-{n.devices.index(device)}"
notif_id = str(uuid4())
# XXX: shouldn't we use the same notif_id for each retry?

log.info(
"Sending (attempt %i) => %s APNs-ID:%s room:%s, event:%s",
retry_number,
notif_id,
device.pushkey,
n.room_id,
n.event_id,
)

return await self._dispatch_request(
log, span, device, shaved_payload, prio
log, span, device, shaved_payload, prio, notif_id
)
except TemporaryNotificationDispatchException as exc:
retry_delay = self.RETRY_DELAY_BASE * (2**retry_number)
Expand Down
2 changes: 1 addition & 1 deletion sygnal/gcmpushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ async def _dispatch_notification_unlimited(
else:
body["registration_ids"] = pushkeys

log.info("Sending (attempt %i) => %r", retry_number, pushkeys)
log.info("Sending (attempt %i) => %r room:%s, event:%s", retry_number, pushkeys, n.room_id, n.event_id)

try:
span_tags = {"retry_num": retry_number}
Expand Down