Skip to content

Commit 87d33ea

Browse files
committed
feat:update metrics
1 parent 39d4997 commit 87d33ea

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/AElfScanServer.Worker.Core/Service/TokenTransferMonitoringService.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,28 @@ public void SendTransferMetrics(TransferEventDto transfer)
331331
};
332332

333333
// Always record counter (for all transfers)
334-
_transferCountsCounter.Add(1, outboundTags);
335-
_transferCountsCounter.Add(1, inboundTags);
336-
334+
335+
if (!transfer.FromAddress.IsNullOrEmpty())
336+
{
337+
_transferCountsCounter.Add(1, outboundTags);
338+
}
339+
340+
if (!transfer.ToAddress.IsNullOrEmpty())
341+
{
342+
_transferCountsCounter.Add(1, inboundTags);
343+
}
337344
// Only record histogram for high-value transfers
338345
if (isHighValue)
339346
{
340-
_transferUSDEventsHistogram.Record((double)transfer.UsdValue, outboundTags);
341-
_transferUSDEventsHistogram.Record((double)transfer.UsdValue, inboundTags);
347+
if (!transfer.FromAddress.IsNullOrEmpty())
348+
{
349+
_transferUSDEventsHistogram.Record((double)transfer.UsdValue, outboundTags);
350+
}
351+
352+
if (!transfer.ToAddress.IsNullOrEmpty())
353+
{
354+
_transferUSDEventsHistogram.Record((double)transfer.UsdValue, inboundTags);
355+
}
342356
_logger.LogInformation("Sent transfer metrics for transaction {TransactionId}, amount {Amount} {Symbol}, USD value {UsdValue}",
343357
transfer.TransactionId, transfer.Amount, transfer.Symbol, transfer.UsdValue);
344358
}

0 commit comments

Comments
 (0)