Skip to content

Commit

Permalink
Merge pull request #218 from bdach/score-uploader-ddog-tracking
Browse files Browse the repository at this point in the history
Add datadog tracking of score uploader metrics
  • Loading branch information
peppy authored Feb 6, 2024
2 parents ad93d3a + 765a4ec commit 6194c54
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions osu.Server.Spectator/Hubs/ScoreUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -27,6 +28,8 @@ public class ScoreUploader : IEntityStore, IDisposable
/// </summary>
public double TimeoutInterval = 30000;

private const string statsd_prefix = "score_uploads";

private readonly ConcurrentQueue<UploadItem> queue = new ConcurrentQueue<UploadItem>();
private readonly IDatabaseFactory databaseFactory;
private readonly IScoreStorage scoreStorage;
Expand Down Expand Up @@ -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++)
{
Expand All @@ -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;
}

Expand All @@ -122,6 +127,7 @@ public async Task Flush()

await scoreStorage.WriteAsync(item.Score);
await db.MarkScoreHasReplay(item.Score);
DogStatsd.Increment($"{statsd_prefix}.uploaded");
}
finally
{
Expand All @@ -134,6 +140,7 @@ public async Task Flush()
catch (Exception e)
{
logger.LogError(e, "Error during score upload");
DogStatsd.Increment($"{statsd_prefix}.failed");
}
}

Expand Down

0 comments on commit 6194c54

Please sign in to comment.