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

Commit

Permalink
update payload sizes to load from config
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Mar 14, 2020
1 parent 46c1f89 commit c134bdb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 16 additions & 5 deletions agent/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ type (
debugMode bool
metadata map[string]interface{}

payloadSpans []PayloadSpan
payloadEvents []PayloadEvent
payloadSpans []PayloadSpan
payloadEvents []PayloadEvent
maxSpansPerPayload int
maxEventsPerPayload int

flushFrequency time.Duration
url string
Expand Down Expand Up @@ -82,6 +84,16 @@ func NewSpanRecorder(agent *Agent) *SpanRecorder {
r.url = agent.getUrl("api/agent/ingest")
r.client = &http.Client{}
r.stats = &RecorderStats{}
if cfg.Tracer.Dispatcher.Events.MaxPayloadSize != nil {
r.maxEventsPerPayload = *cfg.Tracer.Dispatcher.Events.MaxPayloadSize
} else {
r.maxEventsPerPayload = 1000
}
if cfg.Tracer.Dispatcher.Spans.MaxPayloadSize != nil {
r.maxSpansPerPayload = *cfg.Tracer.Dispatcher.Spans.MaxPayloadSize
} else {
r.maxSpansPerPayload = 1000
}
r.t.Go(r.loop)
return r
}
Expand Down Expand Up @@ -142,11 +154,10 @@ func (r *SpanRecorder) loop() error {
// Sends the spans in the buffer to Scope
func (r *SpanRecorder) sendSpans() (error, bool) {
atomic.AddInt64(&r.stats.sendSpansCalls, 1)
const batchSize = 1000
var lastError error
for {
spans, spMore, spTotal := r.popPayloadSpan(batchSize)
events, evMore, evTotal := r.popPayloadEvents(batchSize)
spans, spMore, spTotal := r.popPayloadSpan(r.maxSpansPerPayload)
events, evMore, evTotal := r.popPayloadEvents(r.maxEventsPerPayload)

payload := map[string]interface{}{
"metadata": r.metadata,
Expand Down
4 changes: 2 additions & 2 deletions scope.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ tracer:
healthcheck_frecuency_in_testmode: 1000 #SCOPE_TRACER_DISPATCHER_HEALTHCHECK_FRECUENCY_IN_TESTMODE
concurrency_level: 5 #SCOPE_TRACER_DISPATCHER_CONCURRENCY_LEVEL
spans:
max_payload_size: -1 #SCOPE_TRACER_DISPATCHER_SPANS_MAX_PAYLOAD_SIZE
max_payload_size: 1000 #SCOPE_TRACER_DISPATCHER_SPANS_MAX_PAYLOAD_SIZE
events:
max_payload_size: -1 #SCOPE_TRACER_DISPATCHER_EVENTS_MAX_PAYLOAD_SIZE
max_payload_size: 1000 #SCOPE_TRACER_DISPATCHER_EVENTS_MAX_PAYLOAD_SIZE

0 comments on commit c134bdb

Please sign in to comment.