Skip to content

Commit bbb5af5

Browse files
committed
fix(v0.150): reconcile main's incoming code post-rebase
- cloudwatchlogs deadlock (#2190) part-2 adapted to aws-sdk-go-v2 (sharedRetryer/sharedClient) + v1->v2 tests - windowseventlog translator: component id windowseventlog -> windows_event_log (v0.150 factory type) - regenerate main's new/updated OTel-section goldens for v0.150 (default_otel_config*, files_config, host_metrics azure/aks, prometheus pipelines)
1 parent 253a9d6 commit bbb5af5

16 files changed

Lines changed: 2302 additions & 208 deletions

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/resourcetotel
244244
github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.0.0-20260728215743-95055c0f9cfd/go.mod h1:zk6PvQyUDsjyvgI0ugtzvfgvSmHRsiq4NsU/Nf43mdY=
245245
github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/stanza v0.0.0-20260728215743-95055c0f9cfd h1:Q0TzFlLgphKVvKRtUXih3Uzu5rpDq/fVHUiZBdd1ynE=
246246
github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/stanza v0.0.0-20260728215743-95055c0f9cfd/go.mod h1:8oXRIBSggiKdi+WFeBwbil2VybfOGNnrcxxS4kxuvuw=
247-
github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20260607233959-ee44579b1ae3/go.mod h1:Pw6sp3wj1SH3LVvAn4Lwld9j6RDyw/5SxPii8aK8nu4=
248247
github.com/amazon-contributing/opentelemetry-collector-contrib/processor/attributestocontextprocessor v0.0.0-20260728215743-95055c0f9cfd h1:zF3lNp9NV6pU6iM0srEB20FYCBinyXxx5xE4iU4pYyo=
249248
github.com/amazon-contributing/opentelemetry-collector-contrib/processor/attributestocontextprocessor v0.0.0-20260728215743-95055c0f9cfd/go.mod h1:E+PmgeASy3qNX1QRqcPDypclu8EIGqd7QY9EjPkVFKo=
250249
github.com/amazon-contributing/opentelemetry-collector-contrib/processor/awsattributelimitprocessor v0.0.0-20260728215743-95055c0f9cfd h1:iCGAxLhjH9URw7+YUX+sJtU0+X9SlfyP4XMt4KHxMsk=

internal/retryer/logthrottle_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,14 @@ func TestShouldRetryDoesNotBlockAfterStop(t *testing.T) {
130130
r.Stop()
131131
time.Sleep(50 * time.Millisecond) // Give the goroutine time to exit
132132

133-
req := &request.Request{
134-
Error: awserr.New("RequestLimitExceeded", "Test AWS Error", nil),
135-
Operation: &request.Operation{Name: "Test"},
136-
}
133+
err := &smithy.GenericAPIError{Code: "RequestLimitExceeded", Message: "Test AWS Error"}
137134

138-
// Call ShouldRetry in a goroutine and use a timeout to detect blocking
135+
// Call IsErrorRetryable in a goroutine and use a timeout to detect blocking
139136
done := make(chan bool, 1)
140137
go func() {
141-
// Call ShouldRetry multiple times to exceed channel capacity (1)
138+
// Call IsErrorRetryable multiple times to exceed channel capacity (1)
142139
for i := 0; i < 10; i++ {
143-
r.ShouldRetry(req)
140+
r.IsErrorRetryable(err)
144141
}
145142
done <- true
146143
}()

plugins/outputs/cloudwatchlogs/cloudwatchlogs.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type CloudWatchLogs struct {
7979
// Dedicated retryer/client for the TargetManager, owned by the plugin so its
8080
// lifecycle is independent of any destination stop.
8181
sharedRetryer *retryer.LogThrottleRetryer
82-
sharedClient *cloudwatchlogs.CloudWatchLogs
82+
sharedClient *cloudwatchlogs.Client
8383
}
8484

8585
var _ logs.LogBackend = (*CloudWatchLogs)(nil)
@@ -172,8 +172,13 @@ func (c *CloudWatchLogs) getDest(t pusher.Target, logSrc logs.LogSrc) *cwDest {
172172
}
173173
// Dedicated retryer/client so the TargetManager isn't tied to the first dest.
174174
c.sharedRetryer = retryer.NewLogThrottleRetryer(c.Log)
175-
c.sharedClient = c.createClient(c.sharedRetryer)
176-
c.targetManager = pusher.NewTargetManager(c.Log, c.sharedClient)
175+
sharedClient, cerr := c.createClient(context.Background(), c.sharedRetryer, nil)
176+
if cerr != nil {
177+
c.Log.Errorf("Failed to create shared CloudWatch Logs client for target manager, falling back to per-destination client: %v", cerr)
178+
sharedClient = client
179+
}
180+
c.sharedClient = sharedClient
181+
c.targetManager = pusher.NewTargetManager(c.Log, sharedClient)
177182
})
178183
cwd.pusher = pusher.NewPusher(c.Log, t, client, c.targetManager, logSrc, c.workerPool, c.ForceFlushInterval.Duration, maxRetryTimeout, &c.pusherWaitGroup)
179184
c.cwDests.Store(t, cwd)

