Skip to content

Commit

Permalink
Record listing count 20% of the time because that's a hot path (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
karashiiro authored Jul 26, 2024
1 parent c9fa7a6 commit 212d88e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Universalis.DbAccess/MarketBoard/ListingStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ ORDER BY unit_price
// Cache the result temporarily
await StoreListingsInCache(query.WorldId, query.ItemId, listings, cancellationToken);

RowsReadCount.Observe(listings.Count);
if (Random.Shared.NextDouble() < 0.2)
{
// Record metric 20% of the time because this is a hot path
RowsReadCount.Observe(listings.Count);
}

return listings;
}
catch (Exception e)
Expand Down Expand Up @@ -347,7 +352,12 @@ FROM listing t
kvp => kvp.Value);
await StoreListingsInCacheMulti(toCache, cancellationToken);

RowsReadCount.Observe(result.Count - cacheValues.Count);
if (Random.Shared.NextDouble() < 0.2)
{
// Record metric 20% of the time because this is a hot path
RowsReadCount.Observe(result.Count - cacheValues.Count);
}

return result;
}
catch (Exception e)
Expand Down

0 comments on commit 212d88e

Please sign in to comment.