From 52bd32914a6184ee4d403f8418eb0546074ac5bb Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sat, 18 Mar 2023 13:48:41 +0100 Subject: Print metrics based on flag duration to stderr --- main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index f4763ac..b78b007 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ import ( "fmt" "log" "os" + "time" "git.cs.kau.se/rasmoste/ct-sans/internal/ctflag" ) @@ -43,15 +44,17 @@ Options: -k, --batch-disk: Certificate batch size before persisting (Default: 16384) -q, --batch-req: Certificate batch size to use in request (Default: 512) -a, --http-agent: HTTP agent to use in all request (Default: "git.cs.kau.se/rasmoste/ct-sans") + -m, --metrics: How often to emit metrics to stderr (Default: 15s) ` type options struct { - Directory string - WorkersPerLog uint64 - PersistSize uint64 - BatchSize uint64 - HTTPAgent string + Directory string + WorkersPerLog uint64 + PersistSize uint64 + BatchSize uint64 + HTTPAgent string + MetricsInterval time.Duration logDirectory string metadataFile string @@ -78,6 +81,7 @@ func main() { ctflag.Uint64(&fs, &opts.PersistSize, "batch-disk", "k", 16384) ctflag.Uint64(&fs, &opts.BatchSize, "batch-req", "q", 512) ctflag.String(&fs, &opts.HTTPAgent, "http-agent", "a", "git.cs.kau.se/rasmoste/ct-sans") + ctflag.Duration(&fs, &opts.MetricsInterval, "metrics", "m", 15*time.Second) // Parse command-line options and hardcode additional values if err := ctflag.Parse(fs, os.Args[2:]); err != nil { -- cgit v1.2.3