Skip to content

Commit

Permalink
OTel: implement missing MeterProvider ForceFlush
Browse files Browse the repository at this point in the history
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
(cherry picked from commit 5f4f4f6)
  • Loading branch information
laurazard committed May 15, 2024
1 parent ee359a3 commit 326c713
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cli/command/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,22 @@ func newCLIReader(exp sdkmetric.Exporter) sdkmetric.Reader {
}

func (r *cliReader) Shutdown(ctx context.Context) error {
var rm metricdata.ResourceMetrics
if err := r.Reader.Collect(ctx, &rm); err != nil {
return err
}

// Place a pretty tight constraint on the actual reporting.
// We don't want CLI metrics to prevent the CLI from exiting
// so if there's some kind of issue we need to abort pretty
// quickly.
ctx, cancel := context.WithTimeout(ctx, exportTimeout)
defer cancel()

return r.ForceFlush(ctx)
}

func (r *cliReader) ForceFlush(ctx context.Context) error {
var rm metricdata.ResourceMetrics
if err := r.Reader.Collect(ctx, &rm); err != nil {
return err
}

return r.exporter.Export(ctx, &rm)
}

Expand Down

0 comments on commit 326c713

Please sign in to comment.