Skip to content

Commit

Permalink
fix: Add missing logger in servicequotas fetcher
Browse files Browse the repository at this point in the history
This commit is updating the exporter and servicequotas packages to
properly pass the logger.

In the `serviceQuotaFetcher` struct we have defined a logger field but
it was never initialized. Which means any call to s.logger was panicking
in the `serviceQuotaFetcher` methods.

Properly passing the logger and storing it in the structure will allow
us to properly use `s.logger` inside the `serviceQuotaFetcher` methods.

This change has been made following this [issue][1]

[1]: qonto#205

Signed-off-by: Clovis Delarue <[email protected]>
  • Loading branch information
airclovis committed Aug 20, 2024
1 parent 41da49f commit 11aaa75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/app/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func (c *rdsCollector) getQuotasMetrics(client servicequotas.ServiceQuotasClient

c.logger.Debug("fetch quotas")

fetcher := servicequotas.NewFetcher(ctx, client)
fetcher := servicequotas.NewFetcher(ctx, client, c.logger)

metrics, err := fetcher.GetRDSQuotas()
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/app/servicequotas/servicequotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"context"
"errors"
"fmt"
"log/slog"

aws_servicequotas "github.com/aws/aws-sdk-go-v2/service/servicequotas"
"github.com/qonto/prometheus-rds-exporter/internal/app/trace"
converter "github.com/qonto/prometheus-rds-exporter/internal/app/unit"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"golang.org/x/exp/slog"
)

var (
Expand Down Expand Up @@ -44,10 +44,11 @@ type ServiceQuotasClient interface {
GetServiceQuota(ctx context.Context, input *aws_servicequotas.GetServiceQuotaInput, optFns ...func(*aws_servicequotas.Options)) (*aws_servicequotas.GetServiceQuotaOutput, error)
}

func NewFetcher(ctx context.Context, client ServiceQuotasClient) *serviceQuotaFetcher {
func NewFetcher(ctx context.Context, client ServiceQuotasClient, logger slog.Logger) *serviceQuotaFetcher {
return &serviceQuotaFetcher{
ctx: ctx,
client: client,
logger: &logger,
}
}

Expand Down

0 comments on commit 11aaa75

Please sign in to comment.