mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-23 11:48:33 +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
|
import
|
||||||
std/strutils,
|
std/strutils,
|
||||||
|
chronos,
|
||||||
stew/shims/macros,
|
stew/shims/macros,
|
||||||
stew/byteutils,
|
stew/byteutils,
|
||||||
json_rpc/[rpcserver, jsonmarshal],
|
json_rpc/[rpcserver, jsonmarshal],
|
||||||
@ -18,6 +19,15 @@ logScope: topics = "nimbusapi"
|
|||||||
type
|
type
|
||||||
RpcServer = RpcHttpServer
|
RpcServer = RpcHttpServer
|
||||||
|
|
||||||
|
when defined(chronosFutureTracking):
|
||||||
|
type
|
||||||
|
FutureInfo* = object
|
||||||
|
id*: int
|
||||||
|
procname*: string
|
||||||
|
filename*: string
|
||||||
|
line*: int
|
||||||
|
state: string
|
||||||
|
|
||||||
proc installNimbusApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
|
proc installNimbusApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
|
||||||
## Install non-standard api handlers - some of these are used by 3rd-parties
|
## Install non-standard api handlers - some of these are used by 3rd-parties
|
||||||
## such as eth2stats, pending a full REST api
|
## 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...
|
{.gcsafe.}: # It's probably not, actually. Hopefully we don't log from threads...
|
||||||
updateLogLevel(level)
|
updateLogLevel(level)
|
||||||
return true
|
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
|
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