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

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

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion simapp/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions simapp/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
3 changes: 2 additions & 1 deletion simapp/v2/simdv2/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions telemetry/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func IsTelemetryEnabled() bool {
return globalTelemetryEnabled
}

// EnableTelemetry allows for the global telemetry enabled state to be set.
func EnableTelemetry() {
globalTelemetryEnabled = true
}
Comment on lines 24 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change potentially affects state.

Call sequence:

github.com/cosmos/cosmos-sdk/telemetry.IsTelemetryEnabled (telemetry/metrics.go:23)
github.com/cosmos/cosmos-sdk/telemetry.IncrCounter (telemetry/metrics.go:53)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).deliverTx (telemetry/metrics.go:756)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).internalFinalizeBlock (telemetry/metrics.go:747)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).FinalizeBlock (telemetry/metrics.go:902)


// 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{}
Expand Down
Loading