diff --git a/osu.Server.Spectator/Hubs/ScoreUploader.cs b/osu.Server.Spectator/Hubs/ScoreUploader.cs index 5a4d93df..8d4b306f 100644 --- a/osu.Server.Spectator/Hubs/ScoreUploader.cs +++ b/osu.Server.Spectator/Hubs/ScoreUploader.cs @@ -11,6 +11,7 @@ using osu.Server.Spectator.Database.Models; using osu.Server.Spectator.Entities; using osu.Server.Spectator.Storage; +using StatsdClient; namespace osu.Server.Spectator.Hubs { @@ -27,6 +28,8 @@ public class ScoreUploader : IEntityStore, IDisposable /// public double TimeoutInterval = 30000; + private const string statsd_prefix = "score_uploads"; + private readonly ConcurrentQueue queue = new ConcurrentQueue(); private readonly IDatabaseFactory databaseFactory; private readonly IScoreStorage scoreStorage; @@ -91,6 +94,7 @@ public async Task Flush() using (var db = databaseFactory.GetInstance()) { int countToTry = queue.Count; + DogStatsd.Gauge($"{statsd_prefix}.total_in_queue", countToTry); for (int i = 0; i < countToTry; i++) { @@ -111,6 +115,7 @@ public async Task Flush() if (dbScore == null) { logger.LogError("Score upload timed out for token: {tokenId}", item.Token); + DogStatsd.Increment($"{statsd_prefix}.timed_out"); return; } @@ -122,6 +127,7 @@ public async Task Flush() await scoreStorage.WriteAsync(item.Score); await db.MarkScoreHasReplay(item.Score); + DogStatsd.Increment($"{statsd_prefix}.uploaded"); } finally { @@ -134,6 +140,7 @@ public async Task Flush() catch (Exception e) { logger.LogError(e, "Error during score upload"); + DogStatsd.Increment($"{statsd_prefix}.failed"); } }