Skip to content
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

[chore] migrate obsreport to use errors.Join instead of go.uber.org/multierr #8223

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions obsreport/obsreport_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
"go.uber.org/multierr"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -89,37 +88,37 @@
obsmetrics.ExporterPrefix+obsmetrics.SentSpansKey,
metric.WithDescription("Number of spans successfully sent to destination."),
metric.WithUnit("1"))
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 91 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 91 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 91 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 91 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename variable errors to not clash with the package name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errs


exp.failedToSendSpans, err = meter.Int64Counter(
obsmetrics.ExporterPrefix+obsmetrics.FailedToSendSpansKey,
metric.WithDescription("Number of spans in failed attempts to send to destination."),
metric.WithUnit("1"))
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 97 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 97 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 97 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 97 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

exp.sentMetricPoints, err = meter.Int64Counter(
obsmetrics.ExporterPrefix+obsmetrics.SentMetricPointsKey,
metric.WithDescription("Number of metric points successfully sent to destination."),
metric.WithUnit("1"))
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 103 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 103 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 103 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 103 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

exp.failedToSendMetricPoints, err = meter.Int64Counter(
obsmetrics.ExporterPrefix+obsmetrics.FailedToSendMetricPointsKey,
metric.WithDescription("Number of metric points in failed attempts to send to destination."),
metric.WithUnit("1"))
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 109 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 109 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 109 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 109 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

exp.sentLogRecords, err = meter.Int64Counter(
obsmetrics.ExporterPrefix+obsmetrics.SentLogRecordsKey,
metric.WithDescription("Number of log record successfully sent to destination."),
metric.WithUnit("1"))
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 115 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 115 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 115 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 115 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

exp.failedToSendLogRecords, err = meter.Int64Counter(
obsmetrics.ExporterPrefix+obsmetrics.FailedToSendLogRecordsKey,
metric.WithDescription("Number of log records in failed attempts to send to destination."),
metric.WithUnit("1"))
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 121 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 121 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 121 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 121 in obsreport/obsreport_exporter.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

return errors
}
Expand Down
19 changes: 9 additions & 10 deletions obsreport/obsreport_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"go.opencensus.io/tag"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.uber.org/multierr"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -102,63 +101,63 @@
metric.WithDescription("Number of spans successfully pushed into the next component in the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 104 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 104 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 104 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 104 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

por.refusedSpansCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.RefusedSpansKey,
metric.WithDescription("Number of spans that were rejected by the next component in the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 111 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 111 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 111 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 111 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

por.droppedSpansCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.DroppedSpansKey,
metric.WithDescription("Number of spans that were dropped."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 118 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 118 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 118 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 118 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

por.acceptedMetricPointsCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.AcceptedMetricPointsKey,
metric.WithDescription("Number of metric points successfully pushed into the next component in the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

Check failure on line 125 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / Integration test

errors.Join undefined (type error has no field or method Join)

Check failure on line 125 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / govulncheck

errors.Join undefined (type error has no field or method Join)

Check failure on line 125 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / test-coverage

errors.Join undefined (type error has no field or method Join)

Check failure on line 125 in obsreport/obsreport_processor.go

View workflow job for this annotation

GitHub Actions / contrib_tests

errors.Join undefined (type error has no field or method Join)

por.refusedMetricPointsCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.RefusedMetricPointsKey,
metric.WithDescription("Number of metric points that were rejected by the next component in the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

por.droppedMetricPointsCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.DroppedMetricPointsKey,
metric.WithDescription("Number of metric points that were dropped."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

por.acceptedLogRecordsCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.AcceptedLogRecordsKey,
metric.WithDescription("Number of log records successfully pushed into the next component in the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

por.refusedLogRecordsCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.RefusedLogRecordsKey,
metric.WithDescription("Number of log records that were rejected by the next component in the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

por.droppedLogRecordsCounter, err = meter.Int64Counter(
obsmetrics.ProcessorPrefix+obsmetrics.DroppedLogRecordsKey,
metric.WithDescription("Number of log records that were dropped."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

return errors
}
Expand Down
13 changes: 6 additions & 7 deletions obsreport/obsreport_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
"go.uber.org/multierr"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -107,42 +106,42 @@ func (rec *Receiver) createOtelMetrics() error {
metric.WithDescription("Number of spans successfully pushed into the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

rec.refusedSpansCounter, err = rec.meter.Int64Counter(
obsmetrics.ReceiverPrefix+obsmetrics.RefusedSpansKey,
metric.WithDescription("Number of spans that could not be pushed into the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

rec.acceptedMetricPointsCounter, err = rec.meter.Int64Counter(
obsmetrics.ReceiverPrefix+obsmetrics.AcceptedMetricPointsKey,
metric.WithDescription("Number of metric points successfully pushed into the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

rec.refusedMetricPointsCounter, err = rec.meter.Int64Counter(
obsmetrics.ReceiverPrefix+obsmetrics.RefusedMetricPointsKey,
metric.WithDescription("Number of metric points that could not be pushed into the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

rec.acceptedLogRecordsCounter, err = rec.meter.Int64Counter(
obsmetrics.ReceiverPrefix+obsmetrics.AcceptedLogRecordsKey,
metric.WithDescription("Number of log records successfully pushed into the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

rec.refusedLogRecordsCounter, err = rec.meter.Int64Counter(
obsmetrics.ReceiverPrefix+obsmetrics.RefusedLogRecordsKey,
metric.WithDescription("Number of log records that could not be pushed into the pipeline."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

return errors
}
Expand Down
5 changes: 2 additions & 3 deletions obsreport/obsreport_scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
"go.uber.org/multierr"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -94,14 +93,14 @@ func (s *Scraper) createOtelMetrics(cfg ScraperSettings) error {
metric.WithDescription("Number of metric points successfully scraped."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

s.erroredMetricsPoints, err = meter.Int64Counter(
obsmetrics.ScraperPrefix+obsmetrics.ErroredMetricPointsKey,
metric.WithDescription("Number of metric points that were unable to be scraped."),
metric.WithUnit("1"),
)
errors = multierr.Append(errors, err)
errors = errors.Join(errors, err)

return errors
}
Expand Down
6 changes: 3 additions & 3 deletions obsreport/obsreporttest/obsreporttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package obsreporttest // import "go.opentelemetry.io/collector/obsreport/obsrepo

import (
"context"
"errors"

ocprom "contrib.go.opencensus.io/exporter/prometheus"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -14,7 +15,6 @@ import (
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/sdk/trace/tracetest"
"go.uber.org/multierr"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
Expand Down Expand Up @@ -136,9 +136,9 @@ func (tts *TestTelemetry) Shutdown(ctx context.Context) error {
view.Unregister(tts.views...)
view.UnregisterExporter(tts.ocExporter)
var errs error
errs = multierr.Append(errs, tts.SpanRecorder.Shutdown(ctx))
errs = errors.Join(errs, tts.SpanRecorder.Shutdown(ctx))
if tts.meterProvider != nil {
errs = multierr.Append(errs, tts.meterProvider.Shutdown(ctx))
errs = errors.Join(errs, tts.meterProvider.Shutdown(ctx))
}
return errs
}
Expand Down
Loading