mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-22 11:18:25 +00:00
add rpc call to get chronos futures at runtime
This commit is contained in:
parent
b2e0221f2d
commit
5b011b65ae
@ -6,6 +6,7 @@
|
||||
|
||||
import
|
||||
std/strutils,
|
||||
chronos,
|
||||
stew/shims/macros,
|
||||
stew/byteutils,
|
||||
json_rpc/[rpcserver, jsonmarshal],
|
||||
@ -18,6 +19,15 @@ logScope: topics = "nimbusapi"
|
||||
type
|
||||
RpcServer = RpcHttpServer
|
||||
|
||||
when defined(chronosFutureTracking):
|
||||
type
|
||||
FutureInfo* = object
|
||||
id*: int
|
||||
procname*: string
|
||||
filename*: string
|
||||
line*: int
|
||||
state: string
|
||||
|
||||
proc installNimbusApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
|
||||
## Install non-standard api handlers - some of these are used by 3rd-parties
|
||||
## such as eth2stats, pending a full REST api
|
||||
@ -88,3 +98,19 @@ proc installNimbusApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
|
||||
{.gcsafe.}: # It's probably not, actually. Hopefully we don't log from threads...
|
||||
updateLogLevel(level)
|
||||
return true
|
||||
|
||||
when defined(chronosFutureTracking):
|
||||
rpcServer.rpc("getChronosFutures") do () -> seq[FutureInfo]:
|
||||
var res: seq[FutureInfo]
|
||||
|
||||
for item in pendingFutures():
|
||||
let loc = item.location[LocCreateIndex][]
|
||||
res.add FutureInfo(
|
||||
id: item.id,
|
||||
procname: $loc.procedure,
|
||||
filename: $loc.file,
|
||||
line: loc.line,
|
||||
state: $item.state
|
||||
)
|
||||
|
||||
return res
|
||||
|
@ -183,3 +183,11 @@ Set the current logging level dynamically: TRACE, DEBUG, INFO, NOTICE, WARN, ERR
|
||||
```
|
||||
curl -d '{"jsonrpc":"2.0","id":"id","method":"setLogLevel","params":["DEBUG; TRACE:discv5,libp2p; REQUIRED:none; DISABLED:none"] }' -H 'Content-Type: application/json' localhost:9190 -s | jq
|
||||
```
|
||||
|
||||
### getChronosFutures
|
||||
|
||||
Get the current list of live async futures in the process - compile with `-d:chronosFutureTracking` to enable.
|
||||
|
||||
```
|
||||
curl -d '{"jsonrpc":"2.0","id":"id","method":"getChronosFutures","params":[] }' -H 'Content-Type: application/json' localhost:9190 -s | jq '.result | (.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv'
|
||||
```
|
||||
|
2
vendor/nim-chronos
vendored
2
vendor/nim-chronos
vendored
@ -1 +1 @@
|
||||
Subproject commit 1ffd1cd3dc2145b6922eba465d29d1990e9d4254
|
||||
Subproject commit 710454cc6b792748144882d7c97912b0c6cef138
|
Loading…
x
Reference in New Issue
Block a user