Skip to content

Commit 1a2aea3

Browse files
authored
fix(agent): prevent metadata from being discarded if report is slow (#10386)
1 parent 6683ad9 commit 1a2aea3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

agent/agent.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,14 @@ func (a *agent) reportMetadataLoop(ctx context.Context) {
536536
continue
537537
case <-report:
538538
if len(updatedMetadata) > 0 {
539+
select {
540+
case <-reportSemaphore:
541+
default:
542+
// If there's already a report in flight, don't send
543+
// another one, wait for next tick instead.
544+
continue
545+
}
546+
539547
metadata := make([]agentsdk.Metadata, 0, len(updatedMetadata))
540548
for key, result := range updatedMetadata {
541549
metadata = append(metadata, agentsdk.Metadata{
@@ -545,14 +553,6 @@ func (a *agent) reportMetadataLoop(ctx context.Context) {
545553
delete(updatedMetadata, key)
546554
}
547555

548-
select {
549-
case <-reportSemaphore:
550-
default:
551-
// If there's already a report in flight, don't send
552-
// another one, wait for next tick instead.
553-
continue
554-
}
555-
556556
go func() {
557557
ctx, cancel := context.WithTimeout(ctx, reportTimeout)
558558
defer func() {

0 commit comments

Comments
 (0)