plugins/outputs/cloudwatchlogs/internal/pusher/queue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ func TestForceFlushTimerRearmsAfterHeldSend(t *testing.T) {
844844
releaseSend := func() { releaseOnce.Do(func() { close(release) }) }
845845

846846
var s stubLogsService
847-
s.ple = func(_ *cloudwatchlogs.PutLogEventsInput) (*cloudwatchlogs.PutLogEventsOutput, error) {
847+
s.ple = func(_ context.Context, _ *cloudwatchlogs.PutLogEventsInput) (*cloudwatchlogs.PutLogEventsOutput, error) {
848848
switch sendCount.Load() {
849849
case 0:
850850
sendCount.Add(1)
@@ -896,7 +896,7 @@ func TestForceFlushTimer_SingleLowVolumeEventFlushes(t *testing.T) {
896896

897897
var sendCount atomic.Int32
898898
var s stubLogsService
899-
s.ple = func(_ *cloudwatchlogs.PutLogEventsInput) (*cloudwatchlogs.PutLogEventsOutput, error) {
899+
s.ple = func(_ context.Context, _ *cloudwatchlogs.PutLogEventsInput) (*cloudwatchlogs.PutLogEventsOutput, error) {
900900
sendCount.Add(1)
901901
return &cloudwatchlogs.PutLogEventsOutput{}, nil
902902
}

plugins/outputs/cloudwatchlogs/internal/pusher/target_deadlock_test.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,41 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/aws/aws-sdk-go/aws"
14-
"github.com/aws/aws-sdk-go/aws/credentials"
15-
"github.com/aws/aws-sdk-go/aws/session"
13+
"github.com/aws/aws-sdk-go-v2/aws"
14+
"github.com/aws/aws-sdk-go-v2/credentials"
15+
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
1616

1717
"github.com/aws/amazon-cloudwatch-agent/internal/retryer"
18-
"github.com/aws/amazon-cloudwatch-agent/sdk/service/cloudwatchlogs"
1918
"github.com/aws/amazon-cloudwatch-agent/tool/testutil"
2019
)
2120

2221
// newThrottlingClient returns a real CloudWatch Logs client whose endpoint points
2322
// at a local server that always responds with a ThrottlingException, wired with a
2423
// LogThrottleRetryer. The returned retryer is also handed back so the test can stop
2524
// its consumer goroutine to reproduce the dead-consumer condition.
26-
func newThrottlingClient(t *testing.T) (*cloudwatchlogs.CloudWatchLogs, *retryer.LogThrottleRetryer, func()) {
25+
func newThrottlingClient(t *testing.T) (*cloudwatchlogs.Client, *retryer.LogThrottleRetryer, func()) {
2726
t.Helper()
2827

2928
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
3029
// JSON 1.1 protocol: the SDK classifies the error from the error type,
3130
// which it reads from this header / body. ThrottlingException is a
32-
// throttling error, so the SDK will invoke ShouldRetry and retry.
31+
// throttling error, so the SDK will invoke IsErrorRetryable and retry.
3332
w.Header().Set("X-Amzn-Errortype", "ThrottlingException")
3433
w.Header().Set("Content-Type", "application/x-amz-json-1.1")
3534
w.WriteHeader(http.StatusBadRequest)
3635
_, _ = w.Write([]byte(`{"__type":"ThrottlingException","message":"Rate exceeded"}`))
3736
}))
3837

38+
// The embedded retry.Standard bounds attempts (default 3, i.e. >1) so a dead
39+
// consumer fills the capacity-1 throttle channel and (pre-fix) the next send blocks.
3940
r := retryer.NewLogThrottleRetryer(testutil.NewNopLogger())
40-
// Bound the retry count: fast, but >1 so a dead consumer fills the capacity-1
41-
// throttle channel and (pre-fix) the next send blocks.
42-
r.NumMaxRetries = 2
4341

44-
sess := session.Must(session.NewSession())
45-
client := cloudwatchlogs.New(sess, &aws.Config{
46-
Region: aws.String("us-east-1"),
47-
Endpoint: aws.String(srv.URL),
48-
DisableSSL: aws.Bool(true),
49-
Credentials: credentials.NewStaticCredentials("ak", "sk", ""),
50-
Retryer: r,
42+
client := cloudwatchlogs.NewFromConfig(aws.Config{
43+
Region: "us-east-1",
44+
Credentials: credentials.NewStaticCredentialsProvider("ak", "sk", ""),
45+
}, func(o *cloudwatchlogs.Options) {
46+
o.BaseEndpoint = aws.String(srv.URL)
47+
o.Retryer = r
5148
})
5249

5350
return client, r, srv.Close

0 commit comments

Comments
 (0)