Skip to content

Commit

Permalink
go/oasis-node/cmd/control: Add runtime-stats
Browse files Browse the repository at this point in the history
This is a cleaned up version of the command in the tools repository.
  • Loading branch information
Yawning committed Mar 23, 2022
1 parent 9c9652c commit fb24f8b
Show file tree
Hide file tree
Showing 5 changed files with 579 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/4596.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go/oasis-node/cmd/control: Add runtime-stats

This command allows querying historical runtime statistics.
2 changes: 2 additions & 0 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ require (
github.com/multiformats/go-multiaddr v0.5.0
github.com/oasisprotocol/curve25519-voi v0.0.0-20211219162838-e9a669f65da9
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5
github.com/powerman/rpc-codec v1.2.2
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/common v0.32.1
Expand Down Expand Up @@ -163,6 +164,7 @@ require (
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/miekg/dns v1.1.43 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
Expand Down
2 changes: 2 additions & 0 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down Expand Up @@ -924,6 +925,7 @@ github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtb
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5 h1:58+kh9C6jJVXYjt8IE48G2eWl6BjwU5Gj0gqY84fy78=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
11 changes: 11 additions & 0 deletions go/oasis-node/cmd/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ var (
Run: doStatus,
}

controlRuntimeStatsCmd = &cobra.Command{
Use: "runtime-stats <runtime-id> [<start-height> [<end-height>]]",
Short: "show runtime statistics",
Run: doRuntimeStats,
}

logger = logging.GetLogger("cmd/control")
)

Expand All @@ -80,6 +86,10 @@ func DoConnect(cmd *cobra.Command) (*grpc.ClientConn, control.NodeController) {
cmdCommon.EarlyLogAndExit(err)
}

return doConnectOnly(cmd)
}

func doConnectOnly(cmd *cobra.Command) (*grpc.ClientConn, control.NodeController) {
conn, err := cmdGrpc.NewClient(cmd)
if err != nil {
logger.Error("failed to establish connection with node",
Expand Down Expand Up @@ -301,5 +311,6 @@ func Register(parentCmd *cobra.Command) {
controlCmd.AddCommand(controlUpgradeBinaryCmd)
controlCmd.AddCommand(controlCancelUpgradeCmd)
controlCmd.AddCommand(controlStatusCmd)
controlCmd.AddCommand(controlRuntimeStatsCmd)
parentCmd.AddCommand(controlCmd)
}
Loading

0 comments on commit fb24f8b

Please sign in to comment.