From bacc31d5ccb0afadd57604833cfe7f4fa72b7e89 Mon Sep 17 00:00:00 2001 From: Bjoern Rabenstein Date: Wed, 2 Jul 2014 20:43:15 +0200 Subject: [PATCH] Remove work-around that required copying all bytes of a scrape. Now that the subtle bug in matttproud/golang_protobuf_extensions is fixed, we do not need to copy the bytes of a scrape into a buffer first before starting to parse it. Change-Id: Ib73ecae16173ddd219cda56388a8f853332f8853 --- retrieval/target.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/retrieval/target.go b/retrieval/target.go index 22bd1bec7..dbf80548c 100644 --- a/retrieval/target.go +++ b/retrieval/target.go @@ -14,7 +14,6 @@ package retrieval import ( - "bytes" "fmt" "net/http" "os" @@ -264,14 +263,6 @@ func (t *target) scrape(timestamp clientmodel.Timestamp, ingester extraction.Ing baseLabels[baseLabel] = baseValue } - // N.B. - It is explicitly required to extract the entire payload before - // attempting to deserialize, as the underlying reader will interpret - // pending data as a truncated message. - buf := new(bytes.Buffer) - if _, err := buf.ReadFrom(resp.Body); err != nil { - return err - } - i := &MergeLabelsIngester{ Labels: baseLabels, CollisionPrefix: clientmodel.ExporterLabelPrefix, @@ -281,7 +272,7 @@ func (t *target) scrape(timestamp clientmodel.Timestamp, ingester extraction.Ing processOptions := &extraction.ProcessOptions{ Timestamp: timestamp, } - return processor.ProcessSingle(buf, i, processOptions) + return processor.ProcessSingle(resp.Body, i, processOptions) } func (t *target) State() TargetState {