diff --git a/utils/metrics/metrics_util.go b/utils/metrics/metrics_util.go index 6a2a4ff8af..a342878306 100644 --- a/utils/metrics/metrics_util.go +++ b/utils/metrics/metrics_util.go @@ -130,3 +130,11 @@ func SetOracleVotePenaltyCount(count uint64, valAddr string, penaltyType string) }, ) } + +// sei_epoch_new +func SetEpochNew(epochNum uint64) { + metrics.SetGauge( + []string{"sei", "epoch", "new"}, + float32(epochNum), + ) +} diff --git a/x/epoch/module.go b/x/epoch/module.go index 58792d39d7..9cc0b0944b 100644 --- a/x/epoch/module.go +++ b/x/epoch/module.go @@ -17,6 +17,7 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/sei-protocol/sei-chain/utils/metrics" "github.com/sei-protocol/sei-chain/x/epoch/client/cli" "github.com/sei-protocol/sei-chain/x/epoch/keeper" "github.com/sei-protocol/sei-chain/x/epoch/types" @@ -183,6 +184,14 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { } am.keeper.SetEpoch(ctx, newEpoch) am.keeper.BeforeEpochStart(ctx, newEpoch) + ctx.EventManager().EmitEvent( + sdk.NewEvent(types.EventTypeNewEpoch, + sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprint(newEpoch.CurrentEpoch)), + sdk.NewAttribute(types.AttributeEpochTime, newEpoch.CurrentEpochStartTime.String()), + sdk.NewAttribute(types.AttributeEpochHeight, fmt.Sprint(newEpoch.CurrentEpochHeight)), + ), + ) + metrics.SetEpochNew(newEpoch.CurrentEpoch) } } diff --git a/x/epoch/types/events.go b/x/epoch/types/events.go new file mode 100644 index 0000000000..ee2adb9b0c --- /dev/null +++ b/x/epoch/types/events.go @@ -0,0 +1,9 @@ +package types + +const ( + EventTypeNewEpoch = "new_epoch" + + AttributeEpochNumber = "epoch_number" + AttributeEpochTime = "epoch_time" + AttributeEpochHeight = "epoch_height" +)