Skip to content

Commit

Permalink
fix(cloudotel): downgrade metric export error to warning
Browse files Browse the repository at this point in the history
Currently investigating underlying cause for failing the final metric
export.

The previous change enabled metric export on shutdown to happen -
previously it has not been triggered in the first place - so we are not
missing any metrics that we haven't already been missing.
  • Loading branch information
odsod committed Aug 5, 2024
1 parent e2ccc4b commit 6abad7a
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions cloudotel/metricexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"go.opentelemetry.io/otel/sdk/resource"
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

// MetricExporterConfig configures the metrics exporter.
Expand Down Expand Up @@ -86,16 +84,7 @@ func StartMetricExporter(
shutdown := func() {
if err := reader.Shutdown(context.Background()); err != nil {
if logger, ok := cloudzap.GetLogger(ctx); ok {
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,
// Cloud Monitoring API will fail with InvalidArgument. In that case, there's nothing to do
// so only warn about it.
logger.Warn(msg, zap.Error(err))
default:
logger.Error(msg, zap.Error(err))
}
logger.Warn("error stopping periodic reader, final metric export might have failed", zap.Error(err))
}
}
}
Expand Down

0 comments on commit 6abad7a

Please sign in to comment.