-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: OpenTelemetry configuration and BaseApp instrumentation #25516
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
base: main
Are you sure you want to change the base?
Changes from 15 commits
1cf5e6c
a207f94
ee0bfb3
d5f5ea4
47f83e8
7fafce3
bdba035
25e3135
5c7e464
d71f7c1
56b215a
f9ce55c
3fff00f
5077567
31536b6
c922688
ed891cc
f685bd4
42da2f7
699f5d3
5df2460
1c84edb
46e4bcb
f0c3955
7dfb754
1ce344b
edbae92
0f8085a
03b6069
c4dbd07
2a1dffd
7b3ee34
06e1245
cf720f9
743fdc9
5bfe192
4f50709
c3e781d
6ddac1d
70e8fa8
2258c1f
0968a22
6fb271d
90885bb
5e9c6ba
a1f27c8
6c9cde1
75279fa
10436c9
b870b7c
3b2440c
2c20c90
033e51d
ebe7fd9
3a188c1
9e09f53
8b4e5f2
6c961ea
6081f68
14fa35a
2649644
aa22513
f48d89f
575a12f
e817154
8e992c7
a8dddd8
bfeb28d
f320bfe
107dbd4
3313d91
902ff52
0ecf579
10e286f
cfaffe2
336805c
49f752a
e27a022
cea27dd
c73c140
72fa3e1
8b265b0
4481d57
51a6537
fdac609
86d6325
45e9739
faf5c1d
f665c6c
968efa4
1ae88a0
a4877ea
6c2a994
92783e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,9 @@ | |
| ) | ||
|
|
||
| func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { | ||
| _, span := tracer.Start(context.Background(), "InitChain") | ||
| defer span.End() | ||
|
|
||
| if req.ChainId != app.chainID { | ||
| return nil, fmt.Errorf("invalid chain-id on InitChain; expected: %s, got: %s", app.chainID, req.ChainId) | ||
| } | ||
|
|
@@ -152,7 +155,10 @@ | |
|
|
||
| // Query implements the ABCI interface. It delegates to CommitMultiStore if it | ||
| // implements Queryable. | ||
| func (app *BaseApp) Query(_ context.Context, req *abci.RequestQuery) (resp *abci.ResponseQuery, err error) { | ||
| func (app *BaseApp) Query(ctx context.Context, req *abci.RequestQuery) (resp *abci.ResponseQuery, err error) { | ||
| ctx, span := tracer.Start(ctx, "Query") | ||
| defer span.End() | ||
|
|
||
| // add panic recovery for all queries | ||
| // | ||
| // Ref: https://github.com/cosmos/cosmos-sdk/pull/8039 | ||
|
|
@@ -342,6 +348,9 @@ | |
| // will contain relevant error information. Regardless of tx execution outcome, | ||
| // the ResponseCheckTx will contain the relevant gas execution context. | ||
| func (app *BaseApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { | ||
| _, span := tracer.Start(context.Background(), "CheckTx") | ||
|
||
| defer span.End() | ||
|
|
||
| var mode sdk.ExecMode | ||
|
|
||
| switch req.Type { | ||
|
|
@@ -454,7 +463,10 @@ | |
| } | ||
| }() | ||
|
|
||
| resp, err = app.abciHandlers.PrepareProposalHandler(prepareProposalState.Context(), req) | ||
| ctx := prepareProposalState.Context() | ||
| ctx, span := ctx.StartSpan(tracer, "PrepareProposal") | ||
|
||
| defer span.End() | ||
| resp, err = app.abciHandlers.PrepareProposalHandler(ctx, req) | ||
| if err != nil { | ||
| app.logger.Error("failed to prepare proposal", "height", req.Height, "time", req.Time, "err", err) | ||
| return &abci.ResponsePrepareProposal{Txs: req.Txs}, nil | ||
|
|
@@ -513,7 +525,10 @@ | |
| } | ||
|
|
||
| processProposalState := app.stateManager.GetState(execModeProcessProposal) | ||
| processProposalState.SetContext(app.getContextForProposal(processProposalState.Context(), req.Height). | ||
| ctx := processProposalState.Context() | ||
| ctx, span := ctx.StartSpan(tracer, "ProcessProposal") | ||
| defer span.End() | ||
| processProposalState.SetContext(app.getContextForProposal(ctx, req.Height). | ||
| WithVoteInfos(req.ProposedLastCommit.Votes). // this is a set of votes that are not finalized yet, wait for commit | ||
| WithBlockHeight(req.Height). | ||
| WithBlockTime(req.Time). | ||
|
|
@@ -595,6 +610,9 @@ | |
| return nil, errors.New("application ExtendVote handler not set") | ||
| } | ||
|
|
||
| ctx, span := ctx.StartSpan(tracer, "ExtendVote") | ||
| defer span.End() | ||
|
|
||
| // If vote extensions are not enabled, as a safety precaution, we return an | ||
| // error. | ||
| cp := app.GetConsensusParams(ctx) | ||
|
|
@@ -666,6 +684,9 @@ | |
| ctx = sdk.NewContext(ms, emptyHeader, false, app.logger).WithStreamingManager(app.streamingManager) | ||
| } | ||
|
|
||
| ctx, span := ctx.StartSpan(tracer, "VerifyVoteExtension") | ||
| defer span.End() | ||
|
|
||
| // If vote extensions are not enabled, as a safety precaution, we return an | ||
| // error. | ||
| cp := app.GetConsensusParams(ctx) | ||
|
|
@@ -716,7 +737,7 @@ | |
| // Execution flow or by the FinalizeBlock ABCI method. The context received is | ||
| // only used to handle early cancellation, for anything related to state app.stateManager.GetState(execModeFinalize).Context() | ||
| // must be used. | ||
| func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { | ||
| func (app *BaseApp) internalFinalizeBlock(goCtx context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { | ||
| var events []abci.Event | ||
|
|
||
| if err := app.checkHalt(req.Height, req.Time); err != nil { | ||
|
|
@@ -750,9 +771,12 @@ | |
| app.stateManager.SetState(execModeFinalize, app.cms, header, app.logger, app.streamingManager) | ||
| finalizeState = app.stateManager.GetState(execModeFinalize) | ||
| } | ||
| ctx := finalizeState.Context().WithContext(goCtx) | ||
| ctx, span := ctx.StartSpan(tracer, "internalFinalizeBlock") | ||
| defer span.End() | ||
|
|
||
| // Context is now updated with Header information. | ||
| finalizeState.SetContext(finalizeState.Context(). | ||
| finalizeState.SetContext(ctx. | ||
| WithBlockHeader(header). | ||
| WithHeaderHash(req.Hash). | ||
| WithHeaderInfo(coreheader.Info{ | ||
|
|
@@ -846,7 +870,7 @@ | |
| WithBlockGasUsed(blockGasUsed). | ||
| WithBlockGasWanted(blockGasWanted), | ||
| ) | ||
| endBlock, err := app.endBlock(finalizeState.Context()) | ||
| endBlock, err := app.endBlock() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
@@ -959,7 +983,11 @@ | |
| // height. | ||
| func (app *BaseApp) Commit() (*abci.ResponseCommit, error) { | ||
| finalizeState := app.stateManager.GetState(execModeFinalize) | ||
| header := finalizeState.Context().BlockHeader() | ||
| ctx := finalizeState.Context() | ||
| ctx, span := ctx.StartSpan(tracer, "Commit") | ||
| defer span.End() | ||
|
|
||
| header := ctx.BlockHeader() | ||
| retainHeight := app.GetBlockRetentionHeight(header.Height) | ||
|
|
||
| if app.abciHandlers.Precommiter != nil { | ||
|
|
@@ -1005,6 +1033,10 @@ | |
| // The SnapshotIfApplicable method will create the snapshot by starting the goroutine | ||
| app.snapshotManager.SnapshotIfApplicable(header.Height) | ||
|
|
||
| blockCnt.Add(ctx, 1) | ||
| blockTime.Record(ctx, time.Since(app.blockStartTime).Seconds()) | ||
| app.blockStartTime = time.Now() | ||
|
||
|
|
||
| return resp, nil | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.