Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Main (unreleased)

- Fix direction of arrows for pyroscope components in UI graph. (@dehaansa)

- Fix `prometheus.exporter.cloudwatch` to not always emit debug logs but respect debug property. (@kalleep)

v1.11.0
-----------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ func NewCloudwatchExporter(name string, logger log.Logger, conf yaceModel.JobsCo
var factory cachingFactory
var err error

l := slog.New(newSlogHandler(logging.NewSlogGoKitHandler(logger), debug))

if useAWSSDKVersionV2 {
factory, err = yaceClientsV2.NewFactory(slog.New(logging.NewSlogGoKitHandler(logger)), conf, fipsEnabled)
factory, err = yaceClientsV2.NewFactory(l, conf, fipsEnabled)
} else {
factory = yaceClientsV1.NewFactory(slog.New(logging.NewSlogGoKitHandler(logger)), conf, fipsEnabled)
factory = yaceClientsV1.NewFactory(l, conf, fipsEnabled)
}

if err != nil {
Expand All @@ -52,7 +54,7 @@ func NewCloudwatchExporter(name string, logger log.Logger, conf yaceModel.JobsCo

return &exporter{
name: name,
logger: slog.New(logging.NewSlogGoKitHandler(logger)),
logger: l,
cachingClientFactory: factory,
scrapeConf: conf,
}, nil
Expand Down
30 changes: 30 additions & 0 deletions internal/static/integrations/cloudwatch_exporter/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cloudwatch_exporter

import (
"context"
"log/slog"

"github.com/grafana/alloy/internal/runtime/logging"
)

// slogHandler is wrapping our internal logging adapter with support for cloudwatch debug field.
// cloudwatch exporter will inspect check for debug logging level and pass that to aws sdk that perform
// it's own logging without going through the logger we pass.
type slogHandler struct {
debug bool
*logging.SlogGoKitHandler
}

func newSlogHandler(logger *logging.SlogGoKitHandler, debug bool) *slogHandler {
return &slogHandler{
debug: debug,
SlogGoKitHandler: logger,
}
}

func (s *slogHandler) Enabled(ctx context.Context, level slog.Level) bool {
if level == slog.LevelDebug {
return s.debug
}
return s.SlogGoKitHandler.Enabled(ctx, level)
}