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

Commit 5f19b6a

Browse files
committed
update payload sizes to load from config
1 parent 003c710 commit 5f19b6a

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

agent/recorder.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ type (
3838
debugMode bool
3939
metadata map[string]interface{}
4040

41-
payloadSpans []PayloadSpan
42-
payloadEvents []PayloadEvent
41+
payloadSpans []PayloadSpan
42+
payloadEvents []PayloadEvent
43+
maxSpansPerPayload int
44+
maxEventsPerPayload int
4345

4446
flushFrequency time.Duration
4547
url string
@@ -82,6 +84,16 @@ func NewSpanRecorder(agent *Agent) *SpanRecorder {
8284
r.url = agent.getUrl("api/agent/ingest")
8385
r.client = &http.Client{}
8486
r.stats = &RecorderStats{}
87+
if cfg.Tracer.Dispatcher.Events.MaxPayloadSize != nil {
88+
r.maxEventsPerPayload = *cfg.Tracer.Dispatcher.Events.MaxPayloadSize
89+
} else {
90+
r.maxEventsPerPayload = 1000
91+
}
92+
if cfg.Tracer.Dispatcher.Spans.MaxPayloadSize != nil {
93+
r.maxSpansPerPayload = *cfg.Tracer.Dispatcher.Spans.MaxPayloadSize
94+
} else {
95+
r.maxSpansPerPayload = 1000
96+
}
8597
r.t.Go(r.loop)
8698
return r
8799
}
@@ -142,11 +154,10 @@ func (r *SpanRecorder) loop() error {
142154
// Sends the spans in the buffer to Scope
143155
func (r *SpanRecorder) sendSpans() (error, bool) {
144156
atomic.AddInt64(&r.stats.sendSpansCalls, 1)
145-
const batchSize = 1000
146157
var lastError error
147158
for {
148-
spans, spMore, spTotal := r.popPayloadSpan(batchSize)
149-
events, evMore, evTotal := r.popPayloadEvents(batchSize)
159+
spans, spMore, spTotal := r.popPayloadSpan(r.maxSpansPerPayload)
160+
events, evMore, evTotal := r.popPayloadEvents(r.maxEventsPerPayload)
150161

151162
payload := map[string]interface{}{
152163
"metadata": r.metadata,

scope.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ tracer:
3535
healthcheck_frecuency_in_testmode: 1000 #SCOPE_TRACER_DISPATCHER_HEALTHCHECK_FRECUENCY_IN_TESTMODE
3636
concurrency_level: 5 #SCOPE_TRACER_DISPATCHER_CONCURRENCY_LEVEL
3737
spans:
38-
max_payload_size: -1 #SCOPE_TRACER_DISPATCHER_SPANS_MAX_PAYLOAD_SIZE
38+
max_payload_size: 1000 #SCOPE_TRACER_DISPATCHER_SPANS_MAX_PAYLOAD_SIZE
3939
events:
40-
max_payload_size: -1 #SCOPE_TRACER_DISPATCHER_EVENTS_MAX_PAYLOAD_SIZE
40+
max_payload_size: 1000 #SCOPE_TRACER_DISPATCHER_EVENTS_MAX_PAYLOAD_SIZE

0 commit comments

Comments
 (0)