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

feat: adding metrics to provide insights about the module #78

Merged
merged 8 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/tendermint/budget
go 1.16

require (
github.com/armon/go-metrics v0.3.9
github.com/cosmos/cosmos-sdk v0.44.2
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
Expand Down
21 changes: 21 additions & 0 deletions x/budget/keeper/budget.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package keeper

import (
"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

Expand Down Expand Up @@ -52,6 +55,24 @@ func (k Keeper) CollectBudgets(ctx sdk.Context) error {
}
for i, budget := range budgetsBySource.Budgets {
k.AddTotalCollectedCoins(ctx, budget.Name, budgetsBySource.CollectionCoins[i])

defer func() {
for _, collectionCoins := range budgetsBySource.CollectionCoins {
for _, coin := range collectionCoins {
if coin.Amount.IsInt64() {
telemetry.SetGaugeWithLabels(
[]string{types.ModuleName},
float32(coin.Amount.Int64()),
[]metrics.Label{
telemetry.NewLabel("collection_address", budget.CollectionAddress),
telemetry.NewLabel("denom", coin.Denom),
},
)
}
}
}
}()

jaybxyz marked this conversation as resolved.
Show resolved Hide resolved
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeBudgetCollected,
Expand Down