Skip to content

Commit 90aaa2a

Browse files
committed
Record an action in AML metrics
1 parent 5078a07 commit 90aaa2a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pkg/code/aml/guard.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ func (g *Guard) AllowMoneyMovement(ctx context.Context, intentRecord *intent.Rec
4646
var nativeAmount float64
4747
var usdMarketValue float64
4848
var consumptionCalculator func(ctx context.Context, owner string, since time.Time) (uint64, float64, error)
49+
var action string
4950
switch intentRecord.IntentType {
5051
case intent.SendPublicPayment:
5152
// Public sends are subject to limits
5253
currency = intentRecord.SendPublicPaymentMetadata.ExchangeCurrency
5354
nativeAmount = intentRecord.SendPublicPaymentMetadata.NativeAmount
5455
usdMarketValue = intentRecord.SendPublicPaymentMetadata.UsdMarketValue
5556
consumptionCalculator = g.data.GetTransactedAmountForAntiMoneyLaundering
57+
action = actionSendPayment
5658
case intent.ReceivePaymentsPublicly:
5759
// Public receives are always allowed
5860
return true, nil
@@ -73,13 +75,13 @@ func (g *Guard) AllowMoneyMovement(ctx context.Context, intentRecord *intent.Rec
7375
sendLimit, ok := limit.SendLimits[currency]
7476
if !ok {
7577
log.Info("denying intent with unsupported currency")
76-
recordDenialEvent(ctx, "unsupported currency")
78+
recordDenialEvent(ctx, action, "unsupported currency")
7779
return false, nil
7880
}
7981

8082
if nativeAmount > sendLimit.PerTransaction {
8183
log.Info("denying intent that exceeds per-transaction value")
82-
recordDenialEvent(ctx, "exceeds per-transaction value")
84+
recordDenialEvent(ctx, action, "exceeds per-transaction value")
8385
return false, nil
8486
}
8587

@@ -93,7 +95,7 @@ func (g *Guard) AllowMoneyMovement(ctx context.Context, intentRecord *intent.Rec
9395

9496
if usdInLastDay+usdMarketValue > maxDailyUsdLimit {
9597
log.Info("denying intent that exceeds daily usd limit")
96-
recordDenialEvent(ctx, "exceeds daily usd value")
98+
recordDenialEvent(ctx, action, "exceeds daily usd value")
9799
return false, nil
98100
}
99101

pkg/code/aml/metrics.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ const (
1010
metricsStructName = "aml.guard"
1111

1212
eventName = "AntiMoneyLaunderingGuardDenial"
13+
14+
actionSendPayment = "SendPayment"
1315
)
1416

15-
func recordDenialEvent(ctx context.Context, reason string) {
17+
func recordDenialEvent(ctx context.Context, action, reason string) {
1618
kvPairs := map[string]interface{}{
19+
"action": action,
1720
"reason": reason,
1821
"count": 1,
1922
}

0 commit comments

Comments
 (0)