Skip to content

Commit

Permalink
instrumentation for bench tool (#1337)
Browse files Browse the repository at this point in the history
* instrument postgres

* more instrumentation

* check for err getoffsetsize

* emit metrics every 10sec

* ignore errors

* add postgres-drop

* use directly tables

* fix: go mod tidy

* use INSERT INTO instead of tmp tables

* try to catch sig

* remove transaction commit

* fixup

* add postgres-init

* fixuop

* split create and init

* fixup

* remove if not exist

---------

Co-authored-by: Dirk McCormick <dirkmdev@gmail.com>
  • Loading branch information
nonsense and dirkmc committed Apr 5, 2023
1 parent 366b58a commit f8ca07d
Show file tree
Hide file tree
Showing 10 changed files with 581 additions and 143 deletions.
4 changes: 4 additions & 0 deletions extern/boostd-data/bench/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ CREATE TABLE PieceBlockOffsetSize (
BlockSize BIGINT,
PRIMARY KEY (PieceCid, PayloadMultihash)
);

SELECT create_distributed_table('PayloadToPieces', 'PayloadMultihash');

SELECT create_distributed_table('PieceBlockOffsetSize', 'PieceCid');
29 changes: 28 additions & 1 deletion extern/boostd-data/bench/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package main

import (
"os"
"time"

"github.com/ethereum/go-ethereum/metrics"
"github.com/filecoin-project/boostd-data/shared/cliutil"
logging "github.com/ipfs/go-log/v2"
"github.com/urfave/cli/v2"
"os"
)

var log = logging.Logger("bench")
Expand All @@ -21,6 +24,9 @@ func main() {
cassandraCmd,
foundationCmd,
postgresCmd,
createCmd,
initCmd,
dropCmd,
},
}
app.Setup()
Expand All @@ -29,6 +35,8 @@ func main() {
log.Errorf("Error: %s", err.Error())
os.Exit(1)
}

time.Sleep(11 * time.Second) // 10+1 because of influxdb reporter
}

func before(cctx *cli.Context) error {
Expand All @@ -38,5 +46,24 @@ func before(cctx *cli.Context) error {
_ = logging.SetLogLevel("bench", "debug")
}

metricsSetup()

return nil
}

func metricsSetup() {
metrics.Enabled = true

hostname, _ := os.Hostname()
tags := make(map[string]string)
tags["host"] = hostname

endpoint := "http://10.14.1.226:8086"
username := "admin"
password := "admin"
database := "metrics"
namespace := ""

go InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, namespace, tags)
log.Info("setting up influxdb exporter")
}
Loading

0 comments on commit f8ca07d

Please sign in to comment.