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 telemetry and logs for liquidation daemon #2122

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 13 additions & 1 deletion protocol/daemons/liquidation/client/grpc_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/telemetry"
"github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/types/query"
Expand Down Expand Up @@ -271,9 +272,20 @@ func (c *Client) SendLiquidatableSubaccountIds(
)...,
)

telemetry.ModuleSetGauge(
metrics.LiquidationDaemon,
float32(len(requests)),
metrics.NumRequests,
metrics.Count,
)

for _, req := range requests {
if _, err := c.LiquidationServiceClient.LiquidateSubaccounts(ctx, req); err != nil {
return err
return errorsmod.Wrapf(
err,
"failed to send liquidatable subaccount ids to protocol at block height %d",
blockHeight,
)
}
}

Expand Down
24 changes: 20 additions & 4 deletions protocol/daemons/liquidation/client/sub_task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,21 @@ func (c *Client) FetchApplicationStateAtBlockHeight(
// Subaccounts
subaccounts, err = c.GetAllSubaccounts(queryCtx, liqFlags.QueryPageLimit)
if err != nil {
return nil, nil, err
return nil, nil, errorsmod.Wrapf(
err,
"failed to fetch subaccounts at block height %d",
blockHeight,
)
}

// Market prices
marketPrices, err := c.GetAllMarketPrices(queryCtx, liqFlags.QueryPageLimit)
if err != nil {
return nil, nil, err
return nil, nil, errorsmod.Wrapf(
err,
"failed to fetch market prices at block height %d",
blockHeight,
)
}
marketPricesMap := lib.UniqueSliceToMap(marketPrices, func(m pricestypes.MarketPrice) uint32 {
return m.Id
Expand All @@ -135,13 +143,21 @@ func (c *Client) FetchApplicationStateAtBlockHeight(
// Perpetuals
perpetuals, err := c.GetAllPerpetuals(queryCtx, liqFlags.QueryPageLimit)
if err != nil {
return nil, nil, err
return nil, nil, errorsmod.Wrapf(
err,
"failed to fetch perpetuals at block height %d",
blockHeight,
)
}

// Liquidity tiers
liquidityTiers, err := c.GetAllLiquidityTiers(queryCtx, liqFlags.QueryPageLimit)
if err != nil {
return nil, nil, err
return nil, nil, errorsmod.Wrapf(
err,
"failed to fetch liquidity tiers at block height %d",
blockHeight,
)
}
liquidityTiersMap := lib.UniqueSliceToMap(liquidityTiers, func(l perptypes.LiquidityTier) uint32 {
return l.Id
Expand Down
1 change: 1 addition & 0 deletions protocol/lib/metrics/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ const (
GetSubaccountsFromKey = "get_subaccounts_from_key"
LiquidatableSubaccountIds = "liquidatable_subaccount_ids"
LiquidationDaemon = "liquidation_daemon"
NumRequests = "num_requests"
NegativeTncSubaccountIds = "negative_tnc_subaccount_ids"
PageLimit = "page_limit"
SendLiquidatableSubaccountIds = "send_liquidatable_subaccount_ids"
Expand Down
Loading