From 511f4aa65dddfeddf811b3a6368df68e795e4ce2 Mon Sep 17 00:00:00 2001 From: Julio Lopez <1953782+julio-lopez@users.noreply.github.com> Date: Tue, 31 May 2022 14:04:01 -0700 Subject: [PATCH] chore(cli): minor metrics-related cleanups (#1995) * stop ticker to release resources * nit: fix typo * nit: add new line at EOF --- .github/config.yml | 2 +- cli/observability_flags.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/config.yml b/.github/config.yml index 1ee8f4ebd..8afbfd7aa 100644 --- a/.github/config.yml +++ b/.github/config.yml @@ -1,2 +1,2 @@ PR_TITLE_REGEX: /(feat|fix|breaking|build|chore|docs|style|refactor|test)\((app|cli|server|providers|deps|site|ci|infra|general)\): .*/ -COMMIT_MESSAGE_REGEX: /(feat|fix|breaking|build|chore|docs|style|refactor|test)\((app|cli|server|providers|deps|site|ci|infra|general)\): .*/ \ No newline at end of file +COMMIT_MESSAGE_REGEX: /(feat|fix|breaking|build|chore|docs|style|refactor|test)\((app|cli|server|providers|deps|site|ci|infra|general)\): .*/ diff --git a/cli/observability_flags.go b/cli/observability_flags.go index 913b3bd32..109d4258d 100644 --- a/cli/observability_flags.go +++ b/cli/observability_flags.go @@ -25,7 +25,7 @@ ) // nolint:gochecknoglobals -var matricsPushFormats = map[string]expfmt.Format{ +var metricsPushFormats = map[string]expfmt.Format{ "text": expfmt.FmtText, "proto-text": expfmt.FmtProtoText, "proto-delim": expfmt.FmtProtoDelim, @@ -68,7 +68,7 @@ func (c *observabilityFlags) setup(app *kingpin.Application) { var formats []string - for k := range matricsPushFormats { + for k := range metricsPushFormats { formats = append(formats, k) } @@ -122,7 +122,7 @@ func (c *observabilityFlags) startMetrics(ctx context.Context) error { } if c.metricsPushFormat != "" { - pusher.Format(matricsPushFormats[c.metricsPushFormat]) + pusher.Format(metricsPushFormats[c.metricsPushFormat]) } log(ctx).Infof("starting prometheus pusher on %v every %v", c.metricsPushAddr, c.metricsPushInterval) @@ -195,7 +195,9 @@ func (c *observabilityFlags) pushPeriodically(ctx context.Context, p *push.Pushe c.pushOnce(ctx, "periodic", p) case <-c.stopPusher: + ticker.Stop() c.pushOnce(ctx, "final", p) + return } }