Skip to content

Commit

Permalink
PMM-7 Fix datarace (#2501)
Browse files Browse the repository at this point in the history
* PMM-7 Fix datarace

* PMM-7 Fix datarace
  • Loading branch information
artemgavrilov authored Sep 26, 2023
1 parent 07a89bf commit a407ad5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions managed/services/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ func (s *Service) processSendCh(ctx context.Context) {
reportsBuf = []*pmmv1.ServerMetric{}
reportsBufSync.Unlock()

go func() {
err := s.send(sendCtx, &reporter.ReportRequest{
go func(ctx context.Context) {
err := s.send(ctx, &reporter.ReportRequest{
Metrics: reportsToSend,
})
if err != nil {
Expand All @@ -201,7 +201,7 @@ func (s *Service) processSendCh(ctx context.Context) {
}

s.l.Debug("Telemetry info sent.")
}()
}(sendCtx)
}
case <-ctx.Done():
if cancel != nil {
Expand Down
3 changes: 1 addition & 2 deletions managed/services/telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"context"
"io/fs"
"os"
"reflect"
"testing"
"time"

Expand Down Expand Up @@ -264,7 +263,7 @@ func initMockTelemetrySender(t *testing.T, expectedReport *reporter.ReportReques
var mockTelemetrySender mockSender
mockTelemetrySender.Test(t)
mockTelemetrySender.On("SendTelemetry",
mock.AnythingOfType(reflect.TypeOf(context.TODO()).Name()),
mock.Anything,
mock.MatchedBy(func(report *reporter.ReportRequest) bool {
return matchExpectedReport(report, expectedReport)
}),
Expand Down

0 comments on commit a407ad5

Please sign in to comment.