Skip to content

Commit

Permalink
feat: emit more data in prom metrics, fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
dhanusaputra committed Apr 6, 2023
1 parent 1e0b15e commit fd2353a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func startStandAlone(svrCtx *Context, appCreator types.AppCreator) error {
return err
}

emitServerInfoMetrics(home)
emitServerInfoMetrics()

svr, err := server.NewServer(addr, transport, app)
if err != nil {
Expand Down Expand Up @@ -358,7 +358,7 @@ func startInProcess(svrCtx *Context, clientCtx client.Context, appCreator types.
return err
}

emitServerInfoMetrics(home)
emitServerInfoMetrics()

var (
apiSrv *api.Server
Expand Down Expand Up @@ -513,7 +513,7 @@ func wrapCPUProfile(svrCtx *Context, callbackFn func() error) error {
}

// emitServerInfoMetrics emits server info related metrics using application telemetry.
func emitServerInfoMetrics(homePath string) {
func emitServerInfoMetrics() {
var ls []metrics.Label

versionInfo := version.NewInfo()
Expand Down
5 changes: 5 additions & 0 deletions x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path"
"path/filepath"
"sort"
"strconv"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
Expand All @@ -16,7 +17,9 @@ import (
xp "cosmossdk.io/x/upgrade/exported"
"cosmossdk.io/x/upgrade/types"

"github.com/armon/go-metrics"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/kv"
Expand Down Expand Up @@ -217,6 +220,8 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error {
bz := k.cdc.MustMarshal(&plan)
store.Set(types.PlanKey(), bz)

telemetry.SetGaugeWithLabels([]string{"server", "info"}, 1, []metrics.Label{telemetry.NewLabel("upgrade_height", strconv.FormatInt(plan.Height, 10))})

return nil
}

Expand Down
7 changes: 0 additions & 7 deletions x/upgrade/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strconv"

"github.com/armon/go-metrics"
abci "github.com/cometbft/cometbft/abci/types"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cast"
Expand All @@ -30,7 +28,6 @@ import (
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -226,10 +223,6 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
m := NewAppModule(k, in.AddressCodec)
gh := govv1beta1.HandlerRoute{RouteKey: types.RouterKey, Handler: NewSoftwareUpgradeProposalHandler(k)}

if upgradePlan, err := k.ReadUpgradeInfoFromDisk(); err == nil && upgradePlan.Height > 0 {
telemetry.SetGaugeWithLabels([]string{"server", "info"}, 1, []metrics.Label{telemetry.NewLabel("upgrade_height", strconv.FormatInt(upgradePlan.Height, 10))})
}

return ModuleOutputs{UpgradeKeeper: k, Module: m, GovHandler: gh, BaseAppOption: baseappOpt}
}

Expand Down

0 comments on commit fd2353a

Please sign in to comment.