Skip to content

Commit 79bd6e1

Browse files
Centralize logging of the profile exceptions (#5673)
* Introduce a custom retry policy for profiles (which is more Catalyst aware) * NOT_FOUND - to contain the enforced lambdas URL * Clean up local profile-related exceptions * Properly suppress exceptions where they are not expected Signed-off-by: Ashley Canning <[email protected]> Co-authored-by: Ashley Canning <[email protected]>
1 parent fb54b73 commit 79bd6e1

File tree

19 files changed

+112
-51
lines changed

19 files changed

+112
-51
lines changed

Explorer/Assets/DCL/Chat/_Refactor/ChatCommands/CreateChannelViewModelCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DCL.Profiles;
1010
using DCL.UI.ProfileElements;
1111
using DCL.UI.Profiles.Helpers;
12+
using DCL.Utilities.Extensions;
1213
using DCL.VoiceChat;
1314
using System;
1415
using System.Threading;
@@ -126,7 +127,7 @@ private async UniTaskVoid FetchCommunityThumbnailAndUpdateAsync(CommunityChannel
126127

127128
private async UniTaskVoid FetchProfileAndUpdateAsync(UserChannelViewModel viewModel, CancellationToken ct)
128129
{
129-
Profile? profile = await profileRepository.GetProfileAsync(viewModel.Id.Id, ct);
130+
Profile? profile = await profileRepository.GetProfileAsync(viewModel.Id.Id, ct).SuppressAnyExceptionWithFallback(null);
130131

131132
if (ct.IsCancellationRequested) return;
132133

Explorer/Assets/DCL/Friends/UI/FriendPanel/Sections/Friends/FriendListRequestManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using DCL.Diagnostics;
33
using DCL.Profiles;
44
using DCL.UI.Profiles.Helpers;
5+
using DCL.Utilities.Extensions;
56
using SuperScrollView;
67
using System;
78
using System.Collections.Generic;

Explorer/Assets/DCL/Infrastructure/MVC/MVCFacade/MVCManagerMenusAccessFacade.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public async UniTask ShowChatEntryMenuPopupAsync(ChatEntryMenuPopupData data, Ca
107107
public async UniTask ShowUserProfileContextMenuFromWalletIdAsync(Web3Address walletId, Vector3 position, Vector2 offset, CancellationToken ct, UniTask closeMenuTask,
108108
Action onHide = null, MenuAnchorPoint anchorPoint = MenuAnchorPoint.DEFAULT, Action onShow = null)
109109
{
110-
Profile profile = await profileRepository.GetAsync(walletId, ct);
110+
Profile? profile = await profileRepository.GetAsync(walletId, ct);
111111

112112
if (profile == null)
113113
return;
@@ -120,7 +120,7 @@ public async UniTask ShowCommunityPlayerEntryContextMenuAsync(string participant
120120
if (string.IsNullOrEmpty(participantWalletId)) return;
121121

122122
Web3Address walletId = new Web3Address(participantWalletId);
123-
Profile profile = await profileRepository.GetAsync(walletId, ct);
123+
Profile? profile = await profileRepository.GetAsync(walletId, ct);
124124

125125
if (profile == null) return;
126126

Explorer/Assets/DCL/Multiplayer/Profiles/RemoteProfiles/RemoteProfiles.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,27 +104,17 @@ private async UniTaskVoid TryDownloadAsync(RemoteAnnouncement remoteAnnouncement
104104
Profile? profile = await profileRepository.GetAsync(remoteAnnouncement.WalletId, remoteAnnouncement.Version, lambdasEndpoint, cts.Token);
105105

106106
if (profile is null)
107-
{
108-
ReportHub.LogError(ReportCategory.PROFILE, $"Profile not found {remoteAnnouncement} after {(DateTime.Now - startedAt).TotalSeconds} s.");
109107
return;
110-
}
111108

112109
// Take the room source from the dictionary as the value could be updated
113110
remoteProfiles.Add(new RemoteProfile(profile, remoteAnnouncement.WalletId, pendingProfiles[remoteAnnouncement.WalletId].FromRoom));
114111

115112
ReportHub.Log(ReportCategory.PROFILE,
116113
$"{remoteAnnouncement} was downloaded for {(DateTime.Now - startedAt).TotalSeconds} s.");
117114
}
118-
catch (OperationCanceledException)
119-
{
120-
// ignore cancellation
121-
}
122115
catch (Exception)
123116
{
124-
ReportHub.Log(ReportCategory.PROFILE,
125-
$"{remoteAnnouncement} threw an exception after {(DateTime.Now - startedAt).TotalSeconds} s.");
126-
127-
throw;
117+
// exceptions are logged by the remote repository
128118
}
129119
finally
130120
{

Explorer/Assets/DCL/Notifications/NotificationsMenu/NotificationsMenuController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using DCL.UI.SharedSpaceManager;
1111
using DCL.UI.Utilities;
1212
using DCL.Utilities;
13+
using DCL.Utilities.Extensions;
1314
using DCL.Web3.Identities;
1415
using DCL.WebRequests;
1516
using MVC;
@@ -267,7 +268,7 @@ private void ClickedNotification(NotificationType notificationType, INotificatio
267268
NotificationsBusController.Instance.ClickNotification(notificationType, notification);
268269
}
269270

270-
private async UniTask LoadNotificationThumbnailAsync(INotificationView notificationImage, INotification notificationData,
271+
private async UniTaskVoid LoadNotificationThumbnailAsync(INotificationView notificationImage, INotification notificationData,
271272
DefaultNotificationThumbnail defaultThumbnail, CancellationToken ct)
272273
{
273274
if (notificationData.Type == NotificationType.REFERRAL_INVITED_USERS_ACCEPTED)
@@ -315,7 +316,7 @@ private async UniTask LoadNotificationThumbnailAsync(INotificationView notificat
315316

316317
async UniTask<Sprite?> DownloadProfileThumbnailAsync(string user)
317318
{
318-
Profile? profile = await profileRepository.GetProfileAsync(user, ct);
319+
Profile? profile = await profileRepository.GetProfileAsync(user, ct).SuppressAnyExceptionWithFallback(null);
319320

320321
if (profile != null)
321322
return await profileRepository.GetProfileThumbnailAsync(profile.Avatar.FaceSnapshotUrl, ct);

Explorer/Assets/DCL/Passport/Modules/EquippedItems_PassportModuleController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ CancellationToken ct
264264
{
265265
const string ERROR_MESSAGE = "There was an error while trying to load the equipped items. Please try again!";
266266
passportErrorsController.Show(ERROR_MESSAGE);
267-
ReportHub.LogError(ReportCategory.PROFILE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
267+
ReportHub.LogError(ReportCategory.WEARABLE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
268268
}
269269
}
270270

@@ -281,7 +281,7 @@ private async UniTaskVoid WaitForThumbnailAsync(IWearable itemWearable, Equipped
281281
itemView.EquippedItemThumbnail.sprite = null;
282282
const string ERROR_MESSAGE = "There was an error while trying to load wearable thumbnails. Please try again!";
283283
passportErrorsController.Show(ERROR_MESSAGE);
284-
ReportHub.LogError(ReportCategory.PROFILE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
284+
ReportHub.LogError(ReportCategory.WEARABLE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
285285
}
286286
}
287287

@@ -298,7 +298,7 @@ private async UniTaskVoid WaitForThumbnailAsync(IEmote itemEmote, EquippedItem_P
298298
itemView.EquippedItemThumbnail.sprite = null;
299299
const string ERROR_MESSAGE = "There was an error while trying to load emote thumbnails. Please try again!";
300300
passportErrorsController.Show(ERROR_MESSAGE);
301-
ReportHub.LogError(ReportCategory.PROFILE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
301+
ReportHub.LogError(ReportCategory.WEARABLE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
302302
}
303303
}
304304

Explorer/Assets/DCL/Passport/PassportController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,10 @@ private async UniTaskVoid LoadPassportSectionAsync(string userId, PassportSectio
567567
alreadyLoadedSections |= sectionToLoad;
568568
}
569569
catch (OperationCanceledException) { }
570-
catch (Exception e)
570+
catch (Exception)
571571
{
572572
const string ERROR_MESSAGE = "There was an error while opening the Passport. Please try again!";
573573
passportErrorsController!.Show(ERROR_MESSAGE);
574-
ReportHub.LogError(ReportCategory.PROFILE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
575574
}
576575
}
577576

@@ -729,7 +728,7 @@ private async UniTaskVoid OpenPassportFromBadgeNotificationAsync(string badgeIdT
729728
{
730729
const string ERROR_MESSAGE = "There was an error while opening the Badges section into the Passport. Please try again!";
731730
passportErrorsController!.Show(ERROR_MESSAGE);
732-
ReportHub.LogError(ReportCategory.PROFILE, $"{ERROR_MESSAGE} ERROR: {e.Message}");
731+
ReportHub.LogException(e, ReportCategory.PROFILE);
733732
}
734733
}
735734

Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/StaticDebouncer.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,25 @@ public partial class StaticDebouncer : IReportsDebouncer
1111
{
1212
private readonly HashSet<ReportMessageFingerprint> fingerprints = new ();
1313

14-
public ReportHandler AppliedTo => ReportHandler.All;
14+
public StaticDebouncer() : this(ReportHandler.All) { }
15+
16+
internal StaticDebouncer(ReportHandler appliedTo)
17+
{
18+
AppliedTo = appliedTo;
19+
}
20+
21+
public ReportHandler AppliedTo { get; }
1522

1623
public bool Debounce(ReportMessageFingerprint fingerprint) =>
1724
!fingerprints.Add(fingerprint);
1825
}
26+
27+
/// <summary>
28+
/// <inheritdoc cref="StaticDebouncer" />. Applies only to Sentry reports.
29+
/// </summary>
30+
[Singleton(SingletonGenerationBehavior.ALLOW_IMPLICIT_CONSTRUCTION)]
31+
public partial class SentryStaticDebouncer : StaticDebouncer
32+
{
33+
public SentryStaticDebouncer() : base(ReportHandler.Sentry) { }
34+
}
1935
}

Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportsHandlingSettingsProduction.asset

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ MonoBehaviour:
394394
Severity: 0
395395
- Category: DEBUG
396396
Severity: 0
397+
- Category: PROFILE
398+
Severity: 0
397399
sentryMatrix:
398400
entries:
399401
- Category: AUDIO_SOURCES
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using DCL.WebRequests;
2+
3+
namespace DCL.Profiles
4+
{
5+
/// <summary>
6+
/// Catalysts are prone to huge replication delays.
7+
/// This special non-strict policy allows more retry attempts with bigger delays between them.
8+
/// </summary>
9+
public static class CatalystRetryPolicy
10+
{
11+
/// <summary>
12+
/// k=1 → 2000 × 2^0 = 2000 ms (2.00 s) <br />
13+
/// k=2 → 2000 × 2^1 = 4000 ms (4.00 s) <br />
14+
/// k=3 → 2000 × 2^2 = 8000 ms (8.00 s) <br />
15+
/// k=4 → 2000 × 2^3 = 16000 ms (16.00 s) <br />
16+
/// k=5 → 2000 × 2^4 = 32000 ms (32.00 s) <br />
17+
/// k=6 → 2000 × 2^5 = 64000 ms → capped at 60000 ms (60.00 s) <br />
18+
/// Total wait time ≈ 122 s (~2.0 minutes)
19+
/// </summary>
20+
public static readonly RetryPolicy VALUE = RetryPolicy.Enforce(6, 2000, 2);
21+
}
22+
}

0 commit comments

Comments
 (0)