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

Add datadog tracking of score uploader metrics #218

Merged
merged 1 commit into from
Feb 6, 2024
Merged
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
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
Loading