Skip to content

Commit

Permalink
tools: block generator data reporting (#5339)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiqizng authored May 3, 2023
1 parent e24a35a commit d17c1b5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/block-generator/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
datadog==0.45.0
5 changes: 5 additions & 0 deletions tools/block-generator/runner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ func (r *Args) runTest(report *os.File, metricsURL string, generatorURL string)
return fmt.Errorf("problem collecting final metrics (%d / %s): %w", count, time.Since(start), err)
}

// write scenario to report
scenario := path.Base(r.Path)
if _, err := report.WriteString(fmt.Sprintf("scenario:%s\n", scenario)); err != nil {
return fmt.Errorf("unable to write scenario to report: %w", err)
}
// Collect results.
durationStr := fmt.Sprintf("test_duration_seconds:%d\ntest_duration_actual_seconds:%f\n",
uint64(r.RunDuration.Seconds()),
Expand Down
53 changes: 53 additions & 0 deletions tools/block-generator/upload_metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from datadog import initialize
from datadog import api
import os
import argparse

parser = argparse.ArgumentParser(description="Upload performance metrics to Datadog")
parser.add_argument(
"-f",
"--perf-reports",
required=True,
action="store",
dest="files",
type=str,
nargs="*",
help="list of reports created by the block generator",
)
parser.add_argument(
"-c",
"--binary-version",
required=True,
help="Release version or the commit hash of the Conduit binary used during the performance test",
)
args = parser.parse_args()


def parse_report(report):
data = dict()
with open(report) as f:
for line in f:
tag, value = line.split(":")
data[tag] = value if tag == "scenario" else float(value)
return data


if __name__ == "__main__":
print("initializing datadog")
options = {
"api_key": os.getenv("DATADOG_API_KEY"),
"app_key": os.getenv("DATADOG_APP_KEY"),
}
initialize(**options)
for fp in args.files:
print(f"uploading metrics for {fp}")
data = parse_report(fp)
tags = [
f"conduit_version:{args.binary_version}",
f'duration:{data["test_duration_seconds"]}s',
f'scenario:{data["scenario"]}',
]
transactionsPerBlockAvgMetricName = "conduit.perf.transactions_per_second"
tps = data["final_overall_transactions_per_second"]
api.Metric.send(metric=transactionsPerBlockAvgMetricName, points=tps, tags=tags)
print("uploaded metrics")

0 comments on commit d17c1b5

Please sign in to comment.