-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error handling #492
Improve error handling #492
Conversation
@@ -148,14 +147,10 @@ func newMetricExporter(o *options) (*metricExporter, error) { | |||
|
|||
// Export exports OpenTelemetry Metrics to Google Cloud Monitoring. | |||
func (me *metricExporter) Export(ctx context.Context, rm metricdata.ResourceMetrics) error { | |||
if err := me.exportMetricDescriptor(ctx, rm); err != nil { | |||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this return would've prevented sending TS if we failed to write descriptors.
for kmd, md := range mds { | ||
err := me.createMetricDescriptorIfNeeded(ctx, md) | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this return would've prevented other descriptors from being written
|
||
for _, scope := range rm.ScopeMetrics { | ||
for _, metrics := range scope.Metrics { | ||
ts, err := me.recordToTspb(metrics, mr, scope.Scope) | ||
if err != nil { | ||
errs = append(errs, err) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this else prevented appending timeseries if recordToTspb returned a partial error (an error, and some timeseries)
|
||
if aggError != nil { | ||
if me.o.onError != nil { | ||
me.o.onError(aggError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is removed in-favor of returning the error.
This has a number of improvements:
nil
errors by not appending, so we aren't required to check fornil
anymore.