fix(server/v2/api/telemetry): enable global metrics (backport #22571) (#22579)

Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
mergify[bot] 2024-11-20 19:57:53 +01:00 committed by GitHub
parent f1b3b3d7e6
commit cc6b60ff8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 4 deletions

View File

@ -11,7 +11,7 @@ require (
cosmossdk.io/log v1.5.0
cosmossdk.io/math v1.3.0
cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 // main
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 // main
cosmossdk.io/server/v2 v2.0.0-20241120173909-b45cf753a7a3 // main
cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main
cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000

View File

@ -214,8 +214,8 @@ cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 h1:hYI7pvrmdkgFZJ4HVQ
cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:J4Wv2eOwAz8t14Ak8XBMWDoFbwqwyllMaJF91O7n/wI=
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 h1:WUho1r7Zcg5aPn5YtYRN5TW9fvxUirX1mSihBDJ6ccg=
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0=
cosmossdk.io/server/v2 v2.0.0-20241120173909-b45cf753a7a3 h1:92+h62WOgxdb3eqjIT1sNn+/gcQYLvtZ9eln84h0nMg=
cosmossdk.io/server/v2 v2.0.0-20241120173909-b45cf753a7a3/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0=
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 h1:GOznErJieaI0OS0LDUsu5Vy3qPnCyjdvkncejP0Zv5s=
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95/go.mod h1:elhlrldWtm+9U4PxE0G3wjz83yQwVVGVAOncXJPY1Xc=
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 h1:cK7wvmlA18AvLcaInseKTBmt5EXtLwafe7oH1rx7veU=

View File

@ -25,6 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/debug"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rpc"
sdktelemetry "github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/genutil"
@ -118,7 +119,7 @@ func InitRootCmd[T transaction.Tx](
}
}
telemetryServer, err := telemetry.New[T](deps.GlobalConfig, logger)
telemetryServer, err := telemetry.New[T](deps.GlobalConfig, logger, sdktelemetry.EnableTelemetry)
if err != nil {
return nil, err
}

View File

@ -24,6 +24,11 @@ func IsTelemetryEnabled() bool {
return globalTelemetryEnabled
}
// EnableTelemetry allows for the global telemetry enabled state to be set.
func EnableTelemetry() {
globalTelemetryEnabled = true
}
// globalLabels defines the set of global labels that will be applied to all
// metrics emitted using the telemetry package function wrappers.
var globalLabels = []metrics.Label{}