-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Merge PR :fix function error in keywords of block.number/hash/timestamp (#879) * fix error in keywords of block.number/hash/timestamp * optimize code * Merge PR:fix invalid state set when the value is zero (#881) * Merge PR:open bloom filter default (#886) * Merge PR: compatible with etherclient (#888) * Merge PR :rpc monitor: register metrics to prometheus (#884) * optimize rpc eth_getBalance method (#891) * add mutex in websocket connection, in case of concurrent write (#887) * add mutex in websocket connection, in case of concurrent write * adpat the header format * inital refactor * add mutex in EventSystem Co-authored-by: KamiD <[email protected]> * Merge PR :fix rpc monitor error (#892) * fix rpc monitor error * fix rpc monitor elapse time Co-authored-by: KamiD <[email protected]> * Add LRU cache for GetCodeByHash (#893) * delete json parse in function getCodeByHash * add LRU cache * change lru to lru.cache to make sure thread safe (#894) * optimize code to avoid reinit cdc (#895) * Merge PR:concurrent safe cdc&config singleton (#897) * Merge PR :add state lru cache to optimize eth_call (#898) * add 1KW LRU cache to optimize eth_call * optimize code * Merge PR :optimize viper to avoid recall (#899) Co-authored-by: KamiD <[email protected]> Co-authored-by: MengXiangJian <[email protected]> Co-authored-by: Evan Han <[email protected]> Co-authored-by: Ray Green <[email protected]>
- Loading branch information
1 parent
df1f078
commit 2cc33d4
Showing
23 changed files
with
677 additions
and
257 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package monitor | ||
|
||
import ( | ||
"fmt" | ||
"github.com/go-kit/kit/metrics" | ||
"github.com/tendermint/tendermint/libs/log" | ||
"time" | ||
) | ||
|
||
type Monitor struct { | ||
method string | ||
logger log.Logger | ||
lastTimestamp int64 | ||
} | ||
|
||
func GetMonitor(method string, logger log.Logger) *Monitor { | ||
return &Monitor{ | ||
method: method, | ||
logger: logger, | ||
} | ||
} | ||
|
||
func (m *Monitor) OnBegin(metrics map[string]metrics.Counter) { | ||
m.lastTimestamp = time.Now().UnixNano() | ||
|
||
if metrics == nil { | ||
return | ||
} | ||
if _, ok := metrics[m.method]; ok { | ||
metrics[m.method].Add(1) | ||
} | ||
} | ||
|
||
func (m *Monitor) OnEnd(args ...interface{}) { | ||
now := time.Now().UnixNano() | ||
unit := int64(1e6) | ||
m.logger.Debug(fmt.Sprintf("RPC: Method<%s>, Interval<%dms>, Params<%v>", m.method, (now-m.lastTimestamp)/unit, args)) | ||
} |
Oops, something went wrong.