From dd619e85ff2f88282c8bb973f084159d39682e49 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 13 Aug 2020 16:48:29 +0200 Subject: [PATCH 1/2] Add total gas limit to stats Signed-off-by: Jakub Sztandera --- tools/stats/metrics.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/stats/metrics.go b/tools/stats/metrics.go index 15c28039d..728570c02 100644 --- a/tools/stats/metrics.go +++ b/tools/stats/metrics.go @@ -16,6 +16,7 @@ import ( "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin/power" "github.com/filecoin-project/specs-actors/actors/util/adt" + "golang.org/x/xerrors" "github.com/ipfs/go-cid" "github.com/multiformats/go-multihash" @@ -135,6 +136,7 @@ func RecordTipsetPoints(ctx context.Context, api api.FullNode, pl *PointList, ti p = NewPoint("chain.basefee", baseFeeFloat) pl.AddPoint(p) + totalGasLimit := int64(0) for _, blockheader := range tipset.Blocks() { bs, err := blockheader.Serialize() if err != nil { @@ -146,7 +148,20 @@ func RecordTipsetPoints(ctx context.Context, api api.FullNode, pl *PointList, ti p = NewPoint("chain.blockheader_size", len(bs)) pl.AddPoint(p) + + msgs, err := api.ChainGetBlockMessages(ctx, blockheader.Cid()) + if err != nil { + return xerrors.Errorf("ChainGetBlockMessages failed: %w", msgs) + } + for _, m := range msgs.BlsMessages { + totalGasLimit += m.GasLimit + } + for _, m := range msgs.SecpkMessages { + totalGasLimit += m.Message.GasLimit + } } + p = NewPoint("chain.gas_limit_total", totalGasLimit) + pl.AddPoint(p) return nil } From 3198d2d1e51c39813de9ad42e2ec2b890e42df71 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 13 Aug 2020 16:55:12 +0200 Subject: [PATCH 2/2] Add total gas used Signed-off-by: Jakub Sztandera --- tools/stats/metrics.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/stats/metrics.go b/tools/stats/metrics.go index 728570c02..ab7b876bc 100644 --- a/tools/stats/metrics.go +++ b/tools/stats/metrics.go @@ -105,7 +105,8 @@ func InfluxNewBatch() (client.BatchPoints, error) { } func NewPoint(name string, value interface{}) models.Point { - pt, _ := models.NewPoint(name, models.Tags{}, map[string]interface{}{"value": value}, build.Clock.Now()) + pt, _ := models.NewPoint(name, models.Tags{}, + map[string]interface{}{"value": value}, build.Clock.Now().UTC()) return pt } @@ -301,8 +302,16 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point msgn := make(map[msgTag][]cid.Cid) + totalGasUsed := int64(0) + for _, r := range recp { + totalGasUsed += r.GasUsed + } + p := NewPoint("chain.gas_used_total", totalGasUsed) + pl.AddPoint(p) + for i, msg := range msgs { // FIXME: use float so this doesn't overflow + // FIXME: this doesn't work as time points get overriden p := NewPoint("chain.message_gaspremium", msg.Message.GasPremium.Int64()) pl.AddPoint(p) p = NewPoint("chain.message_gasfeecap", msg.Message.GasFeeCap.Int64())