Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
Changes the condition from the first payload to until a successful pa…
Browse files Browse the repository at this point in the history
…yload has been delivered
  • Loading branch information
tonyredondo committed Mar 2, 2020
1 parent df519b5 commit ba8a700
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions agent/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ type (
sync.RWMutex
t tomb.Tomb

agentId string
apiKey string
apiEndpoint string
version string
userAgent string
debugMode bool
metadata map[string]interface{}
metadataOnce sync.Once
agentId string
apiKey string
apiEndpoint string
version string
userAgent string
debugMode bool
metadata map[string]interface{}

spans []tracer.RawSpan

Expand Down Expand Up @@ -349,10 +348,11 @@ func (r *SpanRecorder) getPayload(rawSpans []tracer.RawSpan) map[string]interfac
"events": events,
tags.AgentID: r.agentId,
}
// We send the metadata only in the first payload
r.metadataOnce.Do(func() {
// We send the metadata only if not spans are sent successfully
if atomic.LoadInt64(&r.stats.sendSpansOk) == 0 {
r.logger.Println("adding payload metadata")
payload["metadata"] = r.metadata
})
}
return payload
}

Expand Down

0 comments on commit ba8a700

Please sign in to comment.