-
Notifications
You must be signed in to change notification settings - Fork 324
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
Log summary about the node status #3870
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a01d000
add nodestats pkg
millken e78a54c
update nodestats pkg
millken c4678ef
Merge branch 'master' into issue3782
millken 9df2d4e
Merge branch 'master' into issue3782
millken 419b3ae
fix ci issues
millken 55bc49b
fix ci issues
millken 4e809db
add missing files
millken ff47ec7
fix tests
millken c25e771
Merge branch 'master' into issue3782
millken 32e2fef
add disk usage stats
millken efacfd2
add disk usage stats
millken 9abe32a
add disk usage stats
millken 07adfd9
remove interface{}
millken dc2425b
remove interface{}
millken f890c6b
fix ci errors
millken b185237
fix ci errors
millken f57aae7
use sync.Map instead of generic.Map
millken 40f4270
Merge branch 'master' into issue3782
millken d410ea4
update nodestats
millken 5611262
Merge branch 'master' into issue3782
dustinxie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ func (svr *web3Handler) HandlePOSTReq(ctx context.Context, reader io.Reader, wri | |
if err != nil { | ||
err := errors.Wrap(err, "failed to parse web3 requests.") | ||
span.RecordError(err) | ||
return writer.Write(&web3Response{err: err}) | ||
_, err = writer.Write(&web3Response{err: err}) | ||
return err | ||
} | ||
if !web3Reqs.IsArray() { | ||
return svr.handleWeb3Req(ctx, &web3Reqs, writer) | ||
|
@@ -116,7 +117,8 @@ func (svr *web3Handler) HandlePOSTReq(ctx context.Context, reader io.Reader, wri | |
svr.batchRequestLimit, | ||
) | ||
span.RecordError(err) | ||
return writer.Write(&web3Response{err: err}) | ||
_, err = writer.Write(&web3Response{err: err}) | ||
return err | ||
} | ||
batchWriter := apitypes.NewBatchWriter(writer) | ||
for i := range web3ReqArr { | ||
|
@@ -129,10 +131,12 @@ func (svr *web3Handler) HandlePOSTReq(ctx context.Context, reader io.Reader, wri | |
|
||
func (svr *web3Handler) handleWeb3Req(ctx context.Context, web3Req *gjson.Result, writer apitypes.Web3ResponseWriter) error { | ||
var ( | ||
res interface{} | ||
err error | ||
method = web3Req.Get("method").Value() | ||
res interface{} | ||
err, err1 error | ||
method = web3Req.Get("method").Value() | ||
size int | ||
) | ||
defer func(start time.Time) { svr.coreService.Track(ctx, start, method.(string), int64(size), err == nil) }(time.Now()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do gRPC and HTTP servers not require invoking the |
||
span := tracer.SpanFromContext(ctx) | ||
defer span.End() | ||
span.AddEvent("handleWeb3Req") | ||
|
@@ -239,11 +243,12 @@ func (svr *web3Handler) handleWeb3Req(ctx context.Context, web3Req *gjson.Result | |
} else { | ||
log.Logger("api").Debug("web3Debug", zap.String("response", fmt.Sprintf("%+v", res))) | ||
} | ||
return writer.Write(&web3Response{ | ||
size, err1 = writer.Write(&web3Response{ | ||
id: int(web3Req.Get("id").Int()), | ||
result: res, | ||
err: err, | ||
}) | ||
return err1 | ||
} | ||
|
||
func parseWeb3Reqs(reader io.Reader) (gjson.Result, error) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import ( | |
"github.com/iotexproject/iotex-core/pkg/lifecycle" | ||
"github.com/iotexproject/iotex-core/pkg/log" | ||
"github.com/iotexproject/iotex-core/pkg/routine" | ||
"github.com/iotexproject/iotex-core/server/itx/nodestats" | ||
) | ||
|
||
type ( | ||
|
@@ -42,7 +43,7 @@ type ( | |
// BlockSync defines the interface of blocksyncer | ||
BlockSync interface { | ||
lifecycle.StartStopper | ||
|
||
nodestats.StatsReporter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this, don't need to explicitly tell, so we can remove the import at L26 above |
||
// TargetHeight returns the target height to sync to | ||
TargetHeight() uint64 | ||
// ProcessSyncRequest processes a block sync request | ||
|
@@ -122,6 +123,10 @@ func (*dummyBlockSync) SyncStatus() (uint64, uint64, uint64, string) { | |
return 0, 0, 0, "" | ||
} | ||
|
||
func (*dummyBlockSync) BuildReport() string { | ||
return "" | ||
} | ||
|
||
// NewBlockSyncer returns a new block syncer instance | ||
func NewBlockSyncer( | ||
cfg Config, | ||
|
@@ -335,3 +340,15 @@ func (bs *blockSyncer) SyncStatus() (uint64, uint64, uint64, string) { | |
} | ||
return bs.startingHeight, bs.tipHeightHandler(), bs.targetHeight, syncSpeedDesc | ||
} | ||
|
||
// BuildReport builds a report of block syncer | ||
func (bs *blockSyncer) BuildReport() string { | ||
startingHeight, tipHeight, targetHeight, syncSpeedDesc := bs.SyncStatus() | ||
return fmt.Sprintf( | ||
"BlockSync startingHeight: %d, tipHeight: %d, targetHeight: %d, %s", | ||
startingHeight, | ||
tipHeight, | ||
targetHeight, | ||
syncSpeedDesc, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is an API added in the
coreservice
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is passed through the
Option
ofnewCoreService
. There is alreadycoreService
inweb3Handler
, we can use it directly.