Skip to content

Commit 18191d7

Browse files
committed
receiver: avoid allocation if rawBytes is empty
Signed-off-by: Florian Lehner <[email protected]>
1 parent 4fb0bc5 commit 18191d7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

apmproxy/receiver.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,20 @@ func (c *Client) handleIntakeV2Events() func(w http.ResponseWriter, r *http.Requ
136136

137137
agentFlushed := r.URL.Query().Get("flushed") == "true"
138138

139-
agentData := accumulator.APMData{
140-
Data: rawBytes,
141-
ContentEncoding: r.Header.Get("Content-Encoding"),
142-
AgentInfo: r.UserAgent(),
143-
}
139+
if len(rawBytes) != 0 {
140+
agentData := accumulator.APMData{
141+
Data: rawBytes,
142+
ContentEncoding: r.Header.Get("Content-Encoding"),
143+
AgentInfo: r.UserAgent(),
144+
}
144145

145-
if len(agentData.Data) != 0 {
146146
select {
147147
case c.AgentDataChannel <- agentData:
148148
default:
149149
c.logger.Warnf("Channel full: dropping a subset of agent data")
150150
}
151+
} else {
152+
c.logger.Debugf("Received empy request from '%s'", r.UserAgent())
151153
}
152154

153155
if agentFlushed {

0 commit comments

Comments
 (0)