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

feat: upgrade otel #1074

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions controllers/configmap/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -103,7 +103,7 @@
defer cancel()

_, _, provider = metrics.ConfigureMetrics(ctx, log, otlpEndpoint)
global.SetMeterProvider(provider)
otel.SetMeterProvider(provider)

Check warning on line 106 in controllers/configmap/configmap.go

View check run for this annotation

Codecov / codecov/patch

controllers/configmap/configmap.go#L106

Added line #L106 was not covered by tests
}

rec := &Reconciler{
Expand Down
8 changes: 4 additions & 4 deletions controllers/imagecollector/imagecollector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"syscall"
"time"

"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -120,7 +120,7 @@
defer cancel()

exporter, reader, provider = metrics.ConfigureMetrics(ctx, log, otlpEndpoint)
global.SetMeterProvider(provider)
otel.SetMeterProvider(provider)

Check warning on line 123 in controllers/imagecollector/imagecollector_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/imagecollector/imagecollector_controller.go#L123

Added line #L123 was not covered by tests
}

rec := &Reconciler{
Expand Down Expand Up @@ -556,7 +556,7 @@

if otlpEndpoint != "" {
// record metrics
if err := metrics.RecordMetricsController(ctx, global.MeterProvider(), float64(time.Since(startTime).Seconds()), int64(childJob.Status.Succeeded), int64(childJob.Status.Failed)); err != nil {
if err := metrics.RecordMetricsController(ctx, otel.GetMeterProvider(), float64(time.Since(startTime).Seconds()), int64(childJob.Status.Succeeded), int64(childJob.Status.Failed)); err != nil {

Check warning on line 559 in controllers/imagecollector/imagecollector_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/imagecollector/imagecollector_controller.go#L559

Added line #L559 was not covered by tests
log.Error(err, "error recording metrics")
}
metrics.ExportMetrics(log, exporter, reader)
Expand All @@ -578,7 +578,7 @@

if otlpEndpoint != "" {
// record metrics
if err := metrics.RecordMetricsController(ctx, global.MeterProvider(), float64(time.Since(startTime).Milliseconds()), int64(childJob.Status.Succeeded), int64(childJob.Status.Failed)); err != nil {
if err := metrics.RecordMetricsController(ctx, otel.GetMeterProvider(), float64(time.Since(startTime).Milliseconds()), int64(childJob.Status.Succeeded), int64(childJob.Status.Failed)); err != nil {

Check warning on line 581 in controllers/imagecollector/imagecollector_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/imagecollector/imagecollector_controller.go#L581

Added line #L581 was not covered by tests
log.Error(err, "error recording metrics")
}
metrics.ExportMetrics(log, exporter, reader)
Expand Down
6 changes: 3 additions & 3 deletions controllers/imagelist/imagelist_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"syscall"
"time"

"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -97,7 +97,7 @@
defer cancel()

exporter, reader, provider = metrics.ConfigureMetrics(ctx, log, otlpEndpoint)
global.SetMeterProvider(provider)
otel.SetMeterProvider(provider)

Check warning on line 100 in controllers/imagelist/imagelist_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/imagelist/imagelist_controller.go#L100

Added line #L100 was not covered by tests
}

rec := &Reconciler{
Expand Down Expand Up @@ -209,7 +209,7 @@
otlpEndpoint := eraserConfig.Manager.OTLPEndpoint
if otlpEndpoint != "" {
// record metrics
if err := metrics.RecordMetricsController(ctx, global.MeterProvider(), float64(time.Since(startTime).Seconds()), int64(job.Status.Succeeded), int64(job.Status.Failed)); err != nil {
if err := metrics.RecordMetricsController(ctx, otel.GetMeterProvider(), float64(time.Since(startTime).Seconds()), int64(job.Status.Succeeded), int64(job.Status.Failed)); err != nil {

Check warning on line 212 in controllers/imagelist/imagelist_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/imagelist/imagelist_controller.go#L212

Added line #L212 was not covered by tests
log.Error(err, "error recording metrics")
}
metrics.ExportMetrics(log, exporter, reader)
Expand Down
58 changes: 28 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
module github.com/eraser-dev/eraser

go 1.18
go 1.21

toolchain go1.22.5

require (
github.com/aquasecurity/trivy v0.35.0
github.com/aquasecurity/trivy-db v0.0.0-20220627104749-930461748b63 // indirect
github.com/go-logr/logr v1.2.3
github.com/go-logr/logr v1.4.2
github.com/onsi/ginkgo/v2 v2.6.0
github.com/onsi/gomega v1.24.1
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.34.0
go.opentelemetry.io/otel/metric v0.34.0
go.opentelemetry.io/otel/sdk v1.14.0
go.opentelemetry.io/otel/sdk/metric v0.34.0
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0
go.opentelemetry.io/otel/metric v1.28.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/sdk/metric v1.28.0
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
golang.org/x/sys v0.18.0
google.golang.org/grpc v1.58.3
golang.org/x/sys v0.21.0
google.golang.org/grpc v1.65.0
k8s.io/api v0.26.11
k8s.io/apimachinery v0.26.11
k8s.io/client-go v0.26.11
Expand All @@ -42,8 +44,8 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/caarlos0/env/v6 v6.10.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/containerd v1.6.26 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -65,14 +67,14 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-containerregistry v0.14.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -103,26 +105,22 @@ require (
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vladimirvivien/gexe v0.1.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.34.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading
Loading