Skip to content

Commit

Permalink
Use api reader to avoid cache issues
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed May 30, 2024
1 parent b1d33cc commit f16d7ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apis/v1beta1/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func BootstrapMetrics() (metric.MeterProvider, error) {
return sdkmetric.NewMeterProvider(sdkmetric.WithReader(exporter)), err
}

func NewMetrics(prv metric.MeterProvider, ctx context.Context, cl client.Client) (*Metrics, error) {
func NewMetrics(prv metric.MeterProvider, ctx context.Context, cl client.Reader) (*Metrics, error) {
meter := prv.Meter(meterName)
modeCounter, err := meter.Int64UpDownCounter(modeMetricName)
if err != nil {
Expand Down Expand Up @@ -120,7 +120,7 @@ func NewMetrics(prv metric.MeterProvider, ctx context.Context, cl client.Client)
}

// Init metrics from the first time the operator starts.
func (m *Metrics) init(ctx context.Context, cl client.Client) error {
func (m *Metrics) init(ctx context.Context, cl client.Reader) error {
opts := []client.ListOption{
client.MatchingLabels(map[string]string{
"app.kubernetes.io/managed-by": "opentelemetry-operator",
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ func main() {
setupLog.Error(metricsErr, "Error bootstrapping CRD metrics")
}

crdMetrics, err = otelv1beta1.NewMetrics(meterProvider, ctx, mgr.GetClient())
crdMetrics, err = otelv1beta1.NewMetrics(meterProvider, ctx, mgr.GetAPIReader())
if err != nil {
setupLog.Error(err, "Error bootstrapping CRD metrics")
setupLog.Error(err, "Error init CRD metrics")
}

}
Expand Down

0 comments on commit f16d7ef

Please sign in to comment.