Skip to content

Commit

Permalink
feat(cloudotel): call reader.Shutdown instead of exporter.Shutdown
Browse files Browse the repository at this point in the history
The periodic reader collects and exports metrics previously recorded at
a given interval.

In order to make sure we do not miss recorded metrics that have not yet
been exported at shutdown, we need to call the reader's Shutdown method
which performs a last collect and export.

It also performs a shutdown of the exporter so we don't need to do that
ourselves.

relates to [PE-910](https://einride.atlassian.net/browse/PE-910)
  • Loading branch information
alethenorio committed Jul 31, 2024
1 parent 6d4186d commit dc50fc1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cloudotel/metricexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ func StartMetricExporter(
)
otel.SetMeterProvider(provider)
shutdown := func() {
if err := exporter.Shutdown(context.Background()); err != nil {
if err := reader.Shutdown(context.Background()); err != nil {
if logger, ok := cloudzap.GetLogger(ctx); ok {
const msg = "error stopping metric exporter, final metric export might have failed"
const msg = "error stopping periodic reader, final metric export might have failed"
switch status.Code(err) {
case codes.InvalidArgument:
// In case final export happens within the minimum frequency time from the previous export,
Expand Down

0 comments on commit dc50fc1

Please sign in to comment.