mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Fix observable counters
This commit is contained in:
parent
7023040882
commit
17c4ec6790
2 changed files with 17 additions and 17 deletions
|
@ -249,33 +249,33 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IDisposable, IOfficialG
|
||||||
);
|
);
|
||||||
|
|
||||||
Meter.CreateObservableCounter(
|
Meter.CreateObservableCounter(
|
||||||
$"{MetricNamePrefix}_bot_trades", () => TradeStatistics.SelectMany<KeyValuePair<Bot, TradeStatistics>, Measurement<uint>>(
|
$"{MetricNamePrefix}_bot_trades", () => TradeStatistics.SelectMany<KeyValuePair<Bot, TradeStatistics>, Measurement<int>>(
|
||||||
static kv => [
|
static kv => [
|
||||||
new Measurement<uint>(
|
new Measurement<int>(
|
||||||
kv.Value.AcceptedOffers,
|
kv.Value.AcceptedOffers,
|
||||||
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
||||||
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
||||||
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "accepted")
|
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "accepted")
|
||||||
),
|
),
|
||||||
new Measurement<uint>(
|
new Measurement<int>(
|
||||||
kv.Value.RejectedOffers,
|
kv.Value.RejectedOffers,
|
||||||
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
||||||
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
||||||
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "rejected")
|
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "rejected")
|
||||||
),
|
),
|
||||||
new Measurement<uint>(
|
new Measurement<int>(
|
||||||
kv.Value.IgnoredOffers,
|
kv.Value.IgnoredOffers,
|
||||||
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
||||||
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
||||||
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "ignored")
|
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "ignored")
|
||||||
),
|
),
|
||||||
new Measurement<uint>(
|
new Measurement<int>(
|
||||||
kv.Value.BlacklistedOffers,
|
kv.Value.BlacklistedOffers,
|
||||||
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
||||||
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
||||||
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "blacklisted")
|
new KeyValuePair<string, object?>(TagNames.TradeOfferResult, "blacklisted")
|
||||||
),
|
),
|
||||||
new Measurement<uint>(
|
new Measurement<int>(
|
||||||
kv.Value.ConfirmedOffers,
|
kv.Value.ConfirmedOffers,
|
||||||
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName),
|
||||||
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID),
|
||||||
|
@ -287,12 +287,12 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IDisposable, IOfficialG
|
||||||
);
|
);
|
||||||
|
|
||||||
Meter.CreateObservableCounter(
|
Meter.CreateObservableCounter(
|
||||||
$"{MetricNamePrefix}_bot_items_given", () => TradeStatistics.Select(static kv => new Measurement<uint>(kv.Value.ItemsGiven, new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID))),
|
$"{MetricNamePrefix}_bot_items_given", () => TradeStatistics.Select(static kv => new Measurement<int>(kv.Value.ItemsGiven, new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID))),
|
||||||
description: "Items given per bot"
|
description: "Items given per bot"
|
||||||
);
|
);
|
||||||
|
|
||||||
Meter.CreateObservableCounter(
|
Meter.CreateObservableCounter(
|
||||||
$"{MetricNamePrefix}_bot_items_received", () => TradeStatistics.Select(static kv => new Measurement<uint>(kv.Value.ItemsReceived, new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID))),
|
$"{MetricNamePrefix}_bot_items_received", () => TradeStatistics.Select(static kv => new Measurement<int>(kv.Value.ItemsReceived, new KeyValuePair<string, object?>(TagNames.BotName, kv.Key.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, kv.Key.SteamID))),
|
||||||
description: "Items received per bot"
|
description: "Items received per bot"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,13 @@ namespace ArchiSteamFarm.OfficialPlugins.Monitoring;
|
||||||
internal sealed class TradeStatistics {
|
internal sealed class TradeStatistics {
|
||||||
private readonly object Lock = new();
|
private readonly object Lock = new();
|
||||||
|
|
||||||
internal uint AcceptedOffers { get; private set; }
|
internal int AcceptedOffers { get; private set; }
|
||||||
internal uint BlacklistedOffers { get; private set; }
|
internal int BlacklistedOffers { get; private set; }
|
||||||
internal uint ConfirmedOffers { get; private set; }
|
internal int ConfirmedOffers { get; private set; }
|
||||||
internal uint IgnoredOffers { get; private set; }
|
internal int IgnoredOffers { get; private set; }
|
||||||
internal uint ItemsGiven { get; private set; }
|
internal int ItemsGiven { get; private set; }
|
||||||
internal uint ItemsReceived { get; private set; }
|
internal int ItemsReceived { get; private set; }
|
||||||
internal uint RejectedOffers { get; private set; }
|
internal int RejectedOffers { get; private set; }
|
||||||
|
|
||||||
internal void Include(ParseTradeResult result) {
|
internal void Include(ParseTradeResult result) {
|
||||||
ArgumentNullException.ThrowIfNull(result);
|
ArgumentNullException.ThrowIfNull(result);
|
||||||
|
@ -45,8 +45,8 @@ internal sealed class TradeStatistics {
|
||||||
case ParseTradeResult.EResult.Accepted when result.Confirmed:
|
case ParseTradeResult.EResult.Accepted when result.Confirmed:
|
||||||
ConfirmedOffers++;
|
ConfirmedOffers++;
|
||||||
|
|
||||||
ItemsGiven += (uint) (result.ItemsToGive?.Count ?? 0);
|
ItemsGiven += result.ItemsToGive?.Count ?? 0;
|
||||||
ItemsReceived += (uint) (result.ItemsToReceive?.Count ?? 0);
|
ItemsReceived += result.ItemsToReceive?.Count ?? 0;
|
||||||
|
|
||||||
goto case ParseTradeResult.EResult.Accepted;
|
goto case ParseTradeResult.EResult.Accepted;
|
||||||
case ParseTradeResult.EResult.Accepted:
|
case ParseTradeResult.EResult.Accepted:
|
||||||
|
|
Loading…
Reference in a new issue