feat: emit more data in prom metrics (#15657)
This commit is contained in:
parent
b2c84188de
commit
17debf2efa
@ -57,6 +57,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (x/bank) [#14894](https://github.com/cosmos/cosmos-sdk/pull/14894) Return a human readable denomination for IBC vouchers when querying bank balances. Added a `ResolveDenom` parameter to `types.QueryAllBalancesRequest` and `--resolve-denom` flag to `GetBalancesCmd()`.
|
||||
* (x/gov) [#15151](https://github.com/cosmos/cosmos-sdk/pull/15151) Add `burn_vote_quorum`, `burn_proposal_deposit_prevote` and `burn_vote_veto` params to allow applications to decide if they would like to burn deposits
|
||||
* (runtime) [#15547](https://github.com/cosmos/cosmos-sdk/pull/15547) Allow runtime to pass event core api service to modules
|
||||
* (telemetry) [#15657](https://github.com/cosmos/cosmos-sdk/pull/15657) Emit more data (go version, sdk version, upgrade height) in prom metrics
|
||||
|
||||
### Improvements
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"runtime/pprof"
|
||||
|
||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/cometbft/cometbft/abci/server"
|
||||
cmtcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
|
||||
"github.com/cometbft/cometbft/node"
|
||||
@ -32,6 +33,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
"github.com/cosmos/cosmos-sdk/types/mempool"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
@ -225,6 +227,8 @@ func startStandAlone(svrCtx *Context, appCreator types.AppCreator) error {
|
||||
return err
|
||||
}
|
||||
|
||||
emitServerInfoMetrics()
|
||||
|
||||
svr, err := server.NewServer(addr, transport, app)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating listener: %v", err)
|
||||
@ -354,6 +358,8 @@ func startInProcess(svrCtx *Context, clientCtx client.Context, appCreator types.
|
||||
return err
|
||||
}
|
||||
|
||||
emitServerInfoMetrics()
|
||||
|
||||
var (
|
||||
apiSrv *api.Server
|
||||
grpcSrv *grpc.Server
|
||||
@ -505,3 +511,22 @@ func wrapCPUProfile(svrCtx *Context, callbackFn func() error) error {
|
||||
|
||||
return <-errCh
|
||||
}
|
||||
|
||||
// emitServerInfoMetrics emits server info related metrics using application telemetry.
|
||||
func emitServerInfoMetrics() {
|
||||
var ls []metrics.Label
|
||||
|
||||
versionInfo := version.NewInfo()
|
||||
if len(versionInfo.GoVersion) > 0 {
|
||||
ls = append(ls, telemetry.NewLabel("go", versionInfo.GoVersion))
|
||||
}
|
||||
if len(versionInfo.CosmosSdkVersion) > 0 {
|
||||
ls = append(ls, telemetry.NewLabel("version", versionInfo.CosmosSdkVersion))
|
||||
}
|
||||
|
||||
if len(ls) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
telemetry.SetGaugeWithLabels([]string{"server", "info"}, 1, ls)
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/log"
|
||||
@ -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"
|
||||
@ -46,7 +49,7 @@ type Keeper struct {
|
||||
// homePath - root directory of the application's config
|
||||
// vs - the interface implemented by baseapp which allows setting baseapp's protocol version field
|
||||
func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, homePath string, vs xp.ProtocolVersionSetter, authority string) *Keeper {
|
||||
return &Keeper{
|
||||
k := &Keeper{
|
||||
homePath: homePath,
|
||||
skipUpgradeHeights: skipUpgradeHeights,
|
||||
storeKey: storeKey,
|
||||
@ -55,6 +58,12 @@ func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey storetypes.StoreKey,
|
||||
versionSetter: vs,
|
||||
authority: authority,
|
||||
}
|
||||
|
||||
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 k
|
||||
}
|
||||
|
||||
// SetVersionSetter sets the interface implemented by baseapp which allows setting baseapp's protocol version field
|
||||
@ -217,6 +226,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
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user