mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Completely extract response payload for decoding.
This commit forces the extraction framework to read the entire response payload into a buffer before attempting to decode it, for the underlying Protocol Buffer message readers do not block on partial messages.
This commit is contained in:
parent
b85ca7c657
commit
e20e6980e9
|
@ -10,9 +10,11 @@
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package retrieval
|
package retrieval
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -236,7 +238,15 @@ func (t *target) scrape(timestamp time.Time, results chan<- *extraction.Result)
|
||||||
BaseLabels: baseLabels,
|
BaseLabels: baseLabels,
|
||||||
}
|
}
|
||||||
|
|
||||||
return processor.ProcessSingle(resp.Body, results, processOptions)
|
// N.B. - It is explicitly required to extract the entire payload before
|
||||||
|
// attempting to deserialize, as the underlying reader expects will
|
||||||
|
// interpret pending data as a truncated message.
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
if _, err := buf.ReadFrom(resp.Body); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return processor.ProcessSingle(buf, results, processOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t target) State() TargetState {
|
func (t target) State() TargetState {
|
||||||
|
|
Loading…
Reference in a new issue